View | Details | Raw Unified | Return to bug 167048 | Differences between
and this patch

Collapse All | Expand All

(-)templates/editor/CreationWizardPage.javajet (-1 / +4 lines)
Lines 72-77 Link Here
72
	}
72
	}
73
<%}%>
73
<%}%>
74
74
75
	<%@ include file="CreationWizardPage_getUniqueFileName.jetinc" fail="alternative"%>
76
	<%@ start%>
75
	/**
77
	/**
76
	 * @generated
78
	 * @generated
77
	 */
79
	 */
Lines 100-105 Link Here
100
		}
102
		}
101
		return filePath.lastSegment();
103
		return filePath.lastSegment();
102
	}
104
	}
105
	<%@ end%>	
103
106
104
	/**
107
	/**
105
	 * @generated
108
	 * @generated
Lines 118-124 Link Here
118
			return false;
121
			return false;
119
		}
122
		}
120
		String extension = getExtension();
123
		String extension = getExtension();
121
		if (extension != null && !extension.equals(getFilePath().getFileExtension())) {
124
		if (extension != null && !getFilePath().toString().endsWith("." + extension)) {
122
			setErrorMessage(NLS.bind("File name should have ''{0}'' extension.", extension));
125
			setErrorMessage(NLS.bind("File name should have ''{0}'' extension.", extension));
123
			return false;
126
			return false;
124
		}
127
		}
(-)src-templates/org/eclipse/gmf/codegen/templates/editor/CreationWizardPageGenerator.java (-3 / +9 lines)
Lines 31-38 Link Here
31
  protected final String TEXT_14 = NL + "\t\treturn URI.createFileURI(getFilePath().toString());";
31
  protected final String TEXT_14 = NL + "\t\treturn URI.createFileURI(getFilePath().toString());";
32
  protected final String TEXT_15 = NL + "\t}";
32
  protected final String TEXT_15 = NL + "\t}";
33
  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}";
33
  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}";
34
  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 (";
34
  protected final String TEXT_17 = NL + NL + "\t";
35
  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 + "}";
35
  protected final String TEXT_18 = NL + "\t";
36
  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 (";
37
  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";
38
  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 + "}";
36
39
37
  public String generate(Object argument)
40
  public String generate(Object argument)
38
  {
41
  {
Lines 80-87 Link Here
80
    stringBuffer.append(TEXT_16);
83
    stringBuffer.append(TEXT_16);
81
    }
84
    }
82
    stringBuffer.append(TEXT_17);
85
    stringBuffer.append(TEXT_17);
83
    stringBuffer.append(importManager.getImportedName(genDiagram.getDiagramEditorUtilQualifiedClassName()));
84
    stringBuffer.append(TEXT_18);
86
    stringBuffer.append(TEXT_18);
87
    stringBuffer.append(TEXT_19);
88
    stringBuffer.append(importManager.getImportedName(genDiagram.getDiagramEditorUtilQualifiedClassName()));
89
    stringBuffer.append(TEXT_20);
90
    stringBuffer.append(TEXT_21);
85
    importManager.emitSortedImports();
91
    importManager.emitSortedImports();
86
    return stringBuffer.toString();
92
    return stringBuffer.toString();
87
  }
93
  }

Return to bug 167048