Project

General

Profile

Download (3.04 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2007 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9

    
10
package eu.etaxonomy.taxeditor.molecular.editor.e4.handler;
11

    
12
import javax.inject.Named;
13

    
14
import org.eclipse.e4.core.di.annotations.Execute;
15
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
16
import org.eclipse.e4.ui.services.IServiceConstants;
17
import org.eclipse.jface.resource.ImageDescriptor;
18

    
19
import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor;
20
import eu.etaxonomy.taxeditor.molecular.editor.e4.AlignmentEditorE4;
21
import eu.etaxonomy.taxeditor.molecular.handler.HandlerTools;
22

    
23

    
24

    
25
/**
26
 * Switches an {@link AlignmentEditor} between insertion in the base sequence to
27
 * the left or to the right.
28
 *
29
 * @author Ben Stöver
30
 * @date 04.12.2014
31
 */
32
public class ToggleLeftRightInsertionHandlerE4 {
33
    public static final String COMMAND_ID = "eu.etaxonomy.taxeditor.molecular.AlignmentEditor.toggleLeftRightInsertion"; //$NON-NLS-1$
34

    
35

    
36
    private final ImageDescriptor INSERT_LEFT_DESCRIPTOR =
37
            HandlerTools.createImageDescriptor("pherogram-insert-left-16x16.png"); //$NON-NLS-1$
38
    private final ImageDescriptor INSERT_RIGHT_DESCRIPTOR =
39
            HandlerTools.createImageDescriptor("pherogram-insert-right-16x16.png"); //$NON-NLS-1$
40
    private final ImageDescriptor INSERT_LEFT_DISABLED_DESCRIPTOR =
41
            HandlerTools.createImageDescriptor("pherogram-insert-left-disabled-16x16.png"); //$NON-NLS-1$
42
    private final ImageDescriptor INSERT_RIGHT_DISABLED_DESCRIPTOR =
43
            HandlerTools.createImageDescriptor("pherogram-insert-right-disabled-16x16.png"); //$NON-NLS-1$
44

    
45

    
46
    @Execute
47
    public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
48
        AlignmentEditorE4 editor = (AlignmentEditorE4) activePart.getObject();
49
        editor.toggleLeftRightInsertionInPherogram();
50
    }
51

    
52

    
53
//    @Override
54
//    public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {
55
//        Object activeEditor = AbstractUtility.getActiveE4Editor();
56
//        if (activeEditor instanceof AlignmentEditor) {
57
//            setBaseEnabled(((AlignmentEditor)activeEditor).isInsertMode());
58
//            if (((AlignmentEditor)activeEditor).isInsertLeftInPherogram()) {
59
//                element.setIcon(INSERT_LEFT_DESCRIPTOR);
60
//                element.setDisabledIcon(INSERT_LEFT_DISABLED_DESCRIPTOR);
61
//                element.setText(Messages.ToggleLeftRightInsertionHandler_LEFT);
62
//                element.setTooltip(Messages.ToggleLeftRightInsertionHandler_SWITCH_RIGHT);
63
//            }
64
//            else {
65
//                element.setIcon(INSERT_RIGHT_DESCRIPTOR);
66
//                element.setDisabledIcon(INSERT_RIGHT_DISABLED_DESCRIPTOR);
67
//                element.setText(Messages.ToggleLeftRightInsertionHandler_RIGHT);
68
//                element.setTooltip(Messages.ToggleLeftRightInsertionHandler_SWITCH_LEFT);
69
//            }
70
//        }
71
//    }
72
}
(14-14/17)