commit c8daeda03149f541813cdda01c8e5f6de7c4bcff
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Wed Dec 20 16:33:34 2017 +0100

    ref #6806 Add remove taxon node key listener for DEL

diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/TaxonNodeDropAdapter.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/TaxonNodeDropAdapter.java
index 0ea497b0a..fab487b9a 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/TaxonNodeDropAdapter.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/TaxonNodeDropAdapter.java
@@ -8,14 +8,10 @@
 */
 package eu.etaxonomy.taxeditor.editor.workingSet;
 
-import java.util.ArrayList;
-import java.util.Collection;
-
 import org.eclipse.jface.util.LocalSelectionTransfer;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.ITreeSelection;
-import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerDropAdapter;
 import org.eclipse.swt.dnd.TransferData;
 
@@ -41,20 +37,7 @@ public class TaxonNodeDropAdapter extends ViewerDropAdapter {
     @Override
     public boolean performDrop(Object data) {
         TaxonNode taxonNode= (TaxonNode) ((ITreeSelection) data).getFirstElement();
-        //load into WS editor session
-        taxonNode = workingSetEditor.getCdmEntitySession().load(taxonNode, false);
-        Viewer taxonTreeViewer = workingSetEditor.getTaxonTreeViewer();
-        Object input = taxonTreeViewer.getInput();
-        Collection<TaxonNode> treeNodes;
-        if(input==null){
-            treeNodes = new ArrayList<>();
-        }
-        else{
-            treeNodes = (Collection<TaxonNode>) input;
-        }
-        treeNodes.add(taxonNode);
-        taxonTreeViewer.setInput(treeNodes);
-        workingSetEditor.setDirty();
+        workingSetEditor.addTaxonNode(taxonNode);
         return true;
     }
 
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/WorkingSetEditor.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/WorkingSetEditor.java
index e008fa9a3..fe573e793 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/WorkingSetEditor.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/WorkingSetEditor.java
@@ -8,8 +8,10 @@
 */
 package eu.etaxonomy.taxeditor.editor.workingSet;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -28,10 +30,13 @@ import org.eclipse.e4.ui.di.Persist;
 import org.eclipse.e4.ui.model.application.ui.MDirtyable;
 import org.eclipse.e4.ui.services.IServiceConstants;
 import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.dnd.DND;
 import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
 import org.eclipse.swt.events.ModifyEvent;
 import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.widgets.Composite;
@@ -124,6 +129,20 @@ public class WorkingSetEditor implements IE4SavablePart, IConversationEnabled, I
         Transfer[] transfers = new Transfer[] {LocalSelectionTransfer.getTransfer()};
         composite.getTaxonNodeTree().addDropSupport(dndOperations, transfers, new TaxonNodeDropAdapter(this));
 
+        composite.getTaxonNodeTree().getTree().addKeyListener(new KeyAdapter() {
+            @Override
+            public void keyPressed(KeyEvent e) {
+                if(e.character==SWT.DEL){
+                    IStructuredSelection selection = (IStructuredSelection) composite.getTaxonNodeTree().getSelection();
+                    Iterator<TaxonNode> iterator = selection.iterator();
+                    while(iterator.hasNext()){
+                        TaxonNode taxonNode = iterator.next();
+                        removeTaxonNode(taxonNode);
+                    }
+                }
+            }
+        });
+
     }
 
     public void init(UUID workingSetUuid) {
@@ -154,6 +173,31 @@ public class WorkingSetEditor implements IE4SavablePart, IConversationEnabled, I
         composite.getTxt_label().addModifyListener(labelModifyListener);
     }
 
+    public void addTaxonNode(TaxonNode taxonNode){
+        //load into WS editor session
+        taxonNode = getCdmEntitySession().load(taxonNode, false);
+        Viewer taxonTreeViewer = getTaxonTreeViewer();
+        Object input = taxonTreeViewer.getInput();
+        Collection<TaxonNode> treeNodes;
+        if(input==null){
+            treeNodes = new ArrayList<>();
+        }
+        else{
+            treeNodes = (Collection<TaxonNode>) input;
+        }
+        treeNodes.add(taxonNode);
+        taxonTreeViewer.setInput(treeNodes);
+        dirty.setDirty(true);
+    }
+
+    private void removeTaxonNode(TaxonNode taxonNode){
+        Viewer taxonTreeViewer = getTaxonTreeViewer();
+        Collection<TaxonNode> input = (Collection<TaxonNode>) taxonTreeViewer.getInput();
+        input.remove(taxonNode);
+        taxonTreeViewer.setInput(input);
+        dirty.setDirty(true);
+    }
+
     /**
      * {@inheritDoc}
      */
@@ -237,10 +281,6 @@ public class WorkingSetEditor implements IE4SavablePart, IConversationEnabled, I
         return composite.getTaxonNodeTree();
     }
 
-    public void setDirty() {
-        dirty.setDirty(true);
-    }
-
     /**
      * {@inheritDoc}
      */
