/**\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
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();
}
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.
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
}
}
}
-
-
+
+
public static PherogramProvider readPherogram(URI uri) throws IOException, UnsupportedChromatogramFormatException {
PherogramProvider result;
InputStream stream = uri.toURL().openStream();