Skip to content

Commit 56a6d20

Browse files
committed
Graphviz installation check only 'soft-try' (continue of PATH cannot be checked)
1 parent 9762435 commit 56a6d20

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

org.contextmapper.dsl.ui/src/org/contextmapper/dsl/ui/handler/ContextMapGenerationHandler.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@
1919
import org.contextmapper.dsl.generator.exception.GeneratorInputException;
2020
import org.contextmapper.dsl.ui.handler.wizard.GenerateContextMapContext;
2121
import org.contextmapper.dsl.ui.handler.wizard.GenerateContextMapWizard;
22+
import org.contextmapper.dsl.ui.internal.DslActivator;
2223
import org.eclipse.core.commands.ExecutionEvent;
24+
import org.eclipse.core.runtime.IStatus;
25+
import org.eclipse.core.runtime.Status;
2326
import org.eclipse.emf.ecore.resource.Resource;
2427
import org.eclipse.jface.dialogs.MessageDialog;
2528
import org.eclipse.jface.wizard.WizardDialog;
2629
import org.eclipse.swt.widgets.Display;
2730
import org.eclipse.ui.handlers.HandlerUtil;
31+
import org.eclipse.ui.statushandlers.StatusManager;
2832
import org.eclipse.xtext.generator.GeneratorContext;
2933
import org.eclipse.xtext.generator.IFileSystemAccess2;
3034
import org.eclipse.xtext.generator.IGenerator2;
@@ -43,10 +47,18 @@ protected IGenerator2 getGenerator() {
4347

4448
@Override
4549
protected void runGeneration(Resource resource, ExecutionEvent event, IFileSystemAccess2 fsa) {
46-
if (!generator.isGraphvizInstalled()) {
47-
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "Graphviz installation not found",
48-
"Graphviz has not been found on your system. Ensure it is installed and the binaries are part of your PATH environment variable.");
49-
return;
50+
try {
51+
if (!generator.isGraphvizInstalled()) {
52+
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "Graphviz installation not found",
53+
"Graphviz has not been found on your system. Ensure it is installed and the binaries are part of your PATH environment variable.");
54+
return;
55+
}
56+
} catch (Exception e) {
57+
String message = e.getMessage() != null && !"".equals(e.getMessage()) ? e.getMessage() : e.getClass().getName() + " occurred in " + this.getClass().getName();
58+
Status status = new Status(IStatus.ERROR, DslActivator.PLUGIN_ID, message, e);
59+
StatusManager.getManager().handle(status);
60+
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), "Graphviz installation check",
61+
"Your PATH variable could not be parsed to check if Graphviz is installed. The generator may not work if Graphviz is not available.");
5062
}
5163

5264
GenerateContextMapContext context = new GenerateContextMapContext();

0 commit comments

Comments
 (0)