ref #6909 Migrate remote handler
authorPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 6 Sep 2017 10:34:35 +0000 (12:34 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 6 Sep 2017 10:34:35 +0000 (12:34 +0200)
 - delete e3 handlers

20 files changed:
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java
eu.etaxonomy.taxeditor.navigation/fragment.e4xmi
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RemotingChangeAcceptedTaxonToSynonymHandlerE4.java [moved from eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/RemotingChangeAcceptedTaxonToSynonymHandler.java with 65% similarity]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RemotingDeleteTaxonNodeHandlerE4.java [moved from eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/RemotingDeleteTaxonNodeHandler.java with 70% similarity]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RemotingMoveFactualDataHandlerE4.java [moved from eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/RemotingMoveFactualDataHandler.java with 59% similarity]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RemotingMoveTaxonNodeHandlerE4.java [moved from eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/RemotingMoveTaxonNodeHandler.java with 76% similarity]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/SetSecReferenceForSubtreeHandlerE4.java
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/ChangeAcceptedTaxonToSynonymHandler.java [deleted file]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/CloneClassificationHandler.java [deleted file]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/CopyHandler.java [deleted file]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/CreateClassificationHierarchyHandler.java [deleted file]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java [deleted file]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveFactualDataHandler.java [deleted file]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveTaxonHandler.java [deleted file]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/NavigatorHandlerUtils.java [deleted file]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/NewClassificationHandler.java [deleted file]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/NewTaxonNodeHandler.java [deleted file]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/RefreshTreeHandler.java [deleted file]
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/SetSecReferenceForSubtreeHandler.java [deleted file]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/e4/RemotingCdmHandlerE4.java

index c7f6c413ac81162cca1ba0a0cff21207d752a35f..b31f1d60c7cece76c9ad99142e04d0fc7d69514b 100644 (file)
@@ -9,6 +9,7 @@
 
 package eu.etaxonomy.taxeditor.editor;
 
+import java.util.Collection;
 import java.util.UUID;
 
 import org.eclipse.core.commands.ExecutionEvent;
@@ -24,13 +25,10 @@ import org.eclipse.jface.viewers.TreeNode;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 import eu.etaxonomy.cdm.api.service.ITaxonService;
-import eu.etaxonomy.cdm.model.common.ITreeNode;
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
 import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
@@ -360,27 +358,18 @@ public class EditorUtil extends AbstractUtility {
         return null;
     }
 
-    public static boolean closeObsoleteEditor(TaxonNode taxonNode, IWorkbenchPage activePage){
-        boolean result = true;
-        for (IEditorReference ref : activePage.getEditorReferences()) {
-            try {
-                String treeIndex = ((ITreeNode)taxonNode).treeIndex();
-
-
-                IEditorInput input = ref.getEditorInput();
-                if (input instanceof TaxonEditorInput) {
-                    TaxonNode node = ((TaxonEditorInput) input).getTaxonNode();
-                    //if node is a child of taxonNode then close the editor
-                    if( ((ITreeNode) node).treeIndex().startsWith(treeIndex)){
-                    //if (taxonNode.equals(node)) {
-                        result &= activePage.closeEditor(ref.getEditor(false), true);
-
-                    }
+    public static void closeObsoleteEditor(TaxonNode taxonNode, EPartService partService){
+        String treeIndex = taxonNode.treeIndex();
+        Collection<MPart> parts = partService.getParts();
+        for (MPart part : parts) {
+            Object object = part.getObject();
+            if(object instanceof TaxonNameEditorE4){
+                TaxonNameEditorE4 taxonEditor = (TaxonNameEditorE4)object;
+                TaxonNode node = taxonEditor.getEditorInput().getTaxonNode();
+                if(node.treeIndex().startsWith(treeIndex)){
+                    partService.hidePart(part, true);
                 }
-            } catch (PartInitException e) {
-                continue;
             }
         }
-        return result;
     }
 }
index ff74818109094fdcbd9d66e448e017e9bda8f754..8a36a624676ac35b0c6896d1651bb44f8b9017d8 100644 (file)
@@ -5,16 +5,16 @@
   </fragments>
   <fragments xsi:type="fragment:StringModelFragment" xmi:id="_Z-4rwJIVEeeJAdt8ZUxyaw" featurename="descriptors" parentElementId="org.eclipse.e4.legacy.ide.application">
     <elements xsi:type="basic:PartDescriptor" xmi:id="_gH5RYJIVEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator" label="%view.name.2" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.navigation/icons/edit_16x16.gif" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4">
-      <handlers xmi:id="_Ic-1EJIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.MoveTaxonHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.MoveTaxonHandlerE4" command="_w4RNkJIxEeeJAdt8ZUxyaw"/>
+      <handlers xmi:id="_Ic-1EJIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RemotingMoveTaxonNodeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RemotingMoveTaxonNodeHandlerE4" command="_w4RNkJIxEeeJAdt8ZUxyaw"/>
       <handlers xmi:id="_xeEM0JIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RefreshTreeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RefreshTreeHandlerE4" command="_ukhM0JIyEeeJAdt8ZUxyaw"/>
       <handlers xmi:id="_0d3l0JIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CopyHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CopyHandlerE4" command="_EJ-u0JIyEeeJAdt8ZUxyaw"/>
-      <handlers xmi:id="_3I_vUJIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.ChangeAcceptedTaxonToSynonymHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.ChangeAcceptedTaxonToSynonymHandlerE4" command="_p7Oi8JIxEeeJAdt8ZUxyaw"/>
+      <handlers xmi:id="_3I_vUJIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RemotingChangeAcceptedTaxonToSynonymHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RemotingChangeAcceptedTaxonToSynonymHandlerE4" command="_p7Oi8JIxEeeJAdt8ZUxyaw"/>
       <handlers xmi:id="_6l8-YJIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.SetSecReferenceForSubtreeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.SetSecReferenceForSubtreeHandlerE4" command="_uFj1YJIxEeeJAdt8ZUxyaw"/>
       <handlers xmi:id="_-QYowJIyEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.NewClassificationHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.NewClassificationHandlerE4" command="_Vco-4JIxEeeJAdt8ZUxyaw"/>
       <handlers xmi:id="_Bc8EUJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.NewTaxonNodeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.NewTaxonNodeHandlerE4" command="_Nx06MJIvEeeJAdt8ZUxyaw"/>
-      <handlers xmi:id="_GTyegJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.MoveFactualDataHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.MoveFactualDataHandlerE4" command="_3PRy8JIxEeeJAdt8ZUxyaw"/>
+      <handlers xmi:id="_GTyegJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RemotingMoveFactualDataHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RemotingMoveFactualDataHandlerE4" command="_3PRy8JIxEeeJAdt8ZUxyaw"/>
       <handlers xmi:id="_JPKqgJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CreateClassificationHierarchyHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CreateClassificationHierarchyHandlerE4" command="_jXX0YJIxEeeJAdt8ZUxyaw"/>
-      <handlers xmi:id="_M64uUJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.DeleteHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.DeleteHandlerE4" command="__n644JIxEeeJAdt8ZUxyaw"/>
+      <handlers xmi:id="_M64uUJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RemotingDeleteTaxonNodeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.RemotingDeleteTaxonNodeHandlerE4" command="__n644JIxEeeJAdt8ZUxyaw"/>
       <handlers xmi:id="_QQq-YJIzEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CloneClassificationHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.navigator.e4.handler.CloneClassificationHandlerE4" command="_nOOxMJIxEeeJAdt8ZUxyaw"/>
       <menus xsi:type="menu:PopupMenu" xmi:id="_XNXnkJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigator.popupmenu.taxonnavigator">
         <children xsi:type="menu:Menu" xmi:id="_yzFmYJIvEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menu.new" label="%menu.label">
@@ -1,55 +1,49 @@
 /**
  *
  */
-package eu.etaxonomy.taxeditor.navigation.navigator.handler;
+package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
 
-import org.apache.log4j.Logger;
-import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.operations.AbstractOperation;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
 import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.swt.widgets.Shell;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolderMock;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
 import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
 import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingChangeAcceptedTaxonToSynonymOperation;
-import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
+import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
 import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
 
 /**
- * <p>ChangeAcceptedTaxonToSynonymHandler class.</p>
  *
- * @author n.hoffmann
- * @created Jan 4, 2010
- * @version 1.0
+ * @author pplitzner
+ * @since Sep 6, 2017
+ *
  */
-public class RemotingChangeAcceptedTaxonToSynonymHandler extends RemotingCdmHandler {
-
-    private static final Logger logger = Logger
-            .getLogger(RemotingChangeAcceptedTaxonToSynonymHandler.class);
+public class RemotingChangeAcceptedTaxonToSynonymHandlerE4 extends RemotingCdmHandlerE4 {
 
 
     private TaxonNode oldTaxonNode;
 
-       /**
-     * @param label
-     */
-    public RemotingChangeAcceptedTaxonToSynonymHandler() {
+    public RemotingChangeAcceptedTaxonToSynonymHandlerE4() {
         super(TaxonNavigatorLabels.CHANGE_ACCEPTED_TAXON_TO_SYNONYM_LABEL);
     }
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#allowOperations(org.eclipse.core.commands.ExecutionEvent)
-     */
+
     @Override
-    public IStatus allowOperations(ExecutionEvent event) {
-        TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
+    public IStatus allowOperations(TreeSelection selection,
+            Shell shell,
+            MPart activePart,
+            MHandledMenuItem menuItem) {
         // check that only a single taxon tree node has been selected
         if(selection.size() > 1) {
             return new Status(IStatus.ERROR,
@@ -87,23 +81,19 @@ public class RemotingChangeAcceptedTaxonToSynonymHandler extends RemotingCdmHand
         }
 
         // check if corresponding name editor is closed
-        boolean editorClosed = NavigatorHandlerUtils.closeObsoleteEditor(event, oldTaxonNode);
-        if(editorClosed != true) {
-            return new Status(IStatus.ERROR,
-                    "unknown", //$NON-NLS-1$
-                    TaxonNavigatorLabels.RELATED_EDITOR_NOT_CLOSED_MESSAGE);
-        }
+        EditorUtil.closeObsoleteEditor(oldTaxonNode, partService);
 
         return Status.OK_STATUS;
     }
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#doOperations(org.eclipse.core.commands.ExecutionEvent)
-     */
+
     @Override
-    public AbstractOperation prepareOperation(ExecutionEvent event) {
+    public AbstractOperation prepareOperation(TreeSelection selection,
+            Shell shell,
+            MPart activePart,
+            MHandledMenuItem menuItem) {
         List<UUID> excludeTaxa = new ArrayList<UUID>();
         excludeTaxa.add(oldTaxonNode.getTaxon().getUuid());
-        TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event),
+        TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(shell,
                 new ConversationHolderMock(),
                 Messages.RemotingChangeAcceptedTaxonToSynonymHandler_CHOOSE_TAXON,
                 excludeTaxa,
@@ -115,7 +105,7 @@ public class RemotingChangeAcceptedTaxonToSynonymHandler extends RemotingCdmHand
         }
 
         RemotingChangeAcceptedTaxonToSynonymOperation rcattso =
-                new RemotingChangeAcceptedTaxonToSynonymOperation(event.getTrigger(),
+                new RemotingChangeAcceptedTaxonToSynonymOperation(getTrigger(),
                         false,
                         oldTaxonNode.getUuid(),
                         newAcceptedTaxonNode.getUuid());
@@ -123,16 +113,15 @@ public class RemotingChangeAcceptedTaxonToSynonymHandler extends RemotingCdmHand
         return rcattso;
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#onComplete(org.eclipse.core.commands.ExecutionEvent)
-     */
     @Override
     public void onComplete() {
-        // TODO Auto-generated method stub
-
     }
 
-
-
-
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected Object getTrigger() {
+        return this;
+    }
 }
@@ -6,20 +6,20 @@
  * 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.navigation.navigator.handler;
+package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
 
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
-import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.operations.AbstractOperation;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.swt.widgets.Shell;
 
 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
 import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;
@@ -33,7 +33,7 @@ import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
 import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
 import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingDeleteTaxonNodeOperation;
-import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
+import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
 import eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator.DeleteConfiguratorDialog;
 
 /**
@@ -41,18 +41,20 @@ import eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator.DeleteCo
  * @date 22 Jun 2015
  *
  */
-public class RemotingDeleteTaxonNodeHandler extends RemotingCdmHandler {
+public class RemotingDeleteTaxonNodeHandlerE4 extends RemotingCdmHandlerE4 {
 
     private TaxonDeletionConfigurator config;
     private Set<ITaxonTreeNode> treeNodes;
 
-    public RemotingDeleteTaxonNodeHandler() {
+    public RemotingDeleteTaxonNodeHandlerE4() {
         super(TaxonNavigatorLabels.DELETE_TAXON_NODE_LABEL);
     }
 
     @Override
-    public IStatus allowOperations(ExecutionEvent event) {
-        TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
+    public IStatus allowOperations(TreeSelection selection,
+            Shell shell,
+            MPart activePart,
+            MHandledMenuItem menuItem) {
 
         Iterator<?> selectionIterator = selection.iterator();
         treeNodes = new HashSet<ITaxonTreeNode>();
@@ -63,18 +65,11 @@ public class RemotingDeleteTaxonNodeHandler extends RemotingCdmHandler {
                 treeNodes.add((ITaxonTreeNode) object);
             }
         }
-        boolean allEditorsClosed = true;
-        IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
         for (ITaxonTreeNode treeNode : treeNodes) {
             if(treeNode instanceof TaxonNode) {
-                allEditorsClosed &= EditorUtil.closeObsoleteEditor((TaxonNode) treeNode, activePage);
+                EditorUtil.closeObsoleteEditor((TaxonNode) treeNode, partService);
             }
         }
-        if(!allEditorsClosed) {
-            return new Status(IStatus.WARNING,
-                    "unknown", //$NON-NLS-1$
-                    TaxonNavigatorLabels.RELATED_EDITOR_NOT_CLOSED_MESSAGE);
-        }
 
         config = new TaxonDeletionConfigurator();
 
@@ -97,12 +92,12 @@ public class RemotingDeleteTaxonNodeHandler extends RemotingCdmHandler {
                        if (taxonNode instanceof Classification) {
                                String message;
                                if (taxonNode.hasChildNodes()) {
-                                       message = DeleteHandler.DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION+DeleteHandler.THE_TREE_HAS_CHILDREN_THEY_WILL_BE_DELETED_TOO;
+                                       message = DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION+DeleteHandlerE4.THE_TREE_HAS_CHILDREN_THEY_WILL_BE_DELETED_TOO;
                                } else {
-                                       message = DeleteHandler.DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION;
+                                       message = DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION;
                                }
-                               if (!DeleteConfiguratorDialog.openConfirm(
-                                               HandlerUtil.getActiveShell(event), DeleteHandler.CONFIRM_DELETION,
+                               if (!MessageDialog.openConfirm(
+                                               shell, DeleteHandlerE4.CONFIRM_DELETION,
                                                message)) {
                                        return Status.CANCEL_STATUS;
                                }
@@ -112,12 +107,12 @@ public class RemotingDeleteTaxonNodeHandler extends RemotingCdmHandler {
                 if (taxonNode.hasChildNodes()){
                     DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(
                             config,
-                            HandlerUtil.getActiveShell(event),
-                            DeleteHandler.CONFIRM_DELETION,
+                            shell,
+                            DeleteHandlerE4.CONFIRM_DELETION,
                             null,
-                            DeleteHandler.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S+DeleteHandler.THERE_ARE_CHILDNODES_WHICH_WILL_BE_DELETED_TOO,
-                            MessageDialog.WARNING, new String[] { DeleteHandler.DELETE_ALL_CHILDREN,
-                                DeleteHandler.MOVE_CHILDREN_TO_PARENT_NODE, DeleteHandler.SKIP }, 0);
+                            DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S+DeleteHandlerE4.THERE_ARE_CHILDNODES_WHICH_WILL_BE_DELETED_TOO,
+                            MessageDialog.WARNING, new String[] { DeleteHandlerE4.DELETE_ALL_CHILDREN,
+                                    DeleteHandlerE4.MOVE_CHILDREN_TO_PARENT_NODE, DeleteHandlerE4.SKIP }, 0);
                     int result = dialog.open();
 
                     if (result == 0){
@@ -132,7 +127,7 @@ public class RemotingDeleteTaxonNodeHandler extends RemotingCdmHandler {
                         return Status.CANCEL_STATUS;
                     }
                 } else{
-                    if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(configNodes, HandlerUtil.getActiveShell(event), DeleteHandler.CONFIRM_DELETION, DeleteHandler.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S)){
+                    if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(configNodes, shell, DeleteHandlerE4.CONFIRM_DELETION, DeleteHandlerE4.DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S)){
                         return Status.CANCEL_STATUS;
                     }
                     config.setTaxonNodeConfig(configNodes);
@@ -143,8 +138,11 @@ public class RemotingDeleteTaxonNodeHandler extends RemotingCdmHandler {
     }
 
     @Override
-    public AbstractOperation prepareOperation(ExecutionEvent event) {
-        return new RemotingDeleteTaxonNodeOperation(event.getTrigger(),
+    public AbstractOperation prepareOperation(TreeSelection selection,
+            Shell shell,
+            MPart activePart,
+            MHandledMenuItem menuItem) {
+        return new RemotingDeleteTaxonNodeOperation(getTrigger(),
                 false,
                 treeNodes,
                 config);
@@ -154,4 +152,12 @@ public class RemotingDeleteTaxonNodeHandler extends RemotingCdmHandler {
     public void onComplete() {
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected Object getTrigger() {
+        return this;
+    }
+
 }
@@ -6,33 +6,29 @@
 * 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.navigation.navigator.handler;
+package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
 
-import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.operations.AbstractOperation;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
 import org.eclipse.jface.viewers.TreeSelection;
 import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.swt.widgets.Shell;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolderMock;
 import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
 import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
 import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
 import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingMoveFactualDataOperation;
-import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
+import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
 import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
 
 /**
@@ -40,24 +36,20 @@ import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
  * @date 19 Jun 2015
  *
  */
-public class RemotingMoveFactualDataHandler extends RemotingCdmHandler {
-
+public class RemotingMoveFactualDataHandlerE4 extends RemotingCdmHandlerE4 {
 
     private TaxonNode sourceTaxonNode;
     private TaxonNode targetTaxonNode;
-    /**
-     * @param label
-     */
-    public RemotingMoveFactualDataHandler() {
+
+    public RemotingMoveFactualDataHandlerE4() {
         super(TaxonNavigatorLabels.MOVE_FACTUAL_DATA_LABEL);
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#allowOperations(org.eclipse.core.commands.ExecutionEvent)
-     */
     @Override
-    public IStatus allowOperations(ExecutionEvent event) {
-        TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
+    public IStatus allowOperations(TreeSelection selection,
+            Shell shell,
+            MPart activePart,
+            MHandledMenuItem menuItem) {
         // check that only a single taxon tree node has been selected
         if(selection.size() > 1) {
             return new Status(IStatus.ERROR,
@@ -91,7 +83,7 @@ public class RemotingMoveFactualDataHandler extends RemotingCdmHandler {
         List<UUID> excludeTaxa = new ArrayList<UUID>();
         excludeTaxa.add(sourceTaxonNode.getTaxon().getUuid());
 
-        targetTaxonNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event),
+        targetTaxonNode = TaxonNodeSelectionDialog.select(shell,
                 new ConversationHolderMock(),
                 Messages.RemotingMoveFactualDataHandler_CHOOSE_TAXA,
                 excludeTaxa,
@@ -111,45 +103,49 @@ public class RemotingMoveFactualDataHandler extends RemotingCdmHandler {
         return Status.OK_STATUS;
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#prepareOperation(org.eclipse.core.commands.ExecutionEvent)
-     */
     @Override
-    public AbstractOperation prepareOperation(ExecutionEvent event) {
-        return new RemotingMoveFactualDataOperation(event.getTrigger(),
+    public AbstractOperation prepareOperation(TreeSelection selection,
+            Shell shell,
+            MPart activePart,
+            MHandledMenuItem menuItem) {
+        return new RemotingMoveFactualDataOperation(getTrigger(),
                 false,
                 sourceTaxonNode.getTaxon().getUuid(),
                 targetTaxonNode.getTaxon().getUuid());
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#onComplete()
-     */
     @Override
     public void onComplete() {
         Display.getDefault().asyncExec(new Runnable(){
             @Override
             public void run() {
-                try {
-                    //close and re-open to refresh factual data view
-                    MultiPageTaxonEditor sourceEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(sourceTaxonNode.getUuid());
-                    MultiPageTaxonEditor targetEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(targetTaxonNode.getUuid());
-                    if(targetEditor != null){
-                        AbstractUtility.close(sourceEditor);
-                        AbstractUtility.close(targetEditor);
-                    }
-                    EditorUtil.openTaxonNodeE4(sourceTaxonNode.getUuid());
-                    EditorUtil.openTaxonNodeE4(targetTaxonNode.getUuid());
-                } catch (PartInitException e) {
-                    MessagingUtils.error(this.getClass(), e);
-                    throw new RuntimeException(e);
-                } catch (Exception e) {
-                    MessagingUtils.warningDialog(Messages.RemotingMoveFactualDataHandler_CREATE_FAILED, this, e.getMessage());
-                }
+                //FIXME E4 refresh factual view via events or similar
+//                try {
+//                    //close and re-open to refresh factual data view
+//                    MultiPageTaxonEditor sourceEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(sourceTaxonNode.getUuid());
+//                    MultiPageTaxonEditor targetEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(targetTaxonNode.getUuid());
+//                    if(targetEditor != null){
+//                        AbstractUtility.close(sourceEditor);
+//                        AbstractUtility.close(targetEditor);
+//                    }
+//                    EditorUtil.openTaxonNodeE4(sourceTaxonNode.getUuid());
+//                    EditorUtil.openTaxonNodeE4(targetTaxonNode.getUuid());
+//                } catch (PartInitException e) {
+//                    MessagingUtils.error(this.getClass(), e);
+//                    throw new RuntimeException(e);
+//                } catch (Exception e) {
+//                    MessagingUtils.warningDialog(Messages.RemotingMoveFactualDataHandler_CREATE_FAILED, this, e.getMessage());
+//                }
             }
 
         });
-
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected Object getTrigger() {
+        return this;
+    }
 }
@@ -6,20 +6,20 @@
  * 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.navigation.navigator.handler;
+package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
 
-import org.eclipse.core.commands.ExecutionEvent;
 import org.eclipse.core.commands.operations.AbstractOperation;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.TreeSelection;
 import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.handlers.HandlerUtil;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolderMock;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
@@ -28,7 +28,7 @@ import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
 import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
 import eu.etaxonomy.taxeditor.navigation.navigator.TreeNodeDropAdapter.MovingType;
 import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingMoveTaxonOperation;
-import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
+import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
 import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
 
@@ -37,20 +37,19 @@ import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
  * @date 19 Jun 2015
  *
  */
-public class RemotingMoveTaxonNodeHandler extends RemotingCdmHandler {
+public class RemotingMoveTaxonNodeHandlerE4 extends RemotingCdmHandlerE4 {
 
     private TaxonNode oldTaxonNode;
 
-    public RemotingMoveTaxonNodeHandler() {
+    public RemotingMoveTaxonNodeHandlerE4() {
         super(TaxonNavigatorLabels.MOVE_TAXON_LABEL);
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#allowOperations(org.eclipse.core.commands.ExecutionEvent)
-     */
     @Override
-    public IStatus allowOperations(ExecutionEvent event) {
-        TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
+    public IStatus allowOperations(TreeSelection selection,
+            Shell shell,
+            MPart activePart,
+            MHandledMenuItem menuItem) {
         // check that only a single taxon tree node has been selected
         if(selection.size() > 1) {
             return new Status(IStatus.ERROR,
@@ -76,13 +75,11 @@ public class RemotingMoveTaxonNodeHandler extends RemotingCdmHandler {
         return Status.OK_STATUS;
     }
 
-
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#prepareOperation(org.eclipse.core.commands.ExecutionEvent)
-     */
     @Override
-    public AbstractOperation prepareOperation(ExecutionEvent event) {
-        Shell activeShell = HandlerUtil.getActiveShell(event);
+    public AbstractOperation prepareOperation(TreeSelection selection,
+            Shell shell,
+            MPart activePart,
+            MHandledMenuItem menuItem) {
         TaxonNode parentTaxonNode;
 
         List<UUID> excludeTaxa = new ArrayList<UUID>();
@@ -93,7 +90,7 @@ public class RemotingMoveTaxonNodeHandler extends RemotingCdmHandler {
         if (PreferencesUtil.getSortNodesNaturally()){
 
 
-            parentTaxonNode = TaxonNodeSelectionDialog.select(activeShell,
+            parentTaxonNode = TaxonNodeSelectionDialog.select(shell,
                     new ConversationHolderMock(),
                     Messages.RemotingMoveTaxonNodeHandler_CHOOSE_TAXON,
                     excludeTaxa,
@@ -109,7 +106,7 @@ public class RemotingMoveTaxonNodeHandler extends RemotingCdmHandler {
                 moveToNewParent = MovingType.BEHIND;
             }
         } else {
-            parentTaxonNode = TaxonNodeSelectionDialog.select(activeShell,
+            parentTaxonNode = TaxonNodeSelectionDialog.select(shell,
                     new ConversationHolderMock(),
                     Messages.RemotingMoveTaxonNodeHandler_CHOOSE_PARENT,
                     excludeTaxa,
@@ -120,13 +117,13 @@ public class RemotingMoveTaxonNodeHandler extends RemotingCdmHandler {
 
         if(parentTaxonNode != null){
             if(NavigationUtil.isDirty(parentTaxonNode)){
-                MessageDialog.openWarning(activeShell,
+                MessageDialog.openWarning(shell,
                         Messages.RemotingMoveTaxonNodeHandler_UNSAVED_PARENT,
                         Messages.RemotingMoveTaxonNodeHandler_UNSAVED_PARENT_MESSAGE);
                 return null;
             }
 
-            return new RemotingMoveTaxonOperation(event.getTrigger(),
+            return new RemotingMoveTaxonOperation(getTrigger(),
                     false,
                     oldTaxonNode.getUuid(),
                     parentTaxonNode.getUuid(),
@@ -136,13 +133,15 @@ public class RemotingMoveTaxonNodeHandler extends RemotingCdmHandler {
         return null;
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#onComplete()
-     */
     @Override
     public void onComplete() {
-        // TODO Auto-generated method stub
-
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected Object getTrigger() {
+        return this;
+    }
 }
index 937d6466e7d3465a6e07266a43e4eb44605cef3c..0efd7f1ec14f322e61e8c6c2cbe3d54c0127d8e6 100755 (executable)
@@ -1,11 +1,11 @@
 /**
-* 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.
-*/
+ * 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.navigation.navigator.e4.handler;
 
 import javax.inject.Named;
@@ -39,91 +39,91 @@ import eu.etaxonomy.taxeditor.ui.dialog.configurator.SetSecundumForSubtreeConfig
  */
 public class SetSecReferenceForSubtreeHandlerE4 extends RemotingCdmHandlerE4 {
 
-       private ITaxonTreeNode taxonNode;
-       private SetSecundumForSubtreeConfigurator configurator;
-
-       public SetSecReferenceForSubtreeHandlerE4() {
-           super(TaxonNavigatorLabels.CHANGE_SECUNDUM_FOR_SUBTREE);
-       }
-
-       @Override
-       public IStatus allowOperations(TreeSelection selection,
-               Shell shell,
-               MPart activePart,
-               MHandledMenuItem menuItem) {
-           // check that only a single taxon tree node has been selected
-           if(selection.size() > 1) {  }
-
-           // check for no taxon tree node selected
-           if(selection.size() == 0) {
-               return new Status(IStatus.ERROR,
-                       "unknown", //$NON-NLS-1$
-                       TaxonNavigatorLabels.NO_TAXON_SELECTION_MESSAGE);
-           }
-
-           // check that selected object is a taxon node
-           Object obj = selection.iterator().next();
-           if(obj instanceof ITaxonTreeNode) {
-               if (obj instanceof Classification){
-                   taxonNode = ((Classification)obj).getRootNode();
-               }else{
-                   taxonNode = (ITaxonTreeNode)obj;
-               }
-          } else{
-               return new Status(IStatus.ERROR,
-                       "unknown", //$NON-NLS-1$
-                       TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE);
-           }
-
-
-           // check if corresponding name editor is closed
-           //FIXME E4 migrate
-//           boolean editorClosed = NavigatorHandlerUtils.closeObsoleteEditor(event, (TaxonNode) taxonNode);
-//           if(editorClosed != true) {
-//               return new Status(IStatus.ERROR,
-//                       "unknown", //$NON-NLS-1$
-//                       TaxonNavigatorLabels.RELATED_EDITOR_NOT_CLOSED_MESSAGE);
-//           }
-
-           configurator = new SetSecundumForSubtreeConfigurator(taxonNode.getUuid());
-           SetSecundumForSubtreeConfigurationWizard wizard = new SetSecundumForSubtreeConfigurationWizard(configurator);
-
-           WizardDialog dialog = new WizardDialog(AbstractUtility.getShell(), wizard);
-
-           if (dialog.open() == Window.OK) {
-              return Status.OK_STATUS;
-           }else{
-               return Status.CANCEL_STATUS;
-           }
-       }
-
-       @CanExecute
-       private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
-           boolean canExecute = false;
-           menuItem.setVisible(canExecute);
-           canExecute = selection.getFirstElement() instanceof ITaxonTreeNode;
-           return canExecute;
-       }
-
-       @Override
-       public AbstractOperation prepareOperation(TreeSelection selection,
-               Shell shell,
-               MPart activePart,
-               MHandledMenuItem menuItem) {
-          SetSecundumForSubtreeOperation operation =
-                   new SetSecundumForSubtreeOperation(getTrigger(),
-                           false,
-                           taxonNode.getUuid(),
-                           configurator);
-
-           return operation;
-       }
-
-       @Override
-       public void onComplete() {
-       }
-
-       /**
+    private ITaxonTreeNode taxonNode;
+    private SetSecundumForSubtreeConfigurator configurator;
+
+    public SetSecReferenceForSubtreeHandlerE4() {
+        super(TaxonNavigatorLabels.CHANGE_SECUNDUM_FOR_SUBTREE);
+    }
+
+    @Override
+    public IStatus allowOperations(TreeSelection selection,
+            Shell shell,
+            MPart activePart,
+            MHandledMenuItem menuItem) {
+        // check that only a single taxon tree node has been selected
+        if(selection.size() > 1) {  }
+
+        // check for no taxon tree node selected
+        if(selection.size() == 0) {
+            return new Status(IStatus.ERROR,
+                    "unknown", //$NON-NLS-1$
+                    TaxonNavigatorLabels.NO_TAXON_SELECTION_MESSAGE);
+        }
+
+        // check that selected object is a taxon node
+        Object obj = selection.iterator().next();
+        if(obj instanceof ITaxonTreeNode) {
+            if (obj instanceof Classification){
+                taxonNode = ((Classification)obj).getRootNode();
+            }else{
+                taxonNode = (ITaxonTreeNode)obj;
+            }
+        } else{
+            return new Status(IStatus.ERROR,
+                    "unknown", //$NON-NLS-1$
+                    TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE);
+        }
+
+
+        // check if corresponding name editor is closed
+        //FIXME E4 migrate
+        //           boolean editorClosed = NavigatorHandlerUtils.closeObsoleteEditor(event, (TaxonNode) taxonNode);
+        //           if(editorClosed != true) {
+        //               return new Status(IStatus.ERROR,
+        //                       "unknown", //$NON-NLS-1$
+        //                       TaxonNavigatorLabels.RELATED_EDITOR_NOT_CLOSED_MESSAGE);
+        //           }
+
+        configurator = new SetSecundumForSubtreeConfigurator(taxonNode.getUuid());
+        SetSecundumForSubtreeConfigurationWizard wizard = new SetSecundumForSubtreeConfigurationWizard(configurator);
+
+        WizardDialog dialog = new WizardDialog(AbstractUtility.getShell(), wizard);
+
+        if (dialog.open() == Window.OK) {
+            return Status.OK_STATUS;
+        }else{
+            return Status.CANCEL_STATUS;
+        }
+    }
+
+    @CanExecute
+    private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){
+        boolean canExecute = false;
+        menuItem.setVisible(canExecute);
+        canExecute = selection.getFirstElement() instanceof ITaxonTreeNode;
+        return canExecute;
+    }
+
+    @Override
+    public AbstractOperation prepareOperation(TreeSelection selection,
+            Shell shell,
+            MPart activePart,
+            MHandledMenuItem menuItem) {
+        SetSecundumForSubtreeOperation operation =
+                new SetSecundumForSubtreeOperation(getTrigger(),
+                        false,
+                        taxonNode.getUuid(),
+                        configurator);
+
+        return operation;
+    }
+
+    @Override
+    public void onComplete() {
+    }
+
+    /**
      * {@inheritDoc}
      */
     @Override
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/ChangeAcceptedTaxonToSynonymHandler.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/ChangeAcceptedTaxonToSynonymHandler.java
deleted file mode 100644 (file)
index 22dc557..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/**
- *
- */
-package eu.etaxonomy.taxeditor.navigation.navigator.handler;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
-import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
-import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
-import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
-import eu.etaxonomy.taxeditor.navigation.navigator.operation.ChangeAcceptedTaxonToSynonymOperation;
-import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
-import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
-import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
-
-/**
- * <p>ChangeAcceptedTaxonToSynonymHandler class.</p>
- *
- * @author n.hoffmann
- * @created Jan 4, 2010
- * @version 1.0
- */
-public class ChangeAcceptedTaxonToSynonymHandler extends DeleteHandler
-               implements IHandler, IPostOperationEnabled {
-       private static final Logger logger = Logger
-                       .getLogger(ChangeAcceptedTaxonToSynonymHandler.class);
-       private ChangeAcceptedTaxonToSynonymOperation operation;
-
-       private UUID newAcceptedTaxonNodeUuid;
-       private TaxonNameEditor editor;
-
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
-        */
-       /** {@inheritDoc} */
-       @Override
-    public Object execute(ExecutionEvent event) throws ExecutionException {
-
-
-                activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
-
-               taxonNavigator = NavigationUtil.showNavigator();
-
-               TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
-
-               // Prompt user for confirmation
-
-
-
-               Iterator selectionIterator = selection.iterator();
-               Set<ITaxonTreeNode> treeNodes = new HashSet<ITaxonTreeNode>();
-
-               while (selectionIterator.hasNext()){
-                       Object object = selectionIterator.next();
-                       if(object instanceof ITaxonTreeNode) {
-                treeNodes.add((ITaxonTreeNode) object);
-            }
-               }
-               boolean allEditorsClosed = true;
-               for (ITaxonTreeNode treeNode : treeNodes){
-                       if(treeNode instanceof TaxonNode) {
-                               allEditorsClosed &= closeObsoleteEditor((TaxonNode) treeNode);
-                       }
-               }
-               AbstractPostOperation operation = null;
-               if (treeNodes.size() == 1 ){
-                       try {
-
-                               ITaxonTreeNode treeNode = treeNodes.iterator().next();
-                               ITaxonTreeNode oldAcceptedTaxonNode =treeNode;
-
-                               // check if taxon has no children
-                               if(((TaxonNode)oldAcceptedTaxonNode).getCountChildren() > 0) {
-                                       MessagingUtils.warningDialog(Messages.ChangeAcceptedTaxonToSynonymHandler_PREREQUISITE, this,
-                                                       Messages.ChangeAcceptedTaxonToSynonymHandler_PREREQUISITE_MESSAGE);
-                                       return null;
-                               }
-                               /*if(((TaxonNode)oldAcceptedTaxonNode).getTaxon().hasSynonyms()) {
-                                       EditorUtil.warningDialog("Prerequisite not met", this,
-                                                       "The accepted taxon must not have any synonyms. You need to move all synonyms to " +
-                                                       "another taxon before attempting to turn the accepted " +
-                                                       "taxon into a synonym.");
-                                       return null;
-                               }*/
-
-                               List<UUID> excludeTaxa = new ArrayList<UUID>();
-                               excludeTaxa.add(((TaxonNode)oldAcceptedTaxonNode).getTaxon().getUuid());
-                               TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event),
-                                               taxonNavigator.getConversationHolder(),
-                                               Messages.ChangeAcceptedTaxonToSynonymHandler_CHOOSE_TAXON,
-                                               excludeTaxa,
-                                               null,
-                                               ((TaxonNode)oldAcceptedTaxonNode).getClassification());
-
-                               if (newAcceptedTaxonNode == null) {
-                                       return null;
-                               }
-
-                               if (allEditorsClosed){
-
-                                               operation = new ChangeAcceptedTaxonToSynonymOperation(event.getCommand().getName(),
-                                                       NavigationUtil.getUndoContext(),
-                                                       oldAcceptedTaxonNode,
-                                                       newAcceptedTaxonNode,
-                                                               taxonNavigator,
-                                                               taxonNavigator,
-                                                               taxonNavigator);
-
-                                               NavigationUtil.executeOperation(operation);
-                                               //}
-                               }
-
-
-
-                       } catch (NotDefinedException e) {
-                               MessagingUtils.warn(getClass(), "Command name not set"); //$NON-NLS-1$
-                       }
-               } else{
-                       if( MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), Messages.ChangeAcceptedTaxonToSynonymHandler_MOVE_SYNONYMY, Messages.ChangeAcceptedTaxonToSynonymHandler_MOVE_SYNONYMY_MESSAGE)){
-                               return null;
-                       }
-               }
-
-
-               return null;
-
-       }
-
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
-        */
-       /** {@inheritDoc} */
-       @Override
-    public boolean postOperation(CdmBase objectAffectedByOperation) {
-               Display.getDefault().asyncExec(new Runnable(){
-
-                       @Override
-            public void run() {
-                               EditorUtil.close(editor.getMultiPageTaxonEditor());
-
-                               try {
-                                       MultiPageTaxonEditor possibleOpenEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(newAcceptedTaxonNodeUuid);
-                                       if(possibleOpenEditor != null){
-                                               EditorUtil.close(possibleOpenEditor);
-                                       }
-                                       EditorUtil.openTaxonNodeE4(newAcceptedTaxonNodeUuid);
-                               } catch (PartInitException e) {
-                                       MessagingUtils.error(this.getClass(), e);
-                                       throw new RuntimeException(e);
-                               } catch (Exception e) {
-                                       MessagingUtils.warningDialog(Messages.ChangeAcceptedTaxonToSynonymHandler_CREATE_FAILED, this, e.getMessage());
-                               }
-                       }
-
-               });
-
-
-               return true;
-       }
-
-       /**
-        * <p>onComplete</p>
-        *
-        * @return a boolean.
-        */
-       @Override
-    public boolean onComplete() {
-               // TODO Auto-generated method stub
-               return false;
-       }
-}
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/CloneClassificationHandler.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/CloneClassificationHandler.java
deleted file mode 100644 (file)
index e02afdb..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-package eu.etaxonomy.taxeditor.navigation.navigator.handler;
-
-import org.apache.log4j.Logger;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.cdm.model.reference.Reference;
-import eu.etaxonomy.cdm.model.taxon.Classification;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
-import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
-import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
-import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
-import eu.etaxonomy.taxeditor.navigation.operation.CloneClassificationOperation;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
-import eu.etaxonomy.taxeditor.ui.section.classification.CloneClassificationWizard;
-
-public class CloneClassificationHandler extends AbstractHandler {
-
-    @SuppressWarnings("unused")
-    private static final Logger logger = Logger.getLogger(CloneClassificationHandler.class);
-
-    @Override
-    public Object execute(ExecutionEvent event) throws ExecutionException {
-        ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
-        if (currentSelection instanceof IStructuredSelection) {
-            Object selectedElement = ((IStructuredSelection) currentSelection).getFirstElement();
-            if (selectedElement instanceof TaxonNode && !((TaxonNode)selectedElement).hasTaxon()) {
-                Classification classification = ((TaxonNode)selectedElement).getClassification();
-                TaxonNavigator taxonNavigator = (TaxonNavigator)AbstractUtility.showView(TaxonNavigator.ID);
-                CloneClassificationWizard wizard = new CloneClassificationWizard(classification);
-                WizardDialog dialog = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
-                dialog.open();
-
-                String classificationName = wizard.getClassificationName();
-                TaxonRelationshipType relationType = wizard.getRelationType();
-                Reference reference = wizard.getReference();
-
-                CloneClassificationOperation operation = new CloneClassificationOperation(Messages.CloneClassificationHandler_CLONE_CLASSIFICATION,
-                        StoreUtil.getUndoContext(), classification, classificationName, reference, relationType,
-                        NavigationUtil.getNavigator(false), NavigationUtil.getNavigator(false));
-
-                AbstractUtility.executeOperation(operation);
-                taxonNavigator.refresh();
-            }
-        }
-        return null;
-    }
-
-}
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/CopyHandler.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/CopyHandler.java
deleted file mode 100644 (file)
index 9faca12..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/**\r
-* Copyright (C) 2009 EDIT\r
-* European Distributed Institute of Taxonomy \r
-* http://www.e-taxonomy.eu\r
-* \r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
-package eu.etaxonomy.taxeditor.navigation.navigator.handler;\r
-\r
-import org.eclipse.core.commands.AbstractHandler;\r
-import org.eclipse.core.commands.ExecutionEvent;\r
-import org.eclipse.core.commands.ExecutionException;\r
-import org.eclipse.core.commands.IHandler;\r
-import org.eclipse.core.commands.common.NotDefinedException;\r
-import org.eclipse.core.runtime.IStatus;\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-import org.eclipse.ui.handlers.HandlerUtil;\r
-\r
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;\r
-import eu.etaxonomy.taxeditor.model.MessagingUtils;\r
-import eu.etaxonomy.taxeditor.navigation.NavigationUtil;\r
-import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;\r
-import eu.etaxonomy.taxeditor.navigation.navigator.operation.CopyOperation;\r
-import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;\r
-import eu.etaxonomy.taxeditor.store.StoreUtil;\r
-\r
-/**\r
- * @author l.morris\r
- * @date 23 Jan 2012\r
- *\r
- */\r
-public class CopyHandler extends AbstractHandler implements IHandler {\r
-       \r
-       private TaxonNavigator taxonNavigator;\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)\r
-        */\r
-       @Override\r
-       public Object execute(ExecutionEvent event) throws ExecutionException {\r
-               \r
-               taxonNavigator = NavigationUtil.showNavigator();\r
-               \r
-               IStructuredSelection selection = (IStructuredSelection) HandlerUtil\r
-                               .getCurrentSelection(event);\r
-\r
-               if(selection.size() == 1) {\r
-                       \r
-                       Object selectedObject = selection.getFirstElement();\r
-                       \r
-                       if (selectedObject instanceof TaxonNode) {\r
-                               \r
-                               try {\r
-                                       \r
-                                       AbstractPostOperation operation = new CopyOperation(event.getCommand().getName(), StoreUtil.getUndoContext(),\r
-                                       (TaxonNode)selectedObject, taxonNavigator);\r
-                                       \r
-                                       IStatus status = NavigationUtil.executeOperation(operation);\r
-                                       \r
-                               } catch (NotDefinedException e) {\r
-                                       MessagingUtils.warn(getClass(), "Command name not set"); //$NON-NLS-1$\r
-                               }\r
-                       }\r
-               }\r
-               \r
-               \r
-               return null;\r
-       }\r
-\r
-}\r
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/CreateClassificationHierarchyHandler.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/CreateClassificationHierarchyHandler.java
deleted file mode 100644 (file)
index ee633e0..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-package eu.etaxonomy.taxeditor.navigation.navigator.handler;
-
-import org.apache.log4j.Logger;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.cdm.model.taxon.Classification;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
-import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
-import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
-import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
-import eu.etaxonomy.taxeditor.navigation.operation.CreateNewTaxonHierarchyOperation;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
-
-public class CreateClassificationHierarchyHandler extends AbstractHandler {
-
-    private static final Logger logger = Logger.getLogger(CreateClassificationHierarchyHandler.class);
-
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
-     * ExecutionEvent)
-     */
-    @Override
-    public Object execute(ExecutionEvent event) throws ExecutionException {
-        ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
-        if (currentSelection instanceof IStructuredSelection) {
-            Object selectedElement = ((IStructuredSelection) currentSelection).getFirstElement();
-            if (selectedElement instanceof TaxonNode && !((TaxonNode)selectedElement).hasTaxon()) {
-
-                Classification classification = ((TaxonNode) selectedElement).getClassification();
-                try {
-                    TaxonNavigator taxonNavigator = (TaxonNavigator)AbstractUtility.showView(TaxonNavigator.ID);
-//                    IClassificationService service = CdmStore.getService(IClassificationService.class);
-
-                    // Map<String, List<TaxonNode>> sortedGenusList =
-                    // service.getSortedGenusList(classification.getAllNodes());
-
-
-                    CreateNewTaxonHierarchyOperation operation = new CreateNewTaxonHierarchyOperation(Messages.CreateClassificationHierarchyHandler_CREATE_HIERARCHY, StoreUtil.getUndoContext(),classification,NavigationUtil.getNavigator(false), NavigationUtil.getNavigator(false) );
-
-                    AbstractUtility.executeOperation(operation);
-//                    UpdateResult result = service.createHierarchyInClassification(classification, null);
-//
-//                    Classification classification2 = CdmBase.deproxy(result.getCdmEntity(), Classification.class);
-//
-//                    Set<CdmBase> updatedObjects = result.getUpdatedObjects();
-//
-//                    Shell activeShell = HandlerUtil.getActiveShell(event);
-
-//                    MessagingUtils.messageDialog("Add Hierarchy successful",
-//                            FixClassificationHierarchyHandler.class, "Operation 'Fix Hierarchy' was successful. New classification is "
-//                    + classification2.getTitleCache() + "\nUpdated Objects: " + updatedObjects.size());
-                    //Success
-                    taxonNavigator.refresh();
-                } catch (Exception e) {
-                    MessagingUtils.messageDialog(Messages.CreateClassificationHierarchyHandler_FAILED, CreateClassificationHierarchyHandler.class,
-                            Messages.CreateClassificationHierarchyHandler_FAILED_MESSAGE, e);
-                }
-            }
-        }
-        return null;
-    }
-
-}
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java
deleted file mode 100644 (file)
index bafa443..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-/**
-* 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.navigation.navigator.handler;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;
-import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
-import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
-import eu.etaxonomy.cdm.model.common.ITreeNode;
-import eu.etaxonomy.cdm.model.taxon.Classification;
-import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
-import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
-import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
-import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
-import eu.etaxonomy.taxeditor.navigation.navigator.operation.DeleteOperation;
-import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
-import eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator.DeleteConfiguratorDialog;
-
-/**
- * <p>DeleteTreeNodeHandler class.</p>
- *
- * @author n.hoffmann
- * @created 06.04.2009
- * @version 1.0
- */
-public class DeleteHandler extends AbstractHandler{
-
-    protected static final String SKIP = Messages.DeleteHandler_SKIP;
-    protected static final String MOVE_CHILDREN_TO_PARENT_NODE = Messages.DeleteHandler_MOVE_TO_PARENT;
-    protected static final String DELETE_ALL_CHILDREN = Messages.DeleteHandler_DELETE_ALL;
-    protected static final String THERE_ARE_CHILDNODES_WHICH_WILL_BE_DELETED_TOO = Messages.DeleteHandler_THERE_ARE_CHILDNODES;
-    protected static final String THE_TREE_HAS_CHILDREN_THEY_WILL_BE_DELETED_TOO = Messages.DeleteHandler_THERE_ARE_CHILDREN;
-    protected static final String DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S = Messages.DeleteHandler_DELETE_NODE;
-    protected static final String DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION = Messages.DeleteHandler_DELETE_CLASSIFICATION;
-    protected static final String CONFIRM_DELETION = Messages.DeleteHandler_CONFIRM_DELETE;
-
-    protected IWorkbenchPage activePage;
-       protected TaxonNavigator taxonNavigator;
-
-       /** {@inheritDoc} */
-       @Override
-    public Object execute(ExecutionEvent event) throws ExecutionException {
-
-               activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
-
-               taxonNavigator = NavigationUtil.showNavigator();
-
-               TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
-
-
-               // Prompt user for confirmation
-
-
-
-               Iterator selectionIterator = selection.iterator();
-               Set<ITaxonTreeNode> treeNodes = new HashSet<ITaxonTreeNode>();
-
-               while (selectionIterator.hasNext()){
-                       Object object = selectionIterator.next();
-                       if(object instanceof ITaxonTreeNode) {
-                treeNodes.add((ITaxonTreeNode) object);
-            }
-               }
-               boolean allEditorsClosed = true;
-               for (ITaxonTreeNode treeNode : treeNodes){
-                       if(treeNode instanceof TaxonNode) {
-                               allEditorsClosed &= closeObsoleteEditor((TaxonNode) treeNode);
-                       }
-               }
-               AbstractPostOperation operation = null;
-               TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();
-               config.setDeleteInAllClassifications(false);
-
-               if (treeNodes.size() == 1 ){
-                       try {
-
-                               ITaxonTreeNode treeNode = treeNodes.iterator().next();
-                               ITaxonTreeNode taxonNode =treeNode;
-                               TaxonNodeDeletionConfigurator configNodes = new TaxonNodeDeletionConfigurator();
-
-                               //configNodes.setDeleteTaxon(false);
-                               if (taxonNode instanceof Classification && taxonNode.hasChildNodes()){
-                                       if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), CONFIRM_DELETION, DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION+THE_TREE_HAS_CHILDREN_THEY_WILL_BE_DELETED_TOO)){
-                                               return null;
-                                       }
-                               } else if (taxonNode instanceof Classification && !taxonNode.hasChildNodes()){
-                                       if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), CONFIRM_DELETION, DO_YOU_REALLY_WANT_TO_DELETE_THE_CLASSIFICATION)){
-                                               return null;
-                                       }
-                               } else {
-
-                                       if (taxonNode.hasChildNodes()){
-                        DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(
-                                config,
-                                HandlerUtil.getActiveShell(event),
-                                CONFIRM_DELETION,
-                                null,
-                                DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S+THERE_ARE_CHILDNODES_WHICH_WILL_BE_DELETED_TOO,
-                                MessageDialog.WARNING, new String[] { DELETE_ALL_CHILDREN,
-                                        MOVE_CHILDREN_TO_PARENT_NODE, SKIP }, 0);
-                                               int dialog_result = dialog.open();
-
-                                               if (dialog_result == 0){
-                                                       //delete all children
-                                                       configNodes.setChildHandling(ChildHandling.DELETE);
-                                                       config.setTaxonNodeConfig(configNodes);
-                                               } else if (dialog_result == 1){
-                                                       //move children
-                                                       configNodes.setChildHandling(ChildHandling.MOVE_TO_PARENT);
-                                                       config.setTaxonNodeConfig(configNodes);
-                                               } else if (dialog_result == 2){
-                                                       //skip
-                                                       return null;
-
-                                               }
-                                       }else{
-                                               if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(configNodes, HandlerUtil.getActiveShell(event), CONFIRM_DELETION, DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S)){
-                                                       return null;
-                                               }
-                                               config.setTaxonNodeConfig(configNodes);
-                                       }
-                               }
-
-                               if (allEditorsClosed){
-                                       /*if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected nodes?")){
-                                               return null;
-                                       }*/
-
-                                               operation = new DeleteOperation(event.getCommand().getName(),
-                                                       NavigationUtil.getUndoContext(),
-                                                               taxonNode,
-                                                               config,
-                                                               taxonNavigator,
-                                                               taxonNavigator,
-                                                               taxonNavigator);
-
-                                               NavigationUtil.executeOperation(operation);
-
-                                               //}
-                               }
-
-
-
-                       } catch (NotDefinedException e) {
-                               MessagingUtils.warn(getClass(), "Command name not set"); //$NON-NLS-1$
-                       } catch (Exception e){
-                           MessagingUtils.error(getClass(), e);
-                       }
-               } else{
-                       try{
-                               if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), CONFIRM_DELETION, DO_YOU_REALLY_WANT_TO_DELETE_THE_SELECTED_NODE_S)){
-                                       return null;
-                               }
-                               if (allEditorsClosed){
-
-                                       operation = new DeleteOperation(event.getCommand().getName(),
-                                               NavigationUtil.getUndoContext(),
-                                                       treeNodes,
-                                                       new TaxonDeletionConfigurator(),
-                                                       taxonNavigator,
-                                                       taxonNavigator,
-                                                       taxonNavigator);
-
-                                       NavigationUtil.executeOperation(operation);
-
-                               }
-                       }catch (NotDefinedException e) {
-                               MessagingUtils.warn(getClass(), Messages.DeleteHandler_9);
-                       } catch (Exception e){
-                MessagingUtils.error(getClass(), e);
-            }
-               }
-               return null;
-       }
-
-       protected boolean closeObsoleteEditor(TaxonNode taxonNode){
-               boolean result = true;
-               for (IEditorReference ref : activePage.getEditorReferences()) {
-                       try {
-                               String treeIndex = ((ITreeNode)taxonNode).treeIndex();
-
-
-                               IEditorInput input = ref.getEditorInput();
-                               if (input instanceof TaxonEditorInput) {
-                                       TaxonNode node = ((TaxonEditorInput) input).getTaxonNode();
-                                       //if node is a child of taxonNode then close the editor
-                                       if( ((ITreeNode) node).treeIndex().startsWith(treeIndex)){
-                                       //if (taxonNode.equals(node)) {
-                                               result &= activePage.closeEditor(ref.getEditor(false), true);
-
-                                       }
-                               }
-                       } catch (PartInitException e) {
-                               continue;
-                       }
-               }
-               return result;
-       }
-}
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveFactualDataHandler.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveFactualDataHandler.java
deleted file mode 100644 (file)
index 27a014b..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-package eu.etaxonomy.taxeditor.navigation.navigator.handler;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.cdm.api.service.IDescriptionService;
-import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
-import eu.etaxonomy.cdm.api.service.ITaxonService;
-import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
-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.model.AbstractUtility;
-import eu.etaxonomy.taxeditor.model.MessagingUtils;
-import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
-import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
-import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
-import eu.etaxonomy.taxeditor.store.CdmStore;
-import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
-
-public class MoveFactualDataHandler extends AbstractHandler {
-
-    @SuppressWarnings("unused")
-    private static final Logger logger = Logger.getLogger(MoveFactualDataHandler.class);
-
-    @Override
-    public Object execute(ExecutionEvent event) throws ExecutionException {
-        ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
-        Object activePart = AbstractUtility.getActiveE4Part();
-        TaxonNavigator navigator = null;
-        if(activePart instanceof TaxonNavigator){
-            navigator = (TaxonNavigator)activePart;
-        }
-        if(navigator!=null && currentSelection instanceof TreeSelection){
-            Object object = ((TreeSelection) currentSelection).getFirstElement();
-            if(object instanceof TaxonNode){
-                TaxonNode taxonNode = HibernateProxyHelper.deproxy(object, TaxonNode.class);
-                final TaxonNode sourceTaxonNode = CdmStore.getService(ITaxonNodeService.class).load(taxonNode.getUuid());
-                if(NavigationUtil.isDirty(sourceTaxonNode)){
-                    MessageDialog.openWarning(HandlerUtil.getActiveShell(event), Messages.MoveFactualDataHandler_UNSAVED_SOURCE, Messages.MoveFactualDataHandler_UNSAVED_SOURCE_MESSAGE);
-                    return null;
-                }
-                //reload to avoid session conflicts
-                Taxon taxon = HibernateProxyHelper.deproxy(CdmStore.getService(ITaxonService.class).load(sourceTaxonNode.getTaxon().getUuid()), Taxon.class);
-                if(taxon!=null){
-                 // Choose the target taxon
-                    List<UUID> excludeTaxa = new ArrayList<UUID>();
-                    excludeTaxa.add(taxon.getUuid());
-                    TaxonNode dialogTaxonNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event),
-                            navigator.getConversationHolder(),
-                            Messages.MoveFactualDataHandler_CHOOSE_TAXON,
-                            excludeTaxa,
-                            sourceTaxonNode,
-                            sourceTaxonNode.getClassification());
-                    if (dialogTaxonNode == null) {
-                        return null;
-                    }
-                    //reload to avoid session conflicts
-                    final TaxonNode targetTaxonNode = CdmStore.getService(ITaxonNodeService.class).load(dialogTaxonNode.getUuid());
-                    if(NavigationUtil.isDirty(targetTaxonNode)){
-                        MessageDialog.openWarning(HandlerUtil.getActiveShell(event), Messages.MoveFactualDataHandler_UNSAVED_TARGET, Messages.MoveFactualDataHandler_UNSAVED_TARGET_MESSAGE);
-                        return null;
-                    }
-                    CdmStore.getService(IDescriptionService.class).moveTaxonDescriptions(taxon.getUuid(),targetTaxonNode.getTaxon().getUuid());
-
-                    navigator.getConversationHolder().bind();
-                    navigator.getConversationHolder().commit();
-
-                    Display.getDefault().asyncExec(new Runnable(){
-
-                        @Override
-                        public void run() {
-                            try {
-                                //close and re-open to refresh factual data view
-                                MultiPageTaxonEditor sourceEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(sourceTaxonNode.getUuid());
-                                MultiPageTaxonEditor targetEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(targetTaxonNode.getUuid());
-                                if(targetEditor != null){
-                                    AbstractUtility.close(sourceEditor);
-                                    AbstractUtility.close(targetEditor);
-                                }
-                                EditorUtil.openTaxonNodeE4(sourceTaxonNode.getUuid());
-                                EditorUtil.openTaxonNodeE4(targetTaxonNode.getUuid());
-                            } catch (PartInitException e) {
-                                MessagingUtils.error(this.getClass(), e);
-                                throw new RuntimeException(e);
-                            } catch (Exception e) {
-                                MessagingUtils.warningDialog(Messages.MoveFactualDataHandler_CREATE_FAILED, this, e.getMessage());
-                            }
-                        }
-
-                    });
-                }
-            }
-        }
-        return null;
-    }
-
-}
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveTaxonHandler.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/MoveTaxonHandler.java
deleted file mode 100644 (file)
index d1309bf..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
-* 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.navigation.navigator.handler;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.UUID;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
-import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.taxon.Classification;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
-import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
-import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
-import eu.etaxonomy.taxeditor.navigation.navigator.TreeNodeDropAdapter.MovingType;
-import eu.etaxonomy.taxeditor.navigation.navigator.operation.MoveTaxonOperation;
-import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
-import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
-import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
-import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
-
-/**
- * <p>MoveTaxonHandler class.</p>
- *
- * @author n.hoffmann
- * @created 01.04.2009
- * @version 1.0
- */
-public class MoveTaxonHandler extends AbstractHandler implements IPostOperationEnabled {
-
-       private TaxonNode parentTaxonNode;
-       protected IWorkbenchPage activePage;
-
-       /** {@inheritDoc} */
-       @Override
-    public Object execute(ExecutionEvent event) throws ExecutionException {
-               activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
-               TaxonNavigator taxonNavigator = (TaxonNavigator)NavigationUtil.showView(TaxonNavigator.ID);
-
-               TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
-
-               Iterator<?> selectionIterator = selection.iterator();
-               Set<TaxonNode> taxonNodes = new HashSet<TaxonNode>();
-               TaxonNode taxonNode= null;
-               Set<UUID> taxonNodeUUIDs = new HashSet<UUID>();
-               // do not show the current selection
-               List<UUID> excludeTaxa = new ArrayList<UUID>();
-
-               //if (selection.size() == 1){
-
-               while (selectionIterator.hasNext()){
-                       Object object = selectionIterator.next();
-                       if(object instanceof TaxonNode){
-                           taxonNode = HibernateProxyHelper.deproxy(object,TaxonNode.class);
-                               taxonNodes.add(taxonNode);
-                               taxonNodeUUIDs.add(taxonNode.getUuid());
-                               excludeTaxa.add(taxonNode.getTaxon().getUuid());
-                       }
-               }
-               /*} else{
-                       if( MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Moving taxon", "The operation move accepted taxon to other parent is available only for a single taxon.")){
-                               return null;
-                       }
-               }*/
-
-
-//             TaxonNode taxonNode = (TaxonNode) selection.getFirstElement();
-               if (taxonNodes.size() >= 1){
-                   Classification classification = taxonNodes.iterator().next().getClassification();
-                       MovingType moveToNewParent = MovingType.CHILD;
-                       if (PreferencesUtil.getSortNodesNaturally()){
-                               if(!MessageDialog.openQuestion(null, Messages.MoveTaxonHandler_TARGET_NODE, Messages.MoveTaxonHandler_TARGET_NODE_MESSAGE)){
-                                       moveToNewParent = MovingType.BEHIND;
-                               }
-                               parentTaxonNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event), taxonNavigator.getConversationHolder(), Messages.MoveTaxonHandler_CHOOSE_ABOVE, excludeTaxa, null, classification);
-                       }else{
-                               parentTaxonNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event), taxonNavigator.getConversationHolder(), Messages.MoveTaxonHandler_CHOOSE_PARENT, excludeTaxa, null, classification);
-                       }
-                       if(parentTaxonNode != null){
-                               if(NavigationUtil.isDirty(parentTaxonNode)){
-                                       MessageDialog.openWarning(HandlerUtil.getActiveShell(event), Messages.MoveTaxonHandler_UNSAVED_PARENT, Messages.MoveTaxonHandler_UNSAVED_PARENT_MESSAGE);
-                                       return null;
-                               }
-
-
-                               AbstractPostOperation<?> operation = new MoveTaxonOperation
-                                               (Messages.MoveTaxonHandler_MOVE_TO_PARENT, NavigationUtil.getUndoContext(),
-                                                               taxonNodeUUIDs, parentTaxonNode, taxonNavigator, taxonNavigator, moveToNewParent); //$NON-NLS-1$
-                               NavigationUtil.executeOperation(operation);
-                               taxonNavigator.refresh();
-
-                       }
-               }
-               return null;
-       }
-
-       /** {@inheritDoc} */
-       @Override
-    public boolean postOperation(CdmBase objectAffectedByOperation) {
-               return true;
-       }
-
-       /**
-        * <p>onComplete</p>
-        *
-        * @return a boolean.
-        */
-       @Override
-    public boolean onComplete() {
-               return false;
-       }
-
-}
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/NavigatorHandlerUtils.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/NavigatorHandlerUtils.java
deleted file mode 100644 (file)
index 9930db8..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
-* Copyright (C) 2015 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.navigation.navigator.handler;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.cdm.model.common.ITreeNode;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
-
-/**
- * @author cmathew
- * @date 16 Jun 2015
- *
- */
-public class NavigatorHandlerUtils {
-
-    protected static boolean closeObsoleteEditor(ExecutionEvent event, TaxonNode taxonNode){
-        IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
-        boolean result = true;
-        for (IEditorReference ref : activePage.getEditorReferences()) {
-            try {
-                String treeIndex = ((ITreeNode)taxonNode).treeIndex();
-
-
-                IEditorInput input = ref.getEditorInput();
-                if (input instanceof TaxonEditorInput) {
-                    TaxonNode node = ((TaxonEditorInput) input).getTaxonNode();
-                    //if node is a child of taxonNode then close the editor
-                    if( ((ITreeNode) node).treeIndex().startsWith(treeIndex)){
-                    //if (taxonNode.equals(node)) {
-                        result &= activePage.closeEditor(ref.getEditor(false), true);
-
-                    }
-                }
-            } catch (PartInitException e) {
-                continue;
-            }
-        }
-        return result;
-    }
-
-}
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/NewClassificationHandler.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/NewClassificationHandler.java
deleted file mode 100644 (file)
index 1f61acb..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
-* 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.navigation.navigator.handler;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.taxeditor.newWizard.NewClassificationWizard;
-
-/**
- * <p>NewClassificationHandler class.</p>
- *
- * @author n.hoffmann
- * @created Sep 15, 2009
- * @version 1.0
- */
-public class NewClassificationHandler extends AbstractHandler implements
-               IHandler {
-
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
-        */
-       /** {@inheritDoc} */
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               NewClassificationWizard wizard = new NewClassificationWizard();
-               wizard.init(null, null);
-               WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
-               dialog.open();
-               
-               return null;
-       }
-}
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/NewTaxonNodeHandler.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/NewTaxonNodeHandler.java
deleted file mode 100644 (file)
index 179f3a8..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * 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.navigation.navigator.handler;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
-import eu.etaxonomy.taxeditor.newWizard.IWizardPageListener;
-import eu.etaxonomy.taxeditor.newWizard.NewTaxonNodeWizard;
-
-/**
- * <p>NewTaxonNodeHandler class.</p>
- *
- * @author n.hoffmann
- * @created Sep 15, 2009
- * @version 1.0
- */
-public class NewTaxonNodeHandler extends AbstractHandler {
-
-       /** {@inheritDoc} */
-       @Override
-    public Object execute(ExecutionEvent event) throws ExecutionException {
-               final NewTaxonNodeWizard wizard = new NewTaxonNodeWizard();
-               wizard.init(null, null);
-               final WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
-               wizard.addWizardPageListener(new IWizardPageListener() {
-
-                   @Override
-                   public void close() {
-                       wizard.performFinish();
-                       dialog.close();
-                   }
-               });
-               int status = dialog.open();
-
-               if(status == IStatus.OK && wizard.openInEditor()){
-                       if(wizard.openEmpty()){
-                               NavigationUtil.openEmpty(wizard.getParentTreeNode().getUuid());
-                       }else if(wizard.getTaxonNode() != null){
-                               NavigationUtil.openEditor(wizard.getTaxonNode());
-                       }
-               }
-               return null;
-       }
-}
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/RefreshTreeHandler.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/RefreshTreeHandler.java
deleted file mode 100644 (file)
index 5490a3b..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
-* 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.navigation.navigator.handler;
-
-import org.apache.log4j.Logger;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigator;
-
-/**
- * <p>RefreshTreeHandler class.</p>
- *
- * @author p.ciardelli
- * @created 04.09.2009
- * @version 1.0
- */
-public class RefreshTreeHandler extends AbstractHandler {
-       private static final Logger logger = Logger
-                       .getLogger(RefreshTreeHandler.class);
-
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
-        */
-       /** {@inheritDoc} */
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               
-               IWorkbenchPart part = HandlerUtil.getActivePart(event);
-               if (part instanceof TaxonNavigator) {
-                       ((TaxonNavigator) part).refresh();
-               }
-               return null;
-       }
-}
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/SetSecReferenceForSubtreeHandler.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/SetSecReferenceForSubtreeHandler.java
deleted file mode 100755 (executable)
index 8d49f3d..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
-* 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.navigation.navigator.handler;
-
-import org.apache.log4j.Logger;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.operations.AbstractOperation;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.cdm.io.common.SetSecundumForSubtreeConfigurator;
-import eu.etaxonomy.cdm.model.taxon.Classification;
-import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
-import eu.etaxonomy.taxeditor.navigation.navigator.operation.SetSecundumForSubtreeOperation;
-import eu.etaxonomy.taxeditor.operation.RemotingCdmHandler;
-import eu.etaxonomy.taxeditor.store.StoreUtil;
-import eu.etaxonomy.taxeditor.ui.dialog.configurator.SetSecundumForSubtreeConfigurationWizard;
-
-/**
- * @author k.luther
- * @date 10.02.2017
- *
- */
-public class SetSecReferenceForSubtreeHandler extends RemotingCdmHandler {
-
-       private static final Logger logger = Logger
-               .getLogger(SetSecReferenceForSubtreeHandler.class);
-
-
-       private ITaxonTreeNode taxonNode;
-       private SetSecundumForSubtreeConfigurator configurator;
-
-       /**
-        * @param label
-        */
-       public SetSecReferenceForSubtreeHandler() {
-           super(TaxonNavigatorLabels.CHANGE_SECUNDUM_FOR_SUBTREE);
-       }
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#allowOperations(org.eclipse.core.commands.ExecutionEvent)
-        */
-       @Override
-       public IStatus allowOperations(ExecutionEvent event) {
-           TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
-           // check that only a single taxon tree node has been selected
-           if(selection.size() > 1) {  }
-
-           // check for no taxon tree node selected
-           if(selection.size() == 0) {
-               return new Status(IStatus.ERROR,
-                       "unknown", //$NON-NLS-1$
-                       TaxonNavigatorLabels.NO_TAXON_SELECTION_MESSAGE);
-           }
-
-           // check that selected object is a taxon node
-           Object obj = selection.iterator().next();
-           if(obj instanceof ITaxonTreeNode) {
-               if (obj instanceof Classification){
-                   taxonNode = ((Classification)obj).getRootNode();
-               }else{
-                   taxonNode = (ITaxonTreeNode)obj;
-               }
-          } else{
-               return new Status(IStatus.ERROR,
-                       "unknown", //$NON-NLS-1$
-                       TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE);
-           }
-
-
-           // check if corresponding name editor is closed
-           boolean editorClosed = NavigatorHandlerUtils.closeObsoleteEditor(event, (TaxonNode) taxonNode);
-           if(editorClosed != true) {
-               return new Status(IStatus.ERROR,
-                       "unknown", //$NON-NLS-1$
-                       TaxonNavigatorLabels.RELATED_EDITOR_NOT_CLOSED_MESSAGE);
-           }
-
-           configurator = new SetSecundumForSubtreeConfigurator(taxonNode.getUuid());
-           SetSecundumForSubtreeConfigurationWizard wizard = new SetSecundumForSubtreeConfigurationWizard(configurator);
-
-           WizardDialog dialog = new WizardDialog(StoreUtil.getShell(), wizard);
-
-           if (dialog.open() == Window.OK) {
-              return Status.OK_STATUS;
-           }else{
-               return Status.CANCEL_STATUS;
-           }
-
-//           if(!SetSecundumForSubtreeConfigurationWizard.openConfirmWithConfigurator(configurator)){
-//
-//               return Status.CANCEL_STATUS;
-//           }
-//
-//
-//           return Status.OK_STATUS;
-       }
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#doOperations(org.eclipse.core.commands.ExecutionEvent)
-        */
-       @Override
-       public AbstractOperation prepareOperation(ExecutionEvent event) {
-          SetSecundumForSubtreeOperation operation =
-                   new SetSecundumForSubtreeOperation(event.getTrigger(),
-                           false,
-                           taxonNode.getUuid(),
-                           configurator);
-
-           return operation;
-       }
-
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#onComplete(org.eclipse.core.commands.ExecutionEvent)
-        */
-       @Override
-       public void onComplete() {
-           // TODO Auto-generated method stub
-
-       }
-
-
-
-
-
-
-}
index 37dcce49a92996d74ea3082e4cd9799dc4e6cbf5..94490c76e4b63de9de0b762fd5d23a5197cbbf52 100644 (file)
@@ -8,6 +8,7 @@
 */
 package eu.etaxonomy.taxeditor.operation.e4;
 
+import javax.inject.Inject;
 import javax.inject.Named;
 
 import org.eclipse.core.commands.operations.AbstractOperation;
@@ -16,6 +17,7 @@ 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.MHandledMenuItem;
 import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.e4.ui.workbench.modeling.EPartService;
 import org.eclipse.jface.dialogs.ErrorDialog;
 import org.eclipse.jface.viewers.TreeSelection;
 import org.eclipse.swt.widgets.Shell;
@@ -31,6 +33,8 @@ import eu.etaxonomy.taxeditor.model.MessagingUtils;
 public abstract class RemotingCdmHandlerE4 {
 
     private final String label;
+    @Inject
+    protected EPartService partService;
 
     public RemotingCdmHandlerE4(String label) {
         this.label = label;