ref #6902 migrate alignment editor and pherogram view
[taxeditor.git] / eu.etaxonomy.taxeditor.molecular / src / main / java / eu / etaxonomy / taxeditor / molecular / editor / e4 / handler / ToggleLeftRightInsertionHandlerE4.java
diff --git a/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/e4/handler/ToggleLeftRightInsertionHandlerE4.java b/eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/e4/handler/ToggleLeftRightInsertionHandlerE4.java
new file mode 100644 (file)
index 0000000..ed4422e
--- /dev/null
@@ -0,0 +1,72 @@
+/**
+ * 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.editor.e4.handler;
+
+import javax.inject.Named;
+
+import org.eclipse.e4.core.di.annotations.Execute;
+import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.eclipse.e4.ui.services.IServiceConstants;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+import eu.etaxonomy.taxeditor.molecular.editor.AlignmentEditor;
+import eu.etaxonomy.taxeditor.molecular.editor.e4.AlignmentEditorE4;
+import eu.etaxonomy.taxeditor.molecular.handler.HandlerTools;
+
+
+
+/**
+ * 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 ToggleLeftRightInsertionHandlerE4 {
+    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$
+
+
+    @Execute
+    public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart) {
+        AlignmentEditorE4 editor = (AlignmentEditorE4) activePart.getObject();
+        editor.toggleLeftRightInsertionInPherogram();
+    }
+
+
+//    @Override
+//    public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {
+//        Object activeEditor = AbstractUtility.getActiveE4Editor();
+//        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);
+//            }
+//        }
+//    }
+}