From d8c846901c79dba713b3a0bbfa640777999b317b Mon Sep 17 00:00:00 2001 From: "b.stoever" Date: Fri, 19 Jun 2015 09:11:33 +0000 Subject: [PATCH] AbstractAlignmentEditorHandler added. --- .gitattributes | 1 + .../AbstractAlignmentEditorHandler.java | 42 +++++++++++++++++++ .../CreateConsensusSequenceHandler.java | 25 +++++------ .../CutPherogramLeftHandler.java | 17 +++----- .../CutPherogramRightHandler.java | 17 +++----- .../ReverseComplementHandler.java | 27 +++++------- .../ToggleInsertOverwriteHandler.java | 13 ++---- .../ToggleLeftRightInsertionHandler.java | 11 ++--- .../UpdateConsensusSequenceHandler.java | 21 ++++------ 9 files changed, 88 insertions(+), 86 deletions(-) create mode 100644 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/AbstractAlignmentEditorHandler.java diff --git a/.gitattributes b/.gitattributes index 01647faa5..0a972b7a2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -419,6 +419,7 @@ eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handle 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/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 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 new file mode 100644 index 000000000..96ce9732d --- /dev/null +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/AbstractAlignmentEditorHandler.java @@ -0,0 +1,42 @@ +// $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/CreateConsensusSequenceHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/CreateConsensusSequenceHandler.java index 64de1b11d..1424b3088 100644 --- 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 @@ -1,31 +1,28 @@ /** * Copyright (C) 2007 EDIT -* European Distributed Institute of Taxonomy +* 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; -public class CreateConsensusSequenceHandler extends AbstractHandler { - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - IEditorPart activeEditor = AbstractUtility.getActiveEditor(); - if (activeEditor instanceof AlignmentEditor) { - //((AlignmentEditor)activeEditor).; - } - return null; - } +public class CreateConsensusSequenceHandler extends AbstractAlignmentEditorHandler { + /* (non-Javadoc) + * @see eu.etaxonomy.taxeditor.editor.handler.alignmenteditor.AbstractAlignmentEditorHandler#doExecute(org.eclipse.core.commands.ExecutionEvent, eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor) + */ + @Override + public void doExecute(ExecutionEvent event, AlignmentEditor editor) throws ExecutionException { + // TODO Auto-generated method stub + + } } 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 index 0b76ca9f0..305d63edf 100644 --- 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 @@ -10,13 +10,10 @@ 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; import eu.etaxonomy.taxeditor.model.MessagingUtils; @@ -28,16 +25,12 @@ import eu.etaxonomy.taxeditor.model.MessagingUtils; * @author Ben Stöver * @date 15.06.2015 */ -public class CutPherogramLeftHandler extends AbstractHandler { +public class CutPherogramLeftHandler extends AbstractAlignmentEditorHandler { @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - IEditorPart activeEditor = AbstractUtility.getActiveEditor(); - if (activeEditor instanceof AlignmentEditor) { - String errorMessage = ((AlignmentEditor)activeEditor).cutPherogramLeft(); - if (errorMessage != null) { - MessagingUtils.errorDialog("Unable to cut base call sequence", this, errorMessage, "eu.etaxonomy.taxeditor.editor", null, false); //TODO set pluginID - } + 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 } - return null; } } 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 index 15c07fb58..7844fc610 100644 --- 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 @@ -10,13 +10,10 @@ 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; import eu.etaxonomy.taxeditor.model.MessagingUtils; @@ -28,16 +25,12 @@ import eu.etaxonomy.taxeditor.model.MessagingUtils; * @author BenStoever * @date 15.06.2015 */ -public class CutPherogramRightHandler extends AbstractHandler { +public class CutPherogramRightHandler extends AbstractAlignmentEditorHandler { @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - IEditorPart activeEditor = AbstractUtility.getActiveEditor(); - if (activeEditor instanceof AlignmentEditor) { - String errorMessage = ((AlignmentEditor)activeEditor).cutPherogramRight(); - if (errorMessage != null) { - MessagingUtils.errorDialog("Unable to cut base call sequence", this, errorMessage, "eu.etaxonomy.taxeditor.editor", null, false); //TODO set pluginID - } + 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 } - return null; } } 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 index d3da248a9..f8b003e56 100644 --- 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 @@ -1,37 +1,30 @@ /** * Copyright (C) 2007 EDIT -* European Distributed Institute of Taxonomy +* 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; /** - * Reverse complements the single read sequence in an active {@link AlignmentEditor}, where the alignment cursor - * is currently located. - * + * 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 AbstractHandler { - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - IEditorPart activeEditor = AbstractUtility.getActiveEditor(); - if (activeEditor instanceof AlignmentEditor) { - ((AlignmentEditor)activeEditor).reverseComplementSelectedSequences(); - } - return null; - } +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 index 56221f978..283767bd3 100644 --- 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 @@ -12,7 +12,6 @@ package eu.etaxonomy.taxeditor.editor.handler.alignmenteditor; 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.jface.resource.ImageDescriptor; @@ -34,7 +33,7 @@ import eu.etaxonomy.taxeditor.model.AbstractUtility; * @author Ben Stöver * @date 04.12.2014 */ -public class ToggleInsertOverwriteHandler extends AbstractHandler implements IElementUpdater { +public class ToggleInsertOverwriteHandler extends AbstractAlignmentEditorHandler implements IElementUpdater { public static final String COMMAND_ID = "eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor.toggleInsertOverwrite"; @@ -44,13 +43,9 @@ public class ToggleInsertOverwriteHandler extends AbstractHandler implements IEl @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - IEditorPart activeEditor = AbstractUtility.getActiveEditor(); - if (activeEditor instanceof AlignmentEditor) { - ((AlignmentEditor)activeEditor).toggleInsertOverwrite(); - } - return null; - } + public void doExecute(ExecutionEvent event, AlignmentEditor editor) throws ExecutionException { + editor.toggleInsertOverwrite(); + } @Override 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 8b5489ee8..d149eb16b 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 @@ -11,7 +11,6 @@ package eu.etaxonomy.taxeditor.editor.handler.alignmenteditor; 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.jface.resource.ImageDescriptor; @@ -32,7 +31,7 @@ import eu.etaxonomy.taxeditor.model.AbstractUtility; * @author Ben Stöver * @date 04.12.2014 */ -public class ToggleLeftRightInsertionHandler extends AbstractHandler implements IElementUpdater { +public class ToggleLeftRightInsertionHandler extends AbstractAlignmentEditorHandler implements IElementUpdater { public static final String COMMAND_ID = "eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor.toggleLeftRightInsertion"; @@ -47,12 +46,8 @@ public class ToggleLeftRightInsertionHandler extends AbstractHandler implements @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - IEditorPart activeEditor = AbstractUtility.getActiveEditor(); - if (activeEditor instanceof AlignmentEditor) { - ((AlignmentEditor)activeEditor).toggleLeftRightInsertionInPherogram(); - } - return null; + public void doExecute(ExecutionEvent event, AlignmentEditor editor) throws ExecutionException { + editor.toggleLeftRightInsertionInPherogram(); } 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 index 58e93a7d5..802c3b3e5 100644 --- 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 @@ -1,31 +1,24 @@ /** * Copyright (C) 2007 EDIT -* European Distributed Institute of Taxonomy +* 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; -public class UpdateConsensusSequenceHandler extends AbstractHandler { - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - IEditorPart activeEditor = AbstractUtility.getActiveEditor(); - if (activeEditor instanceof AlignmentEditor) { - //((AlignmentEditor)activeEditor).; - } - return null; - } +public class UpdateConsensusSequenceHandler extends AbstractAlignmentEditorHandler { + @Override + public void doExecute(ExecutionEvent event, AlignmentEditor editor) throws ExecutionException { + //TODO implement + } } -- 2.34.1