Project

General

Profile

« Previous | Next » 

Revision 38b45948

Added by Patrick Plitzner almost 7 years ago

ref #6566 Migrate "Link with taxon" context menu items

View differences:

eu.etaxonomy.taxeditor.editor/fragment.e4xmi
13 13
      <handlers xmi:id="_3RPaQDorEeecLdI14WMq7w" elementId="eu.etaxonomy.taxeditor.editor.view.derivate.handler.AddExistingMediaHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.derivate.handler.AddExistingMediaHandler" command="_-haZEDonEeecLdI14WMq7w"/>
14 14
      <handlers xmi:id="_OOIwoDooEeecLdI14WMq7w" elementId="eu.etaxonomy.taxeditor.editor.view.derivate.handler.AddConsensusSequenceHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.derivate.handler.AddConsensusSequenceHandler" command="_IdPwEDooEeecLdI14WMq7w"/>
15 15
      <handlers xmi:id="_Vf1coDooEeecLdI14WMq7w" elementId="eu.etaxonomy.taxeditor.editor.view.derivate.handler.AddSingleReadHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.derivate.handler.AddSingleReadHandler" command="_LTuN8DooEeecLdI14WMq7w"/>
16
      <handlers xmi:id="_Y1cLkDueEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.view.derivate.handler.ToggleLinkWithTaxonSelectionHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.view.derivate.handler.ToggleLinkWithTaxonSelectionHandler" command="_UwK_UDueEeeOtqC_3qh40A"/>
16 17
      <menus xsi:type="menu:PopupMenu" xmi:id="_CYXZ0DQEEeeTNOFVGI4q2w" elementId="eu.etaxonomy.taxeditor.editor.popupmenu.specimeneditor">
17 18
        <children xsi:type="menu:Menu" xmi:id="_cdjzEDmAEeeOos_QXKSXcA" elementId="eu.etaxonomy.taxeditor.editor.menu.add" label="Add...">
18 19
          <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_ASKmMDpCEeecM-jyCkToYw" coreExpressionId="isAddDerivateAllowed"/>
......
28 29
          </children>
29 30
          <children xsi:type="menu:HandledMenuItem" xmi:id="_Z-LKEDmBEeeOos_QXKSXcA" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.singleread" label="Single Read" command="_LTuN8DooEeecLdI14WMq7w"/>
30 31
        </children>
32
        <children xsi:type="menu:MenuSeparator" xmi:id="_O4ujcDuhEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.1"/>
31 33
        <children xsi:type="menu:HandledMenuItem" xmi:id="_um1oYDVpEee_b7RlBzTDRw" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.create_field_unit_for_taxon" label="Create Field Unit For ..." command="_BjF3ADVqEee_b7RlBzTDRw"/>
32 34
        <children xsi:type="menu:HandledMenuItem" xmi:id="_5GMRcDWQEeeNfoZ3nN0K8Q" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.createfieldunit" label="Create Field Unit" command="_BjF3ADVqEee_b7RlBzTDRw"/>
35
        <children xsi:type="menu:MenuSeparator" xmi:id="_QoiUMDuhEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.2"/>
36
        <children xsi:type="menu:HandledMenuItem" xmi:id="_eElJ8DueEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.commandlabellink_with_taxon_selection" label="%command.label.LINK_WITH_TAXON_SELECTION" command="_UwK_UDueEeeOtqC_3qh40A"/>
33 37
      </menus>
34 38
    </elements>
35 39
  </fragments>
......
48 52
    <elements xsi:type="commands:Command" xmi:id="_pKdiQDoqEeecLdI14WMq7w" elementId="eu.etaxonomy.taxeditor.editor.command.add_derivate.add_media_specimen" commandName="Add Media Specimen"/>
49 53
    <elements xsi:type="commands:Command" xmi:id="_IdPwEDooEeecLdI14WMq7w" elementId="eu.etaxonomy.taxeditor.editor.command.add_derivate.add_consensus_sequence" commandName="Add Consensus Sequence"/>
50 54
    <elements xsi:type="commands:Command" xmi:id="_LTuN8DooEeecLdI14WMq7w" elementId="eu.etaxonomy.taxeditor.editor.command.add_derivate.add_single_read" commandName="Add Single Read"/>
55
    <elements xsi:type="commands:Command" xmi:id="_UwK_UDueEeeOtqC_3qh40A" elementId="eu.etaxonomy.taxeditor.editor.derivative.toggleLinkWithTaxonSelection" commandName="%command.label.LINK_WITH_TAXON_SELECTION"/>
51 56
  </fragments>
52 57
</fragment:ModelFragments>
eu.etaxonomy.taxeditor.editor/plugin.xml
800 800
               class="eu.etaxonomy.taxeditor.view.CdmViewerContextMenu"
801 801
               id="eu.etaxonomy.taxeditor.editor.derivativeEditor.CdmViewerContextMenu">
802 802
         </dynamic>
803
         <separator
804
               name="eu.etaxonomy.taxeditor.editor.separator1"
805
               visible="true">
806
         </separator>
807
         <command
808
               commandId="eu.etaxonomy.taxeditor.editor.derivative.toggleLinkWithTaxonSelection"
809
               label="%command.label.LINK_WITH_TAXON_SELECTION"
810
               style="push">
811
            <visibleWhen
812
                  checkEnabled="true">
813
               <not>
814
                  <reference
815
                        definitionId="isDerivativeEditorLinkedToTaxonSelection">
816
                  </reference>
817
               </not>
818
            </visibleWhen>
819
         </command>
820
         <command
821
               commandId="eu.etaxonomy.taxeditor.editor.derivative.toggleLinkWithTaxonSelection"
822
               label="%command.label.UNLINK_FROM_TAXON_SELECTION"
823
               style="push">
824
            <visibleWhen
825
                  checkEnabled="true">
826
               <reference
827
                     definitionId="isDerivativeEditorLinkedToTaxonSelection">
828
               </reference>
829
            </visibleWhen>
830
         </command>
831
         <separator
832
               name="eu.etaxonomy.taxeditor.editor.separator3"
833
               visible="true">
834
         </separator>
835 803
         <command
836 804
               commandId="eu.etaxonomy.taxeditor.editor.derivative.reuseSingleRead"
837 805
               id="eu.etaxonomy.taxeditor.editor.derivative.reuseSingleReadMenuItem"
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/handler/ToggleLinkWithTaxonSelectionHandler.java
1 1
package eu.etaxonomy.taxeditor.editor.view.derivate.handler;
2 2

  
3
import org.eclipse.core.commands.AbstractHandler;
4
import org.eclipse.core.commands.ExecutionEvent;
5
import org.eclipse.core.commands.ExecutionException;
6
import org.eclipse.ui.handlers.HandlerUtil;
3
import javax.inject.Named;
4

  
5
import org.eclipse.e4.core.di.annotations.CanExecute;
6
import org.eclipse.e4.core.di.annotations.Execute;
7
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
8
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
9
import org.eclipse.e4.ui.services.IServiceConstants;
7 10

  
8 11
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
9 12

  
10
public class ToggleLinkWithTaxonSelectionHandler extends AbstractHandler {
13
public class ToggleLinkWithTaxonSelectionHandler {
11 14

  
12
    @Override
13
    public Object execute(ExecutionEvent event) throws ExecutionException {
14
        DerivateView derivateView = (DerivateView) HandlerUtil.getActiveEditor(event);
15
    @Execute
16
    public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part){
17
        DerivateView derivateView = (DerivateView) part.getObject();
15 18
        derivateView.toggleListenToSelectionChange();
16
        return null;
17 19
    }
18 20

  
21
    @CanExecute
22
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_PART) MPart part, MHandledMenuItem item){
23
        DerivateView derivateView = (DerivateView) part.getObject();
24
        if(derivateView.isListenToSelectionChange()){
25
            item.setLabel("Unlink from taxon selection");
26
        }
27
        else{
28
            item.setLabel("Link with taxon selection");
29
        }
30
        return true;
31
    }
19 32
}

Also available in: Unified diff