Project

General

Profile

Download (1.74 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.taxeditor.molecular.handler;
2

    
3

    
4
import javax.inject.Named;
5

    
6
import org.eclipse.e4.core.di.annotations.Execute;
7
import org.eclipse.e4.core.di.annotations.Optional;
8
import org.eclipse.e4.ui.services.IServiceConstants;
9
import org.eclipse.jface.viewers.TreeNode;
10
import org.eclipse.ui.PartInitException;
11

    
12
import eu.etaxonomy.cdm.model.molecular.Sequence;
13
import eu.etaxonomy.taxeditor.molecular.TaxeditorMolecularPlugin;
14
import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor;
15
import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditorInput;
16
import eu.etaxonomy.taxeditor.molecular.l10n.Messages;
17

    
18

    
19

    
20
/**
21
 * Opens the alignment editor from the CDM tree.
22
 *
23
 * @author Ben Stöver
24
 * @author pplitzner
25
 */
26
public class EditSequenceHandler {
27
    private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(EditSequenceHandler.class);
28

    
29

    
30
    @Execute
31
    public void execute(@Optional@Named(IServiceConstants.ACTIVE_SELECTION)TreeNode treeNodeOfSelection) {
32
        if(treeNodeOfSelection != null && treeNodeOfSelection.getValue() instanceof Sequence){
33
            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.
34
            try {
35
                TaxeditorMolecularPlugin.getDefault().getWorkbench()
36
                .getActiveWorkbenchWindow().getActivePage().openEditor(input, AlignmentEditor.ID);
37
            }
38
            catch (PartInitException e) {
39
                logger.error(Messages.EditSequenceHandler_COULD_NOT_OPEN, e);
40
            }
41
        }
42
    }
43
}
(11-11/22)