Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-05-19 13:09:29 +0000
committeratikhomirov2006-05-19 13:09:29 +0000
commitc7570ce689f207c9353a2df1e84e329421bacebe (patch)
tree05a0f00a9af45e133b73ae2f4526cc530ba70fdf /plugins/org.eclipse.gmf.codegen.ui
parent9f19b8e442685cec0edd534f83545c0cb9189aaa (diff)
downloadorg.eclipse.gmf-tooling-c7570ce689f207c9353a2df1e84e329421bacebe.tar.gz
org.eclipse.gmf-tooling-c7570ce689f207c9353a2df1e84e329421bacebe.tar.xz
org.eclipse.gmf-tooling-c7570ce689f207c9353a2df1e84e329421bacebe.zip
better validation error reporting
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen.ui')
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/plugin.properties8
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/CodeGenUIPlugin.java21
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/popup/actions/ErrorDialogEx.java1
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/popup/actions/ExecuteTemplatesAction.java22
4 files changed, 15 insertions, 37 deletions
diff --git a/plugins/org.eclipse.gmf.codegen.ui/plugin.properties b/plugins/org.eclipse.gmf.codegen.ui/plugin.properties
index d66389321..d405e3f2d 100644
--- a/plugins/org.eclipse.gmf.codegen.ui/plugin.properties
+++ b/plugins/org.eclipse.gmf.codegen.ui/plugin.properties
@@ -15,11 +15,11 @@ transform.action=Create generator model...
generatecode.action=Generate diagram code
generatecode.ok=Code generation completed successfully.
-generatecode.info=Code generation was successful, although few subtle notes:\n{0}
-generatecode.warn=There are some non-critical problems with generated code:\n{0}
-generatecode.err=Errors while generating code:\n{0}
+generatecode.info=Code generation was successful, although with few subtle notes
+generatecode.warn=There are some non-critical problems with generated code
+generatecode.err=Errors while generating code
generatecode.neveragain=Never show me this dialog again.
-generatecode.badsrc=Source generator model is not completely ok, would you like to proceed?\n{0}
+generatecode.badsrc=Source generator model is not completely ok, would you like to proceed?
transform.err=Problems were encountered in mapping definition
transform.warn=There are non-critical issues with mapping definition, would you like to proceed?\n{0}
diff --git a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/CodeGenUIPlugin.java b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/CodeGenUIPlugin.java
index d4b591919..97896e19e 100644
--- a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/CodeGenUIPlugin.java
+++ b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/CodeGenUIPlugin.java
@@ -68,27 +68,6 @@ public class CodeGenUIPlugin extends AbstractUIPlugin {
return getDefault().getBundle().getSymbolicName();
}
- public static String formatMessage(String bundleStringKey, IStatus status) {
- if (status.isMultiStatus()) {
- IStatus[] children = status.getChildren();
- StringBuffer sb = new StringBuffer();
- // don't care about too nested statuses just because will switch to
- // jobs soon, with
- // required support already in place
- for (int i = 0; i < children.length && i < 3; i++) {
- sb.append(children[i].getMessage());
- sb.append('\n');
- sb.append('\n');
- }
- if (children.length >= 3) {
- sb.append("...");
- }
- return CodeGenUIPlugin.getBundleString(bundleStringKey, new Object[] { sb.toString() });
- } else {
- return CodeGenUIPlugin.getBundleString(bundleStringKey, new Object[] { status.getMessage() });
- }
- }
-
public static boolean needsReconcile() {
return !Boolean.FALSE.toString().equals(Platform.getDebugOption(getPluginID() + "/reconcile"));
}
diff --git a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/popup/actions/ErrorDialogEx.java b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/popup/actions/ErrorDialogEx.java
index 51633516b..f8a231b66 100644
--- a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/popup/actions/ErrorDialogEx.java
+++ b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/popup/actions/ErrorDialogEx.java
@@ -19,6 +19,7 @@ import org.eclipse.swt.widgets.Shell;
/**
* ErrorDialog with button variability of MessageDialog
+ * TODO add toggle mechanism like in MessageDialogWithToggle
* @author artem
*/
public class ErrorDialogEx extends ErrorDialog {
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 1293489bf..077ef6802 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
@@ -30,7 +30,8 @@ import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
import org.eclipse.gmf.codegen.util.Generator;
import org.eclipse.gmf.internal.codegen.CodeGenUIPlugin;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
@@ -48,7 +49,6 @@ import org.eclipse.ui.IWorkbenchPart;
*/
public class ExecuteTemplatesAction implements IObjectActionDelegate, IRunnableWithProgress {
- private static final String ASK_INFO = "ask_info";
private static final String ASK_OK = "ask_ok";
private IFile mySelection;
@@ -69,7 +69,11 @@ public class ExecuteTemplatesAction implements IObjectActionDelegate, IRunnableW
assert getGenModel() != null;
IStatus isGenModelValid = validateGenModel();
if (!isGenModelValid.isOK()) {
- if (!MessageDialog.openConfirm(getShell(), action.getText(), formatMessage("generatecode.badsrc", isGenModelValid))) {
+ final String[] buttons = new String[] {IDialogConstants.PROCEED_LABEL, IDialogConstants.CANCEL_LABEL };
+ final int[] buttonIDs = new int[] {IDialogConstants.PROCEED_ID, IDialogConstants.CANCEL_ID };
+ final String msg = CodeGenUIPlugin.getBundleString("generatecode.badsrc");
+ ErrorDialogEx dlg = new ErrorDialogEx(getShell(), action.getText(), msg, isGenModelValid, buttons, buttonIDs, 0);
+ if (dlg.open() == IDialogConstants.CANCEL_ID) {
return;
}
}
@@ -82,13 +86,11 @@ public class ExecuteTemplatesAction implements IObjectActionDelegate, IRunnableW
}
} else if (myRunStatus.matches(IStatus.ERROR)) {
CodeGenUIPlugin.getDefault().getLog().log(getRunStatus());
- MessageDialog.openError(getShell(), action.getText(), formatMessage("generatecode.err", getRunStatus()));
+ ErrorDialog.openError(getShell(), action.getText(), CodeGenUIPlugin.getBundleString("generatecode.err"), getRunStatus());
} else if (myRunStatus.matches(IStatus.WARNING)) {
- MessageDialog.openWarning(getShell(), action.getText(), formatMessage("generatecode.warn", getRunStatus()));
+ ErrorDialog.openError(getShell(), action.getText(), CodeGenUIPlugin.getBundleString("generatecode.warn"), getRunStatus());
} else if (myRunStatus.matches(IStatus.INFO)) {
- if (!MessageDialogWithToggle.ALWAYS.equals(getPreferences().getString(ASK_INFO))) {
- MessageDialogWithToggle.openInformation(getShell(), action.getText(), formatMessage("generatecode.info", getRunStatus()), CodeGenUIPlugin.getBundleString("generatecode.neveragain"), false, getPreferences(), ASK_INFO);
- }
+ ErrorDialog.openError(getShell(), action.getText(), CodeGenUIPlugin.getBundleString("generatecode.info"), getRunStatus());
}
} catch (InterruptedException ex) {
// presumably, user canceled the operation, don't bother him with additional messages
@@ -130,10 +132,6 @@ public class ExecuteTemplatesAction implements IObjectActionDelegate, IRunnableW
action.setEnabled(true);
}
- private static String formatMessage(String bundleStringKey, IStatus status) {
- return CodeGenUIPlugin.formatMessage(bundleStringKey, status);
- }
-
private IStatus getRunStatus() {
return myRunStatus;
}

Back to the top