Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2006-05-19 11:56:00 +0000
committeratikhomirov2006-05-19 11:56:00 +0000
commitfb50f10c0f405f13e147d804add58f10e79faba2 (patch)
treedc2a49aa775acf681e123d59bf7ed24b70d1c9c0 /plugins/org.eclipse.gmf.codegen.ui
parent9cfbd1194d4cea4affac3d485f91588939dc9d42 (diff)
downloadorg.eclipse.gmf-tooling-fb50f10c0f405f13e147d804add58f10e79faba2.tar.gz
org.eclipse.gmf-tooling-fb50f10c0f405f13e147d804add58f10e79faba2.tar.xz
org.eclipse.gmf-tooling-fb50f10c0f405f13e147d804add58f10e79faba2.zip
Provide option to proceed with transformation even when gmfmap is bad
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/ErrorDialogEx.java58
-rw-r--r--plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/popup/actions/TransformToGenModel.java13
2 files changed, 66 insertions, 5 deletions
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
new file mode 100644
index 000000000..51633516b
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/popup/actions/ErrorDialogEx.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2006 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+package org.eclipse.gmf.internal.codegen.popup.actions;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * ErrorDialog with button variability of MessageDialog
+ * @author artem
+ */
+public class ErrorDialogEx extends ErrorDialog {
+
+ private final String[] myButtonLabels;
+
+ private final int[] myButtonIDs;
+
+ private final int myDefaultButtonIndex;
+
+
+ public ErrorDialogEx(Shell parentShell, String title, String message, IStatus status, String[] dialogButtonLabels, int[] buttonIDs, int defaultIndex) {
+ super(parentShell, title, message, status, IStatus.OK | IStatus.INFO | IStatus.WARNING | IStatus.ERROR);
+ assert dialogButtonLabels.length == buttonIDs.length;
+ assert dialogButtonLabels.length > 0;
+ assert defaultIndex >= 0 && defaultIndex < dialogButtonLabels.length;
+ myButtonLabels = dialogButtonLabels;
+ myButtonIDs = buttonIDs;
+ myDefaultButtonIndex = defaultIndex;
+ }
+
+ protected void createButtonsForButtonBar(Composite parent) {
+ for (int i = 0; i < myButtonLabels.length; i++) {
+ createButton(parent, myButtonIDs[i], myButtonLabels[i], myDefaultButtonIndex == i);
+ }
+ createDetailsButton(parent);
+ }
+
+ protected void buttonPressed(int buttonId) {
+ if (IDialogConstants.DETAILS_ID == buttonId) {
+ super.buttonPressed(buttonId);
+ } else {
+ setReturnCode(buttonId);
+ close();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/popup/actions/TransformToGenModel.java b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/popup/actions/TransformToGenModel.java
index e7a69bccc..bc36e7079 100644
--- a/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/popup/actions/TransformToGenModel.java
+++ b/plugins/org.eclipse.gmf.codegen.ui/src/org/eclipse/gmf/internal/codegen/popup/actions/TransformToGenModel.java
@@ -58,7 +58,6 @@ import org.eclipse.gmf.internal.common.reconcile.Reconciler;
import org.eclipse.gmf.internal.graphdef.codegen.ui.FigureGeneratorOptionsDialog;
import org.eclipse.gmf.mappings.Mapping;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IInputValidator;
import org.eclipse.jface.dialogs.InputDialog;
@@ -104,10 +103,14 @@ public class TransformToGenModel implements IObjectActionDelegate {
return;
}
if (mapIsValid.matches(IStatus.ERROR)) {
- ErrorDialog.openError(getShell(), action.getText(), CodeGenUIPlugin.getBundleString("transform.err"), mapIsValid);
- return;
- }
- if ((mapIsValid.matches(IStatus.INFO | IStatus.WARNING))) {
+ 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("transform.err");
+ ErrorDialogEx dlg = new ErrorDialogEx(getShell(), action.getText(), msg, mapIsValid, buttons, buttonIDs, 0);
+ if (dlg.open() == IDialogConstants.CANCEL_ID) {
+ return;
+ }
+ } else if ((mapIsValid.matches(IStatus.INFO | IStatus.WARNING))) {
if (!MessageDialogWithToggle.ALWAYS.equals(getPreferences().getString(ASK_WARN))) {
if (MessageDialogWithToggle.OK != MessageDialogWithToggle.openOkCancelConfirm(getShell(), action.getText(), CodeGenUIPlugin.getBundleString("transform.warn"), CodeGenUIPlugin.getBundleString("transform.neverwarn"), false, getPreferences(), ASK_WARN).getReturnCode()) {
return;

Back to the top