From: <pat...@us...> - 2009-08-14 21:45:44
|
Revision: 921 http://cishell.svn.sourceforge.net/cishell/?rev=921&view=rev Author: pataphil Date: 2009-08-14 21:45:32 +0000 (Fri, 14 Aug 2009) Log Message: ----------- * Fixed file copy bug. Modified Paths: -------------- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/BasicTemplate.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmTemplate.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/BasicTemplate.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/BasicTemplate.java 2009-08-14 17:41:28 UTC (rev 920) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/BasicTemplate.java 2009-08-14 21:45:32 UTC (rev 921) @@ -46,6 +46,7 @@ import org.eclipse.pde.ui.templates.OptionTemplateSection; import org.eclipse.pde.ui.templates.TemplateOption; +// TODO Could we safely reduce some of the method visibilities here? public abstract class BasicTemplate extends OptionTemplateSection { protected final String sectionID; protected Map valueMap; @@ -125,6 +126,10 @@ return value; } + public boolean shouldProcessFile(File file) { + return true; + } + public void execute(IProject project, IPluginModelBase model, IProgressMonitor monitor) throws CoreException { @@ -134,12 +139,12 @@ updateModel(monitor); } - public void generateFiles(IProgressMonitor progressMonitor) + protected void generateFiles(IProgressMonitor progressMonitor) throws CoreException { generateFiles(progressMonitor, getTemplateLocation()); } - public void generateFiles(IProgressMonitor progressMonitor, + protected void generateFiles(IProgressMonitor progressMonitor, URL locationURL) throws CoreException { progressMonitor.setTaskName( PDEUIMessages.AbstractTemplateSection_generating); @@ -167,8 +172,12 @@ return; } - generateFiles( - templateDirectory, project, true, false, progressMonitor); + generateFiles(templateDirectory, + project, + true, + false, + true, + progressMonitor); } else if ("jar".equals(resolvedLocationURLProtocol)) { int exclamationIndex = resolvedLocationURLFileName.indexOf('!'); @@ -223,17 +232,21 @@ progressMonitor.worked(1); } - private void generateFiles( + protected void generateFiles( File sourceFile, IContainer destinationContainer, boolean isFirstLevel, boolean isBinaryFile, + boolean shouldProcessAsTemplate, IProgressMonitor progressMonitor) throws CoreException { File[] sourceSubFiles = sourceFile.listFiles(); for (int ii = 0; ii < sourceSubFiles.length; ii++) { File sourceSubFile = sourceSubFiles[ii]; + boolean shouldProcessSubFileAsTemplate = + shouldProcessAsTemplate && shouldProcessFile(sourceSubFile); + if (sourceSubFile.isDirectory()) { IContainer subDestinationContainer = null; @@ -260,8 +273,15 @@ continue; } - String folderName = getProcessedString( - sourceSubFile.getName(), sourceSubFile.getName()); + String folderName; + + if (shouldProcessSubFileAsTemplate) { + folderName = getProcessedString( + sourceSubFile.getName(), sourceSubFile.getName()); + } else { + folderName = sourceSubFile.getName(); + } + subDestinationContainer = destinationContainer.getFolder(new Path(folderName)); } @@ -276,6 +296,7 @@ subDestinationContainer, false, isBinaryFile, + shouldProcessSubFileAsTemplate, progressMonitor); } else { if (isOkToCreateFile(sourceSubFile)) { @@ -291,6 +312,7 @@ inputStream, destinationContainer, isBinaryFile, + shouldProcessSubFileAsTemplate, progressMonitor); } catch (IOException ioException1) { } finally { @@ -306,7 +328,7 @@ } } - private void generateFiles( + protected void generateFiles( ZipFile zipFile, IPath filePath, IContainer destinationContainer, @@ -314,8 +336,9 @@ boolean isBinary, IProgressMonitor progressMonitor) throws CoreException { int pathLength = filePath.segmentCount(); - // Immidiate children - Map childZipEntries = new HashMap(); // "dir/" or "dir/file.java" + // Immediate children. + // "dir/" or "dir/file.java" + Map childZipEntries = new HashMap(); for (Enumeration zipEntries = zipFile.entries(); zipEntries.hasMoreElements();) { @@ -327,7 +350,7 @@ } if (!filePath.isPrefixOf(entryPath)) { - // not a descendant + // Not a descendant. continue; } @@ -404,6 +427,7 @@ inputStream, destinationContainer, isBinary, + true, progressMonitor); } catch (IOException ioException1) { } finally { @@ -457,7 +481,7 @@ return source; } - int location = -1; + int locationIndex = -1; StringBuffer buffer = new StringBuffer(); boolean shouldReplace = false; @@ -466,7 +490,7 @@ if (currentCharacter == '$') { if (shouldReplace) { - String key = source.substring(location, ii); + String key = source.substring(locationIndex, ii); String value; if (key.length() == 0) { @@ -479,7 +503,7 @@ shouldReplace = false; } else { shouldReplace = true; - location = ii + 1; + locationIndex = ii + 1; continue; } @@ -495,17 +519,30 @@ InputStream inputStream, IContainer destinationContainer, boolean isBinary, + boolean shouldProcessSubFileAsTemplate, IProgressMonitor progressMonitor) throws CoreException { - String targetFileName = getProcessedString(fileName, fileName); + String targetFileName; + + if (shouldProcessSubFileAsTemplate) { + targetFileName = getProcessedString(fileName, fileName); + } else { + targetFileName = fileName; + } progressMonitor.subTask(targetFileName); IFile destinationFile = destinationContainer.getFile(new Path(targetFileName)); try { - InputStream processedInputStream = - getProcessedStream(fileName, inputStream, isBinary); + InputStream processedInputStream; + if (shouldProcessSubFileAsTemplate) { + processedInputStream = + getProcessedStream(fileName, inputStream, isBinary); + } else { + processedInputStream = inputStream; + } + if (destinationFile.exists()) { destinationFile.setContents( processedInputStream, true, true, progressMonitor); Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmTemplate.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmTemplate.java 2009-08-14 17:41:28 UTC (rev 920) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmTemplate.java 2009-08-14 21:45:32 UTC (rev 921) @@ -13,6 +13,9 @@ * ***************************************************************************/ package org.cishell.templates.wizards.staticexecutable; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -182,6 +185,18 @@ { MENU_END_LABEL, MENU_END_DESCRIPTION } }; + public static final String[] IGNORED_REPLACEMENT_STRING_FILES = + new String[] { + "ant.sh", + "build.xml" + }; + + public static final String[] IGNORED_REPLACEMENT_STRING_DIRECTORIES = + new String[] { + "l10n", + "lib" + }; + private WizardNewProjectCreationPage createProjectPage; private WizardPage bundlePropertiesPage; private ChooseExecutableFilesPage chooseExecutableFilesPage; @@ -327,6 +342,32 @@ super.execute(project, model, monitor); } + + public boolean shouldProcessFile(File file) { + String fileName = file.getName(); + String filePath = file.getParent(); + + for (int ii = 0; ii < IGNORED_REPLACEMENT_STRING_FILES.length; ii++) { + if (IGNORED_REPLACEMENT_STRING_FILES[ii].equals(fileName)) { + return false; + } + } + + /* TODO What if the path happens to include an ignored string, + * like "lib", but without the meaning intended here? + * Like ".../workspace/reginald_libby/...". + */ + for (int ii = 0; + ii < IGNORED_REPLACEMENT_STRING_DIRECTORIES.length; + ii++) { + if (filePath.contains( + IGNORED_REPLACEMENT_STRING_DIRECTORIES[ii])) { + return false; + } + } + + return true; + } protected void updateModel(IProgressMonitor monitor) throws CoreException { } Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java 2009-08-14 17:41:28 UTC (rev 920) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmWizard.java 2009-08-14 21:45:32 UTC (rev 921) @@ -102,7 +102,8 @@ */ public ITemplateSection[] createTemplateSections() { template = new NewStaticExecutableAlgorithmTemplate(); - return new ITemplateSection[]{template}; + + return new ITemplateSection[] { template }; } public boolean performFinish() { @@ -206,9 +207,7 @@ /** * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) */ - public void init(IWorkbench workbench, IStructuredSelection selection) { - - } + public void init(IWorkbench workbench, IStructuredSelection selection) {} private void copyTemplateOptionFile(TemplateOption templateOption, String directoryPath, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pat...@us...> - 2009-08-20 23:50:40
|
Revision: 934 http://cishell.svn.sourceforge.net/cishell/?rev=934&view=rev Author: pataphil Date: 2009-08-20 23:50:23 +0000 (Thu, 20 Aug 2009) Log Message: ----------- * Fixed some naming and other miscellaneous typo issues. Modified Paths: -------------- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddOutputDataPanel.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmTemplate.java trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/OutputDataItemEditor.java Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddOutputDataPanel.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddOutputDataPanel.java 2009-08-20 17:31:49 UTC (rev 933) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/pagepanels/AddOutputDataPanel.java 2009-08-20 23:50:23 UTC (rev 934) @@ -64,7 +64,7 @@ GetOutputDataAction action = new GetOutputDataAction(); display.syncExec(action); - return action.inputDataItems; + return action.outputDataItems; } else { return new OutputDataItem[0]; } @@ -108,16 +108,16 @@ } private class GetOutputDataAction implements Runnable { - OutputDataItem[] inputDataItems; + OutputDataItem[] outputDataItems; public void run() { TableItem[] tableItems = listBuilder.getTable().getItems(); - inputDataItems = new OutputDataItem[tableItems.length]; - Map idToInputDataItemMap = delegate.getIDToOutputDataItemMap(); + outputDataItems = new OutputDataItem[tableItems.length]; + Map idToOutputDataItemMap = delegate.getIDToOutputDataItemMap(); for (int ii = 0; ii < tableItems.length; ii++) { - inputDataItems[ii] = (OutputDataItem) - idToInputDataItemMap.get(tableItems[ii].getText(0)); + outputDataItems[ii] = (OutputDataItem) + idToOutputDataItemMap.get(tableItems[ii].getText(0)); } } } Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmTemplate.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmTemplate.java 2009-08-20 17:31:49 UTC (rev 933) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/NewStaticExecutableAlgorithmTemplate.java 2009-08-20 23:50:23 UTC (rev 934) @@ -411,7 +411,7 @@ createPage(PROJECT_BUNDLE_PROPERTIES_PAGE_NUMBER); bundlePropertiesPage.setTitle("Bundle Properties"); bundlePropertiesPage.setDescription( - "Enter the bundle name, and bundle version"); + "Enter the Bundle Name, Bundle Symbolic Name, and Bundle Version"); return bundlePropertiesPage; } @@ -432,7 +432,7 @@ WizardPage projectPropertiesPage = createPage(PROJECT_PROPERTIES_PAGE_NUMBER); projectPropertiesPage.setTitle("Project Properties"); - projectPropertiesPage.setDescription("Enter project properties"); + projectPropertiesPage.setDescription("Enter Project Properties"); return projectPropertiesPage; } @@ -440,8 +440,8 @@ private ParameterListBuilderPage createProjectParametersPage() { ParameterListBuilderPage projectParametersPage = new ParameterListBuilderPage(SETUP_PARAMETERS_PAGE_ID); - projectParametersPage.setTitle("Project Parameters"); - projectParametersPage.setDescription("Enter project parameters"); + projectParametersPage.setTitle("Algorithm Parameters"); + projectParametersPage.setDescription("Enter Project Parameters"); return projectParametersPage; } @@ -451,7 +451,7 @@ new SpecifyInAndOutDataPage(SPECIFY_IN_AND_OUT_DATA_PAGE_ID); inputAndOutputDataPage.setTitle("Input and Output Data"); inputAndOutputDataPage.setDescription( - "Enter the input and output data"); + "Enter the Input and Output Data"); return inputAndOutputDataPage; } @@ -465,7 +465,7 @@ this.templateStringOption); specifyTemplateStringPage.setTitle("Template String"); specifyTemplateStringPage.setDescription( - "Enter the template string used to execute your program"); + "Enter the Template String Used to Execute Your Program"); return specifyTemplateStringPage; } @@ -477,7 +477,7 @@ this.sourceCodeFilesOption); sourceCodeFilesPage.setTitle("Source Code Files (Optional)"); sourceCodeFilesPage.setDescription( - "Enter the source code files for your program"); + "Enter the Source Code Files for Your Program"); return sourceCodeFilesPage; } Modified: trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/OutputDataItemEditor.java =================================================================== --- trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/OutputDataItemEditor.java 2009-08-20 17:31:49 UTC (rev 933) +++ trunk/templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/staticexecutable/OutputDataItemEditor.java 2009-08-20 23:50:23 UTC (rev 934) @@ -47,7 +47,7 @@ this.mimeTypeText = createTextInput(panel, "Mime Type"); this.mimeTypeText.setText(this.outputDataItem.getMimeType()); - composite.getShell().setText("Input Data Item Editor"); + composite.getShell().setText("Output Data Item Editor"); return composite; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |