Icons added for insert/overwrite button in AlignmentEditor tool bar.
authorb.stoever <b.stoever@localhost>
Mon, 15 Jun 2015 08:52:23 +0000 (08:52 +0000)
committerb.stoever <b.stoever@localhost>
Mon, 15 Jun 2015 08:52:23 +0000 (08:52 +0000)
Insert left/right in pherogram disabled when switching to overwrite mode.

.gitattributes
eu.etaxonomy.taxeditor.editor/icons/insert-16x16.png [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/icons/overwrite-16x16.png [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/HandlerTools.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleInsertOverwriteHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleLeftRightInsertionHandler.java

index 18d4648..743b58a 100644 (file)
@@ -367,8 +367,10 @@ eu.etaxonomy.taxeditor.editor/icons/deep-delete-16x16-32.png -text
 eu.etaxonomy.taxeditor.editor/icons/derivate_view-16x16-32.png -text
 eu.etaxonomy.taxeditor.editor/icons/edit_16x16.gif -text
 eu.etaxonomy.taxeditor.editor/icons/emblem-photos.png -text
+eu.etaxonomy.taxeditor.editor/icons/insert-16x16.png -text
 eu.etaxonomy.taxeditor.editor/icons/leaf_detail.png -text
 eu.etaxonomy.taxeditor.editor/icons/link_obj.gif -text
+eu.etaxonomy.taxeditor.editor/icons/overwrite-16x16.png -text
 eu.etaxonomy.taxeditor.editor/icons/pherogram-insert-left-16x16.png -text
 eu.etaxonomy.taxeditor.editor/icons/pherogram-insert-left-disabled-16x16.png -text
 eu.etaxonomy.taxeditor.editor/icons/pherogram-insert-right-16x16.png -text
@@ -405,6 +407,7 @@ eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/group/authority/handler/EditCdmAuthoritiesHandler.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/EditNewTaxonHandler.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/EditSequenceHandler.java -text
+eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/HandlerTools.java -text svneol=unset#text/plain
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/LoadPherogramHandler.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenAlignmentEditorHandler.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenChecklistEditorHandler.java -text
diff --git a/eu.etaxonomy.taxeditor.editor/icons/insert-16x16.png b/eu.etaxonomy.taxeditor.editor/icons/insert-16x16.png
new file mode 100644 (file)
index 0000000..6c9bce7
Binary files /dev/null and b/eu.etaxonomy.taxeditor.editor/icons/insert-16x16.png differ
diff --git a/eu.etaxonomy.taxeditor.editor/icons/overwrite-16x16.png b/eu.etaxonomy.taxeditor.editor/icons/overwrite-16x16.png
new file mode 100644 (file)
index 0000000..d2aa9e2
Binary files /dev/null and b/eu.etaxonomy.taxeditor.editor/icons/overwrite-16x16.png differ
index ed687ff..3c53822 100644 (file)
                   icon="icons/pherogram-insert-left-16x16.png"
                   style="push">
                <visibleWhen
-                     checkEnabled="true">
+                     checkEnabled="false">
                   <with
                         variable="activePartId">
                      <equals
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/HandlerTools.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/HandlerTools.java
new file mode 100644 (file)
index 0000000..31b96f9
--- /dev/null
@@ -0,0 +1,40 @@
+// $Id$\r
+/**\r
+* Copyright (C) 2015 EDIT\r
+* European Distributed Institute of Taxonomy\r
+* http://www.e-taxonomy.eu\r
+*\r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.taxeditor.editor.handler;\r
+\r
+\r
+import java.net.URL;\r
+\r
+import org.eclipse.core.runtime.FileLocator;\r
+import org.eclipse.core.runtime.Path;\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+\r
+import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;\r
+\r
+\r
+\r
+/**\r
+ * Implements shared functionality for handler implementations using tool bar icons.\r
+ *\r
+ * @author Ben Stöver\r
+ * @date 15.06.2015\r
+ */\r
+public class HandlerTools {  //TODO Move this class or method somewhere else?\r
+    public static ImageDescriptor createImageDescriptor(String iconName) {\r
+        URL url = FileLocator.find(TaxeditorEditorPlugin.getDefault().getBundle(),\r
+                new Path("icons/" + iconName), null);\r
+        if (url != null) {\r
+            return ImageDescriptor.createFromURL(url);\r
+        }\r
+        else {\r
+            throw new InternalError("Icon \"" + iconName + "\" could not be loaded.");  //TODO Throw other type of exception?\r
+        }\r
+    }\r
+}\r
index 7b047f8..2d3ebb8 100644 (file)
@@ -1,8 +1,8 @@
 /**\r
 * Copyright (C) 2007 EDIT\r
-* European Distributed Institute of Taxonomy \r
+* European Distributed Institute of Taxonomy\r
 * http://www.e-taxonomy.eu\r
-* \r
+*\r
 * The contents of this file are subject to the Mozilla Public License Version 1.1\r
 * See LICENSE.TXT at the top of this package for the full license terms.\r
 */\r
 package eu.etaxonomy.taxeditor.editor.handler.alignmenteditor;\r
 \r
 \r
+import java.util.HashMap;\r
 import java.util.Map;\r
 \r
 import org.eclipse.core.commands.AbstractHandler;\r
 import org.eclipse.core.commands.ExecutionEvent;\r
 import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
 import org.eclipse.ui.IEditorPart;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.eclipse.ui.commands.ICommandService;\r
 import org.eclipse.ui.commands.IElementUpdater;\r
 import org.eclipse.ui.menus.UIElement;\r
 \r
+import eu.etaxonomy.taxeditor.editor.handler.HandlerTools;\r
 import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor;\r
 import eu.etaxonomy.taxeditor.model.AbstractUtility;\r
 \r
@@ -26,34 +31,42 @@ import eu.etaxonomy.taxeditor.model.AbstractUtility;
 \r
 /**\r
  * Switches an {@link AlignmentEditor} between insertion and overwrite mode.\r
- * \r
+ *\r
  * @author Ben Stöver\r
  * @date 04.12.2014\r
  */\r
 public class ToggleInsertOverwriteHandler extends AbstractHandler implements IElementUpdater {\r
-       public static final String COMMAND_ID = \r
+       public static final String COMMAND_ID =\r
                        "eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor.toggleInsertOverwrite";\r
-       \r
-       \r
-       @Override\r
+\r
+\r
+    private final ImageDescriptor INSERT_DESCRIPTOR = HandlerTools.createImageDescriptor("insert-16x16.png");\r
+    private final ImageDescriptor OVERWRITE_DESCRIPTOR = HandlerTools.createImageDescriptor("overwrite-16x16.png");\r
+\r
+\r
+    @Override\r
        public Object execute(ExecutionEvent event) throws ExecutionException {\r
         IEditorPart activeEditor = AbstractUtility.getActiveEditor();\r
         if (activeEditor instanceof AlignmentEditor) {\r
             ((AlignmentEditor)activeEditor).toggleInsertOverwrite();\r
+            ((ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class)).refreshElements(\r
+                    ToggleLeftRightInsertionHandler.COMMAND_ID, new HashMap());\r
         }\r
         return null;\r
        }\r
-    \r
-    \r
+\r
+\r
        @Override\r
        public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {\r
         IEditorPart activeEditor = AbstractUtility.getActiveEditor();\r
                if (activeEditor instanceof AlignmentEditor) {\r
                        if (((AlignmentEditor)activeEditor).isInsertMode()) {\r
-                               element.setText(" INS ");\r
+                           element.setIcon(INSERT_DESCRIPTOR);\r
+                               element.setText("INS");\r
                                element.setTooltip("Click to switch to overwrite mode");\r
                        }\r
                        else {\r
+                element.setIcon(OVERWRITE_DESCRIPTOR);\r
                                element.setText("OVR");\r
                                element.setTooltip("Click to switch to insertion mode");\r
                        }\r
index 9e7ba3e..8b5489e 100644 (file)
@@ -9,26 +9,22 @@
 \r
 package eu.etaxonomy.taxeditor.editor.handler.alignmenteditor;\r
 \r
-import java.net.URL;\r
-import java.util.HashMap;\r
 import java.util.Map;\r
 \r
 import org.eclipse.core.commands.AbstractHandler;\r
 import org.eclipse.core.commands.ExecutionEvent;\r
 import org.eclipse.core.commands.ExecutionException;\r
-import org.eclipse.core.runtime.FileLocator;\r
-import org.eclipse.core.runtime.Path;\r
 import org.eclipse.jface.resource.ImageDescriptor;\r
 import org.eclipse.ui.IEditorPart;\r
-import org.eclipse.ui.PlatformUI;\r
-import org.eclipse.ui.commands.ICommandService;\r
 import org.eclipse.ui.commands.IElementUpdater;\r
 import org.eclipse.ui.menus.UIElement;\r
 \r
-import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;\r
+import eu.etaxonomy.taxeditor.editor.handler.HandlerTools;\r
 import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor;\r
 import eu.etaxonomy.taxeditor.model.AbstractUtility;\r
 \r
+\r
+\r
 /**\r
  * Switches an {@link AlignmentEditor} between insertion in the base sequence to\r
  * the left or to the right.\r
@@ -38,64 +34,44 @@ import eu.etaxonomy.taxeditor.model.AbstractUtility;
  */\r
 public class ToggleLeftRightInsertionHandler extends AbstractHandler implements IElementUpdater {\r
     public static final String COMMAND_ID = "eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor.toggleLeftRightInsertion";\r
-    \r
-    \r
-    private final ImageDescriptor INSERT_LEFT_DESCRIPTOR;\r
-    private final ImageDescriptor INSERT_RIGHT_DESCRIPTOR;\r
-    private final ImageDescriptor INSERT_LEFT_DISABLED_DESCRIPTOR;\r
-    private final ImageDescriptor INSERT_RIGHT_DISABLED_DESCRIPTOR;\r
 \r
-    \r
-    private ImageDescriptor createImageDescriptor(String iconName) {\r
-        URL url = FileLocator.find(TaxeditorEditorPlugin.getDefault().getBundle(), \r
-                       new Path("icons/" + iconName), null);\r
-        if (url != null) {\r
-            return ImageDescriptor.createFromURL(url);\r
-        }\r
-        else {\r
-               throw new InternalError("Icon \"" + iconName + "\" could not be loaded.");  //TODO Throw other type of exception?\r
-        }\r
-    }\r
-    \r
-    \r
-    /**\r
-     *\r
-     */\r
-    public ToggleLeftRightInsertionHandler() {\r
-       super();\r
-       INSERT_LEFT_DESCRIPTOR = createImageDescriptor("pherogram-insert-left-16x16.png");\r
-       INSERT_RIGHT_DESCRIPTOR = createImageDescriptor("pherogram-insert-right-16x16.png");\r
-       INSERT_LEFT_DISABLED_DESCRIPTOR = createImageDescriptor("pherogram-insert-left-disabled-16x16.png");\r
-       INSERT_RIGHT_DISABLED_DESCRIPTOR = createImageDescriptor("pherogram-insert-right-disabled-16x16.png");\r
-    }\r
 \r
-    \r
+    private final ImageDescriptor INSERT_LEFT_DESCRIPTOR =\r
+            HandlerTools.createImageDescriptor("pherogram-insert-left-16x16.png");\r
+    private final ImageDescriptor INSERT_RIGHT_DESCRIPTOR =\r
+            HandlerTools.createImageDescriptor("pherogram-insert-right-16x16.png");\r
+    private final ImageDescriptor INSERT_LEFT_DISABLED_DESCRIPTOR =\r
+            HandlerTools.createImageDescriptor("pherogram-insert-left-disabled-16x16.png");\r
+    private final ImageDescriptor INSERT_RIGHT_DISABLED_DESCRIPTOR =\r
+            HandlerTools.createImageDescriptor("pherogram-insert-right-disabled-16x16.png");\r
+\r
+\r
     @Override\r
     public Object execute(ExecutionEvent event) throws ExecutionException {\r
         IEditorPart activeEditor = AbstractUtility.getActiveEditor();\r
         if (activeEditor instanceof AlignmentEditor) {\r
-            ((AlignmentEditor) activeEditor).toggleLeftRightInsertionInPherogram();\r
+            ((AlignmentEditor)activeEditor).toggleLeftRightInsertionInPherogram();\r
         }\r
-        ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
-        commandService.refreshElements(COMMAND_ID, new HashMap());\r
         return null;\r
     }\r
 \r
-    \r
+\r
     @Override\r
     public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {\r
         IEditorPart activeEditor = AbstractUtility.getActiveEditor();\r
         if (activeEditor instanceof AlignmentEditor) {\r
-            if (((AlignmentEditor) activeEditor).isInsertLeftInPherogram()) {\r
+            setBaseEnabled(((AlignmentEditor)activeEditor).isInsertMode());\r
+            if (((AlignmentEditor)activeEditor).isInsertLeftInPherogram()) {\r
                 element.setIcon(INSERT_LEFT_DESCRIPTOR);\r
                 element.setDisabledIcon(INSERT_LEFT_DISABLED_DESCRIPTOR);\r
-                element.setText(" Left ");\r
-                element.setTooltip("Click to switch to insert new distorsions of the base call sequence right of future edits.");\r
-            } else {\r
+                element.setText("Left");\r
+                element.setTooltip("Switch to insert pherogram distorsions right of future edits.");\r
+            }\r
+            else {\r
                 element.setIcon(INSERT_RIGHT_DESCRIPTOR);\r
                 element.setDisabledIcon(INSERT_RIGHT_DISABLED_DESCRIPTOR);\r
                 element.setText("Right");\r
-                element.setTooltip("Click to switch to insert new distorsions of the base call sequence left of future edits.");\r
+                element.setTooltip("Switch to insert pherogram distorsions left of future edits.");\r
             }\r
         }\r
     }\r