Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-04-11 19:53:51 +0000
committeratikhomirov2006-04-11 19:53:51 +0000
commit82e21d10c7629294310007ed4d69278e5806d95a (patch)
tree1fc531dd8d330692cb2d789bce8fdf822f7a938c /plugins/org.eclipse.gmf.codegen.ui
parent7e88da4418a934a6a6e9778219b596c51600bc17 (diff)
downloadorg.eclipse.gmf-tooling-82e21d10c7629294310007ed4d69278e5806d95a.tar.gz
org.eclipse.gmf-tooling-82e21d10c7629294310007ed4d69278e5806d95a.tar.xz
org.eclipse.gmf-tooling-82e21d10c7629294310007ed4d69278e5806d95a.zip
handle InvocationTargetException which may provide information about RuntimeException we didn't manage to handle in generator
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen.ui')
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/popup/actions/ExecuteTemplatesAction.java23
1 files changed, 20 insertions, 3 deletions
diff --git a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/popup/actions/ExecuteTemplatesAction.java b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/popup/actions/ExecuteTemplatesAction.java
index 1681fd2b6..3bac2128a 100644
--- a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/popup/actions/ExecuteTemplatesAction.java
+++ b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/popup/actions/ExecuteTemplatesAction.java
@@ -14,6 +14,7 @@ package org.eclipse.gmf.internal.codegen.popup.actions;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -73,8 +74,7 @@ public class ExecuteTemplatesAction implements IObjectActionDelegate, IRunnableW
}
}
- myRunStatus = Status.CANCEL_STATUS;
- new ProgressMonitorDialog(getShell()).run(true, true, this);
+ doRunWithStatus();
if (getRunStatus().isOK()) {
if (!MessageDialogWithToggle.ALWAYS.equals(getPreferences().getString(ASK_OK))) {
@@ -90,13 +90,30 @@ public class ExecuteTemplatesAction implements IObjectActionDelegate, IRunnableW
MessageDialogWithToggle.openInformation(getShell(), action.getText(), formatMessage("generatecode.info", getRunStatus()), CodeGenUIPlugin.getBundleString("generatecode.neveragain"), false, getPreferences(), ASK_INFO);
}
}
- } catch (InvocationTargetException ex) {
} catch (InterruptedException ex) {
+ // presumably, user canceled the operation, don't bother him with additional messages
} finally {
unloadGenModel();
}
}
+ /**
+ * @return
+ */
+ private void doRunWithStatus() throws InterruptedException {
+ myRunStatus = Status.CANCEL_STATUS;
+ try {
+ new ProgressMonitorDialog(getShell()).run(true, true, this);
+ } catch (InvocationTargetException ex) {
+ Throwable targetException = ex.getTargetException();
+ if (targetException instanceof CoreException) {
+ myRunStatus = ((CoreException)targetException).getStatus();
+ } else {
+ myRunStatus = new Status(IStatus.ERROR, CodeGenUIPlugin.getPluginID(), 0, "Exception occurred while generating code", targetException);
+ }
+ }
+ }
+
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
Generator g = new Generator(getGenModel());
g.run(monitor);

Back to the top