ref #6902 Migrate sequence editing menu item
authorPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 10 Aug 2017 10:16:27 +0000 (12:16 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 10 Aug 2017 12:12:39 +0000 (14:12 +0200)
eu.etaxonomy.taxeditor.editor/fragment.e4xmi
eu.etaxonomy.taxeditor.molecular/META-INF/MANIFEST.MF
eu.etaxonomy.taxeditor.molecular/fragment.e4xmi [new file with mode: 0644]
eu.etaxonomy.taxeditor.molecular/plugin.xml
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/EditSequenceHandler.java

index 071d883d6954ad1f1a3f60e670911d1127ac4edb..1eaf497c78126434c7e88ec33f1ae680a7f302ee 100644 (file)
@@ -50,7 +50,7 @@
         <children xsi:type="menu:HandledMenuItem" xmi:id="_h4pX0DumEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandnamereuse_single_read" label="%command.label.REUSE_SINGLE_READ_HERE" command="_HmerkDumEeeOtqC_3qh40A"/>
         <children xsi:type="menu:HandledMenuItem" xmi:id="_oQXH0DumEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandlabelreuse_single_read_for_other_sequence" label="%command.label.REUSE_SINGLE_READ_FOR_OTHER_SEQUENCE" command="_N0wLsDumEeeOtqC_3qh40A"/>
         <children xsi:type="menu:HandledMenuItem" xmi:id="_1apX0DumEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandlabelremove_single_read_from_this_sequence" label="%command.label.REMOVE_SINGLE_READ_FROM_THIS_SEQUENCE" command="_K4DxEDumEeeOtqC_3qh40A"/>
-        <children xsi:type="menu:MenuSeparator" xmi:id="_c0f98DulEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.3"/>
+        <children xsi:type="menu:MenuSeparator" xmi:id="_c0f98DulEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.beforeDelete"/>
         <children xsi:type="menu:HandledMenuItem" xmi:id="_XWW6QDulEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandlabel52" label="%command.label.52" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.store/icons/delete.gif" command="_YPp1wDvREeeOtqC_3qh40A"/>
         <children xsi:type="menu:HandledMenuItem" xmi:id="_wg0-oDulEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandlabel54" label="%command.label.54" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.editor/icons/deep-delete-16x16-32.png" command="_fKT-wDulEeeOtqC_3qh40A"/>
       </menus>
index d893dcb579c395f784e7a6a6a439094cbc15941b..fd70d7bded669d1a42761b3ae9b52d98672026a9 100644 (file)
@@ -16,7 +16,9 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.core.databinding.observable;bundle-version="1.4.0",
  org.eclipse.core.databinding;bundle-version="1.4.0",
  org.eclipse.jface.databinding;bundle-version="1.5.0",
- org.eclipse.core.databinding.property;bundle-version="1.4.0"
+ org.eclipse.core.databinding.property;bundle-version="1.4.0",
+ org.eclipse.e4.core.di.annotations,
+ org.eclipse.e4.ui.services
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-ActivationPolicy: lazy
 Bundle-Vendor: EDIT
diff --git a/eu.etaxonomy.taxeditor.molecular/fragment.e4xmi b/eu.etaxonomy.taxeditor.molecular/fragment.e4xmi
new file mode 100644 (file)
index 0000000..ef4d443
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="ASCII"?>
+<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmlns:ui="http://www.eclipse.org/ui/2010/UIModel/application/ui" xmi:id="_OhwnQCTfEeeiN5lBIuqN3g">
+  <fragments xsi:type="fragment:StringModelFragment" xmi:id="__mwtMDVpEee_b7RlBzTDRw" featurename="commands" parentElementId="xpath:/">
+    <elements xsi:type="commands:Command" xmi:id="_JZdQ0H2sEeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.editSequence" commandName="%command.EDIT_SEQUENCE"/>
+  </fragments>
+  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_RCmzgH2sEeeVL5aZ55YsWA" featurename="handlers" parentElementId="eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView">
+    <elements xsi:type="commands:Handler" xmi:id="_XuBioH2sEeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.handler.EditSequenceHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.handler.EditSequenceHandler" command="_JZdQ0H2sEeeVL5aZ55YsWA"/>
+  </fragments>
+  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_o08AQH2sEeeVL5aZ55YsWA" featurename="children" parentElementId="eu.etaxonomy.taxeditor.editor.popupmenu.specimeneditor" positionInList="before:eu.etaxonomy.taxeditor.editor.menuseparator.beforeDelete">
+    <elements xsi:type="menu:HandledMenuItem" xmi:id="_txARoH2sEeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.handledmenuitem.commandlabeledit_sequence" label="%command.label.EDIT_SEQUENCE" command="_JZdQ0H2sEeeVL5aZ55YsWA">
+      <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_wpbQQH2sEeeVL5aZ55YsWA" coreExpressionId="isSequence"/>
+    </elements>
+  </fragments>
+</fragment:ModelFragments>
index 7df2be1afbbc52fb9c3a097839186d5dbee532e1..d9233aa48ded9dc9b4b93de9c3c8b85eab4647ff 100644 (file)
       </extension>
       <extension
             point="org.eclipse.ui.commands">
-         <command
-               defaultHandler="eu.etaxonomy.taxeditor.molecular.handler.EditSequenceHandler"
-               id="eu.etaxonomy.taxeditor.molecular.editSequence"
-               name="%command.EDIT_SEQUENCE">
-         </command>
          <command
                defaultHandler="eu.etaxonomy.taxeditor.molecular.handler.ShowPherogramHandler"
                id="eu.etaxonomy.taxeditor.molecular.showPherogram"
                   name="eu.etaxonomy.taxeditor.molecular.separator5"
                   visible="true">
             </separator>
-            <command
-                  commandId="eu.etaxonomy.taxeditor.molecular.editSequence"
-                  label="%command.label.EDIT_SEQUENCE"
-                  style="push">
-               <visibleWhen
-                     checkEnabled="true">
-                  <reference
-                        definitionId="isSequence">
-                  </reference>
-               </visibleWhen>
-            </command>
             <command
                   commandId="eu.etaxonomy.taxeditor.molecular.exportSequenceToFile"
                   label="%command.label.EXPORT_SEQUENCE_TO_FILE"
                sequence="M1+O">
          </key>
       </extension>
+      <extension
+            id="id1"
+            point="org.eclipse.e4.workbench.model">
+         <fragment
+               apply="always"
+               uri="fragment.e4xmi">
+         </fragment>
+      </extension>
       
 </plugin>
index c0d646d401042d98c53b7f70935a806c645787a3..2927a58b9ce73e3b0f49cde36cc745fb650ead6d 100644 (file)
@@ -1,16 +1,15 @@
 package eu.etaxonomy.taxeditor.molecular.handler;
 
 
-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 javax.inject.Named;
+
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.ui.services.IServiceConstants;
 import org.eclipse.jface.viewers.TreeNode;
 import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
 
 import eu.etaxonomy.cdm.model.molecular.Sequence;
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.molecular.TaxeditorMolecularPlugin;
 import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor;
 import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditorInput;
@@ -24,14 +23,12 @@ import eu.etaxonomy.taxeditor.molecular.l10n.Messages;
  * @author Ben St&ouml;ver
  * @author pplitzner
  */
-public class EditSequenceHandler extends AbstractHandler {
+public class EditSequenceHandler {
     private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(EditSequenceHandler.class);
 
-    
-    @Override
-    public Object execute(ExecutionEvent event) throws ExecutionException {
-        ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
-        TreeNode treeNodeOfSelection = EditorUtil.getTreeNodeOfSelection(currentSelection);
+
+    @Execute
+    public void execute(@Optional@Named(IServiceConstants.ACTIVE_SELECTION)TreeNode treeNodeOfSelection) {
         if(treeNodeOfSelection != null && treeNodeOfSelection.getValue() instanceof Sequence){
             AlignmentEditorInput input = new AlignmentEditorInput(((Sequence)treeNodeOfSelection.getValue()).getUuid());  //TODO Should there always be a new instance created here? What if the specified CDM node is already opened in an AlignmentEditor? => Possible create Singleton that keeps instances by sequence objects in a map.
             try {
@@ -42,6 +39,5 @@ public class EditSequenceHandler extends AbstractHandler {
                 logger.error(Messages.EditSequenceHandler_COULD_NOT_OPEN, e);
             }
         }
-        return null;
     }
 }