Project

General

Profile

Download (2 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.CanExecute;
7
import org.eclipse.e4.core.di.annotations.Execute;
8
import org.eclipse.e4.core.di.annotations.Optional;
9
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
10
import org.eclipse.e4.ui.services.IServiceConstants;
11
import org.eclipse.jface.viewers.TreeNode;
12

    
13
import eu.etaxonomy.cdm.model.molecular.Sequence;
14

    
15

    
16

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

    
26

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

    
41
    @CanExecute
42
    public boolean canExecute(@Optional @Named(IServiceConstants.ACTIVE_SELECTION) TreeNode selectedTreeNode, MHandledMenuItem menuItem) {
43
        boolean canExecute = false;
44
        if(selectedTreeNode!=null){
45
            Object value = selectedTreeNode.getValue();
46
            canExecute = value instanceof Sequence;
47
        }
48
        menuItem.setVisible(canExecute);
49
        return canExecute;
50
    }
51
}
(11-11/22)