From: Patric Plitzner Date: Wed, 15 Jul 2015 10:43:01 +0000 (+0000) Subject: - removed dependencies to LibrAlign X-Git-Tag: 3.8.0^2~59^2~16 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/a2a186f364f77d581311e622577a62a2f197c96c - removed dependencies to LibrAlign --- diff --git a/.gitattributes b/.gitattributes index d734c425b..a09fc596d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -376,9 +376,6 @@ eu.etaxonomy.taxeditor.editor/icons/pherogram-insert-left-disabled-16x16.png -te eu.etaxonomy.taxeditor.editor/icons/pherogram-insert-right-16x16.png -text eu.etaxonomy.taxeditor.editor/icons/pherogram-insert-right-disabled-16x16.png -text eu.etaxonomy.taxeditor.editor/icons/xper64.png -text -eu.etaxonomy.taxeditor.editor/lib/commons-lang3-3.1.jar -text -eu.etaxonomy.taxeditor.editor/lib/core-1.8.5.jar -text -eu.etaxonomy.taxeditor.editor/lib/sequencing-1.8.5.jar -text eu.etaxonomy.taxeditor.editor/p2.inf -text eu.etaxonomy.taxeditor.editor/plugin.xml -text eu.etaxonomy.taxeditor.editor/pom.xml -text @@ -404,32 +401,14 @@ 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/CdmAuthorityEditorInput.java -text 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 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenDerivateViewHandler.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenParentHandler.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenTaxonEditorHandler.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/SaveAllHandler.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/SaveTaxonHandler.java -text -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/ShowPherogramHandler.java -text -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/SpecimenPropertyTester.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/TaxonParameterConverter.java -text -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/AbstractAlignmentEditorHandler.java -text svneol=unset#text/plain -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/AbstractPherogramComponentHandler.java -text svneol=unset#text/plain -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ChangePherogramQualityOutputType.java -text svneol=unset#text/plain -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/CreateConsensusSequenceHandler.java -text -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/CutPherogramLeftHandler.java -text svneol=unset#text/plain -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/CutPherogramRightHandler.java -text svneol=unset#text/plain -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ReverseComplementHandler.java -text -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleInsertOverwriteHandler.java -text -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleLeftRightInsertionHandler.java -text -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleShowPherogramBaseCallLinesHandler.java -text svneol=unset#text/plain -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleShowPherogramProbabilitiesHandler.java -text svneol=unset#text/plain -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/UpdateConsensusSequenceHandler.java -text -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/package-info.java -text svneol=unset#text/plain eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/create/NewNameHandler.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/create/NewPersonHandler.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/create/NewReferenceHandler.java -text @@ -457,10 +436,6 @@ eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/po eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/operation/CreateNodeOperation.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/operation/DeleteNodeOperation.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/key/polytomous/operation/RefreshNodeNumberingOperation.java -text -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/AlignmentEditor.java -text -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/AlignmentEditorInput.java -text -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/PherogramMouseListener.java -text -eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/PherogramViewPart.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditor.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/container/AbstractGroup.java -text eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/container/AbstractGroupedContainer.java -text diff --git a/eu.etaxonomy.taxeditor.editor/.classpath b/eu.etaxonomy.taxeditor.editor/.classpath index 078bb0179..856e9f909 100644 --- a/eu.etaxonomy.taxeditor.editor/.classpath +++ b/eu.etaxonomy.taxeditor.editor/.classpath @@ -1,22 +1,9 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + diff --git a/eu.etaxonomy.taxeditor.editor/.project b/eu.etaxonomy.taxeditor.editor/.project index 501b29e2c..f03a32ad0 100644 --- a/eu.etaxonomy.taxeditor.editor/.project +++ b/eu.etaxonomy.taxeditor.editor/.project @@ -25,56 +25,4 @@ org.eclipse.jdt.core.javanature org.eclipse.pde.PluginNature - - - lib/JPhyloIO - 2 - WORKSPACE_LOC/JPhyloIO/bin - - - lib/info.bioinfweb.commons.bio - 2 - WORKSPACE_LOC/info.bioinfweb.commons.bio/bin - - - lib/info.bioinfweb.commons.core - 2 - WORKSPACE_LOC/info.bioinfweb.commons.core/bin - - - lib/info.bioinfweb.commons.experimental - 2 - WORKSPACE_LOC/info.bioinfweb.commons.experimental/bin - - - lib/info.bioinfweb.commons.swt - 2 - WORKSPACE_LOC/info.bioinfweb.commons.swt/bin - - - lib/info.bioinfweb.libralign.biojava1 - 2 - WORKSPACE_LOC/info.bioinfweb.libralign.biojava1/bin - - - lib/info.bioinfweb.libralign.core - 2 - WORKSPACE_LOC/info.bioinfweb.libralign.core/bin - - - lib/info.bioinfweb.libralign.swt - 2 - WORKSPACE_LOC/info.bioinfweb.libralign.swt/bin - - - lib/info.bioinfweb.tic.core - 2 - WORKSPACE_LOC/info.bioinfweb.tic.core/bin - - - lib/info.bioinfweb.tic.swt - 2 - WORKSPACE_LOC/info.bioinfweb.tic.swt/bin - - diff --git a/eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF b/eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF index ebfb62582..bcd8ff062 100644 --- a/eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF +++ b/eu.etaxonomy.taxeditor.editor/META-INF/MANIFEST.MF @@ -177,17 +177,4 @@ Bundle-ClassPath: ., jdimodel.jar, pdebuild.jar, compatibility.jar, - junit.jar, - lib/core-1.8.5.jar, - lib/sequencing-1.8.5.jar, - lib/commons-lang3-3.1.jar, - lib/JPhyloIO/, - lib/info.bioinfweb.libralign.core/, - lib/info.bioinfweb.libralign.swt/, - lib/info.bioinfweb.tic.core/, - lib/info.bioinfweb.tic.swt/, - lib/info.bioinfweb.libralign.biojava1/, - lib/info.bioinfweb.commons.bio/, - lib/info.bioinfweb.commons.core/, - lib/info.bioinfweb.commons.experimental/, - lib/info.bioinfweb.commons.swt/ + junit.jar diff --git a/eu.etaxonomy.taxeditor.editor/build.properties b/eu.etaxonomy.taxeditor.editor/build.properties index 8d591c289..51792637f 100644 --- a/eu.etaxonomy.taxeditor.editor/build.properties +++ b/eu.etaxonomy.taxeditor.editor/build.properties @@ -6,17 +6,4 @@ bin.includes = META-INF/,\ icons/,\ p2.inf,\ OSGI-INF/l10n/plugin.properties,\ - OSGI-INF/l10n/plugin_de.properties,\ - lib/core-1.8.5.jar,\ - lib/sequencing-1.8.5.jar,\ - lib/commons-lang3-3.1.jar,\ - lib/JPhyloIO/,\ - lib/info.bioinfweb.libralign.core/,\ - lib/info.bioinfweb.libralign.swt/,\ - lib/info.bioinfweb.tic.core/,\ - lib/info.bioinfweb.tic.swt/,\ - lib/info.bioinfweb.libralign.biojava1/,\ - lib/info.bioinfweb.commons.bio/,\ - lib/info.bioinfweb.commons.core/,\ - lib/info.bioinfweb.commons.experimental/,\ - lib/info.bioinfweb.commons.swt/ + OSGI-INF/l10n/plugin_de.properties diff --git a/eu.etaxonomy.taxeditor.editor/lib/commons-lang3-3.1.jar b/eu.etaxonomy.taxeditor.editor/lib/commons-lang3-3.1.jar deleted file mode 100644 index a85e539b1..000000000 Binary files a/eu.etaxonomy.taxeditor.editor/lib/commons-lang3-3.1.jar and /dev/null differ diff --git a/eu.etaxonomy.taxeditor.editor/lib/core-1.8.5.jar b/eu.etaxonomy.taxeditor.editor/lib/core-1.8.5.jar deleted file mode 100644 index c6c7bdc54..000000000 Binary files a/eu.etaxonomy.taxeditor.editor/lib/core-1.8.5.jar and /dev/null differ diff --git a/eu.etaxonomy.taxeditor.editor/lib/sequencing-1.8.5.jar b/eu.etaxonomy.taxeditor.editor/lib/sequencing-1.8.5.jar deleted file mode 100644 index b987ebee8..000000000 Binary files a/eu.etaxonomy.taxeditor.editor/lib/sequencing-1.8.5.jar and /dev/null differ diff --git a/eu.etaxonomy.taxeditor.editor/plugin.xml b/eu.etaxonomy.taxeditor.editor/plugin.xml index d16220bdc..39e3bc0bd 100644 --- a/eu.etaxonomy.taxeditor.editor/plugin.xml +++ b/eu.etaxonomy.taxeditor.editor/plugin.xml @@ -83,12 +83,6 @@ id="eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor" name="%editor.name.8"> - - - - @@ -748,28 +735,6 @@ label="%command.label.54" style="push"> - - - - - - - - - - - - @@ -987,81 +952,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1270,46 +1148,6 @@ class="eu.etaxonomy.taxeditor.editor.view.descriptive.handler.ToggleShowOnlyIndividualAssociationsHandler" commandId="eu.etaxonomy.taxeditor.editor.handler.showOnlyIndividualAssociations"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1876,24 +1655,6 @@ - - - - - - - - - - - - @@ -1918,26 +1679,6 @@ properties="isGroupEditor" type="eu.etaxonomy.taxeditor.bulkeditor.BulkEditor"> - - - - - - - - diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java index d923dd9b8..c93501452 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java @@ -37,8 +37,6 @@ import eu.etaxonomy.taxeditor.editor.group.authority.CdmAuthorityEditorInput; import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin; import eu.etaxonomy.taxeditor.editor.key.KeyEditor; import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyEditorInput; -import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor; -import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditorInput; import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditor; import eu.etaxonomy.taxeditor.editor.view.checklist.ChecklistEditorInput; import eu.etaxonomy.taxeditor.editor.view.dataimport.BioCaseEditorInput; @@ -122,16 +120,6 @@ public class EditorUtil extends AbstractUtility { open(input, ChecklistEditor.ID); } - /** - * Opens a new AlignmentEditor for the given input - * @param input - * @throws PartInitException - */ - public static void open(AlignmentEditorInput input) - throws PartInitException { - open(input, AlignmentEditor.ID); - } - /** * Opens a new {@link DataImportEditor} for the given input * @param input a {@link DataImportEditorInput} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/EditSequenceHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/EditSequenceHandler.java deleted file mode 100644 index 74926e0b6..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/EditSequenceHandler.java +++ /dev/null @@ -1,41 +0,0 @@ -package eu.etaxonomy.taxeditor.editor.handler; - - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.TreeNode; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.handlers.HandlerUtil; - -import eu.etaxonomy.cdm.model.molecular.Sequence; -import eu.etaxonomy.taxeditor.editor.EditorUtil; -import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditorInput; - - - -/** - * Opens the alignment editor from the CDM tree. - * - * @author Ben Stöver - * @author pplitzner - */ -public class EditSequenceHandler extends AbstractHandler { - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - ISelection currentSelection = HandlerUtil.getCurrentSelection(event); - TreeNode treeNodeOfSelection = EditorUtil.getTreeNodeOfSelection(currentSelection); - if(treeNodeOfSelection != null && treeNodeOfSelection.getValue() instanceof Sequence){ - AlignmentEditorInput input = new AlignmentEditorInput(((Sequence)treeNodeOfSelection.getValue()).getUuid()); //TODO Should there always be a new instance created here? What if the specified CDM node is already opened in an AlignmentEditor? => Possible create Singleton that keeps instances by sequence objects in a map. - try { - EditorUtil.open(input); - } - catch (PartInitException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - return null; - } -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/LoadPherogramHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/LoadPherogramHandler.java deleted file mode 100644 index a803a64d6..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/LoadPherogramHandler.java +++ /dev/null @@ -1,69 +0,0 @@ -/** -* 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; - - -import java.io.File; -import java.io.IOException; - -import org.biojava.bio.chromatogram.UnsupportedChromatogramFormatException; -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.ui.IEditorPart; - -import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor; -import eu.etaxonomy.taxeditor.model.AbstractUtility; -import eu.etaxonomy.taxeditor.model.MessagingUtils; - - - -/** - * Handler that loads an additional read into the contig alignment displayed by an instance of {@link AlignmentEditor}. - * - * @author Ben Stöver - * @author pplitzner - */ -public class LoadPherogramHandler extends AbstractHandler { - //TODO Change so that also URIs which do not point to files can be specified. - - /* (non-Javadoc) - * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) - */ - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - IEditorPart activeEditor = AbstractUtility.getActiveEditor(); - if (activeEditor instanceof AlignmentEditor) { - AlignmentEditor alignmentEditor = (AlignmentEditor)activeEditor; - - FileDialog fileDialog = new FileDialog(alignmentEditor.getSite().getShell()); - fileDialog.setText("Import pherogram into contig alignment"); - fileDialog.setFilterNames(new String[]{"All supported formats", "AB1 pherogram files", "SCF pherogram files", "All files"}); - fileDialog.setFilterExtensions(new String[]{"*.ab1;*.scf", "*.ab1", "*.scf", "*.*"}); - - String path = fileDialog.open(); - if (path != null) { - try { - alignmentEditor.addRead(new File(path).toURI(), false); - } - catch (UnsupportedChromatogramFormatException e) { - MessagingUtils.errorDialog("Unsupported format", this, "The format of the pherogram file \"" + path + - "\" is not supported. (Only AB1 and SCF are supported.)", "eu.etaxonomy.taxeditor.editor", e, false); //TODO set pluginID - } - catch (IOException e) { - MessagingUtils.errorDialog("Unsupported format", this, - "An IO error occurred while trying to read the file \"" + path + "\".", - "/eu.etaxonomy.taxeditor.editor", e, false); //TODO set pluginID - } - } - } - return null; - } -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenAlignmentEditorHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenAlignmentEditorHandler.java deleted file mode 100644 index 4350fa29c..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenAlignmentEditorHandler.java +++ /dev/null @@ -1,47 +0,0 @@ -// $Id$ -/** -* Copyright (C) 2014 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; - - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.ui.PartInitException; - -import eu.etaxonomy.taxeditor.editor.EditorUtil; -import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor; -import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditorInput; -import eu.etaxonomy.taxeditor.model.MessagingUtils; - - - -/** - * Opens the {@link AlignmentEditor}. - * - * @author pplitzner - * @date 04.08.2014 - */ -@Deprecated -public class OpenAlignmentEditorHandler extends AbstractHandler { - /* (non-Javadoc) - * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) - */ - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - AlignmentEditorInput input = new AlignmentEditorInput(null); //TODO Does it make sense to start an empty editor? - try { - EditorUtil.open(input); - } - catch (PartInitException e) { - MessagingUtils.error(OpenAlignmentEditorHandler.class, "Could not open AlignmentEditor", e); - } - return null; - } -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/ShowPherogramHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/ShowPherogramHandler.java deleted file mode 100644 index bfd21414d..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/ShowPherogramHandler.java +++ /dev/null @@ -1,65 +0,0 @@ -package eu.etaxonomy.taxeditor.editor.handler; - - -import info.bioinfweb.libralign.pherogram.model.PherogramComponentModel; - -import java.net.URI; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.TreeNode; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.handlers.HandlerUtil; - -import eu.etaxonomy.cdm.model.media.MediaUtils; -import eu.etaxonomy.cdm.model.molecular.SingleRead; -import eu.etaxonomy.taxeditor.editor.EditorUtil; -import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor; -import eu.etaxonomy.taxeditor.editor.molecular.PherogramViewPart; -import eu.etaxonomy.taxeditor.model.MessagingUtils; - - - -/** - * Displays an undistorted pherogram with {@link PherogramViewPart}. - * - * @author Ben Stöver - * - */ -public class ShowPherogramHandler extends AbstractHandler { - public static void showPherogram(PherogramComponentModel model) throws PartInitException { - PherogramViewPart.createView(model); - } - - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - ISelection currentSelection = HandlerUtil.getCurrentSelection(event); - TreeNode treeNodeOfSelection = EditorUtil.getTreeNodeOfSelection(currentSelection); - if (treeNodeOfSelection != null && treeNodeOfSelection.getValue() instanceof SingleRead) { - //TODO Can the parent node (containing the cut positions) be extracted from SingleRead? - try { - SingleRead singleRead = (SingleRead)treeNodeOfSelection.getValue(); - URI uri = null; - if (singleRead.getPherogram() != null) { // Pherogram objects without URI are possible. - uri = MediaUtils.getFirstMediaRepresentationPart(singleRead.getPherogram()).getUri(); - } - - if (uri == null) { - MessagingUtils.messageDialog("No pherogram available", this, - "The selected read does not have an associated pherogram."); - } - else { - showPherogram(new PherogramComponentModel(AlignmentEditor.readPherogram(uri))); - } - } - catch (Exception e) { - MessagingUtils.errorDialog("Error", null, e.getLocalizedMessage(), "eu.etaxonomy.taxeditor.editor", - e, false); - } - } - return null; - } -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/SpecimenPropertyTester.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/SpecimenPropertyTester.java deleted file mode 100644 index 17c821365..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/SpecimenPropertyTester.java +++ /dev/null @@ -1,58 +0,0 @@ -package eu.etaxonomy.taxeditor.editor.handler; - - -import org.eclipse.core.expressions.PropertyTester; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TreeNode; - -import eu.etaxonomy.cdm.model.molecular.Sequence; -import eu.etaxonomy.cdm.model.molecular.SingleRead; -import eu.etaxonomy.taxeditor.editor.EditorUtil; - - - -/** - * Tests types of specimens to add items to the context menu. - * - * @author pplitzner - * @author BenStoever - */ -public class SpecimenPropertyTester extends PropertyTester { - private static final String SEQUENCE = "isSequence"; - private static final String SINGLE_READ = "isSingleRead"; - - - public SpecimenPropertyTester() {} - - - /* (non-Javadoc) - * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) - */ - /** {@inheritDoc} */ - @Override - public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - if (receiver instanceof IStructuredSelection) { - IStructuredSelection selection = (IStructuredSelection) receiver; - TreeNode treeNodeOfSelection = EditorUtil.getTreeNodeOfSelection(selection); - if (treeNodeOfSelection!=null) { - if (SEQUENCE.equals(property)) { - return isSequence(treeNodeOfSelection.getValue()); - } - else if (SINGLE_READ.equals(property)) { - return isSingleReadAlignment(treeNodeOfSelection.getValue()); - } - } - } - return false; - } - - - private boolean isSequence(Object object) { - return (object instanceof Sequence); - } - - - private boolean isSingleReadAlignment(Object object) { - return (object instanceof SingleRead); - } -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/AbstractAlignmentEditorHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/AbstractAlignmentEditorHandler.java deleted file mode 100644 index 96ce9732d..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/AbstractAlignmentEditorHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -// $Id$ -/** -* Copyright (C) 2015 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 org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.ui.IEditorPart; - -import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor; -import eu.etaxonomy.taxeditor.model.AbstractUtility; - - - -/** - * Abstract implementation for all handlers triggering actions in an active instance of - * {@link AlignmentEditor}. - * - * @author Ben Stöver - * @date 19.06.2015 - */ -public abstract class AbstractAlignmentEditorHandler extends AbstractHandler { - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - IEditorPart activeEditor = AbstractUtility.getActiveEditor(); - if (activeEditor instanceof AlignmentEditor) { - doExecute(event, (AlignmentEditor)activeEditor); - } - return null; - } - - - public abstract void doExecute(ExecutionEvent event, AlignmentEditor editor) throws ExecutionException; -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/AbstractPherogramComponentHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/AbstractPherogramComponentHandler.java deleted file mode 100644 index e7b92d605..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/AbstractPherogramComponentHandler.java +++ /dev/null @@ -1,60 +0,0 @@ -// $Id$ -/** -* Copyright (C) 2015 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 info.bioinfweb.libralign.alignmentarea.AlignmentArea; -import info.bioinfweb.libralign.dataarea.implementations.pherogram.PherogramArea; -import info.bioinfweb.libralign.pherogram.PherogramComponent; - -import java.util.Iterator; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.ui.IWorkbenchPart; - -import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor; -import eu.etaxonomy.taxeditor.editor.molecular.PherogramViewPart; -import eu.etaxonomy.taxeditor.model.AbstractUtility; - - - -/** - * Abstract handler implementation allows to performs the concrete operation either on an instance of - * {@link PherogramViewPart} or all {@link AlignmentArea}s inside an instance of {@link AlignmentEditor}. - * - * @author Ben Stöver - * @date 23.06.2015 - */ -public abstract class AbstractPherogramComponentHandler extends AbstractHandler { - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - IWorkbenchPart activePart = AbstractUtility.getActivePart(); - - if (activePart instanceof AlignmentEditor) { - AlignmentEditor editor = (AlignmentEditor)activePart; - Iterator idIterator = editor.getReadsArea().getAlignmentModel().sequenceIDIterator(); - while (idIterator.hasNext()) { - PherogramArea area = editor.getPherogramArea(idIterator.next()); - if (area != null) { - doExecute(event, area); - } - } - } - else if (activePart instanceof PherogramViewPart) { - doExecute(event, ((PherogramViewPart)activePart).getPherogramView().getTraceCurveView()); - } - return null; - } - - - public abstract void doExecute(ExecutionEvent event, PherogramComponent component) throws ExecutionException; -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ChangePherogramQualityOutputType.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ChangePherogramQualityOutputType.java deleted file mode 100644 index 18fc06f69..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ChangePherogramQualityOutputType.java +++ /dev/null @@ -1,31 +0,0 @@ -// $Id$ -/** -* Copyright (C) 2015 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 info.bioinfweb.libralign.pherogram.PherogramComponent; - -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; - - - -/** - * Switches between the quality output types available for components displaying pherograms. - * - * @author Ben Stöver - * @date 19.06.2015 - */ -public class ChangePherogramQualityOutputType extends AbstractPherogramComponentHandler { - @Override - public void doExecute(ExecutionEvent event, PherogramComponent component) throws ExecutionException { - component.getFormats().changeQualityOutputType(); - } -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/CreateConsensusSequenceHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/CreateConsensusSequenceHandler.java deleted file mode 100644 index 2a2cc7326..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/CreateConsensusSequenceHandler.java +++ /dev/null @@ -1,33 +0,0 @@ -/** -* 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 org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; - -import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor; - - - -/** - * Handler that creates the consensus sequence from all single read sequences in the active instance - * of {@link AlignmentEditor}. A previously present consensus sequence will be overwritten. - * - * @author Ben Stöver - * @date 19.06.2015 - * @see UpdateConsensusSequenceHandler - * @see AlignmentEditor#createConsensusSequence() - */ -public class CreateConsensusSequenceHandler extends AbstractAlignmentEditorHandler { - @Override - public void doExecute(ExecutionEvent event, AlignmentEditor editor) throws ExecutionException { - editor.createConsensusSequence(); - } -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/CutPherogramLeftHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/CutPherogramLeftHandler.java deleted file mode 100644 index 305d63edf..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/CutPherogramLeftHandler.java +++ /dev/null @@ -1,36 +0,0 @@ -// $Id$ -/** -* Copyright (C) 2015 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 org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; - -import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor; -import eu.etaxonomy.taxeditor.model.MessagingUtils; - - - -/** - * Handler that cuts the base call sequence of a pherogram attached to the current sequence on the left - * of the current selection or cursor position. - * - * @author Ben Stöver - * @date 15.06.2015 - */ -public class CutPherogramLeftHandler extends AbstractAlignmentEditorHandler { - @Override - public void doExecute(ExecutionEvent event, AlignmentEditor editor) throws ExecutionException { - String errorMessage = editor.cutPherogramLeft(); - if (errorMessage != null) { - MessagingUtils.errorDialog("Unable to cut base call sequence", this, errorMessage, "eu.etaxonomy.taxeditor.editor", null, false); //TODO set pluginID - } - } -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/CutPherogramRightHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/CutPherogramRightHandler.java deleted file mode 100644 index 7844fc610..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/CutPherogramRightHandler.java +++ /dev/null @@ -1,36 +0,0 @@ -// $Id$ -/** -* Copyright (C) 2015 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 org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; - -import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor; -import eu.etaxonomy.taxeditor.model.MessagingUtils; - - - -/** - * Handler that cuts the base call sequence of a pherogram attached to the current sequence on the right - * of the current selection or cursor position. - * - * @author BenStoever - * @date 15.06.2015 - */ -public class CutPherogramRightHandler extends AbstractAlignmentEditorHandler { - @Override - public void doExecute(ExecutionEvent event, AlignmentEditor editor) throws ExecutionException { - String errorMessage = editor.cutPherogramRight(); - if (errorMessage != null) { - MessagingUtils.errorDialog("Unable to cut base call sequence", this, errorMessage, "eu.etaxonomy.taxeditor.editor", null, false); //TODO set pluginID - } - } -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ReverseComplementHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ReverseComplementHandler.java deleted file mode 100644 index f8b003e56..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ReverseComplementHandler.java +++ /dev/null @@ -1,30 +0,0 @@ -/** -* 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 org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; - -import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor; - - - -/** - * Reverse complements the single read sequence in an active {@link AlignmentEditor}, where the alignment cursor - * is currently located. - * - * @author Ben Stöver - */ -public class ReverseComplementHandler extends AbstractAlignmentEditorHandler { - @Override - public void doExecute(ExecutionEvent event, AlignmentEditor editor) throws ExecutionException { - editor.reverseComplementSelectedSequences(); - } -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleInsertOverwriteHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleInsertOverwriteHandler.java deleted file mode 100644 index 283767bd3..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleInsertOverwriteHandler.java +++ /dev/null @@ -1,69 +0,0 @@ -/** -* 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.util.Map; - -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -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.handler.HandlerTools; -import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor; -import eu.etaxonomy.taxeditor.model.AbstractUtility; - - - -/** - * Switches an {@link AlignmentEditor} between insertion and overwrite mode. - * - * @author Ben Stöver - * @date 04.12.2014 - */ -public class ToggleInsertOverwriteHandler extends AbstractAlignmentEditorHandler implements IElementUpdater { - public static final String COMMAND_ID = - "eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor.toggleInsertOverwrite"; - - - private final ImageDescriptor INSERT_DESCRIPTOR = HandlerTools.createImageDescriptor("insert-16x16.png"); - private final ImageDescriptor OVERWRITE_DESCRIPTOR = HandlerTools.createImageDescriptor("overwrite-16x16.png"); - - - @Override - public void doExecute(ExecutionEvent event, AlignmentEditor editor) throws ExecutionException { - editor.toggleInsertOverwrite(); - } - - - @Override - public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) { - IEditorPart activeEditor = AbstractUtility.getActiveEditor(); - if (activeEditor instanceof AlignmentEditor) { - if (((AlignmentEditor)activeEditor).isInsertMode()) { - element.setIcon(INSERT_DESCRIPTOR); - element.setText("INS"); - element.setTooltip("Click to switch to overwrite mode"); - } - else { - element.setIcon(OVERWRITE_DESCRIPTOR); - element.setText("OVR"); - element.setTooltip("Click to switch to insertion mode"); - } - ((ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class)).refreshElements( - ToggleLeftRightInsertionHandler.COMMAND_ID, null); - } - } -} 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 deleted file mode 100644 index d149eb16b..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleLeftRightInsertionHandler.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * 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.util.Map; - -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.commands.IElementUpdater; -import org.eclipse.ui.menus.UIElement; - -import eu.etaxonomy.taxeditor.editor.handler.HandlerTools; -import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor; -import eu.etaxonomy.taxeditor.model.AbstractUtility; - - - -/** - * 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 AbstractAlignmentEditorHandler implements IElementUpdater { - public static final String COMMAND_ID = "eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor.toggleLeftRightInsertion"; - - - private final ImageDescriptor INSERT_LEFT_DESCRIPTOR = - HandlerTools.createImageDescriptor("pherogram-insert-left-16x16.png"); - private final ImageDescriptor INSERT_RIGHT_DESCRIPTOR = - HandlerTools.createImageDescriptor("pherogram-insert-right-16x16.png"); - private final ImageDescriptor INSERT_LEFT_DISABLED_DESCRIPTOR = - HandlerTools.createImageDescriptor("pherogram-insert-left-disabled-16x16.png"); - private final ImageDescriptor INSERT_RIGHT_DISABLED_DESCRIPTOR = - HandlerTools.createImageDescriptor("pherogram-insert-right-disabled-16x16.png"); - - - @Override - public void doExecute(ExecutionEvent event, AlignmentEditor editor) throws ExecutionException { - editor.toggleLeftRightInsertionInPherogram(); - } - - - @Override - public void updateElement(UIElement element, @SuppressWarnings("rawtypes") Map parameters) { - IEditorPart activeEditor = AbstractUtility.getActiveEditor(); - 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("Left"); - element.setTooltip("Switch to insert pherogram distorsions right of future edits."); - } - else { - element.setIcon(INSERT_RIGHT_DESCRIPTOR); - element.setDisabledIcon(INSERT_RIGHT_DISABLED_DESCRIPTOR); - element.setText("Right"); - element.setTooltip("Switch to insert pherogram distorsions left of future edits."); - } - } - } -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleShowPherogramBaseCallLinesHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleShowPherogramBaseCallLinesHandler.java deleted file mode 100644 index 43ceb3115..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleShowPherogramBaseCallLinesHandler.java +++ /dev/null @@ -1,30 +0,0 @@ -// $Id$ -/** -* Copyright (C) 2015 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 info.bioinfweb.libralign.pherogram.PherogramComponent; - -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; - - - -/** - * @author BenStoever - * @date 23.06.2015 - * - */ -public class ToggleShowPherogramBaseCallLinesHandler extends AbstractPherogramComponentHandler { - @Override - public void doExecute(ExecutionEvent event, PherogramComponent component) throws ExecutionException { - component.getFormats().toggleShowBaseCallLines(); - } -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleShowPherogramProbabilitiesHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleShowPherogramProbabilitiesHandler.java deleted file mode 100644 index 41b03a010..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleShowPherogramProbabilitiesHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -// $Id$ -/** -* Copyright (C) 2015 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 info.bioinfweb.libralign.pherogram.PherogramComponent; - -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; - -import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor; -import eu.etaxonomy.taxeditor.editor.molecular.PherogramViewPart; - - - -/** - * Toggles whether probability values (substitution, overcall and undercall) should be displayed - * in pherogram areas of {@link AlignmentEditor} or {@link PherogramViewPart}. - * - * @author Ben Stöver - * @date 23.06.2015 - */ -public class ToggleShowPherogramProbabilitiesHandler extends AbstractPherogramComponentHandler { - @Override - public void doExecute(ExecutionEvent event, PherogramComponent component) throws ExecutionException { - component.getFormats().toggleShowProbabilityValues(); - } -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/UpdateConsensusSequenceHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/UpdateConsensusSequenceHandler.java deleted file mode 100644 index 6bcdf98d4..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/UpdateConsensusSequenceHandler.java +++ /dev/null @@ -1,24 +0,0 @@ -/** -* 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 org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; - -import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor; - - - -public class UpdateConsensusSequenceHandler extends AbstractAlignmentEditorHandler { - @Override - public void doExecute(ExecutionEvent event, AlignmentEditor editor) throws ExecutionException { - editor.updateConsensusSequence(); - } -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/package-info.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/package-info.java deleted file mode 100644 index bd0508a83..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/package-info.java +++ /dev/null @@ -1,17 +0,0 @@ -// $Id$ -/** - * Copyright (C) 2015 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. - */ -/** - * Contains handlers that trigger actions in an active instance of - * {@link eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor}. Handlers opening - * an alignment editor or pherogram view are not contained in here. - * - * @author Ben Stöver - */ -package eu.etaxonomy.taxeditor.editor.handler.alignmenteditor; \ No newline at end of file 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 deleted file mode 100644 index acf1aac70..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/AlignmentEditor.java +++ /dev/null @@ -1,717 +0,0 @@ -// $Id$ -/** -* Copyright (C) 2014 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.molecular; - - -import info.bioinfweb.libralign.alignmentarea.AlignmentArea; -import info.bioinfweb.libralign.alignmentarea.selection.SelectionModel; -import info.bioinfweb.libralign.alignmentarea.tokenpainter.NucleotideTokenPainter; -import info.bioinfweb.libralign.dataarea.implementations.ConsensusSequenceArea; -import info.bioinfweb.libralign.dataarea.implementations.SequenceIndexArea; -import info.bioinfweb.libralign.dataarea.implementations.pherogram.PherogramArea; -import info.bioinfweb.libralign.editsettings.EditSettingsChangeEvent; -import info.bioinfweb.libralign.editsettings.EditSettingsListener; -import info.bioinfweb.libralign.model.AlignmentModel; -import info.bioinfweb.libralign.model.AlignmentModelChangeListener; -import info.bioinfweb.libralign.model.AlignmentModelUtils; -import info.bioinfweb.libralign.model.adapters.StringAdapter; -import info.bioinfweb.libralign.model.events.SequenceChangeEvent; -import info.bioinfweb.libralign.model.events.SequenceRenamedEvent; -import info.bioinfweb.libralign.model.events.TokenChangeEvent; -import info.bioinfweb.libralign.model.implementations.PackedAlignmentModel; -import info.bioinfweb.libralign.model.tokenset.CharacterTokenSet; -import info.bioinfweb.libralign.model.tokenset.TokenSet; -import info.bioinfweb.libralign.multiplealignments.AlignmentAreaList; -import info.bioinfweb.libralign.multiplealignments.MultipleAlignmentsContainer; -import info.bioinfweb.libralign.pherogram.model.PherogramAreaModel; -import info.bioinfweb.libralign.pherogram.model.ShiftChange; -import info.bioinfweb.libralign.pherogram.provider.BioJavaPherogramProvider; -import info.bioinfweb.libralign.pherogram.provider.PherogramProvider; -import info.bioinfweb.libralign.pherogram.provider.ReverseComplementPherogramProvider; -import info.bioinfweb.tic.SWTComponentFactory; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URI; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import org.biojava.bio.chromatogram.ChromatogramFactory; -import org.biojava.bio.chromatogram.UnsupportedChromatogramFormatException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.commands.ICommandService; -import org.eclipse.ui.part.EditorPart; - -import eu.etaxonomy.cdm.api.conversation.ConversationHolder; -import eu.etaxonomy.cdm.api.service.molecular.ISequenceService; -import eu.etaxonomy.cdm.model.media.MediaUtils; -import eu.etaxonomy.cdm.model.molecular.Sequence; -import eu.etaxonomy.cdm.model.molecular.SequenceString; -import eu.etaxonomy.cdm.model.molecular.SingleRead; -import eu.etaxonomy.cdm.model.molecular.SingleReadAlignment; -import eu.etaxonomy.cdm.model.molecular.SingleReadAlignment.Shift; -import eu.etaxonomy.taxeditor.editor.handler.alignmenteditor.ToggleInsertOverwriteHandler; -import eu.etaxonomy.taxeditor.editor.handler.alignmenteditor.ToggleLeftRightInsertionHandler; -import eu.etaxonomy.taxeditor.model.MessagingUtils; -import eu.etaxonomy.taxeditor.store.CdmStore; -import eu.etaxonomy.taxeditor.view.derivateSearch.DerivateLabelProvider; - - - -/** - * Editor component to edit a contig alignment used to combine different overlapping pherograms from Sanger sequencing to - * a consensus sequence. - *

- * The contained GUI components used to edit the alignment come from LibrAlign. - * - * @author Ben Stöver - * @author pplitzner - * @date 04.08.2014 - */ -public class AlignmentEditor extends EditorPart { - public static final String ID = "eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor"; - - public static final int READS_AREA_INDEX = 1; - public static final int EDITABLE_CONSENSUS_AREA_INDEX = READS_AREA_INDEX + 1; - public static final int CONSENSUS_HINT_AREA_INDEX = EDITABLE_CONSENSUS_AREA_INDEX + 1; - public static final int PHEROGRAM_AREA_INDEX = 0; - public static final int CONSENSUS_DATA_AREA_INDEX = 0; - public static final String DEFAULT_READ_NAME_PREFIX = "Read "; - public static final String CONSENSUS_NAME = "Consensus"; - - - private final ConversationHolder conversationHolder; - - private final AlignmentModelChangeListener DIRTY_LISTENER = new AlignmentModelChangeListener() { - @Override - public void afterTokenChange(TokenChangeEvent e) { - setDirty(); - } - - @Override - public void afterSequenceRenamed(SequenceRenamedEvent e) { - setDirty(); - } - - @Override - public void afterSequenceChange(SequenceChangeEvent e) { - setDirty(); - } - - @Override - public void afterProviderChanged(AlignmentModel oldProvider, - AlignmentModel newProvider) { // Not expected. - - setDirty(); - } - }; - - private MultipleAlignmentsContainer alignmentsContainer = null; - private final Map cdmMap = new TreeMap(); //TODO Move this to ContigSequenceDataProvider - private boolean dirty = false; - - - public AlignmentEditor() { - super(); - conversationHolder = CdmStore.createConversation(); - //conversationHolder = null; - } - - - private void refreshToolbarElement(String id) { - ICommandService commandService = - (ICommandService)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(ICommandService.class); - if (commandService != null) { - commandService.refreshElements(id, Collections.EMPTY_MAP); - } - } - - - private void registerEditSettingListener(MultipleAlignmentsContainer container) { - container.getEditSettings().addListener(new EditSettingsListener() { - @Override - public void workingModeChanged(EditSettingsChangeEvent e) {} // Currently nothing to do - - @Override - public void insertLeftInDataAreaChanged(EditSettingsChangeEvent e) { - updateStatusBar(); - refreshToolbarElement(ToggleLeftRightInsertionHandler.COMMAND_ID); - } - - @Override - public void insertChanged(EditSettingsChangeEvent e) { - updateStatusBar(); - refreshToolbarElement(ToggleInsertOverwriteHandler.COMMAND_ID); - } - }); - } - - - private AlignmentArea createIndexArea(MultipleAlignmentsContainer container, AlignmentArea labeledArea) { - AlignmentArea result = new AlignmentArea(container); - result.setAllowVerticalScrolling(false); - result.getDataAreas().getTopAreas().add(new SequenceIndexArea(result.getContentArea(), labeledArea)); - return result; - } - - - private AlignmentArea createEditableAlignmentArea(MultipleAlignmentsContainer container, boolean allowVerticalScrolling) { - AlignmentArea result = new AlignmentArea(container); - result.setAllowVerticalScrolling(allowVerticalScrolling); - - CharacterTokenSet tokenSet = CharacterTokenSet.newDNAInstance(); //TODO Should NUCLEOTIDE be used instead? - AlignmentModel provider = new PackedAlignmentModel(tokenSet); - result.setAlignmentModel(provider, false); - provider.getChangeListeners().add(DIRTY_LISTENER); - result.getPaintSettings().getTokenPainterList().set(0, new NucleotideTokenPainter()); - - return result; - } - - - private AlignmentArea createConsensusHintArea(MultipleAlignmentsContainer container, - AlignmentArea labeledArea) { - - AlignmentArea result = new AlignmentArea(container); - result.setAllowVerticalScrolling(false); - result.getDataAreas().getBottomAreas().add( - new ConsensusSequenceArea(result.getContentArea(), labeledArea)); - return result; - } - - - private MultipleAlignmentsContainer getAlignmentsContainer() { - if (alignmentsContainer == null) { - alignmentsContainer = new MultipleAlignmentsContainer(); - - AlignmentAreaList list = alignmentsContainer.getAlignmentAreas(); - AlignmentArea readsArea = createEditableAlignmentArea(alignmentsContainer, true); - list.add(createIndexArea(alignmentsContainer, readsArea)); - list.add(readsArea); // Make sure READS_AREA_INDEX is correct. - list.add(createEditableAlignmentArea(alignmentsContainer, false)); // Make sure COMSENSUS_AREA_INDEX is correct. - list.add(createConsensusHintArea(alignmentsContainer, readsArea)); - - registerEditSettingListener(alignmentsContainer); - } - return alignmentsContainer; - } - - - public AlignmentArea getReadsArea() { - return getAlignmentsContainer().getAlignmentAreas().get(READS_AREA_INDEX); - } - - - private AlignmentArea getEditableConsensusArea() { - return getAlignmentsContainer().getAlignmentAreas().get(EDITABLE_CONSENSUS_AREA_INDEX); - } - - - public boolean hasPherogram(int sequenceID) { - return getReadsArea().getDataAreas().getSequenceAreas(sequenceID).size() > PHEROGRAM_AREA_INDEX; - } - - - public PherogramArea getPherogramArea(int sequenceID) { - if (hasPherogram(sequenceID)) { - return (PherogramArea)getReadsArea().getDataAreas().getSequenceAreas(sequenceID).get(PHEROGRAM_AREA_INDEX); - } - else { - return null; - } - } - - - private ConsensusSequenceArea getConsensusHintDataArea() { - return (ConsensusSequenceArea)getAlignmentsContainer().getAlignmentAreas(). - get(CONSENSUS_HINT_AREA_INDEX).getDataAreas().getBottomAreas(). - get(CONSENSUS_DATA_AREA_INDEX); - } - - - @Deprecated //TODO Remove as soon as testing period is over - private void createTestContents() { - // Just for testing: - try { - addRead(new File("D:/Users/BenStoever/ownCloud/Dokumente/Projekte/EDITor/Quelltexte/LibrAlign branch/Repository/eu.etaxonomy.taxeditor.editor/src/main/resources/AlignmentTestData/JR430_JR-P01.ab1").toURI(), false); - //addRead(new File("D:/Users/BenStoever/ownCloud/Dokumente/Projekte/EDITor/Quelltexte/LibrAlign branch/Repository/eu.etaxonomy.taxeditor.editor/src/main/resources/AlignmentTestData/JR444_JR-P05.ab1").toURI(), false); - addRead(new File("D:/Users/BenStoever/ownCloud/Dokumente/Projekte/EDITor/Quelltexte/LibrAlign branch/Repository/eu.etaxonomy.taxeditor.editor/src/main/resources/AlignmentTestData/Test_qualityScore.scf").toURI(), false); - - // Add test consensus sequence: - AlignmentModel consensusModel = getEditableConsensusArea().getAlignmentModel(); - int id = consensusModel.addSequence(CONSENSUS_NAME); - Collection tokens = new ArrayList(); // First save tokens in a collection to avoid GUI updated for each token. - tokens.add(consensusModel.getTokenSet().tokenByRepresentation("A")); - tokens.add(consensusModel.getTokenSet().tokenByRepresentation("C")); - tokens.add(consensusModel.getTokenSet().tokenByRepresentation("G")); - tokens.add(consensusModel.getTokenSet().tokenByRepresentation("T")); - consensusModel.insertTokensAt(id, 0, tokens); - } - catch (Exception e) { - throw new RuntimeException(e); - } - } - - - private void readCDMData(Sequence sequenceNode) { - //TODO If called from somewhere else than createPartControl() the editorInput needs to be checked and previous contents need to be cleared (or updated). - - // Add reads: - for (SingleReadAlignment singleReadAlignment : sequenceNode.getSingleReadAlignments()) { - try { - SingleRead pherogramInfo = singleReadAlignment.getSingleRead(); - URI uri = null; - if (pherogramInfo.getPherogram() != null) { - uri = MediaUtils.getFirstMediaRepresentationPart(pherogramInfo.getPherogram()).getUri(); - } - int id = addRead(DerivateLabelProvider.getDerivateText(pherogramInfo, conversationHolder), - uri, - singleReadAlignment.isReverseComplement(), - singleReadAlignment.getEditedSequence(), - singleReadAlignment.getFirstSeqPosition(), - singleReadAlignment.getLeftCutPosition(), - singleReadAlignment.getRightCutPosition(), - singleReadAlignment.getShifts()); - cdmMap.put(id, singleReadAlignment); - } - catch (Exception e) { // Usually due to an error while trying to read the pherogram (e.g. due to an unsupported format or an invalid URI). - MessagingUtils.errorDialog("Error", null, "A single read was skipped because of the following error:\n\n" + - e.getLocalizedMessage(), "eu.etaxonomy.taxeditor.editor", e, false); - } - } - - // Set consensus sequence: - AlignmentModel consensusProvider = getEditableConsensusArea().getAlignmentModel(); - int id = consensusProvider.addSequence(CONSENSUS_NAME); - consensusProvider.insertTokensAt(id, 0, AlignmentModelUtils.charSequenceToTokenList( - sequenceNode.getConsensusSequence().getString(), consensusProvider.getTokenSet())); - //TODO Can the consensus sequence also be null? / Should it be created here, if nothing is in the DB? - } - - - /* (non-Javadoc) - * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) - */ - @Override - public void createPartControl(Composite parent) { - SWTComponentFactory.getInstance().getSWTComponent(getAlignmentsContainer(), parent, SWT.NONE); - updateStatusBar(); - - if (getEditorInput() instanceof AlignmentEditorInput) { - if (((AlignmentEditorInput)getEditorInput()).getSequenceNodeUuid() != null) { - Sequence sequenceNode = CdmStore.getService(ISequenceService.class).load(((AlignmentEditorInput)getEditorInput()).getSequenceNodeUuid()); - //re-load into the current session if it is already persisted in the DB - if(sequenceNode!=null && sequenceNode.getId()!=0){ - sequenceNode = CdmStore.getService(ISequenceService.class).load(sequenceNode.getUuid()); - } - readCDMData(sequenceNode); - } - else { - createTestContents(); // This case will removed after the test phase and an exception should probably be thrown. - } - } - else { - throw new IllegalArgumentException("The editor input must have the type " + - AlignmentEditorInput.class.getCanonicalName()); //TODO What should be done here? - } - } - - - private void updateStatusBar() { - IActionBars bars = getEditorSite().getActionBars(); - bars.getStatusLineManager().setMessage("Edit mode: " + - (getReadsArea().getEditSettings().isInsert() ? "Insert" : "Overwrite") + " " + - "Insertion in pherogram: " + - (getReadsArea().getEditSettings().isInsertLeftInDataArea() ? "Left" : "Right")); - } - - - private SingleReadAlignment.Shift[] convertToCDMShifts(PherogramAreaModel model) { - Iterator iterator = model.shiftChangeIterator(); - List shifts = new ArrayList(); - while (iterator.hasNext()) { - ShiftChange shiftChange = iterator.next(); - shifts.add(new SingleReadAlignment.Shift(shiftChange.getBaseCallIndex(), shiftChange.getShiftChange())); - } - return shifts.toArray(new Shift[]{}); - } - - - /* (non-Javadoc) - * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor) - */ - @Override - public void doSave(IProgressMonitor monitor) { - if (getEditorInput() instanceof AlignmentEditorInput) { - String taskName = "Saving alignment"; - monitor.beginTask(taskName, 3); - - //re-loading sequence to avoid session conflicts - Sequence sequenceNode = CdmStore.getService(ISequenceService.class).load(((AlignmentEditorInput)getEditorInput()).getSequenceNodeUuid()); - StringAdapter stringProvider = new StringAdapter(getEditableConsensusArea().getAlignmentModel(), false); // Throws an exception if a token has more than one character. - - // Write consensus sequence: - SequenceString consensusSequenceObj = sequenceNode.getConsensusSequence(); - String newConsensusSequence = stringProvider.getSequence( - getEditableConsensusArea().getAlignmentModel().sequenceIDByName(CONSENSUS_NAME)); - if (consensusSequenceObj == null) { - sequenceNode.setConsensusSequence(SequenceString.NewInstance(newConsensusSequence)); - } - else { - consensusSequenceObj.setString(newConsensusSequence); - } - - // Write single reads: - stringProvider.setUnderlyingProvider(getReadsArea().getAlignmentModel()); - sequenceNode.getSingleReadAlignments().retainAll(cdmMap.values()); // Remove all reads that are not in the alignment anymore. - Iterator iterator = getReadsArea().getAlignmentModel().sequenceIDIterator(); - while (iterator.hasNext()) { - int id = iterator.next(); - SingleReadAlignment singleRead = cdmMap.get(id); - if (singleRead == null) { - throw new InternalError("Creating new reads from AlignmentEditor not implemented."); - //TODO Create new read object. => Shall it be allowed to add reads in the alignment editor which are not represented in the CDM tree before the alignment editor is saved? - //singleRead = SingleReadAlignment.NewInstance(consensusSequence, singleRead, shifts, editedSequence); - } - - singleRead.setEditedSequence(stringProvider.getSequence(id)); - - PherogramAreaModel model = getPherogramArea(id).getModel(); - singleRead.setReverseComplement(model.getPherogramProvider() instanceof ReverseComplementPherogramProvider); // Works only if ReverseComplementPherogramProvider instances are not nested. - singleRead.setShifts(convertToCDMShifts(getPherogramArea(id).getModel())); - singleRead.setFirstSeqPosition(model.getFirstSeqPos()); - singleRead.setLeftCutPosition(model.getLeftCutPosition()); - singleRead.setRightCutPosition(model.getRightCutPosition()); - } - - if (!conversationHolder.isBound()) { - conversationHolder.bind(); - } - monitor.worked(1); - - // Commit the conversation and start a new transaction immediately: - conversationHolder.commit(true); - monitor.worked(1); - - dirty = false; - monitor.worked(1); - monitor.done(); - firePropertyChange(PROP_DIRTY); - } - else { - //TODO Throw exception as soon as testing period which allows unlinked AlignmentEditor is over. - } - } - - - /* (non-Javadoc) - * @see org.eclipse.ui.part.EditorPart#doSaveAs() - */ - @Override - public void doSaveAs() {} - - - /* (non-Javadoc) - * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput) - */ - @Override - public void init(IEditorSite site, IEditorInput input) throws PartInitException { - setSite(site); - setInput(input); - } - - - /* (non-Javadoc) - * @see org.eclipse.ui.part.EditorPart#isDirty() - */ - @Override - public boolean isDirty() { - return dirty; - } - - - private void setDirty() { - dirty = true; - firePropertyChange(IEditorPart.PROP_DIRTY); - } - - - /* (non-Javadoc) - * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed() - */ - @Override - public boolean isSaveAsAllowed() { - return false; // "Save as" not allowed. - } - - - @Override - public void setFocus() { - if(conversationHolder!=null){ - conversationHolder.bind(); - } - } - - - public boolean isInsertMode() { - return getAlignmentsContainer().getEditSettings().isInsert(); - } - - - public boolean isInsertLeftInPherogram() { - return getAlignmentsContainer().getEditSettings().isInsertLeftInDataArea(); - } - - - public void toggleLeftRightInsertionInPherogram() { - getAlignmentsContainer().getEditSettings().toggleInsertLeftInDataArea(); - } - - - public void toggleInsertOverwrite() { - getAlignmentsContainer().getEditSettings().toggleInsert(); - } - - - private String cutPherogram(boolean left) { - SelectionModel selection = getReadsArea().getSelection(); - if (selection.getCursorHeight() != 1) { - return "Cutting pherograms is only possible if exactly one row is selected."; - } - else { - PherogramArea pherogramArea = - getPherogramArea(getReadsArea().getSequenceOrder().idByIndex(selection.getCursorRow())); - if (pherogramArea == null) { - return "There is no pherogram attached to the current sequence."; - } - else { - if (left) { - if (pherogramArea.setLeftCutPositionBySelection()) { - return null; - } - else { - return "The left end of the selection lies outside the pherogram attached to this sequence."; - } - } - else { - if (pherogramArea.setRightCutPositionBySelection()) { - return null; - } - else { - return "The right end of the selection lies outside the pherogram attached to this sequence."; - } - } - } - } - } - - - public String cutPherogramLeft() { - return cutPherogram(true); - } - - - public String cutPherogramRight() { - return cutPherogram(false); - } - - - public void reverseComplementSelectedSequences() { - SelectionModel selection = getReadsArea().getSelection(); - AlignmentModel model = getReadsArea().getAlignmentModel(); - for (int row = selection.getFirstRow(); row < selection.getFirstRow() + selection.getCursorHeight(); row++) { - int sequenceID = getReadsArea().getSequenceOrder().idByIndex(row); - PherogramArea area = getPherogramArea(sequenceID); - PherogramAreaModel pherogramAlignmentModel = area.getModel(); - AlignmentModelUtils.reverseComplement(model, sequenceID, - pherogramAlignmentModel.editableIndexByBaseCallIndex( - pherogramAlignmentModel.getLeftCutPosition()).getBeforeValidIndex(), - pherogramAlignmentModel.editableIndexByBaseCallIndex( - pherogramAlignmentModel.getRightCutPosition()).getAfterValidIndex()); - pherogramAlignmentModel.reverseComplement(); - } - } - - - /** - * Recreates the whole consensus sequence from all single read sequences. The previous consensus - * sequence is overwritte. - */ - @SuppressWarnings("unchecked") - public void createConsensusSequence() { - ConsensusSequenceArea area = getConsensusHintDataArea(); - AlignmentModel model = (AlignmentModel)getEditableConsensusArea().getAlignmentModel(); - int sequenceID = model.sequenceIDIterator().next(); // There is always one sequence contained. - int length = getReadsArea().getAlignmentModel().getMaxSequenceLength(); - - Collection tokens = new ArrayList(length); - for (int column = 0; column < length; column++) { - tokens.add(model.getTokenSet().tokenByRepresentation(area.getConsensusToken(column))); - } - - model.removeTokensAt(sequenceID, 0, model.getSequenceLength(sequenceID)); - model.insertTokensAt(sequenceID, 0, tokens); - } - - - /** - * Updates the current consensus sequence by replacing gaps by the according consensus tokens - * calculated from the single read sequences and extends the consensus sequence if necessary. - */ - @SuppressWarnings("unchecked") - public void updateConsensusSequence() { - ConsensusSequenceArea area = getConsensusHintDataArea(); - AlignmentModel model = (AlignmentModel)getEditableConsensusArea().getAlignmentModel(); - TokenSet tokenSet = model.getTokenSet(); - int sequenceID = model.sequenceIDIterator().next(); // There is always one sequence contained. - int currentConsensusLength = model.getSequenceLength(sequenceID); - int overallLength = getReadsArea().getAlignmentModel().getMaxSequenceLength(); - - // Replace gaps by new information: - for (int column = 0; column < currentConsensusLength; column++) { - if (tokenSet.isGapToken(model.getTokenAt(sequenceID, column))) { - T newToken = tokenSet.tokenByRepresentation(area.getConsensusToken(column)); - if (!tokenSet.isGapToken(newToken)) { - model.setTokenAt(sequenceID, column, newToken); - } - } - } - - // Append additional tokens: - if (overallLength > currentConsensusLength) { - Collection tokens = new ArrayList(overallLength); - for (int column = currentConsensusLength; column < overallLength; column++) { - tokens.add(tokenSet.tokenByRepresentation(area.getConsensusToken(column))); - } - model.appendTokens(sequenceID, tokens); - } - } - - - public static PherogramProvider readPherogram(URI uri) throws IOException, UnsupportedChromatogramFormatException { - PherogramProvider result; - InputStream stream = uri.toURL().openStream(); - try { - result = new BioJavaPherogramProvider(ChromatogramFactory.create(stream)); - } - finally { - stream.close(); - } - return result; - } - - - private String newReadName() { - int index = 1; - while (getReadsArea().getAlignmentModel().sequenceIDByName(DEFAULT_READ_NAME_PREFIX + index) - != AlignmentModel.NO_SEQUENCE_FOUND) { - - index++; - } - return DEFAULT_READ_NAME_PREFIX + index; - } - - - public void addRead(URI pherogramURI, boolean reverseComplemented) throws IOException, UnsupportedChromatogramFormatException { - addRead(newReadName(), pherogramURI, reverseComplemented, null, null, null, null, null); - } - - - /** - * Adds a new sequence with attached phergram data area to the reads alignment. - *

- * If {@code null} is specified as {@code editedSequence} the base call sequence from the pherogram will - * be set as the edited sequence. If {@code null} is specified as {@code shifts} no shifts between the edited - * and the base calls sequence are assumed. - * - * @param name the name of the new sequence - * @param pherogramURI the URI where the associated pherogram file is located - * @param reverseComplemented Specify {@code true} here, if the reverse complement of the pherogram data should - * be added, {@code false} otherwise. - * @param editedSequence the edited version of the base call sequence (May be {@code null}.) - * @param shifts the alignment information that links the edited and the base call sequence (May be {@code null}.) - * @return the sequence ID of the added read - * @throws IOException if an error occurred when trying to read the pherogram file - * @throws UnsupportedChromatogramFormatException if the format of the pherogram file is not supported - */ - public int addRead(String name, URI pherogramURI, boolean reverseComplemented, String editedSequence, - Integer firstSeqPos, Integer leftCutPos, Integer rightCutPos, SingleReadAlignment.Shift[] shifts) - throws IOException, UnsupportedChromatogramFormatException { - - AlignmentModel provider = getReadsArea().getAlignmentModel(); - PherogramProvider pherogramProvider = null; - if (pherogramURI != null) { - pherogramProvider = readPherogram(pherogramURI); // Must happen before a sequence is added, because it might throw an exception. - if (reverseComplemented) { - pherogramProvider = new ReverseComplementPherogramProvider(pherogramProvider); - } - } - - // Create sequence: - provider.addSequence(name); - int id = provider.sequenceIDByName(name); - - // Set edited sequence: - Collection tokens = null; // First save tokens in a collection to avoid GUI updated for each token. - if (editedSequence != null) { - tokens = AlignmentModelUtils.charSequenceToTokenList(editedSequence, provider.getTokenSet()); - } - else if (pherogramProvider != null) { // Copy base call sequence into alignment: - tokens = new ArrayList(); - for (int i = 0; i < pherogramProvider.getSequenceLength(); i++) { - tokens.add(provider.getTokenSet().tokenByRepresentation( - Character.toString(pherogramProvider.getBaseCall(i)))); - } - setDirty(); - } - - if (tokens != null) { // If either an edited sequence or a pherogram URI was provided. - provider.insertTokensAt(id, 0, tokens); - // Create pherogram area: - PherogramArea pherogramArea = new PherogramArea(getReadsArea().getContentArea(), - new PherogramAreaModel(pherogramProvider)); - - // Set position properties and shifts: - PherogramAreaModel model = pherogramArea.getModel(); - if ((firstSeqPos != null) && (leftCutPos != null)) { - model.setFirstSeqLeftCutPos(firstSeqPos, leftCutPos); - } - if (rightCutPos != null) { - model.setRightCutPosition(rightCutPos); - } - if ((shifts != null) && (shifts.length > 0)) { - for (int i = 0; i < shifts.length; i++) { - model.addShiftChange(shifts[i].position, shifts[i].shift); - } - setDirty(); - } - - // Add pherogram area to GUI: - pherogramArea.addMouseListener(new PherogramMouseListener(pherogramArea)); - getReadsArea().getDataAreas().getSequenceAreas(id).add(pherogramArea); - } - - return id; - } -} \ No newline at end of file diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/AlignmentEditorInput.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/AlignmentEditorInput.java deleted file mode 100644 index eea3525e2..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/AlignmentEditorInput.java +++ /dev/null @@ -1,138 +0,0 @@ -// $Id$ -/** -* Copyright (C) 2014 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.molecular; - - -import java.util.UUID; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IPersistableElement; - - - -/** - * @author pplitzner - * @author Ben Stöver - * @date 04.08.2014 - */ -public class AlignmentEditorInput implements IEditorInput { - private static final String name = "AlignmentEditor"; - - - private final UUID sequenceNodeUuid; - - - public AlignmentEditorInput(UUID sequenceNodeUuid) { - super(); - this.sequenceNodeUuid = sequenceNodeUuid; - } - - - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ - @Override - public Object getAdapter(Class adapter) { - // TODO Auto-generated method stub - return null; - } - - - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#exists() - */ - @Override - public boolean exists() { - // TODO Auto-generated method stub - return false; - } - - - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#getImageDescriptor() - */ - @Override - public ImageDescriptor getImageDescriptor() { - // TODO Auto-generated method stub - return null; - } - - - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#getName() - */ - @Override - public String getName() { - return name; - } - - - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#getPersistable() - */ - @Override - public IPersistableElement getPersistable() { - return null; - } - - - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#getToolTipText() - */ - @Override - public String getToolTipText() { - return name; - } - - - /** - * Returns the {@link UUID} of the sequence CDM node that should be edited by the {@link AlignmentEditor} this object - * is used with. - * - * @return the uuid of the CDM node to work on - */ - public UUID getSequenceNodeUuid() { - return sequenceNodeUuid; - } - - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((sequenceNodeUuid == null) ? 0 : sequenceNodeUuid.hashCode()); - return result; - } - - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - AlignmentEditorInput other = (AlignmentEditorInput) obj; - if (sequenceNodeUuid == null) { - if (other.sequenceNodeUuid != null) { - return false; - } - } else if (!sequenceNodeUuid.equals(other.sequenceNodeUuid)) { - return false; - } - return true; - } -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/PherogramMouseListener.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/PherogramMouseListener.java deleted file mode 100644 index 544421543..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/PherogramMouseListener.java +++ /dev/null @@ -1,55 +0,0 @@ -/** -* 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.molecular; - - -import info.bioinfweb.libralign.dataarea.implementations.pherogram.PherogramArea; -import info.bioinfweb.tic.input.TICMouseAdapter; -import info.bioinfweb.tic.input.TICMouseEvent; - -import org.eclipse.ui.PartInitException; - -import eu.etaxonomy.taxeditor.editor.handler.ShowPherogramHandler; -import eu.etaxonomy.taxeditor.model.MessagingUtils; - - - -/** - * Listens to mouse events on data areas displaying a pherogram in {@link AlignmentEditor}. - * - * @author Ben Stöver - * @date 25.11.2014 - */ -public class PherogramMouseListener extends TICMouseAdapter { - private final PherogramArea area; - - - public PherogramMouseListener(PherogramArea area) { - super(); - this.area = area; - } - - - @Override - public boolean mousePressed(TICMouseEvent event) { - if (event.getClickCount() == 2) { // Double click - try { - ShowPherogramHandler.showPherogram(area.getModel()); - } - catch (PartInitException e) { - MessagingUtils.errorDialog("Unable to create pherogram view", null, e.getLocalizedMessage(), - "eu.etaxonomy.taxeditor.editor", e, false); //TODO set pluginID - } - return true; - } - else { - return false; - } - } -} diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/PherogramViewPart.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/PherogramViewPart.java deleted file mode 100644 index 9d79e27e9..000000000 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/PherogramViewPart.java +++ /dev/null @@ -1,68 +0,0 @@ -/** -* 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.molecular; - - -import info.bioinfweb.libralign.pherogram.PherogramFormats.QualityOutputType; -import info.bioinfweb.libralign.pherogram.model.PherogramComponentModel; -import info.bioinfweb.libralign.pherogram.view.PherogramView; -import info.bioinfweb.tic.SWTComponentFactory; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.part.ViewPart; - - - -/** - * Component that allows to view a pherogram without the distortion due to aligning it to a sequence as in - * {@link AlignmentEditor}. - * - * @author Ben Stöver - * @date Nov 20, 2014 - */ -public class PherogramViewPart extends ViewPart { - public static final String ID = "eu.etaxonomy.taxeditor.editor.molecular.PherogramView"; - - private PherogramView pherogramView = null; - - - public static PherogramViewPart createView(PherogramComponentModel model) throws PartInitException { - PherogramViewPart view = (PherogramViewPart)PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(ID); - view.getPherogramView().getTraceCurveView().setModel(model); - view.getPherogramView().assignSize(); - return view; - } - - - public PherogramView getPherogramView() { - if (pherogramView == null) { - pherogramView = new PherogramView(); - pherogramView.getTraceCurveView().getFormats().setShowProbabilityValues(true); - pherogramView.getTraceCurveView().setHorizontalScale(1); - pherogramView.getTraceCurveView().setVerticalScale(100); - pherogramView.getTraceCurveView().getFormats().setQualityOutputType(QualityOutputType.NONE); //TODO Make this user defined - pherogramView.getTraceCurveView().getFormats().setShowProbabilityValues(false); - } - return pherogramView; - } - - - @Override - public void createPartControl(Composite parent) { - SWTComponentFactory.getInstance().getSWTComponent(getPherogramView(), parent, SWT.NONE); - getPherogramView().assignSize(); - } - - - @Override - public void setFocus() {} // nothing to do -}