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 |
} |