import org.eclipse.jface.viewers.TreeNode;
import eu.etaxonomy.cdm.model.molecular.Sequence;
+import eu.etaxonomy.cdm.model.molecular.SingleRead;
import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen;
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
*/
public class SpecimenPropertyTester extends PropertyTester {
private static final String SEQUENCE = "isSequence"; //$NON-NLS-1$
+ private static final String SINGLE_READ = "isSingleRead"; //$NON-NLS-1$
private static final String IS_SPECIMEN_OR_OBSERVATION_BASE = "isSpecimenOrObservationBase"; //$NON-NLS-1$
private static final String IS_ADD_DERIVATE_ALLOWED = "isAddDerivateAllowed"; //$NON-NLS-1$
private static final String IS_ADD_MEDIA_ALLOWED = "isAddMediaAllowed"; //$NON-NLS-1$
if (SEQUENCE.equals(property)) {
return isSequence(treeNodeOfSelection.getValue());
}
+ else if (SINGLE_READ.equals(property)) {
+ return isSingleRead(treeNodeOfSelection.getValue());
+ }
else if (IS_SPECIMEN_OR_OBSERVATION_BASE.equals(property)) {
return isSpecimenOrObservationBase(treeNodeOfSelection.getValue());
}
&& !(object instanceof MediaSpecimen);
}
+ private boolean isSingleRead(Object object) {
+ return (object instanceof SingleRead);
+ }
+
private boolean isSequence(Object object) {
return (object instanceof Sequence);
}
<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"/>
+ <elements xsi:type="commands:Command" xmi:id="_IXQocH22EeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.exportSequenceToFile" commandName="%command.label.EXPORT_SEQUENCE_TO_FILE"/>
+ <elements xsi:type="commands:Command" xmi:id="_m9gZAH22EeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.showPherogram" commandName="%command.name.SHOW_PHEROGRAM"/>
</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"/>
+ <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"/>
+ <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"/>
</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>
+ <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">
+ <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_ZLzjsH22EeeVL5aZ55YsWA" coreExpressionId="isSequence"/>
+ </elements>
+ <elements xsi:type="menu:HandledMenuItem" xmi:id="_xftzgH22EeeVL5aZ55YsWA" elementId="eu.etaxonomy.taxeditor.molecular.handledmenuitem.commandnameshow_pherogram" label="%command.name.SHOW_PHEROGRAM" command="_m9gZAH22EeeVL5aZ55YsWA">
+ <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_0tfXEH22EeeVL5aZ55YsWA" coreExpressionId="isSingleRead"/>
+ </elements>
</fragments>
</fragment:ModelFragments>
</extension>
<extension
point="org.eclipse.ui.commands">
- <command
- defaultHandler="eu.etaxonomy.taxeditor.molecular.handler.ShowPherogramHandler"
- id="eu.etaxonomy.taxeditor.molecular.showPherogram"
- name="%command.name.SHOW_PHEROGRAM">
- </command>
<command
id="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.cutPherogramLeft"
name="%command.name.CUT_PHEROGRAM_LEFT">
id="eu.etaxonomy.taxeditor.molecular.AlignmentEditor.toggleLeftRightInsertion"
name="%command.name.TOGGLE_LEFT_RIGHT_INSERTION">
</command>
- <command
- defaultHandler="eu.etaxonomy.taxeditor.molecular.handler.ExportSequenceToFileHandler"
- id="eu.etaxonomy.taxeditor.molecular.exportSequenceToFile"
- name="%command.name.EXPORT_SEQUENCE_TO_FILE">
- </command>
</extension>
<extension
point="org.eclipse.ui.menus">
</visibleWhen>
</menu>
</menuContribution>
- <menuContribution
- locationURI="popup:eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView?before=eu.etaxonomy.taxeditor.editor.derivative.reuseSingleReadMenuItem">
- <separator
- name="eu.etaxonomy.taxeditor.molecular.separator5"
- visible="true">
- </separator>
- <command
- commandId="eu.etaxonomy.taxeditor.molecular.exportSequenceToFile"
- label="%command.label.EXPORT_SEQUENCE_TO_FILE"
- style="push">
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isSequence">
- </reference>
- </visibleWhen>
- </command>
- <command
- commandId="eu.etaxonomy.taxeditor.molecular.showPherogram"
- label="%command.label.SHOW_PHEROGRAM"
- style="push">
- <visibleWhen
- checkEnabled="true">
- <reference
- definitionId="isSingleRead">
- </reference>
- </visibleWhen>
- </command>
- </menuContribution>
</extension>
<extension
point="org.eclipse.ui.handlers">
package eu.etaxonomy.taxeditor.molecular.handler;\r
\r
\r
-import info.bioinfweb.jphyloio.JPhyloIOEventWriter;\r
-import info.bioinfweb.jphyloio.ReadWriteParameterMap;\r
-import info.bioinfweb.jphyloio.ReadWriteParameterNames;\r
-import info.bioinfweb.jphyloio.dataadapters.implementations.ListBasedDocumentDataAdapter;\r
-import info.bioinfweb.jphyloio.factory.JPhyloIOReaderWriterFactory;\r
-import info.bioinfweb.jphyloio.objecttranslation.ObjectTranslatorFactory;\r
-\r
import java.io.File;\r
import java.io.IOException;\r
\r
-import org.eclipse.core.commands.AbstractHandler;\r
-import org.eclipse.core.commands.ExecutionEvent;\r
-import org.eclipse.core.commands.ExecutionException;\r
+import javax.inject.Named;\r
+\r
import org.eclipse.core.runtime.IStatus;\r
-import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.e4.core.di.annotations.Execute;\r
+import org.eclipse.e4.core.di.annotations.Optional;\r
+import org.eclipse.e4.ui.services.IServiceConstants;\r
import org.eclipse.jface.viewers.TreeNode;\r
import org.eclipse.jface.wizard.WizardDialog;\r
-import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.eclipse.swt.widgets.Shell;\r
\r
import eu.etaxonomy.cdm.model.molecular.Sequence;\r
-import eu.etaxonomy.taxeditor.editor.EditorUtil;\r
import eu.etaxonomy.taxeditor.model.MessagingUtils;\r
import eu.etaxonomy.taxeditor.molecular.TaxeditorMolecularPlugin;\r
import eu.etaxonomy.taxeditor.molecular.io.CDMPherogramAlignmentObjectTranslator;\r
import eu.etaxonomy.taxeditor.molecular.io.wizard.ExportSingleReadAlignmentWizard;\r
import eu.etaxonomy.taxeditor.molecular.l10n.Messages;\r
import eu.etaxonomy.taxeditor.util.ApplicationUtil;\r
+import info.bioinfweb.jphyloio.JPhyloIOEventWriter;\r
+import info.bioinfweb.jphyloio.ReadWriteParameterMap;\r
+import info.bioinfweb.jphyloio.ReadWriteParameterNames;\r
+import info.bioinfweb.jphyloio.dataadapters.implementations.ListBasedDocumentDataAdapter;\r
+import info.bioinfweb.jphyloio.factory.JPhyloIOReaderWriterFactory;\r
+import info.bioinfweb.jphyloio.objecttranslation.ObjectTranslatorFactory;\r
\r
\r
\r
* @author Ben Stöver\r
* @date 24.04.2016\r
*/\r
-public class ExportSequenceToFileHandler extends AbstractHandler {\r
+public class ExportSequenceToFileHandler {\r
private static final JPhyloIOReaderWriterFactory factory = new JPhyloIOReaderWriterFactory();\r
\r
\r
- @Override\r
- public Object execute(ExecutionEvent event) throws ExecutionException {\r
- ISelection currentSelection = HandlerUtil.getCurrentSelection(event);\r
- TreeNode treeNodeOfSelection = EditorUtil.getTreeNodeOfSelection(currentSelection);\r
+ @Execute\r
+ public Object execute(@Optional@Named(IServiceConstants.ACTIVE_SELECTION)TreeNode treeNodeOfSelection,\r
+ @Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {\r
if (treeNodeOfSelection != null && treeNodeOfSelection.getValue() instanceof Sequence) {\r
Sequence sequence = (Sequence)treeNodeOfSelection.getValue();\r
\r
final ExportSingleReadAlignmentWizard wizard = new ExportSingleReadAlignmentWizard();\r
- final WizardDialog dialog = new WizardDialog(HandlerUtil.getActiveShell(event), wizard);\r
+ final WizardDialog dialog = new WizardDialog(shell, wizard);\r
if (dialog.open() == IStatus.OK) {\r
// Prepare writer parameters:\r
ReadWriteParameterMap parameters = new ReadWriteParameterMap();\r
package eu.etaxonomy.taxeditor.molecular.handler;
-import info.bioinfweb.libralign.pherogram.model.PherogramComponentModel;
-
import java.net.URI;
-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.media.MediaUtils;
import eu.etaxonomy.cdm.model.molecular.SingleRead;
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.molecular.TaxeditorMolecularPlugin;
import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor;
import eu.etaxonomy.taxeditor.molecular.editor.PherogramViewPart;
import eu.etaxonomy.taxeditor.molecular.l10n.Messages;
+import info.bioinfweb.libralign.pherogram.model.PherogramComponentModel;
*
* @author Ben Stöver
*/
-public class ShowPherogramHandler extends AbstractHandler {
+public class ShowPherogramHandler {
public static void showPherogram(PherogramComponentModel model) throws PartInitException {
PherogramViewPart.createView(model);
}
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
- TreeNode treeNodeOfSelection = EditorUtil.getTreeNodeOfSelection(currentSelection);
+ @Execute
+ public Object execute(@Optional@Named(IServiceConstants.ACTIVE_SELECTION)TreeNode treeNodeOfSelection) {
if (treeNodeOfSelection != null && treeNodeOfSelection.getValue() instanceof SingleRead) {
//TODO Can the parent node (containing the cut positions) be extracted from SingleRead?
try {