Project

General

Profile

« Previous | Next » 

Revision 61650dda

Added by Patrick Plitzner over 6 years ago

ref #6902 migrate remaining context menu items for molecular module

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/SpecimenPropertyTester.java
6 6
import org.eclipse.jface.viewers.TreeNode;
7 7

  
8 8
import eu.etaxonomy.cdm.model.molecular.Sequence;
9
import eu.etaxonomy.cdm.model.molecular.SingleRead;
9 10
import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
10 11
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
11 12
import eu.etaxonomy.taxeditor.editor.EditorUtil;
......
20 21
 */
21 22
public class SpecimenPropertyTester extends PropertyTester {
22 23
    private static final String SEQUENCE = "isSequence"; //$NON-NLS-1$
24
    private static final String SINGLE_READ = "isSingleRead"; //$NON-NLS-1$
23 25
    private static final String IS_SPECIMEN_OR_OBSERVATION_BASE = "isSpecimenOrObservationBase"; //$NON-NLS-1$
24 26
    private static final String IS_ADD_DERIVATE_ALLOWED = "isAddDerivateAllowed"; //$NON-NLS-1$
25 27
    private static final String IS_ADD_MEDIA_ALLOWED = "isAddMediaAllowed"; //$NON-NLS-1$
......
37 39
                if (SEQUENCE.equals(property)) {
38 40
                    return isSequence(treeNodeOfSelection.getValue());
39 41
                }
42
                else if (SINGLE_READ.equals(property)) {
43
                    return isSingleRead(treeNodeOfSelection.getValue());
44
                }
40 45
                else if (IS_SPECIMEN_OR_OBSERVATION_BASE.equals(property)) {
41 46
                    return isSpecimenOrObservationBase(treeNodeOfSelection.getValue());
42 47
                }
......
66 71
                && !(object instanceof MediaSpecimen);
67 72
    }
68 73

  
74
    private boolean isSingleRead(Object object) {
75
        return (object instanceof SingleRead);
76
    }
77

  
69 78
    private boolean isSequence(Object object) {
70 79
        return (object instanceof Sequence);
71 80
    }
eu.etaxonomy.taxeditor.molecular/fragment.e4xmi
2 2
<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">
3 3
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="__mwtMDVpEee_b7RlBzTDRw" featurename="commands" parentElementId="xpath:/">
4 4
    <elements xsi:type="commands:Command" xmi:id="_JZdQ0H2sEeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.editSequence" commandName="%command.EDIT_SEQUENCE"/>
5
    <elements xsi:type="commands:Command" xmi:id="_IXQocH22EeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.exportSequenceToFile" commandName="%command.label.EXPORT_SEQUENCE_TO_FILE"/>
6
    <elements xsi:type="commands:Command" xmi:id="_m9gZAH22EeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.showPherogram" commandName="%command.name.SHOW_PHEROGRAM"/>
5 7
  </fragments>
6 8
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_RCmzgH2sEeeVL5aZ55YsWA" featurename="handlers" parentElementId="eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView">
7 9
    <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"/>
10
    <elements xsi:type="commands:Handler" xmi:id="_QwuNwH22EeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.handler.ExportSequenceToFileHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.handler.ExportSequenceToFileHandler" command="_IXQocH22EeeVL5aZ55YsWA"/>
11
    <elements xsi:type="commands:Handler" xmi:id="_reIrkH22EeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.handler.ShowPherogramHandler" contributionURI="bundleclass://eu.etaxonomy.taxeditor.molecular/eu.etaxonomy.taxeditor.molecular.handler.ShowPherogramHandler" command="_m9gZAH22EeeVL5aZ55YsWA"/>
8 12
  </fragments>
9 13
  <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">
10 14
    <elements xsi:type="menu:HandledMenuItem" xmi:id="_txARoH2sEeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.handledmenuitem.commandlabeledit_sequence" label="%command.label.EDIT_SEQUENCE" command="_JZdQ0H2sEeeVL5aZ55YsWA">
11 15
      <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_wpbQQH2sEeeVL5aZ55YsWA" coreExpressionId="isSequence"/>
12 16
    </elements>
17
    <elements xsi:type="menu:HandledMenuItem" xmi:id="_VRC-UH22EeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.handledmenuitem.commandlabelexport_sequence_to_file" label="%command.label.EXPORT_SEQUENCE_TO_FILE" command="_IXQocH22EeeVL5aZ55YsWA">
18
      <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_ZLzjsH22EeeVL5aZ55YsWA" coreExpressionId="isSequence"/>
19
    </elements>
20
    <elements xsi:type="menu:HandledMenuItem" xmi:id="_xftzgH22EeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.handledmenuitem.commandnameshow_pherogram" label="%command.name.SHOW_PHEROGRAM" command="_m9gZAH22EeeVL5aZ55YsWA">
21
      <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_0tfXEH22EeeVL5aZ55YsWA" coreExpressionId="isSingleRead"/>
22
    </elements>
13 23
  </fragments>
14 24
</fragment:ModelFragments>
eu.etaxonomy.taxeditor.molecular/plugin.xml
22 22
      </extension>
23 23
      <extension
24 24
            point="org.eclipse.ui.commands">
25
         <command
26
               defaultHandler="eu.etaxonomy.taxeditor.molecular.handler.ShowPherogramHandler"
27
               id="eu.etaxonomy.taxeditor.molecular.showPherogram"
28
               name="%command.name.SHOW_PHEROGRAM">
29
         </command>
30 25
         <command
31 26
               id="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.cutPherogramLeft"
32 27
               name="%command.name.CUT_PHEROGRAM_LEFT">
......
71 66
               id="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.toggleLeftRightInsertion"
72 67
               name="%command.name.TOGGLE_LEFT_RIGHT_INSERTION">
73 68
         </command>
74
         <command
75
               defaultHandler="eu.etaxonomy.taxeditor.molecular.handler.ExportSequenceToFileHandler"
76
               id="eu.etaxonomy.taxeditor.molecular.exportSequenceToFile"
77
               name="%command.name.EXPORT_SEQUENCE_TO_FILE">
78
         </command>
79 69
      </extension>
80 70
      <extension
81 71
            point="org.eclipse.ui.menus">
......
180 170
               </visibleWhen>
181 171
            </menu>
182 172
         </menuContribution>
183
         <menuContribution
184
               locationURI="popup:eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView?before=eu.etaxonomy.taxeditor.editor.derivative.reuseSingleReadMenuItem">
185
            <separator
186
                  name="eu.etaxonomy.taxeditor.molecular.separator5"
187
                  visible="true">
188
            </separator>
189
            <command
190
                  commandId="eu.etaxonomy.taxeditor.molecular.exportSequenceToFile"
191
                  label="%command.label.EXPORT_SEQUENCE_TO_FILE"
192
                  style="push">
193
               <visibleWhen
194
                     checkEnabled="true">
195
                  <reference
196
                        definitionId="isSequence">
197
                  </reference>
198
               </visibleWhen>
199
            </command>
200
            <command
201
                  commandId="eu.etaxonomy.taxeditor.molecular.showPherogram"
202
                  label="%command.label.SHOW_PHEROGRAM"
203
                  style="push">
204
               <visibleWhen
205
                     checkEnabled="true">
206
                  <reference
207
                        definitionId="isSingleRead">
208
                  </reference>
209
               </visibleWhen>
210
            </command>
211
         </menuContribution>
212 173
      </extension>
213 174
      <extension
214 175
            point="org.eclipse.ui.handlers">
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/ExportSequenceToFileHandler.java
10 10
package eu.etaxonomy.taxeditor.molecular.handler;
11 11

  
12 12

  
13
import info.bioinfweb.jphyloio.JPhyloIOEventWriter;
14
import info.bioinfweb.jphyloio.ReadWriteParameterMap;
15
import info.bioinfweb.jphyloio.ReadWriteParameterNames;
16
import info.bioinfweb.jphyloio.dataadapters.implementations.ListBasedDocumentDataAdapter;
17
import info.bioinfweb.jphyloio.factory.JPhyloIOReaderWriterFactory;
18
import info.bioinfweb.jphyloio.objecttranslation.ObjectTranslatorFactory;
19

  
20 13
import java.io.File;
21 14
import java.io.IOException;
22 15

  
23
import org.eclipse.core.commands.AbstractHandler;
24
import org.eclipse.core.commands.ExecutionEvent;
25
import org.eclipse.core.commands.ExecutionException;
16
import javax.inject.Named;
17

  
26 18
import org.eclipse.core.runtime.IStatus;
27
import org.eclipse.jface.viewers.ISelection;
19
import org.eclipse.e4.core.di.annotations.Execute;
20
import org.eclipse.e4.core.di.annotations.Optional;
21
import org.eclipse.e4.ui.services.IServiceConstants;
28 22
import org.eclipse.jface.viewers.TreeNode;
29 23
import org.eclipse.jface.wizard.WizardDialog;
30
import org.eclipse.ui.handlers.HandlerUtil;
24
import org.eclipse.swt.widgets.Shell;
31 25

  
32 26
import eu.etaxonomy.cdm.model.molecular.Sequence;
33
import eu.etaxonomy.taxeditor.editor.EditorUtil;
34 27
import eu.etaxonomy.taxeditor.model.MessagingUtils;
35 28
import eu.etaxonomy.taxeditor.molecular.TaxeditorMolecularPlugin;
36 29
import eu.etaxonomy.taxeditor.molecular.io.CDMPherogramAlignmentObjectTranslator;
......
39 32
import eu.etaxonomy.taxeditor.molecular.io.wizard.ExportSingleReadAlignmentWizard;
40 33
import eu.etaxonomy.taxeditor.molecular.l10n.Messages;
41 34
import eu.etaxonomy.taxeditor.util.ApplicationUtil;
35
import info.bioinfweb.jphyloio.JPhyloIOEventWriter;
36
import info.bioinfweb.jphyloio.ReadWriteParameterMap;
37
import info.bioinfweb.jphyloio.ReadWriteParameterNames;
38
import info.bioinfweb.jphyloio.dataadapters.implementations.ListBasedDocumentDataAdapter;
39
import info.bioinfweb.jphyloio.factory.JPhyloIOReaderWriterFactory;
40
import info.bioinfweb.jphyloio.objecttranslation.ObjectTranslatorFactory;
42 41

  
43 42

  
44 43

  
......
49 48
 * @author Ben Stöver
50 49
 * @date 24.04.2016
51 50
 */
52
public class ExportSequenceToFileHandler extends AbstractHandler {
51
public class ExportSequenceToFileHandler {
53 52
    private static final JPhyloIOReaderWriterFactory factory = new JPhyloIOReaderWriterFactory();
54 53

  
55 54

  
56
    @Override
57
    public Object execute(ExecutionEvent event) throws ExecutionException {
58
        ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
59
        TreeNode treeNodeOfSelection = EditorUtil.getTreeNodeOfSelection(currentSelection);
55
    @Execute
56
    public Object execute(@Optional@Named(IServiceConstants.ACTIVE_SELECTION)TreeNode treeNodeOfSelection,
57
            @Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {
60 58
        if (treeNodeOfSelection != null && treeNodeOfSelection.getValue() instanceof Sequence) {
61 59
            Sequence sequence = (Sequence)treeNodeOfSelection.getValue();
62 60

  
63 61
            final ExportSingleReadAlignmentWizard wizard = new ExportSingleReadAlignmentWizard();
64
            final WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);
62
            final WizardDialog dialog = new WizardDialog(shell, wizard);
65 63
            if (dialog.open() == IStatus.OK) {
66 64
                // Prepare writer parameters:
67 65
                ReadWriteParameterMap parameters = new ReadWriteParameterMap();
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/handler/ShowPherogramHandler.java
1 1
package eu.etaxonomy.taxeditor.molecular.handler;
2 2

  
3 3

  
4
import info.bioinfweb.libralign.pherogram.model.PherogramComponentModel;
5

  
6 4
import java.net.URI;
7 5

  
8
import org.eclipse.core.commands.AbstractHandler;
9
import org.eclipse.core.commands.ExecutionEvent;
10
import org.eclipse.core.commands.ExecutionException;
11
import org.eclipse.jface.viewers.ISelection;
6
import javax.inject.Named;
7

  
8
import org.eclipse.e4.core.di.annotations.Execute;
9
import org.eclipse.e4.core.di.annotations.Optional;
10
import org.eclipse.e4.ui.services.IServiceConstants;
12 11
import org.eclipse.jface.viewers.TreeNode;
13 12
import org.eclipse.ui.PartInitException;
14
import org.eclipse.ui.handlers.HandlerUtil;
15 13

  
16 14
import eu.etaxonomy.cdm.model.media.MediaUtils;
17 15
import eu.etaxonomy.cdm.model.molecular.SingleRead;
18
import eu.etaxonomy.taxeditor.editor.EditorUtil;
19 16
import eu.etaxonomy.taxeditor.model.MessagingUtils;
20 17
import eu.etaxonomy.taxeditor.molecular.TaxeditorMolecularPlugin;
21 18
import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor;
22 19
import eu.etaxonomy.taxeditor.molecular.editor.PherogramViewPart;
23 20
import eu.etaxonomy.taxeditor.molecular.l10n.Messages;
21
import info.bioinfweb.libralign.pherogram.model.PherogramComponentModel;
24 22

  
25 23

  
26 24

  
......
29 27
 *
30 28
 * @author Ben Stöver
31 29
 */
32
public class ShowPherogramHandler extends AbstractHandler {
30
public class ShowPherogramHandler {
33 31
	public static void showPherogram(PherogramComponentModel model) throws PartInitException {
34 32
		PherogramViewPart.createView(model);
35 33
	}
36 34

  
37 35

  
38
	@Override
39
	public Object execute(ExecutionEvent event) throws ExecutionException {
40
		ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
41
		TreeNode treeNodeOfSelection = EditorUtil.getTreeNodeOfSelection(currentSelection);
36
	@Execute
37
	public Object execute(@Optional@Named(IServiceConstants.ACTIVE_SELECTION)TreeNode treeNodeOfSelection) {
42 38
		if (treeNodeOfSelection != null && treeNodeOfSelection.getValue() instanceof SingleRead) {
43 39
		    //TODO Can the parent node (containing the cut positions) be extracted from SingleRead?
44 40
			try {

Also available in: Unified diff