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
.editor
.handler
.alignmenteditor
;
15 import org
.eclipse
.core
.commands
.AbstractHandler
;
16 import org
.eclipse
.core
.commands
.ExecutionEvent
;
17 import org
.eclipse
.core
.commands
.ExecutionException
;
18 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
19 import org
.eclipse
.ui
.IEditorPart
;
20 import org
.eclipse
.ui
.commands
.IElementUpdater
;
21 import org
.eclipse
.ui
.menus
.UIElement
;
23 import eu
.etaxonomy
.taxeditor
.editor
.molecular
.AlignmentEditor
;
24 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
25 import eu
.etaxonomy
.taxeditor
.model
.ImageResources
;
30 * Switches an {@link AlignmentEditor} between insertion in the base sequence to the left or to the right.
35 public class ToggleLeftRightInsertionHandler
extends AbstractHandler
implements IElementUpdater
{
36 public static final String COMMAND_ID
=
37 "eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor.toggleLeftRightInsertion";
39 public static final String INSERT_LEFT_IMAGE
= "pherogram-insert-left-16x16.png";
40 public static final String INSERT_RIGHT_IMAGE
= "pherogram-insert-right-16x16.png";
41 public static final String INSERT_LEFT_IMAGE_DISABLED
= "pherogram-insert-left-disabled-16x16.png";
42 public static final String INSERT_RIGHT_IMAGE_DISABLED
= "pherogram-insert-right-disabled-16x16.png";
44 public static final ImageDescriptor INSERT_LEFT_IMAGE_DESCRIPTOR
=
45 ImageResources
.getImageDescriptor(INSERT_LEFT_IMAGE
);
46 public static final ImageDescriptor INSERT_RIGHT_IMAGE_DESCRIPTOR
=
47 ImageResources
.getImageDescriptor(INSERT_RIGHT_IMAGE
);
48 public static final ImageDescriptor INSERT_LEFT_IMAGE_DESCRIPTOR_DISABLED
=
49 ImageResources
.getImageDescriptor(INSERT_LEFT_IMAGE_DISABLED
);
50 public static final ImageDescriptor INSERT_RIGHT_IMAGE_DESCRIPTOR_DISABLED
=
51 ImageResources
.getImageDescriptor(INSERT_RIGHT_IMAGE_DISABLED
);
55 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
56 IEditorPart activeEditor
= AbstractUtility
.getActiveEditor();
57 if (activeEditor
instanceof AlignmentEditor
) {
58 ((AlignmentEditor
)activeEditor
).toggleLeftRightInsertionInPherogram();
65 public void updateElement(UIElement element
, @SuppressWarnings("rawtypes") Map parameters
) {
66 IEditorPart activeEditor
= AbstractUtility
.getActiveEditor();
67 if (activeEditor
instanceof AlignmentEditor
) {
68 if (((AlignmentEditor
)activeEditor
).isInsertLeftInPherogram()) {
69 element
.setIcon(INSERT_LEFT_IMAGE_DESCRIPTOR
);
70 element
.setDisabledIcon(INSERT_LEFT_IMAGE_DESCRIPTOR_DISABLED
);
71 element
.setText(" Left ");
72 element
.setTooltip("Click to switch to insert new distorsions of the base call sequence right of future edits.");
75 element
.setIcon(INSERT_RIGHT_IMAGE_DESCRIPTOR
);
76 element
.setDisabledIcon(INSERT_RIGHT_IMAGE_DESCRIPTOR_DISABLED
);
77 element
.setText("Right");
78 element
.setTooltip("Click to switch to insert new distorsions of the base call sequence left of future edits.");