From: Patric Plitzner Date: Mon, 20 Apr 2015 09:20:12 +0000 (+0000) Subject: - fixed icon toggling for LeftRightInsertion X-Git-Tag: 3.8.0^2~59^2~68 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/a68da8df0e147e82ef2983c11961647af2c93626 - fixed icon toggling for LeftRightInsertion --- diff --git a/eu.etaxonomy.taxeditor.editor/plugin.xml b/eu.etaxonomy.taxeditor.editor/plugin.xml index 16021314a..f0a093796 100644 --- a/eu.etaxonomy.taxeditor.editor/plugin.xml +++ b/eu.etaxonomy.taxeditor.editor/plugin.xml @@ -1018,9 +1018,7 @@ diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleLeftRightInsertionHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleLeftRightInsertionHandler.java index 0c10adb81..f98ac1fc5 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleLeftRightInsertionHandler.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleLeftRightInsertionHandler.java @@ -1,82 +1,89 @@ /** -* 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. -*/ + * 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.editor.handler.alignmenteditor; - +import java.net.URL; +import java.util.HashMap; import java.util.Map; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.Path; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.commands.ICommandService; import org.eclipse.ui.commands.IElementUpdater; import org.eclipse.ui.menus.UIElement; +import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin; import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor; import eu.etaxonomy.taxeditor.model.AbstractUtility; -import eu.etaxonomy.taxeditor.model.ImageResources; - - /** - * Switches an {@link AlignmentEditor} between insertion in the base sequence to the left or to the right. - * + * 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 AbstractHandler implements IElementUpdater { - public static final String COMMAND_ID = - "eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor.toggleLeftRightInsertion"; - - public static final String INSERT_LEFT_IMAGE = "pherogram-insert-left-16x16.png"; - public static final String INSERT_RIGHT_IMAGE = "pherogram-insert-right-16x16.png"; - public static final String INSERT_LEFT_IMAGE_DISABLED = "pherogram-insert-left-disabled-16x16.png"; - public static final String INSERT_RIGHT_IMAGE_DISABLED = "pherogram-insert-right-disabled-16x16.png"; - - public static final ImageDescriptor INSERT_LEFT_IMAGE_DESCRIPTOR = - ImageResources.getImageDescriptor(INSERT_LEFT_IMAGE); - public static final ImageDescriptor INSERT_RIGHT_IMAGE_DESCRIPTOR = - ImageResources.getImageDescriptor(INSERT_RIGHT_IMAGE); - public static final ImageDescriptor INSERT_LEFT_IMAGE_DESCRIPTOR_DISABLED = - ImageResources.getImageDescriptor(INSERT_LEFT_IMAGE_DISABLED); - public static final ImageDescriptor INSERT_RIGHT_IMAGE_DESCRIPTOR_DISABLED = - ImageResources.getImageDescriptor(INSERT_RIGHT_IMAGE_DISABLED); - - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { + public static final String COMMAND_ID = "eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor.toggleLeftRightInsertion"; + private ImageDescriptor INSER_LEFT_DESCRIPTOR; + private ImageDescriptor INSER_RIGHT_DESCRIPTOR; + + /** + * + */ + public ToggleLeftRightInsertionHandler() { + URL url = FileLocator.find(TaxeditorEditorPlugin.getDefault().getBundle(), new Path( + "icons/pherogram-insert-left-16x16.png"), null); + if (url != null) { + INSER_LEFT_DESCRIPTOR = ImageDescriptor.createFromURL(url); + } + url = FileLocator.find(TaxeditorEditorPlugin.getDefault().getBundle(), new Path( + "icons/pherogram-insert-right-16x16.png"), null); + if (url != null) { + INSER_RIGHT_DESCRIPTOR = ImageDescriptor.createFromURL(url); + } + } + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart activeEditor = AbstractUtility.getActiveEditor(); if (activeEditor instanceof AlignmentEditor) { - ((AlignmentEditor)activeEditor).toggleLeftRightInsertionInPherogram(); + ((AlignmentEditor) activeEditor).toggleLeftRightInsertionInPherogram(); } + ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); + commandService.refreshElements(COMMAND_ID, new HashMap()); return null; - } - - - @Override - public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) { + } + + @Override + public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) { IEditorPart activeEditor = AbstractUtility.getActiveEditor(); - if (activeEditor instanceof AlignmentEditor) { - if (((AlignmentEditor)activeEditor).isInsertLeftInPherogram()) { - element.setIcon(INSERT_LEFT_IMAGE_DESCRIPTOR); - element.setDisabledIcon(INSERT_LEFT_IMAGE_DESCRIPTOR_DISABLED); - element.setText(" Left "); - element.setTooltip("Click to switch to insert new distorsions of the base call sequence right of future edits."); - } - else { - element.setIcon(INSERT_RIGHT_IMAGE_DESCRIPTOR); - element.setDisabledIcon(INSERT_RIGHT_IMAGE_DESCRIPTOR_DISABLED); - element.setText("Right"); - element.setTooltip("Click to switch to insert new distorsions of the base call sequence left of future edits."); - } - } - } + if (activeEditor instanceof AlignmentEditor) { + if (((AlignmentEditor) activeEditor).isInsertLeftInPherogram()) { + element.setIcon(INSER_LEFT_DESCRIPTOR); +// element.setDisabledIcon(ImageResources.getImageDescriptor(ImageResources.INSERT_LEFT_IMAGE_DISABLED)); + // element.setText(" Left "); + element.setTooltip("Click to switch to insert new distorsions of the base call sequence right of future edits."); + } else { + element.setIcon(INSER_RIGHT_DESCRIPTOR); + element.setIcon(INSER_RIGHT_DESCRIPTOR); +// element.setDisabledIcon(ImageResources.getImageDescriptor(ImageResources.INSERT_RIGHT_IMAGE_DISABLED)); + // element.setText("Right"); + element.setTooltip("Click to switch to insert new distorsions of the base call sequence left of future edits."); + } + } + } } diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/AlignmentEditor.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/AlignmentEditor.java index 9add0c797..b4b239e81 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/AlignmentEditor.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/AlignmentEditor.java @@ -125,9 +125,9 @@ public class AlignmentEditor extends EditorPart { private final Map cdmMap = new TreeMap(); //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();