+++ /dev/null
-/**
- * Copyright (C) 2007 EDIT
- * European Distributed Institute of Taxonomy
- * http://www.e-taxonomy.eu
- *
- * The contents of this file are subject to the Mozilla Public License Version 1.1
- * See LICENSE.TXT at the top of this package for the full license terms.
- */
-
-package eu.etaxonomy.taxeditor.molecular.handler;
-
-import java.util.Map;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.commands.IElementUpdater;
-import org.eclipse.ui.menus.UIElement;
-
-import eu.etaxonomy.taxeditor.model.AbstractUtility;
-import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor;
-import eu.etaxonomy.taxeditor.molecular.l10n.Messages;
-
-
-
-/**
- * Switches an {@link AlignmentEditor} between insertion in the base sequence to
- * the left or to the right.
- *
- * @author Ben Stöver
- * @date 04.12.2014
- */
-public class ToggleLeftRightInsertionHandler extends AbstractAlignmentEditorHandler implements IElementUpdater {
- public static final String COMMAND_ID = "eu.etaxonomy.taxeditor.molecular.AlignmentEditor.toggleLeftRightInsertion"; //$NON-NLS-1$
-
-
- private final ImageDescriptor INSERT_LEFT_DESCRIPTOR =
- HandlerTools.createImageDescriptor("pherogram-insert-left-16x16.png"); //$NON-NLS-1$
- private final ImageDescriptor INSERT_RIGHT_DESCRIPTOR =
- HandlerTools.createImageDescriptor("pherogram-insert-right-16x16.png"); //$NON-NLS-1$
- private final ImageDescriptor INSERT_LEFT_DISABLED_DESCRIPTOR =
- HandlerTools.createImageDescriptor("pherogram-insert-left-disabled-16x16.png"); //$NON-NLS-1$
- private final ImageDescriptor INSERT_RIGHT_DISABLED_DESCRIPTOR =
- HandlerTools.createImageDescriptor("pherogram-insert-right-disabled-16x16.png"); //$NON-NLS-1$
-
-
- @Override
- public void doExecute(ExecutionEvent event, AlignmentEditor editor) throws ExecutionException {
- editor.toggleLeftRightInsertionInPherogram();
- }
-
-
- @Override
- public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {
- Object activeEditor = AbstractUtility.getActiveEditor();
- if (activeEditor instanceof AlignmentEditor) {
- setBaseEnabled(((AlignmentEditor)activeEditor).isInsertMode());
- if (((AlignmentEditor)activeEditor).isInsertLeftInPherogram()) {
- element.setIcon(INSERT_LEFT_DESCRIPTOR);
- element.setDisabledIcon(INSERT_LEFT_DISABLED_DESCRIPTOR);
- element.setText(Messages.ToggleLeftRightInsertionHandler_LEFT);
- element.setTooltip(Messages.ToggleLeftRightInsertionHandler_SWITCH_RIGHT);
- }
- else {
- element.setIcon(INSERT_RIGHT_DESCRIPTOR);
- element.setDisabledIcon(INSERT_RIGHT_DISABLED_DESCRIPTOR);
- element.setText(Messages.ToggleLeftRightInsertionHandler_RIGHT);
- element.setTooltip(Messages.ToggleLeftRightInsertionHandler_SWITCH_LEFT);
- }
- }
- }
-}