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
;
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
.model
.AbstractUtility
;
25 import eu
.etaxonomy
.taxeditor
.molecular
.editor
.AlignmentEditor
;
30 * Switches an {@link AlignmentEditor} between insertion and overwrite mode.
35 public class ToggleInsertOverwriteHandler
extends AbstractAlignmentEditorHandler
implements IElementUpdater
{
36 public static final String COMMAND_ID
=
37 "eu.etaxonomy.taxeditor.molecular.AlignmentEditor.toggleInsertOverwrite";
40 private final ImageDescriptor INSERT_DESCRIPTOR
= HandlerTools
.createImageDescriptor("insert-16x16.png");
41 private final ImageDescriptor OVERWRITE_DESCRIPTOR
= HandlerTools
.createImageDescriptor("overwrite-16x16.png");
45 public void doExecute(ExecutionEvent event
, AlignmentEditor editor
) throws ExecutionException
{
46 editor
.toggleInsertOverwrite();
51 public void updateElement(UIElement element
, @SuppressWarnings("rawtypes") Map parameters
) {
52 IEditorPart activeEditor
= AbstractUtility
.getActiveEditor();
53 if (activeEditor
instanceof AlignmentEditor
) {
54 if (((AlignmentEditor
)activeEditor
).isInsertMode()) {
55 element
.setIcon(INSERT_DESCRIPTOR
);
56 element
.setText("INS");
57 element
.setTooltip("Click to switch to overwrite mode");
60 element
.setIcon(OVERWRITE_DESCRIPTOR
);
61 element
.setText("OVR");
62 element
.setTooltip("Click to switch to insertion mode");
64 ((ICommandService
)PlatformUI
.getWorkbench().getService(ICommandService
.class)).refreshElements(
65 ToggleLeftRightInsertionHandler
.COMMAND_ID
, null);