### Eclipse Workspace Patch 1.0 #P org.eclipse.gmf.codegen Index: templates/editor/CreationWizardPage.javajet =================================================================== RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.codegen/templates/editor/CreationWizardPage.javajet,v retrieving revision 1.24 diff -u -r1.24 CreationWizardPage.javajet --- templates/editor/CreationWizardPage.javajet 22 Nov 2006 17:34:44 -0000 1.24 +++ templates/editor/CreationWizardPage.javajet 11 Dec 2006 13:58:46 -0000 @@ -72,6 +72,8 @@ } <%}%> + <%@ include file="CreationWizardPage_getUniqueFileName.jetinc" fail="alternative"%> + <%@ start%> /** * @generated */ @@ -100,6 +102,7 @@ } return filePath.lastSegment(); } + <%@ end%> /** * @generated @@ -118,7 +121,7 @@ return false; } String extension = getExtension(); - if (extension != null && !extension.equals(getFilePath().getFileExtension())) { + if (extension != null && !getFilePath().toString().endsWith("." + extension)) { setErrorMessage(NLS.bind("File name should have ''{0}'' extension.", extension)); return false; } Index: src-templates/org/eclipse/gmf/codegen/templates/editor/CreationWizardPageGenerator.java =================================================================== RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.codegen/src-templates/org/eclipse/gmf/codegen/templates/editor/CreationWizardPageGenerator.java,v retrieving revision 1.30 diff -u -r1.30 CreationWizardPageGenerator.java --- src-templates/org/eclipse/gmf/codegen/templates/editor/CreationWizardPageGenerator.java 22 Nov 2006 20:11:53 -0000 1.30 +++ src-templates/org/eclipse/gmf/codegen/templates/editor/CreationWizardPageGenerator.java 11 Dec 2006 13:58:46 -0000 @@ -31,8 +31,11 @@ protected final String TEXT_14 = NL + "\t\treturn URI.createFileURI(getFilePath().toString());"; protected final String TEXT_15 = NL + "\t}"; protected final String TEXT_16 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected IPath getFilePath() {" + NL + "\t\tIPath path = getContainerFullPath();" + NL + "\t\tif (path == null) {" + NL + "\t\t\tpath = new Path(\"\"); //$NON-NLS-1$" + NL + "\t\t}" + NL + "\t\tString fileName = getFileName();" + NL + "\t\tif (fileName != null) {" + NL + "\t\t\tpath = path.append(fileName);" + NL + "\t\t}" + NL + "\t\treturn path;" + NL + "\t}"; - protected final String TEXT_17 = NL + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate String getUniqueFileName(IPath containerFullPath, String fileName) {" + NL + "\t\tif (containerFullPath == null) {" + NL + "\t\t\tcontainerFullPath = new Path(\"\"); //$NON-NLS-1$" + NL + "\t\t}" + NL + "\t\tif (fileName == null || fileName.trim().length() == 0) {" + NL + "\t\t\tfileName = \"default\"; //$NON-NLS-1$" + NL + "\t\t}" + NL + "\t\tIPath filePath = containerFullPath.append(fileName);" + NL + "\t\tString extension = getExtension();" + NL + "\t\tif (extension != null && !extension.equals(filePath.getFileExtension())) {" + NL + "\t\t\tfilePath = filePath.addFileExtension(extension);" + NL + "\t\t}" + NL + "" + NL + "\t\textension = filePath.getFileExtension();" + NL + "\t\tfileName = filePath.removeFileExtension().lastSegment();" + NL + "\t\tint i = 1;" + NL + "\t\twhile ("; - protected final String TEXT_18 = ".exists(filePath)) {" + NL + "\t\t\ti++;" + NL + "\t\t\tfilePath = containerFullPath.append(fileName + i);" + NL + "\t\t\tif (extension != null) {" + NL + "\t\t\t\tfilePath = filePath.addFileExtension(extension);" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\treturn filePath.lastSegment();" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void createControl(Composite parent) {" + NL + "\t\tsuper.createControl(parent);" + NL + "\t\tsetFileName(getUniqueFileName(getContainerFullPath(), getFileName()));" + NL + "\t\tsetPageComplete(validatePage());" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected boolean validatePage() {" + NL + "\t\tif (!super.validatePage()) {" + NL + "\t\t\treturn false;" + NL + "\t\t}" + NL + "\t\tString extension = getExtension();" + NL + "\t\tif (extension != null && !extension.equals(getFilePath().getFileExtension())) {" + NL + "\t\t\tsetErrorMessage(NLS.bind(\"File name should have ''{0}'' extension.\", extension));" + NL + "\t\t\treturn false;" + NL + "\t\t}" + NL + "\t\treturn true;" + NL + "\t}" + NL + "}"; + protected final String TEXT_17 = NL + NL + "\t"; + protected final String TEXT_18 = NL + "\t"; + protected final String TEXT_19 = NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprivate String getUniqueFileName(IPath containerFullPath, String fileName) {" + NL + "\t\tif (containerFullPath == null) {" + NL + "\t\t\tcontainerFullPath = new Path(\"\"); //$NON-NLS-1$" + NL + "\t\t}" + NL + "\t\tif (fileName == null || fileName.trim().length() == 0) {" + NL + "\t\t\tfileName = \"default\"; //$NON-NLS-1$" + NL + "\t\t}" + NL + "\t\tIPath filePath = containerFullPath.append(fileName);" + NL + "\t\tString extension = getExtension();" + NL + "\t\tif (extension != null && !extension.equals(filePath.getFileExtension())) {" + NL + "\t\t\tfilePath = filePath.addFileExtension(extension);" + NL + "\t\t}" + NL + "" + NL + "\t\textension = filePath.getFileExtension();" + NL + "\t\tfileName = filePath.removeFileExtension().lastSegment();" + NL + "\t\tint i = 1;" + NL + "\t\twhile ("; + protected final String TEXT_20 = ".exists(filePath)) {" + NL + "\t\t\ti++;" + NL + "\t\t\tfilePath = containerFullPath.append(fileName + i);" + NL + "\t\t\tif (extension != null) {" + NL + "\t\t\t\tfilePath = filePath.addFileExtension(extension);" + NL + "\t\t\t}" + NL + "\t\t}" + NL + "\t\treturn filePath.lastSegment();" + NL + "\t}" + NL + "\t"; + protected final String TEXT_21 = "\t" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tpublic void createControl(Composite parent) {" + NL + "\t\tsuper.createControl(parent);" + NL + "\t\tsetFileName(getUniqueFileName(getContainerFullPath(), getFileName()));" + NL + "\t\tsetPageComplete(validatePage());" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @generated" + NL + "\t */" + NL + "\tprotected boolean validatePage() {" + NL + "\t\tif (!super.validatePage()) {" + NL + "\t\t\treturn false;" + NL + "\t\t}" + NL + "\t\tString extension = getExtension();" + NL + "\t\tif (extension != null && !getFilePath().toString().endsWith(\".\" + extension)) {" + NL + "\t\t\tsetErrorMessage(NLS.bind(\"File name should have ''{0}'' extension.\", extension));" + NL + "\t\t\treturn false;" + NL + "\t\t}" + NL + "\t\treturn true;" + NL + "\t}" + NL + "}"; public String generate(Object argument) { @@ -80,8 +83,11 @@ stringBuffer.append(TEXT_16); } stringBuffer.append(TEXT_17); - stringBuffer.append(importManager.getImportedName(genDiagram.getDiagramEditorUtilQualifiedClassName())); stringBuffer.append(TEXT_18); + stringBuffer.append(TEXT_19); + stringBuffer.append(importManager.getImportedName(genDiagram.getDiagramEditorUtilQualifiedClassName())); + stringBuffer.append(TEXT_20); + stringBuffer.append(TEXT_21); importManager.emitSortedImports(); return stringBuffer.toString(); }