ref #6907 Migrate factual data view
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 15 Aug 2017 17:07:13 +0000 (19:07 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 15 Aug 2017 17:07:13 +0000 (19:07 +0200)
16 files changed:
eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.editor/fragment.e4xmi
eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptionElementDragListener.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/DescriptiveViewPart.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/FactualDataPartE4.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/CreateDescriptionElementHandler.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/CreateDescriptionHandler.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/DeleteHandler.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/DescriptionsMenuPropertyTester.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/DynamicFeatureMenu.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/MoveDescriptionElementsHandler.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/MoveDescriptionToOtherTaxonHandler.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/ToggleShowOnlyIndividualAssociationsHandler.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/media/e4/MediaViewPartE4.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/uses/UsesViewPart.java

index 0bc5dff0334455abb473eade72c6075627f4e697..4cfa0860b4aeb146599d8626f5e5a51f13092695 100644 (file)
@@ -33,7 +33,8 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.e4.ui.workbench,
  org.eclipse.e4.core.di,
  org.eclipse.e4.ui.model.workbench,
- org.eclipse.e4.ui.di
+ org.eclipse.e4.ui.di,
+ org.eclipse.e4.core.commands
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-ActivationPolicy: lazy
 Import-Package: javax.annotation;version="1.0.0";resolution:=optional,
index 833cf874e97a088e82940ae72f61f447c5e841f2..4c1ecf52eb477a135a020a55a0f8dce81c750605 100644 (file)
         <children xsi:type="menu:HandledMenuItem" xmi:id="_y6pZwIGCEee6OIMIZFL1jw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.deleteMedia" label="%command.label.41" command="_jWmdEIGCEee6OIMIZFL1jw"/>
       </menus>
     </elements>
+    <elements xsi:type="basic:PartDescriptor" xmi:id="_HxxDsIGxEeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4" label="%view.name" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.editor/icons/address-book-new.png" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4">
+      <handlers xmi:id="_nxGRoIGyEeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.view.descriptive.e4.handler.CreateDescriptionHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.descriptive.e4.handler.CreateDescriptionHandler" command="_gE3lwIGyEeehlNPrK_b5JA"/>
+      <handlers xmi:id="_mOjHgIG3EeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.view.descriptive.e4.handler.MoveDescriptionToOtherTaxonHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.descriptive.e4.handler.MoveDescriptionToOtherTaxonHandler" command="_Al6c0IG4EeehlNPrK_b5JA"/>
+      <handlers xmi:id="_aaq0UIG4EeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.view.descriptive.e4.handler.MoveDescriptionElementsHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.descriptive.e4.handler.MoveDescriptionElementsHandler" command="_QJzBcIG4EeehlNPrK_b5JA"/>
+      <handlers xmi:id="_DgC2MIG5EeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.view.descriptive.e4.handler.DeleteHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.descriptive.e4.handler.DeleteHandler" command="_AqgMcIG5EeehlNPrK_b5JA"/>
+      <menus xsi:type="menu:PopupMenu" xmi:id="_HxxDt4GxEeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.popupmenu.factualDataView">
+        <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_bMfdYIG5EeehlNPrK_b5JA" coreExpressionId="isCdmStoreConnected"/>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_jvmnkIGxEeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.factualData.addDescription" label="%command.label.27" command="_gE3lwIGyEeehlNPrK_b5JA"/>
+        <children xsi:type="menu:DynamicMenuContribution" xmi:id="_2t3BgIHWEeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.dynamicmenucontribution.1" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.descriptive.e4.handler.DynamicFeatureMenu"/>
+        <children xsi:type="menu:MenuSeparator" xmi:id="_ij_wEIGxEeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.8"/>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_mgmvkIGxEeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.factualData.moveDescriptionToTaxon" label="%command.label.28" command="_Al6c0IG4EeehlNPrK_b5JA">
+          <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_BZrDwIGyEeehlNPrK_b5JA" coreExpressionId="isDescription"/>
+        </children>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_m00sEIGxEeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.factualData.moveDescriptionElement" label="%command.label.29" command="_QJzBcIG4EeehlNPrK_b5JA"/>
+        <children xsi:type="menu:MenuSeparator" xmi:id="_nRINkIGxEeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.9"/>
+        <children xsi:type="menu:DynamicMenuContribution" xmi:id="_4KNqkIGxEeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.dynamicmenucontribution.0" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.CdmViewerContextMenuE4"/>
+        <children xsi:type="menu:MenuSeparator" xmi:id="_pOAxAIGxEeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.10"/>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_rLS9EIGxEeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.factualData.delete" label="%command.label.30" command="_AqgMcIG5EeehlNPrK_b5JA"/>
+      </menus>
+    </elements>
   </fragments>
   <fragments xsi:type="fragment:StringModelFragment" xmi:id="__mwtMDVpEee_b7RlBzTDRw" featurename="commands" parentElementId="xpath:/">
     <elements xsi:type="commands:Command" xmi:id="_BjF3ADVqEee_b7RlBzTDRw" elementId="eu.etaxonomy.taxeditor.editor.command.specimeneditor.create_field_unit" commandName="%command.commandname.1"/>
     <elements xsi:type="commands:Command" xmi:id="_459e0IDoEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.media.command.moveimgup" commandName="%command.name.22"/>
     <elements xsi:type="commands:Command" xmi:id="_7tiZsIDoEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.media.command.moveimgdown" commandName="%command.name.19"/>
     <elements xsi:type="commands:Command" xmi:id="_jWmdEIGCEee6OIMIZFL1jw" elementId="eu.etaxonomy.taxeditor.editor.media.command.delete" commandName="Delete Media"/>
+    <elements xsi:type="commands:Command" xmi:id="_gE3lwIGyEeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.adddescription" commandName="%command.name.11"/>
+    <elements xsi:type="commands:Command" xmi:id="_Al6c0IG4EeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.moveDescriptionToTaxon" commandName="%command.name.13"/>
+    <elements xsi:type="commands:Command" xmi:id="_QJzBcIG4EeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.moveDescriptionElements" commandName="%command.name.12"/>
+    <elements xsi:type="commands:Command" xmi:id="_AqgMcIG5EeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.delete" commandName="%command.name.48"/>
+    <elements xsi:type="commands:Command" xmi:id="_8ccfgIHXEeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.createDescriptionElement" commandName="%command.name.10"/>
   </fragments>
   <fragments xsi:type="fragment:StringModelFragment" xmi:id="_pZmusEalEeeXMc6kSYO7Xg" featurename="children" parentElementId="eu.etaxonomy.taxeditor.menu.showView">
-    <elements xsi:type="menu:HandledMenuItem" xmi:id="_tvph4EalEeeXMc6kSYO7Xg" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.featuretreeeditor" label="Character Editor" command="_WPjpoDSnEeek0dKsFNy--Q">
+    <elements xsi:type="menu:HandledMenuItem" xmi:id="_tvph4EalEeeXMc6kSYO7Xg" elementId="eu.etaxonomy.taxeditor.editor.showViewMenu.characterEditor" label="Character Editor" command="_WPjpoDSnEeek0dKsFNy--Q">
       <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_1D-38FvqEeerXd84Zrk_9A" coreExpressionId="isShowExperimentalFeatures"/>
       <parameters xmi:id="_wJkmoEalEeeXMc6kSYO7Xg" elementId="eu.etaxonomy.taxeditor.editor.showView.parameter.charactereditor" name="eu.etaxonomy.taxeditor.workbench.commandparameter.partName" value="eu.etaxonomy.taxeditor.editor.workingSet.CharacterEditor"/>
     </elements>
-    <elements xsi:type="menu:HandledMenuItem" xmi:id="_cBaP4IDMEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.featuretreeeditor" label="%view.name.1" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.editor/icons/camera-photo.png" command="_WPjpoDSnEeek0dKsFNy--Q">
+    <elements xsi:type="menu:HandledMenuItem" xmi:id="_cBaP4IDMEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.showViewMenu.mediaView" label="%view.name.1" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.editor/icons/camera-photo.png" command="_WPjpoDSnEeek0dKsFNy--Q">
       <parameters xmi:id="_cBaP4oDMEeeBD7P1FZoD-g" elementId="eu.etaxonomy.taxeditor.editor.showView.parameter.mediaview" name="eu.etaxonomy.taxeditor.workbench.commandparameter.partName" value="eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4"/>
     </elements>
+    <elements xsi:type="menu:HandledMenuItem" xmi:id="_XBhycIGxEeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.showViewMenu.factualData" label="%view.name" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.editor/icons/address-book-new.png" command="_WPjpoDSnEeek0dKsFNy--Q">
+      <parameters xmi:id="_XBhycYGxEeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.showView.parameter.mediaview" name="eu.etaxonomy.taxeditor.workbench.commandparameter.partName" value="eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4"/>
+    </elements>
+  </fragments>
+  <fragments xsi:type="fragment:StringModelFragment" xmi:id="___fvgIHXEeehlNPrK_b5JA" featurename="handlers" parentElementId="xpath:/">
+    <elements xsi:type="commands:Handler" xmi:id="_GiwoMIHYEeehlNPrK_b5JA" elementId="eu.etaxonomy.taxeditor.editor.handler.0" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.descriptive.e4.handler.CreateDescriptionElementHandler" command="_8ccfgIHXEeehlNPrK_b5JA"/>
   </fragments>
 </fragment:ModelFragments>
index e4eabf4074e678a9dcbec86e1bb0291095e773a8..71ea23779fb20045bab291d5a611b74d244055c5 100644 (file)
    </extension>
       <extension
             point="org.eclipse.ui.views">
-         <view
-               allowMultiple="false"
-               category="eu.etaxonomy.taxeditor.editor.category"
-               class="eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart"
-               icon="icons/address-book-new.png"
-               id="eu.etaxonomy.taxeditor.editor.view.descriptive"
-               name="%view.name"
-               restorable="true">
-         </view>
           <view
                 allowMultiple="false"
                 category="eu.etaxonomy.taxeditor.editor.category"
                name="eu.etaxonomy.taxeditor.editor.showViewMenu"
                visible="true">
          </separator>
-         <command
-               commandId="org.eclipse.ui.views.showView"
-               label="%command.label.4"
-               style="push">
-            <parameter
-                  name="org.eclipse.ui.views.showView.viewId"
-                  value="eu.etaxonomy.taxeditor.editor.view.descriptive">
-            </parameter>
-            <visibleWhen
-                  checkEnabled="true">
-               <reference
-                     definitionId="isCdmStoreConnected">
-               </reference>
-            </visibleWhen>
-         </command>
          <command
                commandId="org.eclipse.ui.views.showView"
                label="%command.label.6"
             id="eu.etaxonomy.taxeditor.editor.view.descriptive.command.category"
             name="%category.name.1">
       </category>
-      <command
-            categoryId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.category"
-            defaultHandler="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.CreateDescriptionElementHandler"
-            id="eu.etaxonomy.taxeditor.editor.view.descriptive.command.createDescriptionElement"
-            name="%command.name.10">
-      </command>
-      <command
-            categoryId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.category"
-            defaultHandler="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.CreateDescriptionHandler"
-            id="eu.etaxonomy.taxeditor.editor.view.descriptive.command.adddescription"
-            name="%command.name.11">
-      </command>
-       <command
-             categoryId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.category"
-             defaultHandler="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.DeleteHandler"
-             id="eu.etaxonomy.taxeditor.editor.view.descriptive.command.delete"
-             name="%command.name.48">
-      </command>
       <category
             id="eu.etaxonomy.taxeditor.editor.view.uses.command.category"
             name="%category.name.2">
                typeId="eu.etaxonomy.taxeditor.uuidParameterType">
          </commandParameter>
       </command>
-      <command
-            categoryId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.category"
-            defaultHandler="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.MoveDescriptionToOtherTaxonHandler"
-            id="eu.etaxonomy.taxeditor.editor.view.descriptive.command.moveDescriptionToTaxon"
-            name="%command.name.13">
-      </command>
        
-      <command
-            categoryId="eu.etaxonomy.taxeditor.editor.view.descriptive.command.category"
-            defaultHandler="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.MoveDescriptionElementsHandler"
-            id="eu.etaxonomy.taxeditor.editor.view.descriptive.command.moveDescriptionElements"
-            name="%command.name.12">
-      </command>
       <command
             defaultHandler="eu.etaxonomy.taxeditor.editor.handler.OpenDerivateViewHandler"
             id="eu.etaxonomy.taxeditor.editor.openSpecimenEditor"
index 293ecf19e4cc3385042f8b72e80891a3b3492188..c11d0c582d6ba5a7218a11853815daaca3480fa5 100644 (file)
@@ -1,8 +1,8 @@
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* 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.
 */
@@ -20,6 +20,7 @@ import org.eclipse.swt.dnd.DragSourceEvent;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.description.DescriptionBase;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
 import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
 
 /**
@@ -29,32 +30,35 @@ import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
  */
 public class DescriptionElementDragListener extends DragSourceAdapter {
 
-       private DescriptiveViewPart part;
+       private FactualDataPartE4 part;
        private DescriptionBase description;
-       
-       public DescriptionElementDragListener(DescriptiveViewPart part){
+
+       public DescriptionElementDragListener(FactualDataPartE4 part){
                this.part = part;
        }
-       
+
        /**
         * Method declared on DragSourceListener
         */
-       public void dragFinished(DragSourceEvent event) {
-               if (!event.doit)
-                       return;
+       @Override
+    public void dragFinished(DragSourceEvent event) {
+               if (!event.doit) {
+            return;
+        }
                // FIXME what to do here?
                if (event.detail != DND.DROP_NONE) {
                        //IStructuredSelection selection = (IStructuredSelection) part.getViewer().getSelection();
                        part.getViewer().refresh();
-                       
+
                part.changed(null);
                }
        }
-       
+
        /**
         * Method declared on DragSourceListener
         */
-       public void dragSetData(DragSourceEvent event) {
+       @Override
+    public void dragSetData(DragSourceEvent event) {
                IStructuredSelection selection = (IStructuredSelection) part.getViewer()
                                .getSelection();
                List<DescriptionElementBase> descriptionElements = new ArrayList<DescriptionElementBase>();
@@ -64,29 +68,30 @@ public class DescriptionElementDragListener extends DragSourceAdapter {
                                        descriptionElements.addAll(((DescriptionBase) object).getElements());
                                }
                                description = HibernateProxyHelper.deproxy(object, DescriptionBase.class);
-                               
+
                        }else if(object instanceof FeatureNodeContainer){
                                descriptionElements.addAll(((FeatureNodeContainer) object).getDescriptionElements());
                        }else if(object instanceof DescriptionElementBase){
                                descriptionElements.add((DescriptionElementBase)object);
                        }
-                       
+
                }
                if (DescriptionElementTransfer.getInstance().isSupportedType(
                                event.dataType)) {
                        if (!descriptionElements.isEmpty()){
                                event.data = descriptionElements.toArray(new DescriptionElementBase[descriptionElements.size()]);
                        }
-                       
+
                }
-               
+
        }
-       
+
        /**
         * Method declared on DragSourceListener
         */
-       public void dragStart(DragSourceEvent event) {
+       @Override
+    public void dragStart(DragSourceEvent event) {
                event.doit = !part.getViewer().getSelection().isEmpty();
        }
-       
+
 }
index 05e5146f586863e813b07fabaf228cdea23c60d3..106ac2f1508a2025c31450435e8d9ff837d734eb 100644 (file)
@@ -98,10 +98,10 @@ public class DescriptiveViewPart extends AbstractCdmEditorViewPart implements IP
                viewer.setSorter(new DescriptiveViewerSorter());
                viewer.setAutoExpandLevel(2);
                Transfer[] transfers = new Transfer[] { DescriptionElementTransfer.getInstance() };
-               viewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener(
-                               this));
-               viewer.addDropSupport(dndOperations, transfers,
-                               new DescriptionElementDropAdapter(viewer));
+//             viewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener(
+//                             this));
+//             viewer.addDropSupport(dndOperations, transfers,
+//                             new DescriptionElementDropAdapter(viewer));
 
                // Propagate selection from viewer
                getSite().setSelectionProvider(viewer);
@@ -200,11 +200,11 @@ public class DescriptiveViewPart extends AbstractCdmEditorViewPart implements IP
                        return;
                }
             }
-            
+
             if(firstElement instanceof IDescribable<?>
-               && partObject instanceof IPartContentHasFactualData  
+               && partObject instanceof IPartContentHasFactualData
                        && !(firstElement instanceof SpecimenOrObservationBase && partObject instanceof BulkEditor)){
-               
+
                 featureNodeContainerCache.clear();
                 showViewer(partObject, (IStructuredSelection) selection);
                 return;
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/FactualDataPartE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/FactualDataPartE4.java
new file mode 100644 (file)
index 0000000..20bec5a
--- /dev/null
@@ -0,0 +1,304 @@
+// $Id$
+/**
+* Copyright (C) 2017 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.view.descriptive.e4;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.services.EMenuService;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+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.graphics.ImageData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Tree;
+
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.description.IDescribable;
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
+import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
+import eu.etaxonomy.taxeditor.editor.l10n.Messages;
+import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDragListener;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDropAdapter;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementTransfer;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveContentProvider;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveLabelProvider;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewerSorter;
+import eu.etaxonomy.taxeditor.editor.view.media.e4.MediaViewPartE4;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
+import eu.etaxonomy.taxeditor.model.FeatureNodeContainerTree;
+import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
+import eu.etaxonomy.taxeditor.model.IPartContentHasFactualData;
+import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
+import eu.etaxonomy.taxeditor.model.ImageResources;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
+import eu.etaxonomy.taxeditor.view.e4.AbstractCdmEditorPartE4;
+import eu.etaxonomy.taxeditor.view.e4.details.DetailsPartE4;
+import eu.etaxonomy.taxeditor.view.e4.supplementaldata.SupplementalDataPartE4;
+
+/**
+ * @author pplitzner
+ * @date 15.08.2017
+ *
+ */
+public class FactualDataPartE4 extends AbstractCdmEditorPartE4
+        implements IPartContentHasDetails, IPartContentHasSupplementalData, ICdmEntitySessionEnabled {
+
+    /**
+     * Maps {@link FeatureNodeContainerTree} to their corresponding {@link TaxonDescritpion}.<br>
+     * This serves as input for the {@link ITreeContentProvider} of the {@link TreeViewer}
+     */
+    protected Map<DescriptionBase<?>, FeatureNodeContainerTree> featureNodeContainerCache = new HashMap<DescriptionBase<?>, FeatureNodeContainerTree>();
+
+    protected ToggleDescriptionAction showAllElementsAction;
+
+    protected ToggleDescriptionAction hideAllElementsAction;
+
+    protected int dndOperations = DND.DROP_COPY | DND.DROP_MOVE;
+
+    private DescriptiveContentProvider provider;
+
+    private ISelectionChangedListener selectionChangedListener;
+
+    @Inject
+    private ESelectionService selService;
+
+    @PostConstruct
+    public void create(Composite parent, EMenuService menuService) {
+        TreeViewer treeViewer = new TreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL
+                | SWT.V_SCROLL | SWT.FULL_SELECTION));
+        provider = new DescriptiveContentProvider(featureNodeContainerCache);
+        treeViewer.setContentProvider(provider);
+        treeViewer.setLabelProvider(new DescriptiveLabelProvider());
+        treeViewer.setSorter(new DescriptiveViewerSorter());
+        treeViewer.setAutoExpandLevel(2);
+        Transfer[] transfers = new Transfer[] { DescriptionElementTransfer.getInstance() };
+        treeViewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener(
+                this));
+        treeViewer.addDropSupport(dndOperations, transfers,
+                new DescriptionElementDropAdapter(viewer));
+
+        viewer = treeViewer;
+
+        // Propagate selection from viewer
+        selectionChangedListener = (event -> selService.setSelection(AbstractUtility.getElementsFromSelectionChangedEvent(event)));
+        viewer.addSelectionChangedListener(selectionChangedListener);
+
+        //create context menu
+        menuService.registerContextMenu(viewer.getControl(), "eu.etaxonomy.taxeditor.editor.popupmenu.factualDataView");
+
+        showAllElementsAction = new ToggleDescriptionAction(false);
+        hideAllElementsAction = new ToggleDescriptionAction(true);
+
+        //FIXME E4 implement toolbar
+//        createToolbar();
+
+    }
+
+//    protected void createToolbar() {
+//        IToolBarManager toolBarManager = getViewSite().getActionBars().getToolBarManager();
+//        toolBarManager.add(showAllElementsAction);
+//        toolBarManager.add(hideAllElementsAction);
+//    }
+
+
+    @Inject
+    @Optional
+    public void selectionChanged(
+            @Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
+            @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
+            MPart thisPart){
+        if(activePart==thisPart){
+            return;
+        }
+
+        Object partObject = createPartObject(activePart);
+
+        if (partObject instanceof DetailsPartE4 || partObject instanceof SupplementalDataPartE4
+                || partObject instanceof MediaViewPartE4) {
+            // do not show empty page as these views are also used to edit the
+            // description selected in this view
+            return;
+        }
+
+        if(partObject instanceof IPartContentHasFactualData){
+            IStructuredSelection structuredSelection = createSelection(selection);
+            if(structuredSelection==null || structuredSelection.isEmpty()){
+                showEmptyPage();
+                return;
+            }
+            if(partObject instanceof ChecklistEditor){
+                if(structuredSelection.getFirstElement() instanceof Taxon){
+                    Taxon taxon = (Taxon)structuredSelection.getFirstElement();
+                    structuredSelection = new StructuredSelection(taxon);
+                }
+            }
+            Object firstElement = structuredSelection.getFirstElement();
+            if (partObject instanceof MultiPageTaxonEditor){
+                if (firstElement != ((MultiPageTaxonEditor)partObject).getTaxon()){
+                    showEmptyPage();
+                    return;
+                }
+            }
+
+            if(firstElement instanceof IDescribable<?>
+                && partObject instanceof IPartContentHasFactualData
+                    && !(firstElement instanceof SpecimenOrObservationBase && partObject instanceof BulkEditor)){
+
+                featureNodeContainerCache.clear();
+                showViewer(structuredSelection, activePart, viewer);
+                return;
+            }
+        }
+        showEmptyPage();
+        return;
+    }
+
+    @Override
+    protected String getViewName(){
+        return Messages.DescriptiveViewPart_FACTUAL_DATA;
+    }
+
+    /**
+     *
+     * @author n.hoffmann
+     * @created May 28, 2010
+     * @version 1.0
+     */
+    protected class ToggleDescriptionAction extends Action{
+        private final boolean expanded;
+
+        public ToggleDescriptionAction(boolean expand){
+            super(null, IAction.AS_PUSH_BUTTON);
+            expanded = expand;
+            setImageAndTooltip();
+        }
+
+        private void setImageAndTooltip(){
+            setImageDescriptor(new ImageDescriptor() {
+                @Override
+                public ImageData getImageData() {
+                    setText(expanded ? Messages.DescriptiveViewPart_COLLAPSE_ALL : Messages.DescriptiveViewPart_EXPAND_ALL);
+                    String resource = expanded ? ImageResources.COLLAPSE_ALL : ImageResources.EXPAND_ALL;
+                    return ImageResources.getImage(resource).getImageData();
+                }
+            });
+
+            String toolTipText = expanded ? Messages.DescriptiveViewPart_COLLAPSE_ALL : Messages.DescriptiveViewPart_SHOW_ALL_DATA;
+            setToolTipText(toolTipText);
+        }
+
+        @Override
+        public void run() {
+            if(expanded){
+                ((AbstractTreeViewer) viewer).collapseAll();
+            }else{
+                ((AbstractTreeViewer) viewer).expandAll();
+            }
+            setImageAndTooltip();
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void changed(Object object) {
+        for(FeatureNodeContainerTree containerTree : featureNodeContainerCache.values()){
+            containerTree.buildTree();
+        }
+        ((AbstractTreeViewer) viewer).expandToLevel(2);
+        viewer.refresh();
+
+        if(object instanceof DescriptionElementBase){
+            DescriptionElementBase descriptionElement = (DescriptionElementBase) object;
+            DescriptionBase description = descriptionElement.getInDescription();
+            FeatureNodeContainerTree containerTree = featureNodeContainerCache.get(description);
+
+            FeatureNodeContainer featureNodeContainer = containerTree.getFeatureNodeContainerForDescriptionElement(descriptionElement);
+            ((AbstractTreeViewer) viewer).expandToLevel(featureNodeContainer, 1);
+
+        }
+
+        if(object != null){
+            StructuredSelection selection = new StructuredSelection(object);
+            viewer.setSelection(selection, true);
+        }
+//        if(part instanceof BulkEditor && !(object instanceof SpecimenOrObservationBase<?>)){
+//            ((BulkEditor) part).forceDirty();
+//            IStructuredSelection selection = (IStructuredSelection) ((BulkEditor) part).getSelectionProvider().getSelection();
+//            ((BulkEditor) part).changed(selection.getFirstElement());
+//
+//        }
+//
+//        if (part instanceof E4PartWrapper){
+//            part = WorkbenchUtility.getE4WrappedPart(part);
+//            if (part instanceof IDirtyMarkable){
+//                 StructuredSelection selection = new StructuredSelection(object);
+//                ((IDirtyMarkable)part).changed(selection.getFirstElement());
+//            }
+//        }
+
+
+        super.changed(object);
+    }
+
+    public void toggleShowOnlyIndividualAssociations(){
+        provider.toggleShowOnlyIndividualAssociations();
+        viewer.refresh();
+    }
+
+    public Viewer getViewer() {
+        return viewer;
+    }
+
+    @Override
+    public ICdmEntitySession getCdmEntitySession() {
+        if(selectionProvidingPart != null && selectionProvidingPart instanceof ICdmEntitySessionEnabled) {
+            return ((ICdmEntitySessionEnabled) selectionProvidingPart).getCdmEntitySession();
+        }
+        return null;
+    }
+
+    @Override
+    public  List<? extends CdmBase> getRootEntities() {
+        return Arrays.asList((CdmBase)getViewer().getInput());
+    }
+    @Override
+    public Map<Object, List<String>> getPropertyPathsMap() {
+        return null;
+    }
+
+}
\ No newline at end of file
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/CreateDescriptionElementHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/CreateDescriptionElementHandler.java
new file mode 100644 (file)
index 0000000..65655da
--- /dev/null
@@ -0,0 +1,78 @@
+/**
+ * Copyright (C) 2007 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.view.descriptive.e4.handler;
+
+import java.util.UUID;
+
+import javax.inject.Named;
+
+import org.eclipse.core.commands.common.NotDefinedException;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
+import org.eclipse.e4.ui.services.IServiceConstants;
+
+import eu.etaxonomy.cdm.api.service.ITermService;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateDescriptionElementOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ *
+ * @author pplitzner
+ * @date 15.08.2017
+ *
+ */
+public class CreateDescriptionElementHandler {
+
+    @Execute
+    public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart,
+            @Optional@Named(IServiceConstants.ACTIVE_SELECTION) DescriptionBase description, MHandledMenuItem menuItem) throws NotDefinedException {
+
+        String commandId = menuItem.getCommand().getElementId();
+        UUID uuid = (UUID) menuItem.getTransientData().get(commandId+".feature.uuid");
+        Feature feature = HibernateProxyHelper.deproxy(CdmStore.getService(ITermService.class).load(uuid), Feature.class);
+
+        FactualDataPartE4 factualDataPart = (FactualDataPartE4) activePart.getObject();
+
+        if (description != null) {
+            AbstractPostOperation operation = null;
+            // TODO use undo context specific to editor
+            operation = operationCreationInstance(menuItem.getLocalizedLabel(), feature, description, factualDataPart);
+            AbstractUtility.executeOperation(operation);
+        } else {
+            MessagingUtils.error(getClass(), new IllegalArgumentException("Could not determine the taxon description")); //$NON-NLS-1$
+        }
+
+    }
+
+    /**
+        * Added to make the Class more generic and limit the amount of code changes required
+        * @param label
+        * @param event
+        * @param taxon
+        * @param description
+        * @param postOperationEnabled
+        * @return
+        */
+       protected AbstractPostOperation operationCreationInstance(String label, Feature feature, DescriptionBase<?> description, IPostOperationEnabled postOperationEnabled) {
+               return new CreateDescriptionElementOperation(label, EditorUtil.getUndoContext(), description, feature, postOperationEnabled);
+       }
+
+}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/CreateDescriptionHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/CreateDescriptionHandler.java
new file mode 100644 (file)
index 0000000..61ed093
--- /dev/null
@@ -0,0 +1,60 @@
+/**
+* Copyright (C) 2011 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.view.descriptive.e4.handler;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuItem;
+import org.eclipse.e4.ui.services.IServiceConstants;
+
+import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateSpecimenDescriptionOperation;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateTaxonDescriptionOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+
+/**
+ *
+ * @author pplitzner
+ * @date 15.08.2017
+ *
+ */
+public class CreateDescriptionHandler {
+
+    @Execute
+    public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart, MMenuItem menuItem) {
+
+        FactualDataPartE4 factualDataPart = (FactualDataPartE4) activePart.getObject();
+
+        AbstractPostOperation<?> operation;
+        Object viewerInput = factualDataPart.getViewer().getInput();
+        if(viewerInput instanceof SpecimenOrObservationBase<?>){
+            operation = new CreateSpecimenDescriptionOperation(menuItem.getLocalizedLabel(), EditorUtil.getUndoContext(), (SpecimenOrObservationBase<?>) viewerInput, factualDataPart);
+            AbstractUtility.executeOperation(operation);
+        }
+        if(viewerInput instanceof TaxonBase){
+            operation = createTaxonOperation(menuItem.getLocalizedLabel(), (Taxon) viewerInput, factualDataPart);
+            AbstractUtility.executeOperation(operation);
+
+        }
+       }
+
+          /** {@inheritDoc} */
+    protected CreateTaxonDescriptionOperation createTaxonOperation(String eventLabel, Taxon taxon, IPostOperationEnabled postOperationEnabled) {
+        return new CreateTaxonDescriptionOperation(eventLabel, EditorUtil.getUndoContext(), taxon, postOperationEnabled);
+    }
+
+}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/DeleteHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/DeleteHandler.java
new file mode 100644 (file)
index 0000000..4264443
--- /dev/null
@@ -0,0 +1,144 @@
+/**
+* Copyright (C) 2007 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.view.descriptive.e4.handler;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.inject.Named;
+
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuItem;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.swt.widgets.Shell;
+
+import eu.etaxonomy.cdm.api.service.config.MediaDeletionConfigurator;
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.description.SpecimenDescription;
+import eu.etaxonomy.cdm.model.description.TaxonDescription;
+import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
+import eu.etaxonomy.cdm.model.media.Media;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.l10n.Messages;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteSpecimenDescriptionOperation;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteTaxonDescriptionOperation;
+import eu.etaxonomy.taxeditor.editor.view.media.operation.DeleteMediaOperation;
+import eu.etaxonomy.taxeditor.editor.view.media.operation.RemoveImageFromDescriptionElementOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
+import eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator.DeleteConfiguratorDialog;
+
+/**
+ *
+ * @author pplitzner
+ * @date 15.08.2017
+ *
+ */
+public class DeleteHandler {
+
+       @Execute
+    public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart,
+            @Optional@Named(IServiceConstants.ACTIVE_SELECTION) Object selection,
+            @Named(IServiceConstants.ACTIVE_SHELL)Shell shell, MMenuItem menuItem) {
+
+        FactualDataPartE4 factualDataPart = (FactualDataPartE4) activePart.getObject();
+
+        Object selectionProvidingPart = factualDataPart.getSelectionProvidingPart();
+        ICdmEntitySessionEnabled cdmEntitySessionEnabled = null;
+        if(selectionProvidingPart instanceof ICdmEntitySessionEnabled){
+            cdmEntitySessionEnabled = (ICdmEntitySessionEnabled) selectionProvidingPart;
+        }
+
+               String label = menuItem.getLocalizedLabel();
+
+        IUndoContext undoContext = EditorUtil.getUndoContext();
+
+        List<AbstractPostOperation<?>> operations = new ArrayList<AbstractPostOperation<?>>();
+
+//                     for(Object object : selection.toArray()){
+
+        // TaxonDescription
+        if(selection instanceof TaxonDescription){
+            operations.add(new DeleteTaxonDescriptionOperation(label, undoContext, (TaxonDescription) selection, factualDataPart, cdmEntitySessionEnabled));
+        }
+        else if(selection instanceof SpecimenDescription){
+            operations.add(new DeleteSpecimenDescriptionOperation(label, undoContext, (SpecimenDescription) selection, factualDataPart, cdmEntitySessionEnabled)) ;
+        }
+        // DescriptionElementBase
+        else if(selection instanceof DescriptionElementBase){
+            operations.add(new DeleteDescriptionElementOperation(label, undoContext, (DescriptionElementBase) selection, factualDataPart, cdmEntitySessionEnabled));
+        }
+        else if(selection instanceof FeatureNodeContainer){
+            List<DescriptionElementBase> descriptions = ((FeatureNodeContainer) selection).getDescriptionElementsForEntireBranch();
+
+            for(DescriptionElementBase description : descriptions){
+                operations.add(new DeleteDescriptionElementOperation(label, undoContext, description, factualDataPart, cdmEntitySessionEnabled));
+            }
+        }
+        // Media
+        else if(selection instanceof Media){
+
+            TreeSelection treeSelection = (TreeSelection) factualDataPart.getViewer().getSelection();
+
+            TreePath[] path = treeSelection.getPathsFor(selection);
+
+            DescriptionBase<?> imageGallery = (DescriptionBase<?>) path[0].getFirstSegment();
+
+            // TODO use undo context specific to editor
+            MediaDeletionConfigurator config = new MediaDeletionConfigurator();
+            config.setDeleteFromDescription(true);
+            config.setOnlyRemoveFromGallery(false);
+
+            if (imageGallery instanceof SpecimenDescription){
+                config.setDeleteFrom(((SpecimenDescription)imageGallery).getDescribedSpecimenOrObservation());
+            } else if (imageGallery instanceof TaxonDescription){
+                config.setDeleteFrom(((TaxonDescription)imageGallery).getTaxon());
+            }else if (imageGallery instanceof TaxonNameDescription){
+                config.setDeleteFrom(((TaxonNameDescription)imageGallery).getTaxonName());
+            }
+
+
+            if (!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, shell, Messages.DeleteHandler_CONFIRM_DELETION,  Messages.DeleteHandler_CONFIRM_DELETION_MESSAGE)){
+                return;
+            }
+
+
+
+            if (config.isOnlyRemoveFromGallery() || ((Media)selection).getId() == 0){
+                operations.add(new RemoveImageFromDescriptionElementOperation(label, undoContext,  (Media) selection, imageGallery, factualDataPart));
+            }else{
+                operations.add(new DeleteMediaOperation(label, undoContext, imageGallery, (Media) selection, config, factualDataPart));
+            }
+
+
+
+        }
+        else{
+            MessagingUtils.error(getClass(), Messages.DeleteHandler_INVALID_SELECTION, null);
+        }
+//                     }
+
+        // execute all cumulated operations
+        for(AbstractPostOperation<?> operation : operations){
+               AbstractUtility.executeOperation(operation);
+        }
+       }
+}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/DescriptionsMenuPropertyTester.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/DescriptionsMenuPropertyTester.java
new file mode 100644 (file)
index 0000000..2ba656c
--- /dev/null
@@ -0,0 +1,182 @@
+/**
+ *
+ */
+package eu.etaxonomy.taxeditor.editor.view.descriptive.e4.handler;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.jface.viewers.IStructuredSelection;
+
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
+import eu.etaxonomy.cdm.model.media.Media;
+import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor;
+import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
+import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
+
+/**
+ * Property tester used by the description tree menu.
+ *
+ * @author p.ciardelli
+ * @author n.hoffmann
+ * @version $Id: $
+ */
+public class DescriptionsMenuPropertyTester extends PropertyTester {
+
+       private static final String MEDIA = "isMedia"; //$NON-NLS-1$
+       private static final String FEATURE_NODE_CONTAINER = "isFeatureNodeContainer"; //$NON-NLS-1$
+       private static final String DESCRIPTION = "isDescription"; //$NON-NLS-1$
+       private static final String INDIVIDUALS_ASSOCIATION = "isIndividualsAssociation"; //$NON-NLS-1$
+       private static final String DESCRIPTION_ELEMENT = "isDescriptionElement"; //$NON-NLS-1$
+       private static final String DELETABLE = "isDeletable"; //$NON-NLS-1$
+       private static final String IMAGE_GALLERY = "isImageGallery"; //$NON-NLS-1$
+       private static final String TAXON_EDITOR = "isTaxonEditor"; //$NON-NLS-1$
+       private static final String BULK_EDITOR = "isBulkEditor"; //$NON-NLS-1$
+       private static final String DERIVATE_EDITOR = "isDerivateEditor"; //$NON-NLS-1$
+
+       /* (non-Javadoc)
+        * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+        */
+       /** {@inheritDoc} */
+       @Override
+    public boolean test(Object receiver, String property, Object[] args,
+                       Object expectedValue) {
+
+           if(TAXON_EDITOR.equals(property)){
+               return isTaxonEditor();
+           }
+           else if(BULK_EDITOR.equals(property)){
+               return isBulkEditor();
+           }
+           else if(DERIVATE_EDITOR.equals(property)){
+               return isDerivateEditor();
+           }
+
+           Object[] selectedElements = ((IStructuredSelection) receiver).toArray();
+
+           if(selectedElements.length == 0){
+                       // nothing selected so all tests should fail
+                       return false;
+               }
+
+               if(MEDIA.equals(property)){
+                       return isMedia(selectedElements);
+               }
+               else if(FEATURE_NODE_CONTAINER.equals(property)){
+                       return isFeatureNodeContainer(selectedElements);
+               }
+               else if(DESCRIPTION.equals(property)){
+                       return isDescription(selectedElements);
+               }
+               else if(INDIVIDUALS_ASSOCIATION.equals(property)){
+                   return isIndividualsAssociation(selectedElements);
+               }
+               else if(DESCRIPTION_ELEMENT.equals(property)){
+                       return isDescriptionElement(selectedElements);
+               }
+               else if(DELETABLE.equals(property)){
+                       return isDeletable(selectedElements);
+               }
+               else if(IMAGE_GALLERY.equals(property)){
+                       return isImageGallery(selectedElements);
+               }
+               else{
+                       return false;
+               }
+       }
+
+       private boolean isImageGallery(Object[] selectedElements) {
+               for (Object object : selectedElements){
+                       if(!(object instanceof DescriptionBase) || !((DescriptionBase<?>) object).isImageGallery()){
+                               return false;
+                       }
+               }
+               return true;
+       }
+
+       private boolean isFeatureNodeContainer(Object[] selectedElements) {
+               for (Object object : selectedElements){
+                       if(!(object instanceof FeatureNodeContainer)){
+                               return false;
+                       }
+               }
+               return true;
+       }
+
+       private boolean isDeletable(Object[] selectedElements) {
+               boolean result = false;
+
+               for (Object object : selectedElements) {
+
+                       if((object instanceof DescriptionBase)
+                               || (object instanceof DescriptionElementBase)
+                               || (object instanceof Media)
+                               || (object instanceof FeatureNodeContainer)){
+                               result = true;
+                       }else{
+                               return false;
+                       }
+
+               }
+               return result;
+       }
+
+       private boolean isDescriptionElement(Object[] selectedElements) {
+               for (Object object : selectedElements){
+                       if(!(object instanceof DescriptionElementBase)){
+                               return false;
+                       }
+               }
+               return true;
+       }
+
+       private boolean isDescription(Object[] selectedElements) {
+               for (Object object : selectedElements){
+                       if(!(object instanceof DescriptionBase)){
+                               return false;
+                       }
+               }
+               return true;
+       }
+
+       private boolean isIndividualsAssociation(Object[] selectedElements) {
+           for (Object object : selectedElements){
+               if(!(object instanceof IndividualsAssociation)){
+                   return false;
+               }
+           }
+           return true;
+       }
+
+       private boolean isMedia(Object[] selectedElements) {
+               for (Object object : selectedElements){
+                       if(!(object instanceof Media)){
+                               return false;
+                       }
+               }
+               return true;
+       }
+
+       private boolean isTaxonEditor() {
+           if(AbstractUtility.getActiveE4Editor() instanceof MultiPageTaxonEditor){
+               return true;
+           }
+           return false;
+       }
+
+       private boolean isBulkEditor() {
+           if(AbstractUtility.getActiveE4Editor() instanceof BulkEditor){
+               return true;
+           }
+           return false;
+       }
+
+       private boolean isDerivateEditor() {
+           if(AbstractUtility.getActiveE4Editor() instanceof DerivateView){
+               return true;
+           }
+           return false;
+       }
+}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/DynamicFeatureMenu.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/DynamicFeatureMenu.java
new file mode 100644 (file)
index 0000000..e1fa8db
--- /dev/null
@@ -0,0 +1,145 @@
+/**
+ * Copyright (C) 2007 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.view.descriptive.e4.handler;
+
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.eclipse.e4.core.commands.ECommandService;
+import org.eclipse.e4.core.commands.EHandlerService;
+import org.eclipse.e4.ui.di.AboutToShow;
+import org.eclipse.e4.ui.model.application.commands.MCommand;
+import org.eclipse.e4.ui.model.application.commands.MCommandsFactory;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
+import org.eclipse.e4.ui.services.IServiceConstants;
+
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.cdm.model.description.FeatureNode;
+import eu.etaxonomy.cdm.model.description.FeatureTree;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateDescriptionElementOperation;
+import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ *
+ * @author pplitzner
+ * @date 15.08.2017
+ *
+ */
+public class DynamicFeatureMenu {
+
+    @Inject
+    private EHandlerService handlerService;
+
+    @Inject
+    private ECommandService commandService;
+
+    /** {@inheritDoc} */
+    @AboutToShow
+    public void aboutToShow(List<MMenuElement> items, @Named(IServiceConstants.ACTIVE_SELECTION) Object selection) {
+
+        MMenu menu = MMenuFactory.INSTANCE.createMenu();
+        menu.setLabel("New");
+        items.add(menu);
+
+        if (selection instanceof DescriptionBase<?>) {
+            FeatureTree featureTree = getFeatureTree((DescriptionBase<?>) selection);
+
+            for (FeatureNode childNode : featureTree.getRootChildren()) {
+                createMenuItem(menu, childNode.getFeature());
+
+            }
+        } else if (selection instanceof FeatureNodeContainer) {
+            FeatureNode featureNode = ((FeatureNodeContainer) selection)
+                    .getFeatureNode();
+
+            // add the feature to the menu
+            createMenuItem(menu, featureNode.getFeature());
+
+            // add possible children to the menu
+            for (FeatureNode childNode : featureNode.getChildNodes()) {
+                createMenuItem(menu, childNode.getFeature());
+            }
+        } else if (selection instanceof DescriptionElementBase) {
+            Feature feature = ((DescriptionElementBase) selection)
+                    .getFeature();
+            createMenuItem(menu, feature);
+        }
+    }
+
+    private void createMenuItem(MMenu menu, final Feature feature) {
+        final Feature deproxiedFeature = HibernateProxyHelper.deproxy(feature, Feature.class);
+
+        String label = deproxiedFeature.getLabel(PreferencesUtil.getGlobalLanguage());
+        if (label == null){
+            label = deproxiedFeature.getLabel();
+        }
+        if(label == null){
+            label = deproxiedFeature.generateTitle();
+        }
+        if(label == null){
+            label = deproxiedFeature.toString();
+        }
+        MHandledMenuItem menuItem = MMenuFactory.INSTANCE.createHandledMenuItem();
+        menuItem.setLabel(label);
+        MCommand mCommand = MCommandsFactory.INSTANCE.createCommand();
+        mCommand.setElementId(CreateDescriptionElementOperation.ID);
+        mCommand.setCommandName(label);
+        //             try {
+        //                 mCommand.setCommandName(command.getName());
+        //             } catch (NotDefinedException e) {
+        //                 e.printStackTrace();
+        //             }
+        //set params
+        menuItem.getTransientData().put(CreateDescriptionElementOperation.ID+".feature.uuid", feature.getUuid());
+
+        menuItem.setCommand(mCommand);
+        menu.getChildren().add(menuItem);
+    }
+
+       /**
+        * Retrieves the feature tree associated with the given description
+        *
+        * TODO as of now this is always the same thing because feature trees may
+        * not be associated to descriptions yet.
+        *
+        * @param description
+        * @return
+        */
+       private FeatureTree getFeatureTree(DescriptionBase description) {
+               FeatureTree featureTree = null;
+
+               // TODO change this to the feature tree associated with this taxon
+               // description
+               if (description.hasStructuredData()) {
+                       featureTree = PreferencesUtil
+                                       .getDefaultFeatureTreeForStructuredDescription();
+               } else {
+                       featureTree = PreferencesUtil
+                                       .getDefaultFeatureTreeForTextualDescription();
+               }
+
+               if (featureTree == null) {
+                       featureTree = FeatureTree.NewInstance(CdmStore.getTermManager()
+                                       .getPreferredTerms(Feature.class));
+               }
+
+               return featureTree;
+       }
+}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/MoveDescriptionElementsHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/MoveDescriptionElementsHandler.java
new file mode 100644 (file)
index 0000000..71ac2fc
--- /dev/null
@@ -0,0 +1,173 @@
+/**
+ * Copyright (C) 2007 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.view.descriptive.e4.handler;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuItem;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PartInitException;
+
+import eu.etaxonomy.cdm.api.service.IDescriptionService;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.description.DescriptionBase;
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.description.TaxonDescription;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
+import eu.etaxonomy.taxeditor.editor.Page;
+import eu.etaxonomy.taxeditor.editor.l10n.Messages;
+import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.MoveDescriptionElementsOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
+
+
+/**
+ *
+ * @author pplitzner
+ * @date 15.08.2017
+ *
+ */
+public class MoveDescriptionElementsHandler implements IPostOperationEnabled{
+    private UUID newAcceptedTaxonNodeUuid;
+    private TaxonNameEditor editor;
+
+    @Execute
+    public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart,
+            @Optional@Named(IServiceConstants.ACTIVE_SELECTION) Object selection,
+            @Named(IServiceConstants.ACTIVE_SHELL)Shell shell, MMenuItem menuItem) {
+
+        FactualDataPartE4 factualDataPart = (FactualDataPartE4) activePart.getObject();
+        Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(factualDataPart.getSelectionProvidingPart());
+        if(e4WrappedPart instanceof MultiPageTaxonEditor){
+            editor = (TaxonNameEditor) ((MultiPageTaxonEditor) e4WrappedPart).getPage(Page.NAME);
+        }
+        Taxon actualTaxon= null;
+
+        List<DescriptionElementBase> elements = new ArrayList<DescriptionElementBase>();
+
+        //                     for(Object element : structuredSelection.toArray()){
+        if(selection instanceof DescriptionElementBase){
+            UUID uuid = ((DescriptionElementBase) selection).getUuid();
+
+            elements.add(CdmStore.getService(IDescriptionService.class).loadDescriptionElement(uuid, null));
+        } else if(selection instanceof FeatureNodeContainer){
+            for(DescriptionElementBase de : ((FeatureNodeContainer)selection).getDescriptionElements()){
+                elements.add(
+                        CdmStore.getService(IDescriptionService.class).loadDescriptionElement(de.getUuid(), null)
+                        );
+            }
+        }
+        //                     }
+
+        if(elements.size() == 0){
+            return;
+        }
+
+        DescriptionBase description = elements.get(0).getInDescription();
+        List<UUID> excludeTaxa = new ArrayList<UUID>();
+        if (description!=null && description.isInstanceOf(TaxonDescription.class)){
+            TaxonDescription taxonDescription = HibernateProxyHelper.deproxy(description, TaxonDescription.class);
+            actualTaxon = taxonDescription.getTaxon();
+            excludeTaxa.add(actualTaxon.getUuid());
+        }
+        Classification classification = null;
+        TaxonNode actualNode = null;
+        if (actualTaxon != null){
+            if (!actualTaxon.getTaxonNodes().isEmpty() && actualTaxon.getTaxonNodes().size() ==1){
+                actualNode = actualTaxon.getTaxonNodes().iterator().next();
+                classification = actualNode.getClassification();
+
+            }
+        }
+        TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(shell,
+                editor.getConversationHolder(),
+                Messages.MoveDescriptionElementsHandler_CHOOSE_ACC_TAXON,
+                excludeTaxa,
+                null, classification
+                );
+        if (newAcceptedTaxonNode != null){
+            Taxon targetTaxon = newAcceptedTaxonNode.getTaxon();
+
+            if(targetTaxon == null){
+                // canceled
+                return;
+            }
+            newAcceptedTaxonNodeUuid = newAcceptedTaxonNode.getUuid();
+
+            String moveMessage = String.format(Messages.MoveDescriptionElementsHandler_ELEMENTS_MOVED, EditorUtil.getActiveMultiPageTaxonEditor().getTaxon());
+
+            AbstractPostOperation operation = new MoveDescriptionElementsOperation(
+                    menuItem.getLocalizedLabel(), EditorUtil.getUndoContext(),
+                    targetTaxon.getUuid(), moveMessage, elements, false, this);
+
+            AbstractUtility.executeOperation(operation);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean postOperation(CdmBase objectAffectedByOperation) {
+
+        editor.getConversationHolder().bind();
+        editor.getConversationHolder().commit(true);
+        Display.getDefault().asyncExec(new Runnable(){
+
+            @Override
+            public void run() {
+                //AbstractUtility.close(editor.getMultiPageTaxonEditor());
+
+                try {
+                    MultiPageTaxonEditor possibleOpenEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(newAcceptedTaxonNodeUuid);
+                    if(possibleOpenEditor != null){
+                        AbstractUtility.close(possibleOpenEditor);
+                    }
+                    EditorUtil.openTaxonNode(newAcceptedTaxonNodeUuid);
+                } catch (PartInitException e) {
+                    MessagingUtils.error(this.getClass(), e);
+                    throw new RuntimeException(e);
+                } catch (Exception e) {
+                    MessagingUtils.warningDialog(Messages.MoveDescriptionElementsHandler_CREATE_FAILURE, this, e.getMessage());
+                }
+            }
+
+        });
+
+
+        return true;
+    }
+
+    @Override
+    public boolean onComplete() {
+        return false;
+    }
+
+}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/MoveDescriptionToOtherTaxonHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/MoveDescriptionToOtherTaxonHandler.java
new file mode 100644 (file)
index 0000000..5b0febc
--- /dev/null
@@ -0,0 +1,149 @@
+/**
+ *
+ */
+package eu.etaxonomy.taxeditor.editor.view.descriptive.e4.handler;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuItem;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PartInitException;
+
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.description.TaxonDescription;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
+import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
+import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
+import eu.etaxonomy.taxeditor.editor.l10n.Messages;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
+import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.MoveDescriptionToOtherTaxonOperation;
+import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
+import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
+import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
+
+/**
+ *
+ * @author pplitzner
+ * @date 15.08.2017
+ *
+ */
+public class MoveDescriptionToOtherTaxonHandler implements IPostOperationEnabled {
+
+    private MoveDescriptionToOtherTaxonOperation operation;
+
+    private UUID newAcceptedTaxonNodeUuid;
+    private MultiPageTaxonEditor editor;
+
+    @Execute
+    public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart,
+            @Optional@Named(IServiceConstants.ACTIVE_SELECTION) TaxonDescription description,
+            @Named(IServiceConstants.ACTIVE_SHELL)Shell shell, MMenuItem menuItem) {
+
+
+        FactualDataPartE4 factualDataPart = (FactualDataPartE4) activePart.getObject();
+        Object e4WrappedPart = WorkbenchUtility.getE4WrappedPart(factualDataPart.getSelectionProvidingPart());
+        if(e4WrappedPart instanceof MultiPageTaxonEditor){
+            editor = (MultiPageTaxonEditor) e4WrappedPart;
+            if (this.editor.isDirty()){
+                boolean proceed = MessageDialog.openQuestion(null,
+                        Messages.MoveDescriptionToOtherTaxonHandler_SAVE_CHANGES, Messages.MoveDescriptionToOtherTaxonHandler_SAVE_CHANGES_MESSAGE);
+                if (proceed) {
+                    editor.doSave(AbstractUtility.getMonitor());
+                } else {
+                    return;
+                }
+
+            }
+        }
+
+        List<TaxonDescription> descriptions = new ArrayList<TaxonDescription>();
+        descriptions.add(description);
+
+        // Choose the target taxon
+        List<UUID> excludeTaxa = new ArrayList<UUID>();
+        excludeTaxa.add(descriptions.get(0).getTaxon().getUuid());
+
+        //get current taxon node
+        TaxonNode node = null;
+        Classification classification = null;
+        MultiPageTaxonEditor taxonEditor = EditorUtil.getActiveMultiPageTaxonEditor();
+        if(taxonEditor!=null){
+            node = ((TaxonEditorInput) taxonEditor.getEditorInput()).getTaxonNode();
+            classification = node.getClassification();
+        }
+        TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(shell,
+                editor.getConversationHolder(),
+                Messages.MoveDescriptionToOtherTaxonHandler_CHOOSE_ACC_TAXON,
+                excludeTaxa,
+                node,
+                classification);
+
+        if (newAcceptedTaxonNode == null) {
+            return ;
+        }
+
+        newAcceptedTaxonNodeUuid = newAcceptedTaxonNode.getUuid();
+
+        for(TaxonDescription taxonDescription : descriptions){
+            operation = new MoveDescriptionToOtherTaxonOperation(menuItem.getLocalizedLabel(),
+                    editor.getUndoContext(),
+                    taxonDescription,
+                    newAcceptedTaxonNode,
+                    this,
+                    editor,
+                    (ICdmEntitySessionEnabled)editor.getEditorInput());
+            AbstractUtility.executeOperation(operation);
+        }
+
+
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean postOperation(CdmBase objectAffectedByOperation) {
+        Display.getDefault().asyncExec(new Runnable(){
+
+            @Override
+            public void run() {
+                AbstractUtility.close(editor);
+
+                try {
+                    MultiPageTaxonEditor possibleOpenEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(newAcceptedTaxonNodeUuid);
+                    if(possibleOpenEditor != null){
+                        AbstractUtility.close(possibleOpenEditor);
+                    }
+                    EditorUtil.openTaxonNode(newAcceptedTaxonNodeUuid);
+                } catch (PartInitException e) {
+                    MessagingUtils.error(this.getClass(), e);
+                    throw new RuntimeException(e);
+                } catch (Exception e) {
+                    MessagingUtils.warningDialog(Messages.MoveDescriptionToOtherTaxonHandler_CREATE_FAILED, this, e.getMessage());
+                }
+            }
+
+        });
+
+
+        return true;
+    }
+
+    @Override
+    public boolean onComplete() {
+        return false;
+    }
+}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/ToggleShowOnlyIndividualAssociationsHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/e4/handler/ToggleShowOnlyIndividualAssociationsHandler.java
new file mode 100644 (file)
index 0000000..f1d9e90
--- /dev/null
@@ -0,0 +1,33 @@
+/**
+* Copyright (C) 2014 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.view.descriptive.e4.handler;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.services.IServiceConstants;
+
+import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
+
+/**
+ *
+ * @author pplitzner
+ * @date 15.08.2017
+ *
+ */
+public class ToggleShowOnlyIndividualAssociationsHandler  {
+
+    @Execute
+    public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart activePart) {
+        FactualDataPartE4 factualDataPart = (FactualDataPartE4) activePart.getObject();
+        factualDataPart.toggleShowOnlyIndividualAssociations();
+    }
+
+}
index 568130465336ef098429bce6e2aebcbea3191c59..e7c82cbc65355d68d1f621e234b2e54eaa472a66 100644 (file)
@@ -29,7 +29,6 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Tree;
 
-import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.description.IDescribable;
 import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
@@ -40,7 +39,6 @@ import eu.etaxonomy.taxeditor.model.AbstractUtility;
 import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.model.IPartContentHasMedia;
 import eu.etaxonomy.taxeditor.model.IPartContentHasSupplementalData;
-import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 import eu.etaxonomy.taxeditor.view.e4.AbstractCdmEditorPartE4;
 import eu.etaxonomy.taxeditor.view.e4.details.DetailsPartE4;
 import eu.etaxonomy.taxeditor.view.e4.supplementaldata.SupplementalDataPartE4;
@@ -52,7 +50,7 @@ import eu.etaxonomy.taxeditor.view.e4.supplementaldata.SupplementalDataPartE4;
  *
  */
 public class MediaViewPartE4 extends AbstractCdmEditorPartE4
-        implements IPartContentHasDetails, IPartContentHasSupplementalData, IPostOperationEnabled {
+        implements IPartContentHasDetails, IPartContentHasSupplementalData {
 
     private ISelectionChangedListener selectionChangedListener;
 
@@ -76,6 +74,7 @@ public class MediaViewPartE4 extends AbstractCdmEditorPartE4
 
         //create context menu
         menuService.registerContextMenu(viewer.getControl(), "eu.etaxonomy.taxeditor.editor.popupmenu.mediaview");
+
        }
 
        @Inject
@@ -117,7 +116,7 @@ public class MediaViewPartE4 extends AbstractCdmEditorPartE4
                }
                else if(firstElement!=null
                        && firstElement instanceof IDescribable<?>){
-                   showViewer((IStructuredSelection) selection, activePart, viewer);
+                   showViewer(structuredSelection, activePart, viewer);
                    return;
                }
            }
@@ -134,23 +133,6 @@ public class MediaViewPartE4 extends AbstractCdmEditorPartE4
                StructuredSelection selection = new StructuredSelection(object);
                viewer.setSelection(selection, true);
            }
-//         //TODO: should be replaced with the possibility to set views dirty
-//         // when we move to Eclipse 4
-//         // take a look at ISaveblePart
-//         if(part instanceof BulkEditor && !(object instanceof SpecimenOrObservationBase<?>)){
-//             ((BulkEditor) part).forceDirty();
-//             IStructuredSelection selection = (IStructuredSelection) ((BulkEditor) part).getSelectionProvider().getSelection();
-//            ((BulkEditor) part).changed(selection.getFirstElement());
-//
-//         }
-//         if (part instanceof E4PartWrapper){
-//             part = WorkbenchUtility.getE4WrappedPart(part);
-//             if (part instanceof IDirtyMarkable){
-//                      StructuredSelection selection = new StructuredSelection(object);
-//                     ((IDirtyMarkable)part).changed(selection.getFirstElement());
-//             }
-//         }
-
            super.changed(object);
        }
 
@@ -163,21 +145,4 @@ public class MediaViewPartE4 extends AbstractCdmEditorPartE4
         return viewer;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean postOperation(CdmBase objectAffectedByOperation) {
-        changed(objectAffectedByOperation);
-        return true;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean onComplete() {
-        viewer.refresh();
-        return true;
-    }
 }
index 2e816f3de8369250e9c959e4f436a5dd668b04d4..7a272b7e63ee8ac88bdb94d54c999e9a9301726c 100644 (file)
@@ -16,8 +16,6 @@ import org.eclipse.swt.widgets.Tree;
 
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
-import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDragListener;
-import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDropAdapter;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementTransfer;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptiveViewPart;
 
@@ -49,10 +47,10 @@ public class UsesViewPart extends DescriptiveViewPart {
 
 
                Transfer[] transfers = new Transfer[] { DescriptionElementTransfer.getInstance() };
-               viewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener(
-                               this));
-               viewer.addDropSupport(dndOperations, transfers,
-                               new DescriptionElementDropAdapter(viewer));
+//             viewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener(
+//                             this));
+//             viewer.addDropSupport(dndOperations, transfers,
+//                             new DescriptionElementDropAdapter(viewer));
 
                // Propagate selection from viewer
                getSite().setSelectionProvider(viewer);