1 package eu
.etaxonomy
.taxeditor
.molecular
.handler
;
4 import org
.eclipse
.core
.commands
.AbstractHandler
;
5 import org
.eclipse
.core
.commands
.ExecutionEvent
;
6 import org
.eclipse
.core
.commands
.ExecutionException
;
7 import org
.eclipse
.jface
.viewers
.ISelection
;
8 import org
.eclipse
.jface
.viewers
.TreeNode
;
9 import org
.eclipse
.ui
.PartInitException
;
10 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
12 import eu
.etaxonomy
.cdm
.model
.molecular
.Sequence
;
13 import eu
.etaxonomy
.taxeditor
.editor
.EditorUtil
;
14 import eu
.etaxonomy
.taxeditor
.molecular
.TaxeditorMolecularPlugin
;
15 import eu
.etaxonomy
.taxeditor
.molecular
.editor
.AlignmentEditor
;
16 import eu
.etaxonomy
.taxeditor
.molecular
.editor
.AlignmentEditorInput
;
21 * Opens the alignment editor from the CDM tree.
23 * @author Ben Stöver
26 public class EditSequenceHandler
extends AbstractHandler
{
27 private org
.apache
.log4j
.Logger logger
= org
.apache
.log4j
.Logger
.getLogger(EditSequenceHandler
.class);
31 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
32 ISelection currentSelection
= HandlerUtil
.getCurrentSelection(event
);
33 TreeNode treeNodeOfSelection
= EditorUtil
.getTreeNodeOfSelection(currentSelection
);
34 if(treeNodeOfSelection
!= null && treeNodeOfSelection
.getValue() instanceof Sequence
){
35 AlignmentEditorInput input
= new AlignmentEditorInput(((Sequence
)treeNodeOfSelection
.getValue()).getUuid()); //TODO Should there always be a new instance created here? What if the specified CDM node is already opened in an AlignmentEditor? => Possible create Singleton that keeps instances by sequence objects in a map.
37 TaxeditorMolecularPlugin
.getDefault().getWorkbench()
38 .getActiveWorkbenchWindow().getActivePage().openEditor(input
, AlignmentEditor
.ID
);
40 catch (PartInitException e
) {
41 logger
.error("Could not open AlignmentEditor", e
);