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
.ui
.IEditorPart
;
19 import org
.eclipse
.ui
.commands
.IElementUpdater
;
20 import org
.eclipse
.ui
.menus
.UIElement
;
22 import eu
.etaxonomy
.taxeditor
.editor
.molecular
.AlignmentEditor
;
23 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
28 * Switches an {@link AlignmentEditor} between insertion and overwrite mode.
33 public class ToggleInsertOverwriteHandler
extends AbstractHandler
implements IElementUpdater
{
34 public static final String COMMAND_ID
=
35 "eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor.toggleInsertOverwrite";
39 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
40 IEditorPart activeEditor
= AbstractUtility
.getActiveEditor();
41 if (activeEditor
instanceof AlignmentEditor
) {
42 ((AlignmentEditor
)activeEditor
).toggleInsertOverwrite();
49 public void updateElement(UIElement element
, @SuppressWarnings("rawtypes") Map parameters
) {
50 IEditorPart activeEditor
= AbstractUtility
.getActiveEditor();
51 if (activeEditor
instanceof AlignmentEditor
) {
52 if (((AlignmentEditor
)activeEditor
).isInsertMode()) {
53 element
.setText(" INS ");
54 element
.setTooltip("Click to switch to overwrite mode");
57 element
.setText("OVR");
58 element
.setTooltip("Click to switch to insertion mode");