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
;
23 import eu
.etaxonomy
.taxeditor
.molecular
.l10n
.Messages
;
28 * Switches an {@link AlignmentEditor} between insertion in the base sequence to
29 * the left or to the right.
34 public class ToggleLeftRightInsertionHandler
extends AbstractAlignmentEditorHandler
implements IElementUpdater
{
35 public static final String COMMAND_ID
= "eu.etaxonomy.taxeditor.molecular.AlignmentEditor.toggleLeftRightInsertion"; //$NON-NLS-1$
38 private final ImageDescriptor INSERT_LEFT_DESCRIPTOR
=
39 HandlerTools
.createImageDescriptor("pherogram-insert-left-16x16.png"); //$NON-NLS-1$
40 private final ImageDescriptor INSERT_RIGHT_DESCRIPTOR
=
41 HandlerTools
.createImageDescriptor("pherogram-insert-right-16x16.png"); //$NON-NLS-1$
42 private final ImageDescriptor INSERT_LEFT_DISABLED_DESCRIPTOR
=
43 HandlerTools
.createImageDescriptor("pherogram-insert-left-disabled-16x16.png"); //$NON-NLS-1$
44 private final ImageDescriptor INSERT_RIGHT_DISABLED_DESCRIPTOR
=
45 HandlerTools
.createImageDescriptor("pherogram-insert-right-disabled-16x16.png"); //$NON-NLS-1$
49 public void doExecute(ExecutionEvent event
, AlignmentEditor editor
) throws ExecutionException
{
50 editor
.toggleLeftRightInsertionInPherogram();
55 public void updateElement(UIElement element
, @SuppressWarnings("rawtypes") Map parameters
) {
56 IEditorPart activeEditor
= AbstractUtility
.getActiveEditor();
57 if (activeEditor
instanceof AlignmentEditor
) {
58 setBaseEnabled(((AlignmentEditor
)activeEditor
).isInsertMode());
59 if (((AlignmentEditor
)activeEditor
).isInsertLeftInPherogram()) {
60 element
.setIcon(INSERT_LEFT_DESCRIPTOR
);
61 element
.setDisabledIcon(INSERT_LEFT_DISABLED_DESCRIPTOR
);
62 element
.setText(Messages
.ToggleLeftRightInsertionHandler_LEFT
);
63 element
.setTooltip(Messages
.ToggleLeftRightInsertionHandler_SWITCH_RIGHT
);
66 element
.setIcon(INSERT_RIGHT_DESCRIPTOR
);
67 element
.setDisabledIcon(INSERT_RIGHT_DISABLED_DESCRIPTOR
);
68 element
.setText(Messages
.ToggleLeftRightInsertionHandler_RIGHT
);
69 element
.setTooltip(Messages
.ToggleLeftRightInsertionHandler_SWITCH_LEFT
);