Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSopot Cela2012-09-10 09:09:14 -0400
committerSopot Cela2012-09-10 09:09:14 -0400
commita64b5dc46a5d25f35d4f9ce80e19884b44d3c918 (patch)
tree7a4fd459afa00217d6f3b2aafd13b55594f759dd
parentce677e7f2d33cb43d9d397dd7ef268217184de6a (diff)
downloadorg.eclipse.e4.tools-a64b5dc46a5d25f35d4f9ce80e19884b44d3c918.tar.gz
org.eclipse.e4.tools-a64b5dc46a5d25f35d4f9ce80e19884b44d3c918.tar.xz
org.eclipse.e4.tools-a64b5dc46a5d25f35d4f9ce80e19884b44d3c918.zip
Bug 385063 - [Tooling] Support delete key for model elements
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
index 02f1430c..698e119b 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java
@@ -200,6 +200,8 @@ import org.eclipse.swt.dnd.DragSourceAdapter;
import org.eclipse.swt.dnd.DragSourceEvent;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.dnd.TransferData;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.RGB;
@@ -507,6 +509,24 @@ public class ModelEditor {
// scrolling.setLayoutData(new GridData(GridData.FILL_BOTH));
contentContainer.setLayout(layout);
+ viewer.getTree().addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyReleased(final KeyEvent e) {
+ if (e.keyCode == SWT.DEL) {
+ final IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+ if (selection.getFirstElement() instanceof EObject) {
+ EObject o = (EObject) selection.getFirstElement();
+
+ Command cmd = DeleteCommand.create(ModelEditor.this.modelProvider.getEditingDomain(), o);
+ if (cmd.canExecute()) {
+ ModelEditor.this.modelProvider.getEditingDomain().getCommandStack().execute(cmd);
+ }
+ }
+
+ }
+ }
+ });
+
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {

Back to the top