commit 63a2e46c500408558065b9c70521efd56884559c
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Fri Jul 6 13:05:14 2018 +0200

    ref #7439 Code refactoring

diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorConfigLabelAccumulator.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorConfigLabelAccumulator.java
new file mode 100644
index 000000000..5ff92e15b
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorConfigLabelAccumulator.java
@@ -0,0 +1,45 @@
+/**
+* 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.bulkeditor.e4;
+
+import org.eclipse.nebula.widgets.nattable.data.ListDataProvider;
+import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
+import org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator;
+
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
+
+/**
+ * @author pplitzner
+ * @since Jul 6, 2018
+ *
+ */
+public class BulkEditorConfigLabelAccumulator implements IConfigLabelAccumulator {
+    private ListDataProvider<CdmBase> dataProvider;
+    private AbstractBulkEditorInput input;
+
+    public BulkEditorConfigLabelAccumulator(ListDataProvider<CdmBase> dataProvider2,
+            AbstractBulkEditorInput input2) {
+        super();
+        this.dataProvider = dataProvider2;
+        this.input = input2;
+    }
+
+
+    @Override
+    public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
+        CdmBase rowObject = dataProvider.getRowObject(rowPosition);
+        if(input.getMergeCandidates().contains(rowObject)){
+            configLabels.addLabel(BulkEditorE4.CANDIDATE_LABEL);
+        }
+        else if(input.getMergeTarget()==rowObject){
+            configLabels.addLabel(BulkEditorE4.TARGET_LABEL);
+        }
+    }
+}
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java
index 0673d594f..f48b05d2b 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java
@@ -41,7 +41,6 @@ import org.eclipse.nebula.widgets.nattable.command.VisualRefreshCommand;
 import org.eclipse.nebula.widgets.nattable.command.VisualRefreshCommandHandler;
 import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
 import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration;
-import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
 import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry;
 import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
 import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
@@ -64,23 +63,18 @@ import org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer;
 import org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer;
 import org.eclipse.nebula.widgets.nattable.layer.AbstractLayer;
 import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
-import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
-import org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator;
 import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack;
 import org.eclipse.nebula.widgets.nattable.selection.RowSelectionModel;
 import org.eclipse.nebula.widgets.nattable.selection.RowSelectionProvider;
 import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer;
 import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration;
-import org.eclipse.nebula.widgets.nattable.style.CellStyleAttributes;
 import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
-import org.eclipse.nebula.widgets.nattable.style.Style;
 import org.eclipse.nebula.widgets.nattable.style.theme.ModernNatTableThemeConfiguration;
 import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
 import org.eclipse.nebula.widgets.nattable.ui.matcher.CellEditorMouseEventMatcher;
 import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
 import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction;
 import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder;
-import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.dnd.Clipboard;
 import org.eclipse.swt.dnd.TextTransfer;
@@ -268,19 +262,7 @@ public class BulkEditorE4 implements IPartContentHasDetails, IConversationEnable
         }));
 
         //add label to deduplication rows
-        dataLayer.setConfigLabelAccumulator(new IConfigLabelAccumulator() {
-
-            @Override
-            public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
-                CdmBase rowObject = bodyDataProvider.getRowObject(rowPosition);
-                if(input.getMergeCandidates().contains(rowObject)){
-                    configLabels.addLabel(CANDIDATE_LABEL);
-                }
-                else if(input.getMergeTarget()==rowObject){
-                    configLabels.addLabel(TARGET_LABEL);
-                }
-            }
-        });
+        dataLayer.setConfigLabelAccumulator(new BulkEditorConfigLabelAccumulator(bodyDataProvider, input));
 
         //add tooltip to table
         new BulkEditorTooltip(natTable);
@@ -290,7 +272,7 @@ public class BulkEditorE4 implements IPartContentHasDetails, IConversationEnable
 
 	    //this configuration enables cell to be editable in general
 	    //necessary because we disabled this beforehand by setting autoconfigure=false
-	    //in the GridLayer
+	    //in the GridLayer constructor
 	    ((AbstractLayer) natTable.getLayer()).addConfiguration(new DefaultEditConfiguration());
 
         natTable.addConfiguration(new AbstractUiBindingConfiguration() {
@@ -301,6 +283,25 @@ public class BulkEditorE4 implements IPartContentHasDetails, IConversationEnable
             }
         });
 
+        //make cells editable to allow selecting the text
+        natTable.addConfiguration(new AbstractRegistryConfiguration() {
+            @Override
+            public void configureRegistry(IConfigRegistry configRegistry) {
+                //make cell editable
+                configRegistry.registerConfigAttribute(
+                        EditConfigAttributes.CELL_EDITABLE_RULE,
+                        IEditableRule.ALWAYS_EDITABLE,
+                        DisplayMode.EDIT);
+                //register editor
+                TextCellEditor editor = new TextCellEditor();
+                editor.setEditable(false);
+                configRegistry.registerConfigAttribute(
+                        EditConfigAttributes.CELL_EDITOR,
+                        editor,
+                        DisplayMode.NORMAL);
+            }
+        });
+
         //+++CONTEXT MENU+++
         menuService.registerContextMenu(natTable, "eu.etaxonomy.taxeditor.bulkeditor.popupmenu.bulkeditor"); //$NON-NLS-1$
         // get the menu registered by EMenuService
@@ -326,50 +327,12 @@ public class BulkEditorE4 implements IPartContentHasDetails, IConversationEnable
             }
         });
 
-        //make cells editable to allow selecting the text
-        natTable.addConfiguration(new AbstractRegistryConfiguration() {
-            @Override
-            public void configureRegistry(IConfigRegistry configRegistry) {
-              //make cell editable
-                configRegistry.registerConfigAttribute(
-                        EditConfigAttributes.CELL_EDITABLE_RULE,
-                        IEditableRule.ALWAYS_EDITABLE,
-                        DisplayMode.EDIT);
-                //register editor
-                TextCellEditor editor = new TextCellEditor();
-                editor.setEditable(false);
-                configRegistry.registerConfigAttribute(
-                        EditConfigAttributes.CELL_EDITOR,
-                        editor,
-                        DisplayMode.NORMAL);
-            }
-        });
 
         //enable sorting
         natTable.addConfiguration(new SingleClickSortConfiguration());
 
         // Custom style for deduplication labels
-        natTable.addConfiguration(new AbstractRegistryConfiguration() {
-            @Override
-            public void configureRegistry(IConfigRegistry configRegistry) {
-                Style cellStyle = new Style();
-                cellStyle.setAttributeValue(
-                        CellStyleAttributes.BACKGROUND_COLOR,
-                        GUIHelper.COLOR_YELLOW);
-                configRegistry.registerConfigAttribute(
-                        CellConfigAttributes.CELL_STYLE, cellStyle,
-                        DisplayMode.NORMAL, CANDIDATE_LABEL);
-
-                cellStyle = new Style();
-                cellStyle.setAttributeValue(
-                        CellStyleAttributes.BACKGROUND_COLOR,
-                        GUIHelper.COLOR_GREEN);
-                configRegistry.registerConfigAttribute(
-                        CellConfigAttributes.CELL_STYLE, cellStyle,
-                        DisplayMode.NORMAL, TARGET_LABEL);
-
-            }
-        });
+        natTable.addConfiguration(new LabelStyleConfiguration());
 
         //add default configuration because autoconfigure is set to false in constructor
         natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
@@ -474,20 +437,9 @@ public class BulkEditorE4 implements IPartContentHasDetails, IConversationEnable
     @Optional
     @Inject
     private void updateAfterSearch(@UIEventTopic(WorkbenchEventConstants.BULK_EDITOR_SEARCH_FINISHED)IStructuredSelection selection){
-
-
         if(selection!=null){
             setSelection(selection);
         }
-//        //auto resize columns
-//        InitializeAutoResizeColumnsCommand command = new InitializeAutoResizeColumnsCommand(
-//                natTable, 2, natTable.getConfigRegistry(), new GCFactory(
-//                        natTable));
-//        natTable.doCommand(command);
-//        command = new InitializeAutoResizeColumnsCommand(
-//                natTable, 1, natTable.getConfigRegistry(), new GCFactory(
-//                        natTable));
-//        natTable.doCommand(command);
     }
 
     public void refresh(){
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/LabelStyleConfiguration.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/LabelStyleConfiguration.java
new file mode 100644
index 000000000..c2339904d
--- /dev/null
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/LabelStyleConfiguration.java
@@ -0,0 +1,44 @@
+/**
+* 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.bulkeditor.e4;
+
+import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
+import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
+import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
+import org.eclipse.nebula.widgets.nattable.style.CellStyleAttributes;
+import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
+import org.eclipse.nebula.widgets.nattable.style.Style;
+import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
+
+/**
+ * @author pplitzner
+ * @since Jul 6, 2018
+ *
+ */
+public final class LabelStyleConfiguration extends AbstractRegistryConfiguration {
+    @Override
+    public void configureRegistry(IConfigRegistry configRegistry) {
+        Style cellStyle = new Style();
+        cellStyle.setAttributeValue(
+                CellStyleAttributes.BACKGROUND_COLOR,
+                GUIHelper.COLOR_YELLOW);
+        configRegistry.registerConfigAttribute(
+                CellConfigAttributes.CELL_STYLE, cellStyle,
+                DisplayMode.NORMAL, BulkEditorE4.CANDIDATE_LABEL);
+
+        cellStyle = new Style();
+        cellStyle.setAttributeValue(
+                CellStyleAttributes.BACKGROUND_COLOR,
+                GUIHelper.COLOR_GREEN);
+        configRegistry.registerConfigAttribute(
+                CellConfigAttributes.CELL_STYLE, cellStyle,
+                DisplayMode.NORMAL, BulkEditorE4.TARGET_LABEL);
+
+    }
+}
\ No newline at end of file
