According commands moved to new package.
authorb.stoever <b.stoever@localhost>
Fri, 27 Mar 2015 16:56:17 +0000 (16:56 +0000)
committerb.stoever <b.stoever@localhost>
Fri, 27 Mar 2015 16:56:17 +0000 (16:56 +0000)
Some placeholder handlers for new AlignmentEditor commands created.
Saving methods in AlignmentEditor adjusted and firing of dirty events implemented.

.gitattributes
eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/CreateConsensusSequenceHandler.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ReverseComplementHandler.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleInsertOverwriteHandler.java [moved from eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/ToggleInsertOverwriteHandler.java with 93% similarity]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/ToggleLeftRightInsertionHandler.java [moved from eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/ToggleLeftRightInsertionHandler.java with 94% similarity]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/alignmenteditor/UpdateConsensusSequenceHandler.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/AlignmentEditor.java

index 801c135..e1e611d 100644 (file)
@@ -409,8 +409,11 @@ 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/ToggleInsertOverwriteHandler.java -text
-eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/ToggleLeftRightInsertionHandler.java -text
+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/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/UpdateConsensusSequenceHandler.java -text
 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
index 3aca8a5..abf1ecd 100644 (file)
             commandId="eu.etaxonomy.taxeditor.editor.handler.FixClassificationHierarchyHandler">
       </handler>
       <handler
-            class="eu.etaxonomy.taxeditor.editor.handler.ToggleInsertOverwriteHandler"
+            class="eu.etaxonomy.taxeditor.editor.handler.alignmenteditor.ToggleInsertOverwriteHandler"
             commandId="eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor.toggleInsertOverwrite">
       </handler>
       <handler
-            class="eu.etaxonomy.taxeditor.editor.handler.ToggleLeftRightInsertionHandler"
+            class="eu.etaxonomy.taxeditor.editor.handler.alignmenteditor.ToggleLeftRightInsertionHandler"
             commandId="eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor.toggleLeftRightInsertion">
       </handler>
    </extension>
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
new file mode 100644 (file)
index 0000000..64de1b1
--- /dev/null
@@ -0,0 +1,31 @@
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\r
+* \r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.taxeditor.editor.handler.alignmenteditor;\r
+\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.ui.IEditorPart;\r
+\r
+import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor;\r
+import eu.etaxonomy.taxeditor.model.AbstractUtility;\r
+\r
+\r
+\r
+public class CreateConsensusSequenceHandler extends AbstractHandler {\r
+       @Override\r
+       public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        IEditorPart activeEditor = AbstractUtility.getActiveEditor();\r
+        if (activeEditor instanceof AlignmentEditor) {\r
+               //((AlignmentEditor)activeEditor).;\r
+        }\r
+        return null;\r
+       }\r
+}\r
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
new file mode 100644 (file)
index 0000000..e3065ab
--- /dev/null
@@ -0,0 +1,37 @@
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\r
+* \r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.taxeditor.editor.handler.alignmenteditor;\r
+\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.ui.IEditorPart;\r
+\r
+import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor;\r
+import eu.etaxonomy.taxeditor.model.AbstractUtility;\r
+\r
+\r
+\r
+/**\r
+ * Reverse complements the single read sequence in an active {@link AlignmentEditor}, where the alignment cursor \r
+ * is currently located. \r
+ * \r
+ * @author Ben Stöver\r
+ */\r
+public class ReverseComplementHandler extends AbstractHandler {\r
+       @Override\r
+       public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        IEditorPart activeEditor = AbstractUtility.getActiveEditor();\r
+        if (activeEditor instanceof AlignmentEditor) {\r
+               ((AlignmentEditor)activeEditor).reverseComplementSelection();\r
+        }\r
+        return null;\r
+       }\r
+}\r
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
new file mode 100644 (file)
index 0000000..58e93a7
--- /dev/null
@@ -0,0 +1,31 @@
+/**\r
+* Copyright (C) 2007 EDIT\r
+* European Distributed Institute of Taxonomy \r
+* http://www.e-taxonomy.eu\r
+* \r
+* The contents of this file are subject to the Mozilla Public License Version 1.1\r
+* See LICENSE.TXT at the top of this package for the full license terms.\r
+*/\r
+package eu.etaxonomy.taxeditor.editor.handler.alignmenteditor;\r
+\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.ui.IEditorPart;\r
+\r
+import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor;\r
+import eu.etaxonomy.taxeditor.model.AbstractUtility;\r
+\r
+\r
+\r
+public class UpdateConsensusSequenceHandler extends AbstractHandler {\r
+       @Override\r
+       public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        IEditorPart activeEditor = AbstractUtility.getActiveEditor();\r
+        if (activeEditor instanceof AlignmentEditor) {\r
+               //((AlignmentEditor)activeEditor).;\r
+        }\r
+        return null;\r
+       }\r
+}\r
index 75eb41c..d78d055 100644 (file)
@@ -11,6 +11,7 @@ package eu.etaxonomy.taxeditor.editor.molecular;
 
 
 import info.bioinfweb.libralign.alignmentarea.AlignmentArea;
+import info.bioinfweb.libralign.alignmentarea.selection.SelectionModel;
 import info.bioinfweb.libralign.dataarea.implementations.ConsensusSequenceArea;
 import info.bioinfweb.libralign.dataarea.implementations.SequenceIndexArea;
 import info.bioinfweb.libralign.dataarea.implementations.pherogram.PherogramAlignmentModel;
@@ -54,6 +55,7 @@ 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;
@@ -67,8 +69,8 @@ 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.taxeditor.editor.handler.ToggleInsertOverwriteHandler;
-import eu.etaxonomy.taxeditor.editor.handler.ToggleLeftRightInsertionHandler;
+import eu.etaxonomy.taxeditor.editor.handler.alignmenteditor.ToggleInsertOverwriteHandler;
+import eu.etaxonomy.taxeditor.editor.handler.alignmenteditor.ToggleLeftRightInsertionHandler;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 
@@ -86,8 +88,6 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
 public class AlignmentEditor extends EditorPart {
     public static final String ID = "eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditor";
 
-    private final ConversationHolder conversationHolder;
-
        public static final int READS_AREA_INDEX = 1;
        public static final int CONSENSUS_AREA_INDEX = READS_AREA_INDEX + 1;
        public static final int PHEROGRAM_AREA_INDEX = 0;
@@ -95,6 +95,8 @@ public class AlignmentEditor extends EditorPart {
        public static final String CONSENSUS_NAME = "Consensus";
 
 
+    private final ConversationHolder conversationHolder;
+
        private final SequenceDataChangeListener DIRTY_LISTENER = new SequenceDataChangeListener() {
                                @Override
                                public <T> void afterTokenChange(TokenChangeEvent<T> e) {
@@ -329,9 +331,10 @@ public class AlignmentEditor extends EditorPart {
      */
     @Override
     public void doSave(IProgressMonitor monitor) {
-       System.out.println("save 1");
        if (getEditorInput() instanceof AlignmentEditorInput) {
-               System.out.println("save 2");
+               String taskName = "Saving alignment";
+            monitor.beginTask(taskName, 3);
+               
                Sequence sequenceNode = ((AlignmentEditorInput)getEditorInput()).getSequenceNode();
                StringAdapter stringProvider = new StringAdapter(getConsensusArea().getSequenceProvider(), false);  // Throws an exception if a token has more than one character.
 
@@ -352,7 +355,6 @@ public class AlignmentEditor extends EditorPart {
                Iterator<Integer> iterator = getReadsArea().getSequenceProvider().sequenceIDIterator();
                while (iterator.hasNext()) {
                        int id = iterator.next();
-                       System.out.println("Saving sequence " + id);
                        SingleReadAlignment singleRead = cdmMap.get(id);
                        if (singleRead == null) {
                                //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?
@@ -362,25 +364,25 @@ public class AlignmentEditor extends EditorPart {
                        singleRead.setEditedSequence(stringProvider.getSequence(id));
                        singleRead.setReverseComplement(getPherogramArea(id).getProvider() instanceof ReverseComplementPherogramProvider);  // Works only if ReverseComplementPherogramProvider instances are not nested.
                        singleRead.setShifts(convertToCDMShifts(getPherogramArea(id).getAlignmentModel()));
-                       System.out.println(singleRead.getShifts());
                }
-       }
 
-       String taskName = "Saving alignment";
-        monitor.beginTask(taskName, 3);
-        if (!conversationHolder.isBound()) {
-            conversationHolder.bind();
-        }
-        monitor.worked(1);
+               if (!conversationHolder.isBound()) {
+                conversationHolder.bind();
+            }
+            monitor.worked(1);
 
-        // commit the conversation and start a new transaction immediately
-        conversationHolder.commit(true);
-        monitor.worked(1);
+            // Commit the conversation and start a new transaction immediately:
+            conversationHolder.commit(true);
+            monitor.worked(1);
 
-        dirty = false;  //TODO "*" is not removed from editor title. Why not? (Should be save action in the tool bar be disabled when isDirty() returns false? This is also not the case.)
-        monitor.worked(1);
-        monitor.done();
-        firePropertyChange(PROP_DIRTY);
+            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.
+       }
     }
 
 
@@ -412,6 +414,7 @@ public class AlignmentEditor extends EditorPart {
 
     private void setDirty() {
        dirty = true;
+       firePropertyChange(IEditorPart.PROP_DIRTY);
     }
 
 
@@ -452,6 +455,22 @@ public class AlignmentEditor extends EditorPart {
     }
 
 
+    public void reverseComplementSelection() {
+       SelectionModel selection = getReadsArea().getSelection();
+       SequenceDataProvider<?> provider = getReadsArea().getSequenceProvider();
+       for (int row = selection.getStartRow(); row < selection.getStartRow() + selection.getCursorHeight(); row++) {
+                       int sequenceID = getReadsArea().getSequenceOrder().idByIndex(row);
+                       //TODO rc edited sequence
+                       
+                       if (getPherogramArea(sequenceID).getProvider() instanceof ReverseComplementPherogramProvider) {
+                               //getPherogramArea(sequenceID).
+                               //TODO Allow to set new provider in PherogramArea or create new PherogramArea
+                               //TODO Reposition pherogram according to previous position in edited sequence and length
+                       }
+               }
+    }
+    
+    
        public static PherogramProvider readPherogram(URI uri) throws IOException, UnsupportedChromatogramFormatException {
                PherogramProvider result;
                InputStream stream = uri.toURL().openStream();
@@ -530,7 +549,7 @@ public class AlignmentEditor extends EditorPart {
                PherogramArea pherogramArea = new PherogramArea(getReadsArea().getContentArea(), pherogramProvider);
 
                // Set shifts:
-               if (shifts != null) {
+               if ((shifts != null) && (shifts.length > 0)) {
                        PherogramAlignmentModel alignmentModel = pherogramArea.getAlignmentModel();
                        for (int i = 0; i < shifts.length; i++) {
                                alignmentModel.addShiftChange(shifts[i].position, shifts[i].shift);