ref #6909 Add "Link with editor" item to context menu
authorPatrick Plitzner <p.plitzner@bgbm.org>
Fri, 20 Oct 2017 06:33:12 +0000 (08:33 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Fri, 20 Oct 2017 06:33:12 +0000 (08:33 +0200)
 - removed icon from navigator toolbar

eu.etaxonomy.taxeditor.navigation/fragment.e4xmi
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/TaxonNavigatorE4.java
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/LinkWithTaxonHandlerE4.java

index 0f9b5620a93bd43050e54af8c9667f59a1a3e673..709244bf9afae2d579b489d036983921745cba60 100644 (file)
@@ -83,6 +83,7 @@
         <children xsi:type="menu:HandledMenuItem" xmi:id="_1JIbQJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.copy" label="%command.label.12" command="_EJ-u0JIyEeeJAdt8ZUxyaw"/>
         <children xsi:type="menu:MenuSeparator" xmi:id="_z0Q6EJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.menuseparator.4"/>
         <children xsi:type="menu:HandledMenuItem" xmi:id="_0FX4MJIwEeeJAdt8ZUxyaw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.refresh" label="%command.label.11" command="_ukhM0JIyEeeJAdt8ZUxyaw"/>
+        <children xsi:type="menu:HandledMenuItem" xmi:id="_7MpwILVfEeeZf_R8QJbACw" elementId="eu.etaxonomy.taxeditor.navigation.handledmenuitem.syncwithtaxon" label="Sync with taxon" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.editor/icons/synced.gif" command="_6iiY8LVbEeeZf_R8QJbACw"/>
       </menus>
     </elements>
     <elements xsi:type="basic:PartDescriptor" xmi:id="_AcycAKOkEee6lJH578buGg" elementId="eu.etaxonomy.taxeditor.navigation.search.e4.SearchResultViewE4" label="%view.name" iconURI="platform:/plugin/eu.etaxonomy.taxeditor.navigation/icons/system-search.png" allowMultiple="true" closeable="true" contributionURI="bundleclass://eu.etaxonomy.taxeditor.navigation/eu.etaxonomy.taxeditor.navigation.search.e4.SearchResultViewE4">
index 05cc7db17d60a2888a04909106f912846b253631..5a967667f8e053c5eecc37db3cba4dd14d8343af 100644 (file)
@@ -25,8 +25,6 @@ import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.inject.Inject;
 
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.common.NotDefinedException;
 import org.eclipse.core.commands.operations.UndoContext;
 import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IProgressMonitor;
@@ -35,13 +33,7 @@ import org.eclipse.e4.core.di.annotations.Optional;
 import org.eclipse.e4.ui.di.Focus;
 import org.eclipse.e4.ui.di.UIEventTopic;
 import org.eclipse.e4.ui.di.UISynchronize;
-import org.eclipse.e4.ui.model.application.commands.MCommand;
-import org.eclipse.e4.ui.model.application.commands.MCommandsFactory;
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
-import org.eclipse.e4.ui.model.application.ui.menu.ItemType;
-import org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem;
-import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
-import org.eclipse.e4.ui.model.application.ui.menu.MToolBar;
 import org.eclipse.e4.ui.services.EMenuService;
 import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
 import org.eclipse.jface.util.LocalSelectionTransfer;
@@ -176,21 +168,21 @@ public class TaxonNavigatorE4 implements
         viewer.addDropSupport(dndOperations, transfers, new TreeNodeDropAdapterE4(this));
 
         //add toolbar
-        MToolBar toolBar = MMenuFactory.INSTANCE.createToolBar();
-        MHandledToolItem linkWithEditor = MMenuFactory.INSTANCE.createHandledToolItem();
-        linkWithEditor.setIconURI("platform:/plugin/eu.etaxonomy.taxeditor.store/icons/synced.gif");
-        Command command = commandService.getCommand("eu.etaxonomy.taxeditor.navigation.command.linkWithTaxon");
-        MCommand mCommand = MCommandsFactory.INSTANCE.createCommand();
-        mCommand.setElementId(command.getId());
-        try {
-            mCommand.setCommandName(command.getName());
-        } catch (NotDefinedException e) {
-            e.printStackTrace();
-        }
-        linkWithEditor.setCommand(mCommand);
-        linkWithEditor.setType(ItemType.CHECK);
-        toolBar.getChildren().add(linkWithEditor);
-        thisPart.setToolbar(toolBar);
+//        MToolBar toolBar = MMenuFactory.INSTANCE.createToolBar();
+//        MHandledToolItem linkWithEditor = MMenuFactory.INSTANCE.createHandledToolItem();
+//        linkWithEditor.setIconURI("platform:/plugin/eu.etaxonomy.taxeditor.store/icons/synced.gif");
+//        Command command = commandService.getCommand("eu.etaxonomy.taxeditor.navigation.command.linkWithTaxon");
+//        MCommand mCommand = MCommandsFactory.INSTANCE.createCommand();
+//        mCommand.setElementId(command.getId());
+//        try {
+//            mCommand.setCommandName(command.getName());
+//        } catch (NotDefinedException e) {
+//            e.printStackTrace();
+//        }
+//        linkWithEditor.setCommand(mCommand);
+//        linkWithEditor.setType(ItemType.CHECK);
+//        toolBar.getChildren().add(linkWithEditor);
+//        thisPart.setToolbar(toolBar);
 
            init();
        }
index 71f40c6eed355c5bf6cd7330cdfb7a22736200d0..340956458257999dc5e291ffcd659541bfa0cc32 100644 (file)
@@ -12,6 +12,7 @@ import javax.inject.Named;
 
 import org.eclipse.e4.core.di.annotations.Execute;
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
 import org.eclipse.e4.ui.services.IServiceConstants;
 
 import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
@@ -25,8 +26,14 @@ import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
 public class LinkWithTaxonHandlerE4 {
 
     @Execute
-    public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
+    public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, MHandledMenuItem menuItem) {
         TaxonNavigatorE4 taxonNavigator = (TaxonNavigatorE4) activePart.getObject();
         taxonNavigator.setLinkWithTaxon(!taxonNavigator.isLinkWithTaxon());
+        if(taxonNavigator.isLinkWithTaxon()){
+            menuItem.setLabel("Do not sync with taxon");
+        }
+        else {
+            menuItem.setLabel("Sync with taxon");
+        }
        }
 }