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
.ExecutionEvent
;
16 import org
.eclipse
.core
.commands
.ExecutionException
;
17 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
18 import org
.eclipse
.ui
.IEditorPart
;
19 import org
.eclipse
.ui
.PlatformUI
;
20 import org
.eclipse
.ui
.commands
.ICommandService
;
21 import org
.eclipse
.ui
.commands
.IElementUpdater
;
22 import org
.eclipse
.ui
.menus
.UIElement
;
24 import eu
.etaxonomy
.taxeditor
.editor
.handler
.HandlerTools
;
25 import eu
.etaxonomy
.taxeditor
.editor
.molecular
.AlignmentEditor
;
26 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
31 * Switches an {@link AlignmentEditor} between insertion and overwrite mode.
36 public class ToggleInsertOverwriteHandler
extends AbstractAlignmentEditorHandler
implements IElementUpdater
{
37 public static final String COMMAND_ID
=
38 "eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor.toggleInsertOverwrite";
41 private final ImageDescriptor INSERT_DESCRIPTOR
= HandlerTools
.createImageDescriptor("insert-16x16.png");
42 private final ImageDescriptor OVERWRITE_DESCRIPTOR
= HandlerTools
.createImageDescriptor("overwrite-16x16.png");
46 public void doExecute(ExecutionEvent event
, AlignmentEditor editor
) throws ExecutionException
{
47 editor
.toggleInsertOverwrite();
52 public void updateElement(UIElement element
, @SuppressWarnings("rawtypes") Map parameters
) {
53 IEditorPart activeEditor
= AbstractUtility
.getActiveEditor();
54 if (activeEditor
instanceof AlignmentEditor
) {
55 if (((AlignmentEditor
)activeEditor
).isInsertMode()) {
56 element
.setIcon(INSERT_DESCRIPTOR
);
57 element
.setText("INS");
58 element
.setTooltip("Click to switch to overwrite mode");
61 element
.setIcon(OVERWRITE_DESCRIPTOR
);
62 element
.setText("OVR");
63 element
.setTooltip("Click to switch to insertion mode");
65 ((ICommandService
)PlatformUI
.getWorkbench().getService(ICommandService
.class)).refreshElements(
66 ToggleLeftRightInsertionHandler
.COMMAND_ID
, null);