- fixed icon toggling for LeftRightInsertion
authorPatric Plitzner <p.plitzner@bgbm.org>
Mon, 20 Apr 2015 09:20:12 +0000 (09:20 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Mon, 20 Apr 2015 09:20:12 +0000 (09:20 +0000)
eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleLeftRightInsertionHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/AlignmentEditor.java

index 16021314a73e4757f8aeb29cfe0a1f3a88f131b3..f0a093796a8d2e088e452e89f4f09dd15b4355ea 100644 (file)
             </command>
             <command
                   commandId="eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor.toggleLeftRightInsertion"
-                  disabledIcon="icons/pherogram-insert-left-disabled-16x16.png"
                   icon="icons/pherogram-insert-left-16x16.png"
-                  label="Left"
                   style="push">
                <visibleWhen
                      checkEnabled="true">
index 0c10adb81f80359f2730c177183237eb763f7748..f98ac1fc5d7c30078aa0c4e9e4342e5974915145 100644 (file)
@@ -1,82 +1,89 @@
 /**\r
-* Copyright (C) 2007 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
+ * Copyright (C) 2007 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
 \r
 package eu.etaxonomy.taxeditor.editor.handler.alignmenteditor;\r
 \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.molecular.AlignmentEditor;\r
 import eu.etaxonomy.taxeditor.model.AbstractUtility;\r
-import eu.etaxonomy.taxeditor.model.ImageResources;\r
-\r
-\r
 \r
 /**\r
- * Switches an {@link AlignmentEditor} between insertion in the base sequence to the left or to the right.\r
- * \r
+ * Switches an {@link AlignmentEditor} between insertion in the base sequence to\r
+ * the left or to the right.\r
+ *\r
  * @author Ben Stöver\r
  * @date 04.12.2014\r
  */\r
 public class ToggleLeftRightInsertionHandler extends AbstractHandler implements IElementUpdater {\r
-       public static final String COMMAND_ID = \r
-                       "eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor.toggleLeftRightInsertion";\r
-       \r
-       public static final String INSERT_LEFT_IMAGE = "pherogram-insert-left-16x16.png";\r
-       public static final String INSERT_RIGHT_IMAGE = "pherogram-insert-right-16x16.png";\r
-       public static final String INSERT_LEFT_IMAGE_DISABLED = "pherogram-insert-left-disabled-16x16.png";\r
-       public static final String INSERT_RIGHT_IMAGE_DISABLED = "pherogram-insert-right-disabled-16x16.png";\r
-       \r
-       public static final ImageDescriptor INSERT_LEFT_IMAGE_DESCRIPTOR = \r
-                       ImageResources.getImageDescriptor(INSERT_LEFT_IMAGE);\r
-       public static final ImageDescriptor INSERT_RIGHT_IMAGE_DESCRIPTOR = \r
-                       ImageResources.getImageDescriptor(INSERT_RIGHT_IMAGE);\r
-       public static final ImageDescriptor INSERT_LEFT_IMAGE_DESCRIPTOR_DISABLED = \r
-                       ImageResources.getImageDescriptor(INSERT_LEFT_IMAGE_DISABLED);\r
-       public static final ImageDescriptor INSERT_RIGHT_IMAGE_DESCRIPTOR_DISABLED = \r
-                       ImageResources.getImageDescriptor(INSERT_RIGHT_IMAGE_DISABLED);\r
-       \r
-       \r
-       @Override\r
-       public Object execute(ExecutionEvent event) throws ExecutionException {\r
+    public static final String COMMAND_ID = "eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor.toggleLeftRightInsertion";\r
+    private ImageDescriptor INSER_LEFT_DESCRIPTOR;\r
+    private ImageDescriptor INSER_RIGHT_DESCRIPTOR;\r
+\r
+    /**\r
+     *\r
+     */\r
+    public ToggleLeftRightInsertionHandler() {\r
+        URL url = FileLocator.find(TaxeditorEditorPlugin.getDefault().getBundle(), new Path(\r
+                "icons/pherogram-insert-left-16x16.png"), null);\r
+        if (url != null) {\r
+            INSER_LEFT_DESCRIPTOR = ImageDescriptor.createFromURL(url);\r
+        }\r
+        url = FileLocator.find(TaxeditorEditorPlugin.getDefault().getBundle(), new Path(\r
+                "icons/pherogram-insert-right-16x16.png"), null);\r
+        if (url != null) {\r
+            INSER_RIGHT_DESCRIPTOR = ImageDescriptor.createFromURL(url);\r
+        }\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
-       @Override\r
-       public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) {\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
-                               element.setIcon(INSERT_LEFT_IMAGE_DESCRIPTOR);\r
-                               element.setDisabledIcon(INSERT_LEFT_IMAGE_DESCRIPTOR_DISABLED);\r
-                               element.setText(" Left ");\r
-                               element.setTooltip("Click to switch to insert new distorsions of the base call sequence right of future edits.");\r
-                       }\r
-                       else {\r
-                               element.setIcon(INSERT_RIGHT_IMAGE_DESCRIPTOR);\r
-                               element.setDisabledIcon(INSERT_RIGHT_IMAGE_DESCRIPTOR_DISABLED);\r
-                               element.setText("Right");\r
-                               element.setTooltip("Click to switch to insert new distorsions of the base call sequence left of future edits.");\r
-                       }\r
-               }\r
-       }\r
+        if (activeEditor instanceof AlignmentEditor) {\r
+            if (((AlignmentEditor) activeEditor).isInsertLeftInPherogram()) {\r
+                element.setIcon(INSER_LEFT_DESCRIPTOR);\r
+//                element.setDisabledIcon(ImageResources.getImageDescriptor(ImageResources.INSERT_LEFT_IMAGE_DISABLED));\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.setIcon(INSER_RIGHT_DESCRIPTOR);\r
+                element.setIcon(INSER_RIGHT_DESCRIPTOR);\r
+//                element.setDisabledIcon(ImageResources.getImageDescriptor(ImageResources.INSERT_RIGHT_IMAGE_DISABLED));\r
+                // element.setText("Right");\r
+                element.setTooltip("Click to switch to insert new distorsions of the base call sequence left of future edits.");\r
+            }\r
+        }\r
+    }\r
 }\r
index 9add0c797bb4dc7595ca7f0b239eb534ca52a1e1..b4b239e81abbb4197f4bed1d7f666a568fba1c4e 100644 (file)
@@ -125,9 +125,9 @@ public class AlignmentEditor extends EditorPart {
     private final Map<Integer, SingleReadAlignment> cdmMap = new TreeMap<Integer, SingleReadAlignment>();  //TODO Move this to ContigSequenceDataProvider
     private boolean dirty = false;
 
-    
+
     public AlignmentEditor() {
-        conversationHolder = null; //CdmStore.createConversation();
+        conversationHolder = CdmStore.createConversation();
     }
 
 
@@ -335,7 +335,7 @@ public class AlignmentEditor extends EditorPart {
        if (getEditorInput() instanceof AlignmentEditorInput) {
                String taskName = "Saving alignment";
             monitor.beginTask(taskName, 3);
-               
+
                Sequence sequenceNode = ((AlignmentEditorInput)getEditorInput()).getSequenceNode();
                StringAdapter stringProvider = new StringAdapter(getConsensusArea().getSequenceProvider(), false);  // Throws an exception if a token has more than one character.
 
@@ -462,7 +462,7 @@ public class AlignmentEditor extends EditorPart {
        for (int row = selection.getStartRow(); row < selection.getStartRow() + selection.getCursorHeight(); row++) {
                        int sequenceID = getReadsArea().getSequenceOrder().idByIndex(row);
                        //TODO rc edited sequence
-                       
+
                        if (getPherogramArea(sequenceID).getProvider() instanceof ReverseComplementPherogramProvider) {
                                //getPherogramArea(sequenceID).
                                //TODO Allow to set new provider in PherogramArea or create new PherogramArea
@@ -470,8 +470,8 @@ public class AlignmentEditor extends EditorPart {
                        }
                }
     }
-    
-    
+
+
        public static PherogramProvider readPherogram(URI uri) throws IOException, UnsupportedChromatogramFormatException {
                PherogramProvider result;
                InputStream stream = uri.toURL().openStream();