commit 598e33b768ba7a87ddf5a85b47220b4551b80307
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Fri Dec 21 09:25:10 2018 +0100

    ref #7580 Add copy&paste configuration (not yet actually working)

diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java
index d63facda6..afce92cb0 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java
@@ -41,8 +41,11 @@ import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry;
 import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
 import org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate;
 import org.eclipse.nebula.widgets.nattable.coordinate.Range;
+import org.eclipse.nebula.widgets.nattable.copy.command.InternalCopyDataCommandHandler;
+import org.eclipse.nebula.widgets.nattable.copy.command.InternalPasteDataCommandHandler;
 import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
 import org.eclipse.nebula.widgets.nattable.data.ListDataProvider;
+import org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommandHandler;
 import org.eclipse.nebula.widgets.nattable.export.command.ExportCommandHandler;
 import org.eclipse.nebula.widgets.nattable.extension.e4.selection.E4SelectionListener;
 import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer;
@@ -185,6 +188,8 @@ public class CharacterMatrix extends Composite {
 
     private boolean isShowTooltips = true;
 
+    private DataLayer bodyDataLayer;
+
     public CharacterMatrix(Composite parent, CharacterMatrixPart part) {
         super(parent, SWT.NONE);
         this.part = part;
@@ -352,7 +357,7 @@ public class CharacterMatrix extends Composite {
          *
 
          */
-        DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
+        bodyDataLayer = new DataLayer(bodyDataProvider);
 
         //register labels
         CharacterMatrixConfigLabelAccumulator labelAccumulator = new CharacterMatrixConfigLabelAccumulator(this);
@@ -461,6 +466,13 @@ public class CharacterMatrix extends Composite {
 
         //register handler for view configuration menu
         natTable.registerCommandHandler(toolbar.getDisplayPersistenceDialogCommandHandler());
+
+        //register handlers for copy&paste
+        natTable.registerCommandHandler(
+                new InternalPasteDataCommandHandler(bodyLayer.getSelectionLayer(), natTable.getInternalCellClipboard()));
+        natTable.registerCommandHandler(
+                new InternalCopyDataCommandHandler(bodyLayer.getSelectionLayer(), natTable.getInternalCellClipboard()));
+        natTable.registerCommandHandler(new UpdateDataCommandHandler(bodyDataLayer));
     }
 
     private void configureNatTable(boolean treeView,
@@ -477,7 +489,7 @@ public class CharacterMatrix extends Composite {
         //add default configuration because autoconfigure is set to false in constructor
         natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
 
-        //FIXME: this is for DEBUG ONLY
+        // this is for DEBUG ONLY
         //        natTable.addConfiguration(new DebugMenuConfiguration(natTable));
 
         // override the default sort configuration and change the mouse bindings
@@ -498,6 +510,9 @@ public class CharacterMatrix extends Composite {
         //register aggregation configuration
         summaryRowLayer.addConfiguration(new AggregationConfiguration(this));
 
+        //copy&paste configuration
+        natTable.addConfiguration(new CopyPasteEditBindings(bodyLayer.getSelectionLayer(), natTable.getInternalCellClipboard()));
+
       //+++CONTEXT MENU+++
         menuService.registerContextMenu(natTable, "eu.etaxonomy.taxeditor.editor.popupmenu.charactermatrix"); //$NON-NLS-1$
         // get the menu registered by EMenuService
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CopyPasteEditBindings.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CopyPasteEditBindings.java
new file mode 100644
index 000000000..e7e6073d3
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CopyPasteEditBindings.java
@@ -0,0 +1,68 @@
+/**
+* Copyright (C) 2018 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
+
+import org.eclipse.nebula.widgets.nattable.copy.InternalCellClipboard;
+import org.eclipse.nebula.widgets.nattable.copy.action.ClearClipboardAction;
+import org.eclipse.nebula.widgets.nattable.copy.action.PasteDataAction;
+import org.eclipse.nebula.widgets.nattable.copy.action.PasteOrMoveSelectionAction;
+import org.eclipse.nebula.widgets.nattable.edit.action.DeleteSelectionAction;
+import org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditBindings;
+import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
+import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
+import org.eclipse.nebula.widgets.nattable.ui.matcher.KeyEventMatcher;
+import org.eclipse.swt.SWT;
+
+/**
+ * @author pplitzner
+ * @since Dec 20, 2018
+ *
+ */
+public class CopyPasteEditBindings extends DefaultEditBindings {
+
+    private SelectionLayer selectionLayer;
+
+    private InternalCellClipboard clipboard;
+
+    public CopyPasteEditBindings(SelectionLayer selectionLayer, InternalCellClipboard clipboard) {
+        this.selectionLayer = selectionLayer;
+        this.clipboard = clipboard;
+    }
+
+    @Override
+    public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
+        super.configureUiBindings(uiBindingRegistry);
+        // ui binding for deleting a cell value on pressing DEL
+        uiBindingRegistry.registerFirstKeyBinding(
+                new KeyEventMatcher(SWT.DEL),
+                new DeleteSelectionAction());
+
+        // ui binding to perform a paste action on pressing CTRL+V
+        uiBindingRegistry.registerFirstKeyBinding(
+                new KeyEventMatcher(SWT.MOD1, 'v'),
+                new PasteDataAction());
+
+        // ui binding to perform paste or selection movement on ENTER
+        uiBindingRegistry.registerFirstKeyBinding(
+                new KeyEventMatcher(SWT.NONE, SWT.CR),
+                new PasteOrMoveSelectionAction(this.clipboard));
+
+        // ui binding to clear the InternalCellClipboard
+        uiBindingRegistry.registerFirstKeyBinding(
+                new KeyEventMatcher(SWT.NONE, SWT.ESC),
+                new ClearClipboardAction(this.clipboard));
+
+        // Mouse drag
+        // trigger the handle drag operations
+        // Note: we ensure a FillHandleLayerPainter is set in configureLayer
+//        uiBindingRegistry.registerFirstMouseDragMode(
+//                new FillHandleEventMatcher((FillHandleLayerPainter) this.selectionLayer.getLayerPainter()),
+//                new FormulaFillHandleDragMode(this.selectionLayer, this.clipboard, this.dataProvider));
+    }
+}
