Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormvelten2012-04-03 10:54:45 +0000
committermvelten2012-04-03 10:54:45 +0000
commit5f93b01834d0dc5443632a6c030e3def6dff6fa0 (patch)
treef4b823a53681445bd2c9961bccfa1eaef9c24f1e
parent77b6fb21b6f91b2ea8fb5bd59976615485d83084 (diff)
downloadorg.eclipse.papyrus-5f93b01834d0dc5443632a6c030e3def6dff6fa0.tar.gz
org.eclipse.papyrus-5f93b01834d0dc5443632a6c030e3def6dff6fa0.tar.xz
org.eclipse.papyrus-5f93b01834d0dc5443632a6c030e3def6dff6fa0.zip
NEW - bug 375927: Uncontrol action should trigger an automatic save
https://bugs.eclipse.org/bugs/show_bug.cgi?id=375927
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/PapyrusUncontrolAction.java55
-rw-r--r--plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/ControlCommand.java32
2 files changed, 45 insertions, 42 deletions
diff --git a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/PapyrusUncontrolAction.java b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/PapyrusUncontrolAction.java
index 19cfa39d410..cb828136f12 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/PapyrusUncontrolAction.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/action/PapyrusUncontrolAction.java
@@ -13,6 +13,8 @@
*****************************************************************************/
package org.eclipse.papyrus.controlmode.action;
+import java.util.ArrayList;
+
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
@@ -32,9 +34,10 @@ import org.eclipse.papyrus.resource.AbstractBaseModel;
import org.eclipse.papyrus.resource.IModel;
import org.eclipse.papyrus.resource.ModelUtils;
import org.eclipse.papyrus.resource.uml.UmlModel;
+import org.eclipse.papyrus.ui.toolbox.notification.NotificationRunnable;
import org.eclipse.papyrus.ui.toolbox.notification.Type;
+import org.eclipse.papyrus.ui.toolbox.notification.builders.IContext;
import org.eclipse.papyrus.ui.toolbox.notification.builders.NotificationBuilder;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
/**
@@ -116,16 +119,48 @@ public class PapyrusUncontrolAction extends CommandActionHandler {
return;
}
- try {
- boolean confirmDelete = MessageDialog.openQuestion(Display.getDefault().getActiveShell(), "Delete controlled resources?", "Delete the original controlled files ?");
- UncontrolCommand transactionalCommand = new UncontrolCommand(EditorUtils.getTransactionalEditingDomain(), eObject, "Uncontrol", null, confirmDelete);
- IStatus status = CheckedOperationHistory.getInstance().execute(transactionalCommand, new NullProgressMonitor(), null);
- if (!status.isOK()) {
- NotificationBuilder.createErrorPopup(status.getMessage()).setTitle("Unable to uncontrol").run();
+ final ArrayList<UncontrolCommand> uncontrolCommand = new ArrayList<UncontrolCommand>();
+ new NotificationBuilder().setType(Type.QUESTION).setAsynchronous(false).setTemporary(false).setHTML(true)
+ .setMessage("<form><p>This uncontrol action will save your model.</p><p>Delete the original controlled files ?</p></form>")
+ .addAction(new NotificationRunnable() {
+
+ public void run(IContext context) {
+ uncontrolCommand.add(new UncontrolCommand(EditorUtils.getTransactionalEditingDomain(), eObject, "Uncontrol", null, true));
+ }
+
+ public String getLabel() {
+ return "Yes";
+ }
+ }).addAction(new NotificationRunnable() {
+
+ public void run(IContext context) {
+ uncontrolCommand.add(new UncontrolCommand(EditorUtils.getTransactionalEditingDomain(), eObject, "Uncontrol", null, false));
+ }
+
+ public String getLabel() {
+ return "No";
+ }
+ }).addAction(new NotificationRunnable() {
+
+ public void run(IContext context) {}
+
+ public String getLabel() {
+ return "Cancel";
+ }
+ }).run();
+
+ if (!uncontrolCommand.isEmpty()) {
+ try {
+ IStatus status = CheckedOperationHistory.getInstance().execute(uncontrolCommand.get(0), new NullProgressMonitor(), null);
+ if (status.isOK()) {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
+ } else {
+ NotificationBuilder.createErrorPopup(status.getMessage()).setTitle("Unable to uncontrol").run();
+ }
+ } catch (ExecutionException e) {
+ MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_InvalidURI_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_CannotCreateResource"));
+ EMFEditUIPlugin.INSTANCE.log(e);
}
- } catch (ExecutionException e) {
- MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), EMFEditUIPlugin.INSTANCE.getString("_UI_InvalidURI_label"), EMFEditUIPlugin.INSTANCE.getString("_WARN_CannotCreateResource"));
- EMFEditUIPlugin.INSTANCE.log(e);
}
}
diff --git a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/ControlCommand.java b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/ControlCommand.java
index 4287a92c695..e32d6783cce 100644
--- a/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/ControlCommand.java
+++ b/plugins/core/org.eclipse.papyrus.controlmode/src/org/eclipse/papyrus/controlmode/commands/ControlCommand.java
@@ -27,7 +27,6 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.command.CompoundCommand;
@@ -65,12 +64,6 @@ import org.eclipse.papyrus.sashwindows.di.PageRef;
import org.eclipse.papyrus.sashwindows.di.SashWindowsMngr;
import org.eclipse.papyrus.sashwindows.di.exception.SashEditorException;
import org.eclipse.papyrus.sashwindows.di.util.DiUtils;
-import org.eclipse.papyrus.ui.toolbox.notification.NotificationRunnable;
-import org.eclipse.papyrus.ui.toolbox.notification.Type;
-import org.eclipse.papyrus.ui.toolbox.notification.builders.IContext;
-import org.eclipse.papyrus.ui.toolbox.notification.builders.NotificationBuilder;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
/**
* The Class ControlCommand in charge of controlling all papyrus resources
@@ -303,31 +296,6 @@ public class ControlCommand extends AbstractTransactionalCommand {
}
/**
- * Display asynchronous popup to inform user about the control action
- */
- protected void notifySave() {
- new NotificationBuilder().setMessage("Your element has been controlled.\nYou need to save your model to see modifications in your workspace.\nDo you want to save ?").addAction(new NotificationRunnable() {
-
- public void run(IContext context) {
- try {
- Display.getDefault().syncExec(new Runnable() {
-
- public void run() {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().doSave(new NullProgressMonitor());
- }
- });
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public String getLabel() {
- return "Save";
- }
- }).setTemporary(true).setAsynchronous(true).setType(Type.INFO).setDelay(2000).run();
- }
-
- /**
* Analyze the history model to update the controlled children
*
* @param domain

Back to the top