### 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 7 Dec 2006 09:19:12 -0000 @@ -82,25 +82,21 @@ if (fileName == null || fileName.trim().length() == 0) { fileName = "default"; //$NON-NLS-1$ } - IPath filePath = containerFullPath.append(fileName); - String extension = getExtension(); - if (extension != null && !extension.equals(filePath.getFileExtension())) { - filePath = filePath.addFileExtension(extension); - } - extension = filePath.getFileExtension(); - fileName = filePath.removeFileExtension().lastSegment(); + String extension = "." + getExtension(); + if (fileName.endsWith(extension)) { + fileName = fileName.substring(0, fileName.length() - extension.length()); + } int i = 1; - while (<%=importManager.getImportedName(genDiagram.getDiagramEditorUtilQualifiedClassName())%>.exists(filePath)) { + IPath filePath = containerFullPath.append(fileName + extension); + while (UMLDiagramEditorUtil.exists(filePath)) { i++; - filePath = containerFullPath.append(fileName + i); - if (extension != null) { - filePath = filePath.addFileExtension(extension); - } + filePath = containerFullPath.append(fileName + i + extension); } return filePath.lastSegment(); } + /** * @generated */ @@ -118,7 +114,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 7 Dec 2006 09:19:12 -0000 @@ -31,8 +31,7 @@ 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/**" + 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 + "" + NL + "\t\tString extension = \".\" + getExtension();" + NL + "\t\tif (fileName.endsWith(extension)) {" + NL + "\t\t\tfileName = fileName.substring(0, fileName.length() - extension.length());" + NL + "\t\t}" + NL + "\t\tint i = 1;" + NL + "\t\tIPath filePath = containerFullPath.append(fileName + extension);" + NL + "\t\twhile (UMLDiagramEditorUtil.exists(filePath)) {" + NL + "\t\t\ti++;" + NL + "\t\t\tfilePath = containerFullPath.append(fileName + i + extension);" + NL + "\t\t}" + NL + "\t\treturn filePath.lastSegment();" + NL + "\t}" + NL + "" + 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 +79,6 @@ stringBuffer.append(TEXT_16); } stringBuffer.append(TEXT_17); - stringBuffer.append(importManager.getImportedName(genDiagram.getDiagramEditorUtilQualifiedClassName())); - stringBuffer.append(TEXT_18); importManager.emitSortedImports(); return stringBuffer.toString(); }