Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2013-06-07 15:19:39 +0000
committervlorenzo2013-06-07 15:19:39 +0000
commite373543be5dadbe6883b64ca7f3d66bbb2c07edc (patch)
tree6d9dcd147d5af6e4400a9787b5a00132e631b03d /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common
parent22dde23beefb0cfd2f1fc5e61b445247446d9960 (diff)
downloadorg.eclipse.papyrus-e373543be5dadbe6883b64ca7f3d66bbb2c07edc.tar.gz
org.eclipse.papyrus-e373543be5dadbe6883b64ca7f3d66bbb2c07edc.tar.xz
org.eclipse.papyrus-e373543be5dadbe6883b64ca7f3d66bbb2c07edc.zip
410206: [General] [Diagram] Hide and Delete seems binded on the same shortcut : Delete key
https://bugs.eclipse.org/bugs/show_bug.cgi?id=410206
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml20
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/DeleteFromDiagramCommandHandler.java48
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/DeleteFromModelCommandHandler.java57
4 files changed, 110 insertions, 18 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF
index 860e2a2ca28..ce720e36764 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/META-INF/MANIFEST.MF
@@ -83,7 +83,8 @@ Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="0.10.0",
org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="0.10.0",
org.eclipse.papyrus.infra.emf;bundle-version="0.10.0",
org.eclipse.papyrus.infra.widgets;bundle-version="0.10.0",
- org.eclipse.papyrus.infra.services.labelprovider;bundle-version="0.10.0"
+ org.eclipse.papyrus.infra.services.labelprovider;bundle-version="0.10.0",
+ org.eclipse.jface
Bundle-Vendor: %providerName
Ant-Version: Apache Ant 1.7.0
Bundle-Version: 0.10.0.qualifier
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml
index ceb092af9e6..6744c69c60c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/plugin.xml
@@ -225,14 +225,8 @@
commandId="org.eclipse.papyrus.uml.diagram.common.commands.DeleteFromDiagram"
contextId="org.eclipse.gmf.runtime.diagram.ui.diagramContext"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
- sequence="DEL">
- </key>
- <key
- commandId="org.eclipse.ui.edit.delete"
- contextId="org.eclipse.gmf.runtime.diagram.ui.diagramContext"
- schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
- sequence="CTRL+DEL">
- </key>
+ sequence="M2+DEL">
+ </key>
</extension>
<extension
point="org.eclipse.papyrus.infra.core.papyrusDiagram">
@@ -423,15 +417,7 @@
</extension>
<extension point="org.eclipse.ui.commands">
-
- <command
- categoryId="org.eclipse.papyrus.editor.category"
- defaultHandler="org.eclipse.papyrus.uml.diagram.common.handlers.DeleteFromModelCommandHandler"
- description="Delete the selection from model"
- id="org.eclipse.papyrus.uml.diagram.common.commands.DeleteFromModel"
- name="Delete From Model Command">
- </command>
-
+
<command
categoryId="org.eclipse.papyrus.editor.category"
defaultHandler="org.eclipse.papyrus.uml.diagram.common.handlers.DeleteFromDiagramCommandHandler"
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/DeleteFromDiagramCommandHandler.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/DeleteFromDiagramCommandHandler.java
index 6f28dfe6c99..3430432e685 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/DeleteFromDiagramCommandHandler.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/DeleteFromDiagramCommandHandler.java
@@ -16,6 +16,7 @@ package org.eclipse.papyrus.uml.diagram.common.handlers;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.emf.ecore.EObject;
@@ -31,6 +32,11 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.uml.diagram.common.Activator;
+import org.eclipse.swt.widgets.Display;
/**
* Command handler for delete from diagram
@@ -122,4 +128,46 @@ public class DeleteFromDiagramCommandHandler extends GraphicalCommandHandler imp
}
return false;
}
+
+ /**
+ *
+ * @see org.eclipse.papyrus.uml.diagram.common.handlers.GraphicalCommandHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ if(canDoAction()) {//the key binding for Delete and Hide action changed, so we display a message for the users
+ return super.execute(event);
+ }
+ return null;
+ }
+
+ private static final String DISPLAY_MESSAGE_FOR_HIDE_ACTION_PREFERENCE_KEY = "displayMessageForHideActionPreferenceKey";
+
+ /**
+ *
+ * @return
+ * <code>true</code> if the action can be done
+ */
+ private boolean canDoAction() {
+ final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ boolean contains = store.contains(DISPLAY_MESSAGE_FOR_HIDE_ACTION_PREFERENCE_KEY);
+ if(!contains) {
+ store.setValue(DISPLAY_MESSAGE_FOR_HIDE_ACTION_PREFERENCE_KEY, MessageDialogWithToggle.NEVER);
+ store.setDefault(DISPLAY_MESSAGE_FOR_HIDE_ACTION_PREFERENCE_KEY, MessageDialogWithToggle.NEVER);
+ }
+ final String hideValue = store.getString(DISPLAY_MESSAGE_FOR_HIDE_ACTION_PREFERENCE_KEY);
+ if(!hideValue.equals(MessageDialogWithToggle.ALWAYS)) {
+
+ final MessageDialogWithToggle toggle = MessageDialogWithToggle.openYesNoQuestion(Display.getDefault().getActiveShell(), "Hide Action", "WARNING! The Shorcuts for Hide and Delete actions have changed. \n \n Do you really want to hide an element of the diagram?", "Don't show this dialog the next time", false, store, DISPLAY_MESSAGE_FOR_HIDE_ACTION_PREFERENCE_KEY);
+ int returnCode = toggle.getReturnCode();
+ if(returnCode != IDialogConstants.YES_ID) {
+ return false;
+ }
+ }
+ return true;
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/DeleteFromModelCommandHandler.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/DeleteFromModelCommandHandler.java
index e8ab313b8b5..2f58bd36f5d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/DeleteFromModelCommandHandler.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/handlers/DeleteFromModelCommandHandler.java
@@ -16,8 +16,12 @@ package org.eclipse.papyrus.uml.diagram.common.handlers;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.preferences.ConfigurationScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.UnexecutableCommand;
import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy;
@@ -27,12 +31,23 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
+import org.eclipse.jface.dialogs.DialogSettings;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.DialogCellEditor;
+import org.eclipse.papyrus.uml.diagram.common.Activator;
+import org.eclipse.swt.widgets.Display;
/**
* Command handler for delete from diagram
*/
public class DeleteFromModelCommandHandler extends GraphicalCommandHandler implements IHandler {
+
+
protected Command getCommand() throws ExecutionException {
// Retrieve currently selected IGraphicalEditPart(s)
@@ -65,4 +80,46 @@ public class DeleteFromModelCommandHandler extends GraphicalCommandHandler imple
return new ICommandProxy(command);
}
+
+ /**
+ *
+ * @see org.eclipse.papyrus.uml.diagram.common.handlers.GraphicalCommandHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ *
+ * @param event
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ if(canDoAction()) {//the key binding for Delete and Hide action changed, so we display a message for the users
+ return super.execute(event);
+ }
+ return null;
+ }
+
+ private static final String DISPLAY_MESSAGE_FOR_DELETE_ACTION_PREFERENCE_KEY = "displayMessageForDeleteActionPreferenceKey";
+
+ /**
+ *
+ * @return
+ * <code>true</code> if the action can be done
+ */
+ protected boolean canDoAction() {
+ final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ boolean contains = store.contains(DISPLAY_MESSAGE_FOR_DELETE_ACTION_PREFERENCE_KEY);
+ if(!contains) {
+ store.setValue(DISPLAY_MESSAGE_FOR_DELETE_ACTION_PREFERENCE_KEY, MessageDialogWithToggle.NEVER);
+ store.setDefault(DISPLAY_MESSAGE_FOR_DELETE_ACTION_PREFERENCE_KEY, MessageDialogWithToggle.NEVER);
+ }
+ final String hideValue = store.getString(DISPLAY_MESSAGE_FOR_DELETE_ACTION_PREFERENCE_KEY);
+ if(!hideValue.equals(MessageDialogWithToggle.ALWAYS)) {
+
+ final MessageDialogWithToggle toggle = MessageDialogWithToggle.openYesNoQuestion(Display.getDefault().getActiveShell(), "Delete Action", "WARNING! The Shorcuts for Hide and Delete actions have changed. \n \n Do you really want to delete an element of the model?", "Don't show this dialog the next time", false, store, DISPLAY_MESSAGE_FOR_DELETE_ACTION_PREFERENCE_KEY);
+ int returnCode = toggle.getReturnCode();
+ if(returnCode != IDialogConstants.YES_ID) {
+ return false;
+ }
+ }
+ return true;
+ }
}

Back to the top