1 package eu
.etaxonomy
.taxeditor
.editor
.handler
;
4 import info
.bioinfweb
.libralign
.pherogram
.model
.PherogramComponentModel
;
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
;
12 import org
.eclipse
.jface
.viewers
.TreeNode
;
13 import org
.eclipse
.ui
.PartInitException
;
14 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
16 import eu
.etaxonomy
.cdm
.model
.media
.MediaUtils
;
17 import eu
.etaxonomy
.cdm
.model
.molecular
.SingleRead
;
18 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
19 import eu
.etaxonomy
.taxeditor
.editor
.molecular
.AlignmentEditor
;
20 import eu
.etaxonomy
.taxeditor
.editor
.molecular
.PherogramViewPart
;
21 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
26 * Displays an undistorted pherogram with {@link PherogramViewPart}.
31 public class ShowPherogramHandler
extends AbstractHandler
{
32 public static void showPherogram(PherogramComponentModel model
) throws PartInitException
{
33 PherogramViewPart
.createView(model
);
38 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
39 ISelection currentSelection
= HandlerUtil
.getCurrentSelection(event
);
40 TreeNode treeNodeOfSelection
= EditorUtil
.getTreeNodeOfSelection(currentSelection
);
41 if (treeNodeOfSelection
!= null && treeNodeOfSelection
.getValue() instanceof SingleRead
) {
42 //TODO Can the parent node (containing the cut positions) be extracted from SingleRead?
44 SingleRead singleRead
= (SingleRead
)treeNodeOfSelection
.getValue();
46 if (singleRead
.getPherogram() != null) { // Pherogram objects without URI are possible.
47 uri
= MediaUtils
.getFirstMediaRepresentationPart(singleRead
.getPherogram()).getUri();
51 MessagingUtils
.messageDialog("No pherogram available", this,
52 "The selected read does not have an associated pherogram.");
55 showPherogram(new PherogramComponentModel(AlignmentEditor
.readPherogram(uri
)));
59 MessagingUtils
.errorDialog("Error", null, e
.getLocalizedMessage(), "eu.etaxonomy.taxeditor.editor",