1 package eu
.etaxonomy
.taxeditor
.molecular
.editor
.e4
.handler
;
4 import eu
.etaxonomy
.cdm
.common
.URI
;
6 import javax
.inject
.Named
;
8 import org
.eclipse
.e4
.core
.di
.annotations
.CanExecute
;
9 import org
.eclipse
.e4
.core
.di
.annotations
.Execute
;
10 import org
.eclipse
.e4
.core
.di
.annotations
.Optional
;
11 import org
.eclipse
.e4
.ui
.model
.application
.ui
.basic
.MPart
;
12 import org
.eclipse
.e4
.ui
.model
.application
.ui
.menu
.MHandledMenuItem
;
13 import org
.eclipse
.e4
.ui
.services
.IServiceConstants
;
14 import org
.eclipse
.e4
.ui
.workbench
.modeling
.EPartService
;
15 import org
.eclipse
.e4
.ui
.workbench
.modeling
.EPartService
.PartState
;
16 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
17 import org
.eclipse
.jface
.viewers
.TreeNode
;
19 import eu
.etaxonomy
.cdm
.model
.media
.MediaUtils
;
20 import eu
.etaxonomy
.cdm
.model
.molecular
.SingleRead
;
21 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
22 import eu
.etaxonomy
.taxeditor
.molecular
.TaxeditorMolecularPlugin
;
23 import eu
.etaxonomy
.taxeditor
.molecular
.editor
.e4
.AlignmentEditorE4
;
24 import eu
.etaxonomy
.taxeditor
.molecular
.editor
.e4
.PherogramPartE4
;
25 import eu
.etaxonomy
.taxeditor
.molecular
.l10n
.Messages
;
26 import info
.bioinfweb
.libralign
.pherogram
.model
.PherogramComponentModel
;
31 * Displays an undistorted pherogram with {@link PherogramPartE4}.
35 public class ShowPherogramHandlerE4
{
38 public void execute(@Optional@Named(IServiceConstants
.ACTIVE_SELECTION
)IStructuredSelection selection
,
39 EPartService partService
) {
40 //TODO Can the parent node (containing the cut positions) be extracted from SingleRead?
42 SingleRead singleRead
= (SingleRead
) ((TreeNode
) selection
.getFirstElement()).getValue();
44 if (singleRead
.getPherogram() != null) { // Pherogram objects without URI are possible.
45 uri
= MediaUtils
.getFirstMediaRepresentationPart(singleRead
.getPherogram()).getUri();
49 MessagingUtils
.messageDialog(Messages
.ShowPherogramHandler_NO_PHEROGRAM
, this,
50 Messages
.ShowPherogramHandler_NO_PHEROGRAM_MESSAGE
);
53 MPart part
= partService
.createPart(eu
.etaxonomy
.taxeditor
.molecular
.AppModelId
.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_MOLECULAR_EDITOR_E4_PHEROGRAMPARTE4
);
54 part
= partService
.showPart(part
, PartState
.ACTIVATE
);
55 PherogramPartE4 pherogramPart
= (PherogramPartE4
) part
.getObject();
56 pherogramPart
.init(new PherogramComponentModel(AlignmentEditorE4
.readPherogram(uri
)));
60 MessagingUtils
.errorDialog(Messages
.ShowPherogramHandler_ERROR
, null, e
.getLocalizedMessage(), TaxeditorMolecularPlugin
.PLUGIN_ID
,
66 public boolean canExecute(@Optional @Named(IServiceConstants
.ACTIVE_SELECTION
) IStructuredSelection selection
, MHandledMenuItem menuItem
) {
67 boolean canExecute
= false;
68 canExecute
= selection
.size()==1
69 && selection
.getFirstElement() instanceof TreeNode
70 && ((TreeNode
) selection
.getFirstElement()).getValue() instanceof SingleRead
;
71 menuItem
.setVisible(canExecute
);