ref #6908 Migrate remaining polytomous context menus and handlers
authorPatrick Plitzner <p.plitzner@bgbm.org>
Fri, 29 Sep 2017 06:51:13 +0000 (08:51 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Fri, 29 Sep 2017 06:51:13 +0000 (08:51 +0200)
12 files changed:
eu.etaxonomy.taxeditor.editor/fragment.e4xmi
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/e4/AbstractGraphKeyEditorE4.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/e4/KeyEditorDataChangeBehaviourE4.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/PolytomousKeyGraphEditorE4.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/PolytomousKeyListEditorE4.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/handler/AbstractPolytomousKeyNodeHandlerE4.java [deleted file]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/handler/CreateChildNodeHandlerE4.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/handler/DeleteNodeHandlerE4.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/handler/InsertNewNodeHandlerE4.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/handler/OpenPolytomousGraphEditorHandler.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.navigation/fragment.e4xmi
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/e4/handler/RemotingEditPolytomousKeyNodesHandlerE4.java

index e2616dbc9e07327165aafdaa9930e9900a26c58f..2cdb42973c1d547b25e7742480fd64ac1483ef98 100644 (file)
     <elements xsi:type="basic:PartDescriptor" xmi:id="_ghDAsKO6EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyGraphEditorE4" label="%editor.name.2" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyGraphEditorE4">
       <handlers xmi:id="_dpB_kKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.key.e4.handler.ApplyLayoutHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.e4.handler.ApplyLayoutHandlerE4" command="_zN-H8KO8EeeWePK798pdTw"/>
       <menus xsi:type="menu:PopupMenu" xmi:id="_J8Q6AKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.popupmenu.polytomouskeygrapheditor" toBeRendered="false" visible="false">
-        <children xsi:type="menu:HandledMenuItem" xmi:id="_bnPG8KRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.keygraph.newnode" label="%command.label.20" command="_jJ_4kKO9EeeWePK798pdTw"/>
-        <children xsi:type="menu:HandledMenuItem" xmi:id="_wKd6cKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.keygraph.delete" label="%command.label.21" command="_uM4zsKO8EeeWePK798pdTw"/>
-        <children xsi:type="menu:MenuSeparator" xmi:id="_whq5gKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.18"/>
-        <children xsi:type="menu:HandledMenuItem" xmi:id="_w9X-EKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.keygraph.applylayout" label="%command.label.22" command="_zN-H8KO8EeeWePK798pdTw"/>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_bnPG8KRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.keygraph.newnode" toBeRendered="false" visible="false" label="%command.label.20" command="_jJ_4kKO9EeeWePK798pdTw"/>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_wKd6cKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.keygraph.delete" toBeRendered="false" visible="false" label="%command.label.21" command="_uM4zsKO8EeeWePK798pdTw"/>
+        <children xsi:type="menu:MenuSeparator" xmi:id="_whq5gKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.18" toBeRendered="false" visible="false"/>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_w9X-EKRbEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.keygraph.applylayout" toBeRendered="false" visible="false" label="%command.label.22" command="_zN-H8KO8EeeWePK798pdTw"/>
       </menus>
     </elements>
     <elements xsi:type="basic:PartDescriptor" xmi:id="_tJeg0KO6EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4" label="%editor.name.3" closeable="true" dirtyable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4">
       <handlers xmi:id="_8DficKRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.CreateChildNodeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.CreateChildNodeHandlerE4" command="_tyHGwKO9EeeWePK798pdTw"/>
       <handlers xmi:id="_QHL6QKRSEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.CreateSiblingNodeHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.CreateSiblingNodeHandlerE4" command="_rkKogKO9EeeWePK798pdTw"/>
       <handlers xmi:id="_pDoJsKRSEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.RefreshNodeNumberingHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.RefreshNodeNumberingHandlerE4" command="_mH1G8KRSEeePufXF8uhoCw"/>
+      <handlers xmi:id="_gCYp4KTaEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.editor.handler.1" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler.OpenPolytomousGraphEditorHandler" command="_ZolPMKTaEeejf7ggYkp-TA"/>
       <menus xsi:type="menu:PopupMenu" xmi:id="_2JO_8KRQEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.popupmenu.polytomouskeylisteditor">
         <children xsi:type="menu:Menu" xmi:id="_2yjpwKRQEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.menu.polytomouskeylist.newkeynumber" label="%menu.label.4">
           <children xsi:type="menu:HandledMenuItem" xmi:id="_DWtt4KRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.polytomouskeylist.new.insertNode" label="%command.label.58" command="_jJ_4kKO9EeeWePK798pdTw"/>
         </children>
         <children xsi:type="menu:HandledMenuItem" xmi:id="_Iqi_AKRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.polytomouskeylist.newAlternative" label="%command.label.24" command="_rkKogKO9EeeWePK798pdTw"/>
         <children xsi:type="menu:HandledMenuItem" xmi:id="_LJ-14KRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.polytomouskeylist.refreshNodes" label="%command.label.25" command="_mH1G8KRSEeePufXF8uhoCw"/>
+        <children xsi:type="menu:MenuSeparator" xmi:id="_Ww_XAKTaEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.19"/>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_TvBa0KTaEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.opengraph" label="Open Graph" command="_ZolPMKTaEeejf7ggYkp-TA"/>
+        <children xsi:type="menu:MenuSeparator" xmi:id="_XMhccKTaEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.20"/>
         <children xsi:type="menu:HandledMenuItem" xmi:id="_Rf4A8KRREeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.polytomouskeylist.delete" label="%command.label.26" command="_uM4zsKO8EeeWePK798pdTw"/>
       </menus>
     </elements>
     <elements xsi:type="commands:Command" xmi:id="_rkKogKO9EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.key.polytomous.command.new.sibling" commandName="%command.name.29"/>
     <elements xsi:type="commands:Command" xmi:id="_tyHGwKO9EeeWePK798pdTw" elementId="eu.etaxonomy.taxeditor.key.polytomous.command.new.child" commandName="%command.name.28"/>
     <elements xsi:type="commands:Command" xmi:id="_mH1G8KRSEeePufXF8uhoCw" elementId="eu.etaxonomy.taxeditor.key.polytomous.command.refresh" commandName="%command.name.30"/>
+    <elements xsi:type="commands:Command" xmi:id="_ZolPMKTaEeejf7ggYkp-TA" elementId="eu.etaxonomy.taxeditor.editor.command.polytomouskeylist.openGraph" commandName="Open Graph Editor"/>
   </fragments>
   <fragments xsi:type="fragment:StringModelFragment" xmi:id="_pZmusEalEeeXMc6kSYO7Xg" featurename="children" parentElementId="eu.etaxonomy.taxeditor.menu.showView" positionInList="after:eu.etaxonomy.taxeditor.store.menuseparator.afterSupplemental">
     <elements xsi:type="menu:MenuSeparator" xmi:id="_eAVmMJ7SEee0IagNh8pHpQ" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.14"/>
index 0746e37c1558db5e7833b96a4bdbf13b45c236d3..241380f565c644a67870a26147d98c920cd3ea1a 100644 (file)
@@ -77,6 +77,9 @@ implements IConversationEnabled,
 
        public void init(PolytomousKeyEditorInput input) {
                this.input = input;
+
+
+        viewer.setInput(getKey());
        }
 
        public boolean isDirty() {
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/e4/KeyEditorDataChangeBehaviourE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/e4/KeyEditorDataChangeBehaviourE4.java
new file mode 100644 (file)
index 0000000..d8791cd
--- /dev/null
@@ -0,0 +1,60 @@
+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
+package eu.etaxonomy.taxeditor.editor.key.e4;
+
+import java.util.Vector;
+
+import eu.etaxonomy.cdm.model.description.PolytomousKey;
+import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeEvent;
+import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeEvent.EventType;
+import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorInput;
+import eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4;
+import eu.etaxonomy.taxeditor.model.AbstractDataChangeBehaviour;
+
+/**
+ * @author n.hoffmann
+ * @created May 5, 2011
+ * @version 1.0
+ */
+public class KeyEditorDataChangeBehaviourE4 extends AbstractDataChangeBehaviour {
+
+       private final PolytomousKeyListEditorE4 source;
+       private PolytomousKeyEditorInput input;
+
+       public KeyEditorDataChangeBehaviourE4(PolytomousKeyListEditorE4 keyEditor) {
+               source = keyEditor;
+       }
+
+       @Override
+       public void reactOnDataChange(CdmDataChangeMap changeEvents) {
+               input = source.getEditorInput();
+
+               if(changeEvents.sizeByEventType(EventType.UPDATE) > 0){
+                       reactOnUpdate(changeEvents.getEvents(EventType.UPDATE));
+               }
+       }
+
+       /** {@inheritDoc} */
+       @Override
+       public void reactOnUpdate(Vector<CdmDataChangeEvent> events){
+
+               for(CdmDataChangeEvent event : events){
+
+                       // update editor title
+                       if(event.getEntity() instanceof PolytomousKey){
+                               if(input.getKey().equals(event.getEntity())){
+                                       // set the name of the editor window
+                                       source.setPartName();
+                               }
+                       }
+               }
+       }
+}
index d9680572cb6cc5f72f1e02d1bff1e9262d0d1d33..1e41bc3dc42239cace89f1dcfe4f731c68c9bb29 100644 (file)
@@ -26,6 +26,7 @@ import eu.etaxonomy.taxeditor.editor.key.e4.AbstractGraphKeyEditorE4;
 import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage;
 import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyGraphContentProvider;
 import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyLabelProvider;
+import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 
 /**
@@ -45,6 +46,11 @@ public class PolytomousKeyGraphEditorE4 extends
        @PostConstruct
     public void createPartControl(Composite parent, EMenuService menuService,
             @Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {
+           if(!CdmStore.isActive()){
+               return;
+           }
+
+        formFactory = new CdmFormFactory(shell.getDisplay());
         container = formFactory.createComposite(parent);
 
         container.setLayout(new FillLayout());
@@ -67,8 +73,6 @@ public class PolytomousKeyGraphEditorE4 extends
         //FIXME E4 migrate
 //      createToolbar();
 
-        viewer.setInput(getKey());
-
         container.addControlListener(new ControlListener() {
 
             @Override
@@ -81,8 +85,6 @@ public class PolytomousKeyGraphEditorE4 extends
 
             }
         });
-
-        formFactory = new CdmFormFactory(shell.getDisplay());
     }
 
        @Override
index a328a622e2a25eb1d11cf5a6dd1ae8734502f481..2255891838f1ec011cc4d804240528710a8dd0e1 100644 (file)
@@ -45,15 +45,17 @@ import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.key.KeyEditorDataChangeBehaviour;
+import eu.etaxonomy.taxeditor.editor.key.e4.KeyEditorDataChangeBehaviourE4;
 import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage;
 import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorInput;
 import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyListContentProvider;
 import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyListLabelProvider;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
+import eu.etaxonomy.taxeditor.model.DataChangeBridge;
 import eu.etaxonomy.taxeditor.model.IDirtyMarkable;
 import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.workbench.part.IE4SavablePart;
 
 /**
  *
@@ -63,7 +65,7 @@ import eu.etaxonomy.taxeditor.model.MessagingUtils;
  */
 public class PolytomousKeyListEditorE4 implements
                IConversationEnabled, IDirtyMarkable, IPartContentHasDetails,
-               IPolytomousKeyEditorPage {
+               IPolytomousKeyEditorPage, IE4SavablePart{
 
        private class LinkListener extends MouseAdapter {
 
@@ -140,9 +142,7 @@ public class PolytomousKeyListEditorE4 implements
 
        private TableViewer viewer;
 
-       private ConversationHolder conversation;
-
-    private KeyEditorDataChangeBehaviour dataChangeBehavior;
+    private KeyEditorDataChangeBehaviourE4 dataChangeBehavior;
 
     private PolytomousKeyEditorInput input;
 
@@ -162,8 +162,11 @@ public class PolytomousKeyListEditorE4 implements
        }
 
        @Override
-       public void update(CdmDataChangeMap arg0) {
-
+       public void update(CdmDataChangeMap map) {
+           if(dataChangeBehavior == null){
+            dataChangeBehavior = new KeyEditorDataChangeBehaviourE4(this);
+        }
+        DataChangeBridge.handleDataChange(map, dataChangeBehavior);
        }
 
        @Override
@@ -171,8 +174,9 @@ public class PolytomousKeyListEditorE4 implements
                return input.getConversationHolder();
        }
 
-       @Persist
-       public void doSave(IProgressMonitor monitor) {
+       @Override
+    @Persist
+       public void save(IProgressMonitor monitor) {
         try {
             monitor.beginTask(Messages.KeyEditor_SAVING, 1);
             getConversationHolder().bind();
@@ -196,6 +200,10 @@ public class PolytomousKeyListEditorE4 implements
         viewer.setInput(input);
        }
 
+    public PolytomousKeyEditorInput getEditorInput() {
+        return input;
+    }
+
        public boolean isDirty() {
                return dirty.isDirty();
        }
@@ -291,10 +299,9 @@ public class PolytomousKeyListEditorE4 implements
        @Override
        public boolean postOperation(CdmBase objectAffectedByOperation) {
                viewer.refresh();
-               getConversationHolder().bind();
-               getConversationHolder().commit(true);
-               //FIXME E4 migrate/delete
-//             editor.changed(objectAffectedByOperation);
+//             getConversationHolder().bind();
+//             getConversationHolder().commit(true);
+               changed(objectAffectedByOperation);
 
                if (objectAffectedByOperation != null) {
                        viewer.setSelection(new StructuredSelection(
@@ -308,4 +315,9 @@ public class PolytomousKeyListEditorE4 implements
                return true;
        }
 
+    public void setPartName() {
+        PolytomousKey key = input.getKey();
+        thisPart.setLabel(key.getTitleCache());
+    }
+
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/handler/AbstractPolytomousKeyNodeHandlerE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/handler/AbstractPolytomousKeyNodeHandlerE4.java
deleted file mode 100644 (file)
index c17ab31..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
-* Copyright (C) 2016 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-package eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler;
-
-import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage;
-import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
-
-/**
- * @author k.luther
- * @date 24.11.2016
- *
- */
-public abstract class AbstractPolytomousKeyNodeHandlerE4 extends RemotingCdmHandlerE4 {
-
-
-    IPolytomousKeyEditorPage editorPage;
-
-    public AbstractPolytomousKeyNodeHandlerE4(String label) {
-        super(label);
-    }
-
-}
index 44c8a9f07a906a806e83b71c187a92a20735b32c..8376e56d21a261073ed49ec90147b832d405ac44 100644 (file)
@@ -6,6 +6,7 @@ package eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler;
 import javax.inject.Named;
 
 import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.e4.core.di.annotations.CanExecute;
 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;
@@ -59,4 +60,13 @@ public class CreateChildNodeHandlerE4 {
         }
     }
 
+    @CanExecute
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
+            MHandledMenuItem menuItem){
+        boolean canExecute = false;
+        canExecute = selection!=null && !selection.isEmpty();
+        menuItem.setVisible(canExecute);
+        return canExecute;
+    }
+
 }
index 6597e9d3cdf3484ad2f9803675c880a4d5207558..25dde004e0c840499fcc6e3fa74516434f55e99d 100644 (file)
@@ -30,13 +30,14 @@ import eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4
 import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.DeleteNodeOperation;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
 
 /**
  * @author n.hoffmann
  * @created Dec 6, 2010
  * @version 1.0
  */
-public class DeleteNodeHandlerE4 extends AbstractPolytomousKeyNodeHandlerE4 {
+public class DeleteNodeHandlerE4 extends RemotingCdmHandlerE4 {
 
 
     private static final String DO_YOU_REALLY_WANT_TO_DELETE_THE_NODE_THIS_OPERATION_IS_NOT_REVERSABLE = Messages.DeleteNodeHandler_REALLY_DELETE;
@@ -117,16 +118,16 @@ public class DeleteNodeHandlerE4 extends AbstractPolytomousKeyNodeHandlerE4 {
             if (!proceed) {
                 return null;
             }else{
-                editor.doSave(AbstractUtility.getMonitor());
+                editor.save(AbstractUtility.getMonitor());
             }
         }
 
         label = menuItem.getLocalizedLabel();
         DeleteNodeOperation operation ;
         if (deleteChildren){
-            operation = new DeleteNodeOperation(label, undoContext, nodeToBeDeleted, editorPage, true);
+            operation = new DeleteNodeOperation(label, undoContext, nodeToBeDeleted, editor, true);
         }else{
-            operation =  new DeleteNodeOperation(label, undoContext, nodeToBeDeleted, editorPage, false);
+            operation =  new DeleteNodeOperation(label, undoContext, nodeToBeDeleted, editor, false);
         }
 
         return operation;
@@ -145,12 +146,12 @@ public class DeleteNodeHandlerE4 extends AbstractPolytomousKeyNodeHandlerE4 {
     }
 
     @CanExecute
-    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
             MHandledMenuItem menuItem){
         boolean canExecute = false;
-        canExecute = selection instanceof PolytomousKeyNode;
+        canExecute = selection!=null && !selection.isEmpty();
         menuItem.setVisible(canExecute);
         return canExecute;
     }
 
-}
+}
\ No newline at end of file
index 47dbbf3f28f8b084d07e75ab7a00ea211621354d..0848e66614e927097813eb2c90feed634fa84191 100644 (file)
@@ -25,13 +25,14 @@ import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
 import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorLabels;
 import eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4;
 import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.InsertPolytomousKeyNodeOperation;
+import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
 
 /**
  * @author k.luther
  * @date 17.11.2016
  *
  */
-public class InsertNewNodeHandlerE4 extends AbstractPolytomousKeyNodeHandlerE4{
+public class InsertNewNodeHandlerE4 extends RemotingCdmHandlerE4{
 
     private PolytomousKeyNode parentNode ;
 
@@ -69,7 +70,8 @@ public class InsertNewNodeHandlerE4 extends AbstractPolytomousKeyNodeHandlerE4{
             @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
             @Named(IServiceConstants.ACTIVE_PART)MPart activePart,
             MHandledMenuItem menuItem) {
-        return new InsertPolytomousKeyNodeOperation(getTrigger(), false, parentNode, editorPage);
+        PolytomousKeyListEditorE4 editor = (PolytomousKeyListEditorE4) activePart.getObject();
+        return new InsertPolytomousKeyNodeOperation(getTrigger(), false, parentNode, editor);
     }
 
     @Override
@@ -77,10 +79,10 @@ public class InsertNewNodeHandlerE4 extends AbstractPolytomousKeyNodeHandlerE4{
     }
 
     @CanExecute
-    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
             MHandledMenuItem menuItem){
         boolean canExecute = false;
-        canExecute = selection instanceof PolytomousKeyNode;
+        canExecute = selection!=null && !selection.isEmpty();
         menuItem.setVisible(canExecute);
         return canExecute;
     }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/handler/OpenPolytomousGraphEditorHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/e4/handler/OpenPolytomousGraphEditorHandler.java
new file mode 100644 (file)
index 0000000..c202fc4
--- /dev/null
@@ -0,0 +1,26 @@
+
+package eu.etaxonomy.taxeditor.editor.key.polytomous.e4.handler;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.e4.ui.workbench.modeling.EPartService;
+import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState;
+
+import eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyGraphEditorE4;
+import eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyListEditorE4;
+
+public class OpenPolytomousGraphEditorHandler {
+
+       @Execute
+       public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, EPartService partService) {
+               MPart part = partService.createPart("eu.etaxonomy.taxeditor.editor.key.polytomous.e4.PolytomousKeyGraphEditorE4");
+               part = partService.showPart(part, PartState.ACTIVATE);
+               PolytomousKeyGraphEditorE4 graphEditor = (PolytomousKeyGraphEditorE4) part.getObject();
+               PolytomousKeyListEditorE4 listEditor = (PolytomousKeyListEditorE4) activePart.getObject();
+               graphEditor.init(listEditor.getEditorInput());
+       }
+
+}
\ No newline at end of file
index a74b6da9b504c806e60676ef2c48fcb4a3cfef27..5f82df04e19a2af343a8fffab78d1fc9e4bd7937 100644 (file)
       <handlers xmi:id="_tvg9wKQVEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RemotingEditPolytomousKeyNodesHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RemotingEditPolytomousKeyNodesHandlerE4" command="_BrgnkKQVEeeTrq_CRrR-jg"/>
       <handlers xmi:id="_xhc-UKQVEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RemotingUpdatePolytomousKeyAllNodesHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RemotingUpdatePolytomousKeyAllNodesHandlerE4" command="_6S6M4KQVEeeTrq_CRrR-jg"/>
       <handlers xmi:id="_CoKnoKQWEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RefreshPolytomousKeyListHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RefreshPolytomousKeyListHandlerE4" command="_4BQ6YKQVEeeTrq_CRrR-jg"/>
-      <handlers xmi:id="_GjyIoKQWEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.key.polytomous.handler.RemotingDeletePolytomousKeyHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.key.polytomous.handler.RemotingDeletePolytomousKeyHandler" command="_8C8AEKQVEeeTrq_CRrR-jg"/>
+      <handlers xmi:id="_GjyIoKQWEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RemotingDeletePolytomousKeyHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.key.polytomous.e4.handler.RemotingDeletePolytomousKeyHandlerE4" command="_8C8AEKQVEeeTrq_CRrR-jg"/>
       <menus xsi:type="menu:PopupMenu" xmi:id="_FajhpKQUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.popupmenu.polytomouskeyview">
         <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_FajhpaQUEeeTrq_CRrR-jg" coreExpressionId="isCdmStoreConnected"/>
         <children xsi:type="menu:HandledMenuItem" xmi:id="_FajhpqQUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.new" label="%command.label.15" command="_lAZG8KQUEeeTrq_CRrR-jg"/>
         <children xsi:type="menu:DynamicMenuContribution" xmi:id="_ot9k4KQUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.polytomouskey.dynamicmenucontribution.cdmViewer" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.CdmViewerContextMenuE4"/>
-        <children xsi:type="menu:HandledMenuItem" xmi:id="_Fajhp6QUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.edit" label="%command.label.16">
-          <command href="../eu.etaxonomy.taxeditor.editor/fragment.e4xmi#_uM4zsKO8EeeWePK798pdTw"/>
-        </children>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_Fajhp6QUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.edit" label="%command.label.16" command="_BrgnkKQVEeeTrq_CRrR-jg"/>
         <children xsi:type="menu:Menu" xmi:id="_IKePEKQVEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.menu.polytomouskey.refresh" label="%menu.label.0">
           <children xsi:type="menu:HandledMenuItem" xmi:id="_JS0-QKQVEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.refreshlist" label="%command.label.17" command="_4BQ6YKQVEeeTrq_CRrR-jg"/>
           <children xsi:type="menu:HandledMenuItem" xmi:id="_JsJdMKQVEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.refreshnodes" label="%command.label.18" command="_6S6M4KQVEeeTrq_CRrR-jg"/>
         </children>
         <children xsi:type="menu:MenuSeparator" xmi:id="_FajhqKQUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.18"/>
-        <children xsi:type="menu:HandledMenuItem" xmi:id="_FajhqaQUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.refresh" label="%command.label.19">
-          <command href="../eu.etaxonomy.taxeditor.editor/fragment.e4xmi#_zN-H8KO8EeeWePK798pdTw"/>
-        </children>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_FajhqaQUEeeTrq_CRrR-jg" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.polytomouskey.refresh" label="%command.label.19" command="_8C8AEKQVEeeTrq_CRrR-jg"/>
       </menus>
     </elements>
   </fragments>
index fc06e7f45903cc0e59aa516a17587ab56df6f3b3..1ba507bb5bf1205cab237a282fd12cbeb6ddd11d 100644 (file)
@@ -14,11 +14,14 @@ import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.e4.core.di.annotations.CanExecute;
 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.e4.ui.workbench.modeling.EPartService.PartState;
+import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.swt.widgets.Display;
 
@@ -90,4 +93,13 @@ public class RemotingEditPolytomousKeyNodesHandlerE4 {
         }
     }
 
+    @CanExecute
+    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)Object selection,
+            MHandledMenuItem menuItem){
+        boolean canExecute = false;
+        canExecute = ((IStructuredSelection)selection).getFirstElement() instanceof PolytomousKey;
+        menuItem.setVisible(canExecute);
+        return canExecute;
+    }
+
 }