Lines 61-76
Link Here
|
61 |
public static final String OPTION_MAIN_PACKAGE_NAME = SECTION_ID + ".mainPackageName"; |
61 |
public static final String OPTION_MAIN_PACKAGE_NAME = SECTION_ID + ".mainPackageName"; |
62 |
public static final String OPTION_NEEDS_MAP_MODE = SECTION_ID + ".needsMapMode"; |
62 |
public static final String OPTION_NEEDS_MAP_MODE = SECTION_ID + ".needsMapMode"; |
63 |
public static final String OPTION_INPUT_RESOURCE_FULL_PATH = SECTION_ID + ".inputResource"; |
63 |
public static final String OPTION_INPUT_RESOURCE_FULL_PATH = SECTION_ID + ".inputResource"; |
|
|
64 |
public static final String OPTION_OUTPUT_RESOURCE_FULL_PATH = SECTION_ID + ".outputResource"; |
64 |
|
65 |
|
65 |
private TemplateOption myPackageNameOption; |
66 |
private TemplateOption myPackageNameOption; |
66 |
private FileNameOption myInputPathOption; |
67 |
private FileNameOption myInputPathOption; |
|
|
68 |
private FileNameOption myOutputGalleryPathOption; |
67 |
private final CachedInputValidationState myCachedInputValidationState; |
69 |
private final CachedInputValidationState myCachedInputValidationState; |
68 |
private ManifestElement[] myRequiredBundles; |
70 |
private ManifestElement[] myRequiredBundles; |
69 |
|
71 |
|
70 |
public ConverterSection(){ |
72 |
public ConverterSection(){ |
71 |
setPageCount(THE_ONLY_PAGE_INDEX + 1); |
73 |
setPageCount(THE_ONLY_PAGE_INDEX + 1); |
72 |
myPackageNameOption = addOption(OPTION_MAIN_PACKAGE_NAME, "Generate figures package", null, THE_ONLY_PAGE_INDEX); |
74 |
myPackageNameOption = addOption(OPTION_MAIN_PACKAGE_NAME, "Generate figures package", null, THE_ONLY_PAGE_INDEX); |
73 |
myInputPathOption = addFileNameOption(OPTION_INPUT_RESOURCE_FULL_PATH, "Input GMFGraph instance", "", THE_ONLY_PAGE_INDEX); |
75 |
myInputPathOption = addFileNameOption(false, OPTION_INPUT_RESOURCE_FULL_PATH, "Input GMFGraph instance", "", THE_ONLY_PAGE_INDEX); |
|
|
76 |
myOutputGalleryPathOption = addFileNameOption(true, OPTION_OUTPUT_RESOURCE_FULL_PATH, "Create Figure Gallery", "", THE_ONLY_PAGE_INDEX); |
77 |
myOutputGalleryPathOption.setRequired(false); |
74 |
addOption(OPTION_NEEDS_MAP_MODE, "Use IMapMode", false, THE_ONLY_PAGE_INDEX); |
78 |
addOption(OPTION_NEEDS_MAP_MODE, "Use IMapMode", false, THE_ONLY_PAGE_INDEX); |
75 |
myCachedInputValidationState = new CachedInputValidationState(); |
79 |
myCachedInputValidationState = new CachedInputValidationState(); |
76 |
} |
80 |
} |
Lines 84-89
Link Here
|
84 |
markPagesAdded(); |
88 |
markPagesAdded(); |
85 |
validateOptions(myPackageNameOption); |
89 |
validateOptions(myPackageNameOption); |
86 |
validateOptions(myInputPathOption); |
90 |
validateOptions(myInputPathOption); |
|
|
91 |
validateOptions(myOutputGalleryPathOption); |
87 |
} |
92 |
} |
88 |
|
93 |
|
89 |
public IPluginReference[] getDependencies(String schemaVersion) { |
94 |
public IPluginReference[] getDependencies(String schemaVersion) { |
Lines 118-123
Link Here
|
118 |
if (!generator.getRunStatus().isOK()){ |
123 |
if (!generator.getRunStatus().isOK()){ |
119 |
throw new CoreException(generator.getRunStatus()); |
124 |
throw new CoreException(generator.getRunStatus()); |
120 |
} |
125 |
} |
|
|
126 |
createFigureGallery(generator.getGenerationInfo()); |
127 |
} |
128 |
|
129 |
private void createFigureGallery(StandaloneGenerator.GenerationInfo info) throws CoreException { |
130 |
if (!myOutputGalleryPathOption.isEmpty()){ |
131 |
String path = myOutputGalleryPathOption.getText(); |
132 |
Resource galleryResource = new ResourceSetImpl().createResource(URI.createFileURI(path)); |
133 |
galleryResource.getContents().add(new StandaloneGalleryConverter().convertFigureGallery(info)); |
134 |
try { |
135 |
galleryResource.save(null); |
136 |
} catch (IOException e) { |
137 |
throw new CoreException(new Status(// |
138 |
IStatus.ERROR, MY_PLUGIN_ID, 0, e.getMessage(), e |
139 |
)); |
140 |
} |
141 |
} |
121 |
} |
142 |
} |
122 |
|
143 |
|
123 |
private void readRequiredBundles() throws CoreException, IOException { |
144 |
private void readRequiredBundles() throws CoreException, IOException { |
Lines 190-195
Link Here
|
190 |
if (!validateInputPath()){ |
211 |
if (!validateInputPath()){ |
191 |
return; |
212 |
return; |
192 |
} |
213 |
} |
|
|
214 |
if (!validateOutputGalleryPath()){ |
215 |
return; |
216 |
} |
193 |
resetPageState(); |
217 |
resetPageState(); |
194 |
} |
218 |
} |
195 |
|
219 |
|
Lines 253-260
Link Here
|
253 |
return buffer.toString().toLowerCase(Locale.ENGLISH); |
277 |
return buffer.toString().toLowerCase(Locale.ENGLISH); |
254 |
} |
278 |
} |
255 |
|
279 |
|
256 |
private FileNameOption addFileNameOption(String name, String label, String value, int pageIndex) { |
280 |
private FileNameOption addFileNameOption(boolean saveNotLoad, String name, String label, String value, int pageIndex) { |
257 |
FileNameOption result = new FileNameOption(this, name, label, new String[] {"*.gmfgraph"}); |
281 |
FileNameOption result = new FileNameOption(this, name, label, new String[] {"*.gmfgraph"}); |
|
|
282 |
result.setSaveNotLoad(saveNotLoad); |
258 |
registerOption(result, value, pageIndex); |
283 |
registerOption(result, value, pageIndex); |
259 |
return result; |
284 |
return result; |
260 |
} |
285 |
} |
Lines 281-286
Link Here
|
281 |
} |
306 |
} |
282 |
return true; |
307 |
return true; |
283 |
} |
308 |
} |
|
|
309 |
|
310 |
private boolean validateOutputGalleryPath() { |
311 |
if (myOutputGalleryPathOption.isEmpty()){ |
312 |
//optional -- ok |
313 |
return true; |
314 |
} |
315 |
String path = myOutputGalleryPathOption.getText(); |
316 |
try { |
317 |
URI.createFileURI(path); |
318 |
} catch (IllegalArgumentException e){ |
319 |
String message = MessageFormat.format("Path {0} is invalid", new Object[] {path}); |
320 |
getTheOnlyPage().setPageComplete(false); |
321 |
getTheOnlyPage().setErrorMessage(message); |
322 |
return false; |
323 |
} |
324 |
return true; |
325 |
} |
284 |
|
326 |
|
285 |
private WizardPage getTheOnlyPage() { |
327 |
private WizardPage getTheOnlyPage() { |
286 |
return getPage(THE_ONLY_PAGE_INDEX); |
328 |
return getPage(THE_ONLY_PAGE_INDEX); |