commit fa0887f6182cd5087f0a59e4aef622c4642cad8f
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Mon Feb 5 11:06:54 2018 +0100

    ref #7095, #7086 Check classification uniqueness of sub tree filter
    
     - fix imports

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 fab487b9a..cfd712cab 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,6 +8,8 @@
 */
 package eu.etaxonomy.taxeditor.editor.workingSet;
 
+import java.util.Set;
+
 import org.eclipse.jface.util.LocalSelectionTransfer;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
@@ -16,6 +18,7 @@ import org.eclipse.jface.viewers.ViewerDropAdapter;
 import org.eclipse.swt.dnd.TransferData;
 
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
 
 /**
  * @author pplitzner
@@ -37,6 +40,17 @@ public class TaxonNodeDropAdapter extends ViewerDropAdapter {
     @Override
     public boolean performDrop(Object data) {
         TaxonNode taxonNode= (TaxonNode) ((ITreeSelection) data).getFirstElement();
+        //check if node belongs to same classification
+        Set<TaxonNode> taxonSubtreeFilter = workingSetEditor.getWorkingSet().getTaxonSubtreeFilter();
+        if(taxonSubtreeFilter!=null && !taxonSubtreeFilter.isEmpty()){
+            if(!taxonSubtreeFilter.iterator().next().getClassification().equals(taxonNode.getClassification())){
+                MessagingUtils.warningDialog("Classifications do not match", this.getClass(),
+                        "The taxon node you are trying to add belongs to another classification "
+                        + "than the node(s) belonging to the working set.");
+                return false;
+            }
+
+        }
         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 699049997..fd2e31417 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
@@ -67,6 +67,7 @@ import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
 
 /**
+ * Editor for configuring WorkingSets
  * @author pplitzner
  * @since Nov 21, 2017
  *
@@ -215,9 +216,6 @@ IPartContentHasDetails, IDirtyMarkable {
         dirty.setDirty(true);
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Persist
     @Override
     public void save(IProgressMonitor monitor) {
@@ -266,7 +264,6 @@ IPartContentHasDetails, IDirtyMarkable {
         dirty.setDirty(false);
     }
 
-    /** {@inheritDoc} */
     @PreDestroy
     public void dispose() {
         if (conversation != null) {
@@ -280,7 +277,6 @@ IPartContentHasDetails, IDirtyMarkable {
         dirty.setDirty(false);
     }
 
-    /** {@inheritDoc} */
     @Focus
     public void setFocus() {
         if (getConversationHolder() != null) {
@@ -295,56 +291,39 @@ IPartContentHasDetails, IDirtyMarkable {
         return composite.getTaxonNodeTree();
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    public WorkingSet getWorkingSet() {
+        return workingSet;
+    }
+
     @Override
     public void update(CdmDataChangeMap arg0) {
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public ICdmEntitySession getCdmEntitySession() {
         return cdmEntitySession;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public Collection<WorkingSet> getRootEntities() {
         return null;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public Map<Object, List<String>> getPropertyPathsMap() {
         return null;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public ConversationHolder getConversationHolder() {
         return conversation;
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public void changed(Object element) {
         dirty.setDirty(true);
     }
 
-    /**
-     * {@inheritDoc}
-     */
     @Override
     public void forceDirty() {
         dirty.setDirty(true);
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java
index 39569a063..391856a62 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/CharacterMatrix.java
@@ -8,13 +8,6 @@
  */
 package eu.etaxonomy.taxeditor.editor.workingSet.matrix;
 
-import java.awt.Button;
-import java.awt.Color;
-import java.awt.Composite;
-import java.awt.DisplayMode;
-import java.awt.GridLayout;
-import java.awt.Label;
-import java.awt.Window;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -33,7 +26,6 @@ import java.util.UUID;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
-import javax.annotation.Resources;
 import javax.inject.Inject;
 
 import org.apache.commons.collections4.map.LinkedMap;
@@ -48,6 +40,7 @@ import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.ComboViewer;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
 import org.eclipse.nebula.widgets.nattable.NatTable;
 import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
 import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
@@ -55,6 +48,7 @@ import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry;
 import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
 import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
 import org.eclipse.nebula.widgets.nattable.config.IEditableRule;
+import org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate;
 import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
 import org.eclipse.nebula.widgets.nattable.data.ListDataProvider;
 import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
@@ -64,7 +58,9 @@ import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEven
 import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsSortModel;
 import org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeData;
 import org.eclipse.nebula.widgets.nattable.extension.glazedlists.tree.GlazedListTreeRowModel;
+import org.eclipse.nebula.widgets.nattable.freeze.CompositeFreezeLayer;
 import org.eclipse.nebula.widgets.nattable.freeze.FreezeHelper;
+import org.eclipse.nebula.widgets.nattable.freeze.FreezeLayer;
 import org.eclipse.nebula.widgets.nattable.freeze.config.DefaultFreezeGridBindings;
 import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
 import org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand;
@@ -87,6 +83,7 @@ import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
 import org.eclipse.nebula.widgets.nattable.layer.config.DefaultColumnHeaderStyleConfiguration;
 import org.eclipse.nebula.widgets.nattable.layer.config.DefaultRowHeaderStyleConfiguration;
 import org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent;
+import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack;
 import org.eclipse.nebula.widgets.nattable.persistence.PersistenceHelper;
 import org.eclipse.nebula.widgets.nattable.persistence.command.DisplayPersistenceDialogCommand;
 import org.eclipse.nebula.widgets.nattable.persistence.command.DisplayPersistenceDialogCommandHandler;
@@ -99,7 +96,9 @@ import org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent;
 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.HorizontalAlignmentEnum;
+import org.eclipse.nebula.widgets.nattable.style.Style;
 import org.eclipse.nebula.widgets.nattable.style.VerticalAlignmentEnum;
 import org.eclipse.nebula.widgets.nattable.summaryrow.FixedSummaryRowLayer;
 import org.eclipse.nebula.widgets.nattable.summaryrow.SummaryRowLayer;
@@ -110,12 +109,18 @@ import org.eclipse.nebula.widgets.nattable.tree.command.TreeExpandAllCommand;
 import org.eclipse.nebula.widgets.nattable.ui.menu.AbstractHeaderMenuConfiguration;
 import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder;
 import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
+import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.FontData;
 import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
 
 import ca.odell.glazedlists.EventList;
 import ca.odell.glazedlists.GlazedLists;
@@ -130,6 +135,8 @@ import eu.etaxonomy.cdm.model.description.Feature;
 import eu.etaxonomy.cdm.model.description.FeatureTree;
 import eu.etaxonomy.cdm.model.description.MeasurementUnit;
 import eu.etaxonomy.cdm.model.description.SpecimenDescription;
+import eu.etaxonomy.cdm.model.description.State;
+import eu.etaxonomy.cdm.model.description.WorkingSet;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
 import eu.etaxonomy.taxeditor.editor.workingSet.matrix.categorical.CategoricalDataCellEditor;
@@ -143,6 +150,7 @@ import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
 import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.model.ImageResources;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.preference.Resources;
 import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
 import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;
@@ -504,7 +512,7 @@ ICdmEntitySessionEnabled{
         // because the Comparator will be set by configuration
         SortedList<Object> sortedList = new SortedList<>(descriptions, new MatrixRowComparator());
         // wrap the SortedList with the TreeList
-        TreeList<Object> treeList = new TreeList(sortedList, new DescriptionTreeFormat(workingSet.getMaxRank()), TreeList.NODES_START_EXPANDED);
+        TreeList<Object> treeList = new TreeList(sortedList, new DescriptionTreeFormat(workingSet), TreeList.NODES_START_EXPANDED);
         /**
          * data provider
          */
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/DescriptionTreeFormat.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/DescriptionTreeFormat.java
index 6cda413ec..13fd34c0e 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/DescriptionTreeFormat.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/DescriptionTreeFormat.java
@@ -14,7 +14,9 @@ import java.util.List;
 import java.util.Set;
 
 import ca.odell.glazedlists.TreeList;
+import eu.etaxonomy.cdm.model.description.WorkingSet;
 import eu.etaxonomy.cdm.model.name.Rank;
+import eu.etaxonomy.cdm.model.taxon.Classification;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 
@@ -29,9 +31,14 @@ import eu.etaxonomy.cdm.model.taxon.TaxonNode;
  public class DescriptionTreeFormat implements TreeList.Format<Object> {
 
      private Rank maxRank;
+     private Classification classification;
 
-     public DescriptionTreeFormat(Rank maxRank) {
-         this.maxRank = maxRank;
+     public DescriptionTreeFormat(WorkingSet workingSet) {
+         this.maxRank = workingSet.getMaxRank();
+         Set<TaxonNode> taxonSubtreeFilter = workingSet.getTaxonSubtreeFilter();
+         if(taxonSubtreeFilter!=null && !taxonSubtreeFilter.isEmpty()){
+             this.classification = taxonSubtreeFilter.iterator().next().getClassification();
+         }
      }
 
      @Override
@@ -39,11 +46,8 @@ import eu.etaxonomy.cdm.model.taxon.TaxonNode;
          if(element instanceof RowWrapper){
              //TODO: check for multiple taxon nodes in multiple classifications
              Taxon taxon = ((RowWrapper) element).getAssociatedTaxon();
-             Set<TaxonNode> taxonNodes = taxon.getTaxonNodes();
-             if(taxonNodes!=null){
-                 TaxonNode node = taxonNodes.iterator().next();
-                 addPathRecursive(path, node);
-             }
+             TaxonNode taxonNode = taxon.getTaxonNode(classification);
+             addPathRecursive(path, taxonNode);
          }
          path.add(element);
      }
