2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.molecular
.handler
;
14 import org
.eclipse
.core
.commands
.ExecutionEvent
;
15 import org
.eclipse
.core
.commands
.ExecutionException
;
16 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
17 import org
.eclipse
.ui
.IEditorPart
;
18 import org
.eclipse
.ui
.commands
.IElementUpdater
;
19 import org
.eclipse
.ui
.menus
.UIElement
;
21 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
22 import eu
.etaxonomy
.taxeditor
.molecular
.editor
.AlignmentEditor
;
27 * Switches an {@link AlignmentEditor} between insertion in the base sequence to
28 * the left or to the right.
33 public class ToggleLeftRightInsertionHandler
extends AbstractAlignmentEditorHandler
implements IElementUpdater
{
34 public static final String COMMAND_ID
= "eu.etaxonomy.taxeditor.molecular.AlignmentEditor.toggleLeftRightInsertion";
37 private final ImageDescriptor INSERT_LEFT_DESCRIPTOR
=
38 HandlerTools
.createImageDescriptor("pherogram-insert-left-16x16.png");
39 private final ImageDescriptor INSERT_RIGHT_DESCRIPTOR
=
40 HandlerTools
.createImageDescriptor("pherogram-insert-right-16x16.png");
41 private final ImageDescriptor INSERT_LEFT_DISABLED_DESCRIPTOR
=
42 HandlerTools
.createImageDescriptor("pherogram-insert-left-disabled-16x16.png");
43 private final ImageDescriptor INSERT_RIGHT_DISABLED_DESCRIPTOR
=
44 HandlerTools
.createImageDescriptor("pherogram-insert-right-disabled-16x16.png");
48 public void doExecute(ExecutionEvent event
, AlignmentEditor editor
) throws ExecutionException
{
49 editor
.toggleLeftRightInsertionInPherogram();
54 public void updateElement(UIElement element
, @SuppressWarnings("rawtypes") Map parameters
) {
55 IEditorPart activeEditor
= AbstractUtility
.getActiveEditor();
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("Left");
62 element
.setTooltip("Switch to insert pherogram distorsions right of future edits.");
65 element
.setIcon(INSERT_RIGHT_DESCRIPTOR
);
66 element
.setDisabledIcon(INSERT_RIGHT_DISABLED_DESCRIPTOR
);
67 element
.setText("Right");
68 element
.setTooltip("Switch to insert pherogram distorsions left of future edits.");