Initial implementation of CDM data reading and writing in AlignmentEditor.
authorb.stoever <b.stoever@localhost>
Sat, 21 Mar 2015 18:22:45 +0000 (18:22 +0000)
committerb.stoever <b.stoever@localhost>
Sat, 21 Mar 2015 18:22:45 +0000 (18:22 +0000)
Minor changes.

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/EditSequenceHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/LoadPherogramHandler.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/OpenAlignmentEditor.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/AlignmentEditor.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/AlignmentEditorInput.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/molecular/PherogramMouseListener.java

index ea3dc5a402c530536159d458400a7465c4b5d94d..d6aa37d47058bdd72e0741344e099961dc90eea8 100644 (file)
@@ -1,4 +1,6 @@
 package eu.etaxonomy.taxeditor.editor.handler;
+
+
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
@@ -12,39 +14,34 @@ import org.eclipse.jface.viewers.TreeNode;
 import org.eclipse.ui.PartInitException;
 import org.eclipse.ui.handlers.HandlerUtil;
 
-import eu.etaxonomy.cdm.model.media.Media;
-import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
-import eu.etaxonomy.cdm.model.media.MediaUtils;
 import eu.etaxonomy.cdm.model.molecular.Sequence;
 import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.editor.molecular.AlignmentEditorInput;
 
 
-public class EditSequenceHandler extends AbstractHandler {
 
+/**
+ * Opens the alignment editor from the CDM tree.
+ * 
+ * @author Ben St&ouml;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){
-            Sequence sequence = (Sequence)treeNodeOfSelection.getValue();
-            List<URI> pherogramUris = new ArrayList<URI>();
-            Set<Media> pherograms = sequence.getPherograms();
-            for (Media media : pherograms) {
-                MediaRepresentationPart firstMediaRepresentationPart = MediaUtils.getFirstMediaRepresentationPart(media);
-                if(firstMediaRepresentationPart!=null){
-                    pherogramUris.add(firstMediaRepresentationPart.getUri());
-                }
+        if(treeNodeOfSelection != null && treeNodeOfSelection.getValue() instanceof Sequence){
+            AlignmentEditorInput input = new AlignmentEditorInput((Sequence)treeNodeOfSelection.getValue());  //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();
             }
         }
-        AlignmentEditorInput input = new AlignmentEditorInput();
-        try {
-            EditorUtil.open(input);
-        } catch (PartInitException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
+        
         return null;
     }
-
 }
index 0d53ed3139c7281c95ffab0a0931eab641df296e..a803a64d6b58b4595eaa22a71dedd0080d63e028 100644 (file)
@@ -51,7 +51,7 @@ public class LoadPherogramHandler extends AbstractHandler {
             String path = fileDialog.open();
             if (path != null) {
                try {
-                       alignmentEditor.addRead(new File(path).toURI());
+                       alignmentEditor.addRead(new File(path).toURI(), false);
                }
                catch (UnsupportedChromatogramFormatException e) {
                     MessagingUtils.errorDialog("Unsupported format", this, "The format of the pherogram file \"" + path + 
index 5fb415c8e9a875320c3a476dd5998992af99aa66..69c9d3456ff41dbea7afc005ccf5701f7d0f4ebf 100644 (file)
@@ -34,10 +34,11 @@ public class OpenAlignmentEditor extends AbstractHandler {
      */
     @Override
     public Object execute(ExecutionEvent event) throws ExecutionException {
-        AlignmentEditorInput input = new AlignmentEditorInput();
+        AlignmentEditorInput input = new AlignmentEditorInput(null);  //TODO Does it make sense to start an empty editor?
         try {
             EditorUtil.open(input);
-        } catch (PartInitException e) {
+        } 
+        catch (PartInitException e) {
             MessagingUtils.error(OpenAlignmentEditor.class, "Could not open AlignmentEditor", e);
         }
         return null;
index a2adc2ee82c93f29a5480fd47e9d1ea1e8d24b1e..e0025ccad17d9b01fbb6613bf5004697a60e83fc 100644 (file)
@@ -11,17 +11,25 @@ package eu.etaxonomy.taxeditor.editor.molecular;
 
 
 import info.bioinfweb.libralign.alignmentarea.AlignmentArea;
-import info.bioinfweb.libralign.alignmentarea.content.AlignmentContentArea;
 import info.bioinfweb.libralign.dataarea.implementations.ConsensusSequenceArea;
 import info.bioinfweb.libralign.dataarea.implementations.SequenceIndexArea;
+import info.bioinfweb.libralign.dataarea.implementations.pherogram.PherogramAlignmentModel;
 import info.bioinfweb.libralign.dataarea.implementations.pherogram.PherogramArea;
+import info.bioinfweb.libralign.dataarea.implementations.pherogram.ShiftChange;
 import info.bioinfweb.libralign.editsettings.EditSettingsChangeEvent;
 import info.bioinfweb.libralign.editsettings.EditSettingsListener;
 import info.bioinfweb.libralign.multiplealignments.AlignmentAreaList;
 import info.bioinfweb.libralign.multiplealignments.MultipleAlignmentsContainer;
 import info.bioinfweb.libralign.pherogram.provider.BioJavaPherogramProvider;
 import info.bioinfweb.libralign.pherogram.provider.PherogramProvider;
+import info.bioinfweb.libralign.pherogram.provider.ReverseComplementPherogramProvider;
+import info.bioinfweb.libralign.sequenceprovider.SequenceDataChangeListener;
 import info.bioinfweb.libralign.sequenceprovider.SequenceDataProvider;
+import info.bioinfweb.libralign.sequenceprovider.SequenceUtils;
+import info.bioinfweb.libralign.sequenceprovider.adapters.StringAdapter;
+import info.bioinfweb.libralign.sequenceprovider.events.SequenceChangeEvent;
+import info.bioinfweb.libralign.sequenceprovider.events.SequenceRenamedEvent;
+import info.bioinfweb.libralign.sequenceprovider.events.TokenChangeEvent;
 import info.bioinfweb.libralign.sequenceprovider.implementations.PackedSequenceDataProvider;
 import info.bioinfweb.libralign.sequenceprovider.tokenset.BioJavaTokenSet;
 import info.bioinfweb.libralign.sequenceprovider.tokenset.TokenSet;
@@ -33,6 +41,7 @@ import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.TreeMap;
 
@@ -51,6 +60,11 @@ import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.commands.ICommandService;
 import org.eclipse.ui.part.EditorPart;
 
+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.taxeditor.editor.handler.ToggleInsertOverwriteHandler;
 import eu.etaxonomy.taxeditor.editor.handler.ToggleLeftRightInsertionHandler;
 
@@ -70,11 +84,38 @@ 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 CONSENSUS_AREA_INDEX = READS_AREA_INDEX + 1;
+       public static final int PHEROGRAM_AREA_INDEX = 0;
        public static final String DEFAULT_READ_NAME_PREFIX = "Read ";
+       public static final String CONSENSUS_NAME = "Consensus";
        
 
+       private final SequenceDataChangeListener DIRTY_LISTENER = new SequenceDataChangeListener() {
+                               @Override
+                               public <T> void afterTokenChange(TokenChangeEvent<T> e) {
+                                       setDirty();
+                               }
+                               
+                               @Override
+                               public <T> void afterSequenceRenamed(SequenceRenamedEvent<T> e) {
+                                       setDirty();
+                               }
+                               
+                               @Override
+                               public <T> void afterSequenceChange(SequenceChangeEvent<T> e) {
+                                       setDirty();
+                               }
+                               
+                               @Override
+                               public <T, U> void afterProviderChanged(SequenceDataProvider<T> oldProvider,
+                                               SequenceDataProvider<U> newProvider) {  // Not expected.
+                                       
+                                       setDirty();
+                               }
+                       };
+       
     private MultipleAlignmentsContainer alignmentsContainer = null;
-    private Map<Integer, URI> uriMap = new TreeMap<Integer, URI>();  //TODO Move this to ContigSequenceDataProvider
+    private Map<Integer, SingleReadAlignment> cdmMap = new TreeMap<Integer, SingleReadAlignment>();  //TODO Move this to ContigSequenceDataProvider
+    private boolean dirty = false;
 
 
     private void refreshToolbarElement(String id) {
@@ -121,6 +162,7 @@ public class AlignmentEditor extends EditorPart {
                TokenSet<NucleotideCompound> tokenSet = new BioJavaTokenSet<NucleotideCompound>(new DNACompoundSet(), true);
                SequenceDataProvider<NucleotideCompound> provider = new PackedSequenceDataProvider<NucleotideCompound>(tokenSet);
                result.setSequenceProvider(provider, false);
+               provider.getChangeListeners().add(DIRTY_LISTENER);
                
                return result;
        }
@@ -163,24 +205,22 @@ public class AlignmentEditor extends EditorPart {
     private AlignmentArea getConsensusArea() {
        return getAlignmentsContainer().getAlignmentAreas().get(CONSENSUS_AREA_INDEX);
     }
-
-
-       /* (non-Javadoc)
-     * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
-     */
-    @Override
-    public void createPartControl(Composite parent) {
-               getAlignmentsContainer().createSWTWidget(parent, SWT.NONE);
-               updateStatusBar();
-
+    
+    
+    private PherogramArea getPherogramArea(int sequenceID) {
+       return (PherogramArea)getReadsArea().getDataAreas().getSequenceAreas(sequenceID).get(PHEROGRAM_AREA_INDEX);
+    }
+    
+    
+    private void createTestContents() {
                // Just for testing:
                try {
-                       addRead(new File("D:/Users/BenStoever/Documents/Studium/Projekte/Promotion/EDITor/Quelltexte/LibrAlign branch/Repository/eu.etaxonomy.taxeditor.editor/src/main/resources/AlignmentTestData/JR430_JR-P01.ab1").toURI());
-                       addRead(new File("D:/Users/BenStoever/Documents/Studium/Projekte/Promotion/EDITor/Quelltexte/LibrAlign branch/Repository/eu.etaxonomy.taxeditor.editor/src/main/resources/AlignmentTestData/JR444_JR-P05.ab1").toURI());
+                       addRead(new File("D:/Users/BenStoever/Documents/Studium/Projekte/Promotion/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/Documents/Studium/Projekte/Promotion/EDITor/Quelltexte/LibrAlign branch/Repository/eu.etaxonomy.taxeditor.editor/src/main/resources/AlignmentTestData/JR444_JR-P05.ab1").toURI(), false);
                        
                        // Add test consensus sequence:
                        SequenceDataProvider consensusProvider = getConsensusArea().getSequenceProvider();
-                       int id = consensusProvider.addSequence("Consensus");
+                       int id = consensusProvider.addSequence(CONSENSUS_NAME);
                        Collection<Object> tokens = new ArrayList<Object>();  // First save tokens in a collection to avoid GUI updated for each token.
                        tokens.add(consensusProvider.getTokenSet().tokenByKeyChar('A'));
                        tokens.add(consensusProvider.getTokenSet().tokenByKeyChar('C'));
@@ -192,6 +232,61 @@ public class AlignmentEditor extends EditorPart {
                        throw new RuntimeException(e);
                }
     }
+
+
+    private void readCDMData() {
+       //TODO If called from somewhere else than createPartControl() the editorInput needs to be checked and previous contents need to be cleared (or updated).
+               Sequence sequenceNode = ((AlignmentEditorInput)getEditorInput()).getSequenceNode();
+               
+               // Add reads:
+               for (SingleReadAlignment singleReadAlignment : sequenceNode.getSingleReadAlignments()) {
+                       try {
+                               SingleRead pherogramInfo = singleReadAlignment.getSingleRead();
+                               int id = addRead(pherogramInfo.getPrimer().getLabel(),  //TODO Should the sequence name contain other/additional/alternative data? Can the same string as in the derivative tree be used here?
+                                               MediaUtils.getFirstMediaRepresentationPart(pherogramInfo.getPherogram()).getUri(),
+                                               singleReadAlignment.isReverseComplement(), 
+                                               singleReadAlignment.getEditedSequence(), 
+                                               singleReadAlignment.getShifts());
+                               cdmMap.put(id, singleReadAlignment);
+                       }
+                       catch (IOException e) {
+                               e.printStackTrace();  //TODO Output to user (Possibly collect for all pherograms and display in the end.)
+                       }
+                       catch (UnsupportedChromatogramFormatException e) {
+                               e.printStackTrace();  //TODO Output to user (Possibly collect for all pherograms and display in the end.)
+                       }
+               }
+               
+               // Set consensus sequence:
+               SequenceDataProvider consensusProvider = getConsensusArea().getSequenceProvider();
+               int id = consensusProvider.addSequence(CONSENSUS_NAME);
+               consensusProvider.insertTokensAt(id, 0, SequenceUtils.stringToTokenList(
+                               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) {
+               getAlignmentsContainer().createSWTWidget(parent, SWT.NONE);
+               updateStatusBar();
+               
+               if (getEditorInput() instanceof AlignmentEditorInput) {
+                       if (((AlignmentEditorInput)getEditorInput()).getSequenceNode() != null) {
+                               readCDMData();
+                       }
+                       else {
+                               createTestContents();  //TODO What to do here instead in the final version?
+                       }
+               }
+               else {
+                       throw new IllegalArgumentException("The editor input must have the type " + 
+                                       AlignmentEditorInput.class.getCanonicalName());  //TODO What should be done here?
+               }
+    }
     
     
     private void updateStatusBar() {
@@ -203,13 +298,60 @@ public class AlignmentEditor extends EditorPart {
     }
 
     
+    private SingleReadAlignment.Shift[] convertToCDMShifts(PherogramAlignmentModel alignmentModel) {
+       SingleReadAlignment.Shift[] result = new SingleReadAlignment.Shift[alignmentModel.getShiftChangeCount()];
+       Iterator<ShiftChange> iterator = alignmentModel.shiftChangeIterator();
+       int pos = 0;
+       while (iterator.hasNext()) {
+               ShiftChange shiftChange = iterator.next();
+               result[pos] = new SingleReadAlignment.Shift(shiftChange.getBaseCallIndex(), shiftChange.getShiftChange());
+       }
+       return result;
+    }
+    
+    
     /* (non-Javadoc)
      * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
      */
     @Override
     public void doSave(IProgressMonitor monitor) {
-        // TODO Auto-generated method stub
-
+       System.out.println("save 1");
+       if (getEditorInput() instanceof AlignmentEditorInput) {
+               System.out.println("save 2");
+               Sequence sequenceNode = ((AlignmentEditorInput)getEditorInput()).getSequenceNode();
+               StringAdapter stringProvider = new StringAdapter(getConsensusArea().getSequenceProvider(), false);  // Throws an exception if a token has more than one character.
+               
+               // Write consensus sequence:
+               SequenceString consensusSequenceObj = sequenceNode.getConsensusSequence();
+               String newConsensusSequence = stringProvider.getSequence(
+                               getConsensusArea().getSequenceProvider().sequenceIDByName(CONSENSUS_NAME));
+               if (consensusSequenceObj == null) {
+                       sequenceNode.setConsensusSequence(SequenceString.NewInstance(newConsensusSequence));
+               }
+               else {
+                       consensusSequenceObj.setString(newConsensusSequence);
+               }
+               
+               // Write single reads:
+               stringProvider.setUnderlyingProvider(getReadsArea().getSequenceProvider());
+               sequenceNode.getSingleReadAlignments().retainAll(cdmMap.values());  // Remove all reads that are not in the alignment anymore.
+               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?
+                               //singleRead = SingleReadAlignment.NewInstance(consensusSequence, singleRead, shifts, editedSequence);
+                       }
+                       
+                       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());
+               }
+       }
+       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.)
     }
     
 
@@ -217,10 +359,7 @@ public class AlignmentEditor extends EditorPart {
      * @see org.eclipse.ui.part.EditorPart#doSaveAs()
      */
     @Override
-    public void doSaveAs() {
-        // TODO Auto-generated method stub
-
-    }
+    public void doSaveAs() {}
     
 
     /* (non-Javadoc)
@@ -238,8 +377,12 @@ public class AlignmentEditor extends EditorPart {
      */
     @Override
     public boolean isDirty() {
-        // TODO Auto-generated method stub
-        return false;
+        return dirty;
+    }
+    
+    
+    private void setDirty() {
+       dirty = true;
     }
     
 
@@ -248,8 +391,7 @@ public class AlignmentEditor extends EditorPart {
      */
     @Override
     public boolean isSaveAsAllowed() {
-        // TODO Auto-generated method stub
-        return false;
+        return false;  // "Save as" not allowed.
     }
     
 
@@ -301,33 +443,73 @@ public class AlignmentEditor extends EditorPart {
        }
 
        
-    public void addRead(URI pherogramURI) throws IOException, UnsupportedChromatogramFormatException {
-       addRead(newReadName(), pherogramURI);
+    public void addRead(URI pherogramURI, boolean reverseComplemented) throws IOException, UnsupportedChromatogramFormatException {
+       addRead(newReadName(), pherogramURI, reverseComplemented, null, null);
     }
     
     
-    public void addRead(String name, URI pherogramURI) throws IOException, UnsupportedChromatogramFormatException {
+    /**
+     * Adds a new sequence with attached phergram data area to the reads alignment.
+     * <p>
+     * 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, 
+               SingleReadAlignment.Shift[] shifts) throws IOException, UnsupportedChromatogramFormatException {
+       
                SequenceDataProvider provider = getReadsArea().getSequenceProvider();
                PherogramProvider 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);
                
-               // Copy base call sequence into alignment:
-               Collection<Object> tokens = new ArrayList<Object>();  // First save tokens in a collection to avoid GUI updated for each token.
-               for (int i = 0; i < pherogramProvider.getSequenceLength(); i++) {
-                       tokens.add(provider.getTokenSet().tokenByKeyChar(
-                               pherogramProvider.getBaseCall(i).getUpperedBase().charAt(0)));
+               // Set edited sequence: 
+               Collection<Object> tokens;  // First save tokens in a collection to avoid GUI updated for each token.
+               if (editedSequence != null) {
+                       tokens = SequenceUtils.stringToTokenList(editedSequence, provider.getTokenSet());
+               }
+               else {  // Copy base call sequence into alignment:
+                       tokens = new ArrayList<Object>();
+                       for (int i = 0; i < pherogramProvider.getSequenceLength(); i++) {
+                               tokens.add(provider.getTokenSet().tokenByKeyChar(
+                                       pherogramProvider.getBaseCall(i).getUpperedBase().charAt(0)));
+                       }
+                       setDirty();
                }
                provider.insertTokensAt(id, 0, tokens);
                
-               // Add data area:
+               // Create pherogram area:
                PherogramArea pherogramArea = new PherogramArea(getReadsArea().getContentArea(), pherogramProvider);
+
+               // Set shifts:
+               if (shifts != null) {
+                       PherogramAlignmentModel alignmentModel = pherogramArea.getAlignmentModel();
+                       for (int i = 0; i < shifts.length; i++) {
+                               alignmentModel.addShiftChange(shifts[i].position, shifts[i].shift);
+                       }
+                       setDirty();
+               }
+               
+               // Add pherogram area to GUI:
                pherogramArea.addMouseListener(new PherogramMouseListener(pherogramURI));
                getReadsArea().getDataAreas().getSequenceAreas(id).add(pherogramArea);
                
                // Save source URI:
-               uriMap.put(id, pherogramURI);
+               return id;
        }
 }
\ No newline at end of file
index 9d25d6677ae2904a61afbda4e8100e9aadff5941..1664a0895fee2f8c17cc36bbcb2462b4e395240e 100644 (file)
@@ -14,6 +14,8 @@ import org.eclipse.jface.resource.ImageDescriptor;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IPersistableElement;
 
+import eu.etaxonomy.cdm.model.molecular.Sequence;
+
 
 
 /**
@@ -24,8 +26,17 @@ import org.eclipse.ui.IPersistableElement;
 public class AlignmentEditorInput implements IEditorInput {
     private static final String name = "AlignmentEditor";
     
+    
+    private final Sequence sequenceNode;
+    
 
-    /* (non-Javadoc)
+    public AlignmentEditorInput(Sequence sequenceNode) {
+               super();
+               this.sequenceNode = sequenceNode;
+       }
+
+
+       /* (non-Javadoc)
      * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
      */
     @Override
@@ -80,4 +91,15 @@ public class AlignmentEditorInput implements IEditorInput {
     public String getToolTipText() {
         return name;
     }
+
+
+       /**
+        * Returns the sequence CDM node that should be edited by the {@link AlignmentEditor} this object
+        * is used with.
+        * 
+        * @return the CDM node to work on
+        */
+       public Sequence getSequenceNode() {
+               return sequenceNode;
+       }
 }
index 2fce3dfb1dbeff2546da97dd5b5754291cb1c93b..25a454c3e15ff75c54013a39eb1bf70003b93297 100644 (file)
@@ -12,7 +12,6 @@ package eu.etaxonomy.taxeditor.editor.molecular;
 import info.bioinfweb.commons.tic.input.TICMouseAdapter;\r
 import info.bioinfweb.commons.tic.input.TICMouseEvent;\r
 \r
-import java.io.File;\r
 import java.net.URI;\r
 \r
 import eu.etaxonomy.taxeditor.model.MessagingUtils;\r
@@ -42,7 +41,8 @@ public class PherogramMouseListener extends TICMouseAdapter {
                                PherogramViewPart.createView(uri);\r
                        }\r
                        catch (Exception e) {\r
-                               MessagingUtils.errorDialog("Error", this, e.getLocalizedMessage(), "eu.etaxonomy.taxeditor.editor", e, false);  //TODO set pluginID\r
+                               MessagingUtils.errorDialog("Error", this, e.getLocalizedMessage(), "eu.etaxonomy.taxeditor.editor", \r
+                                               e, false);  //TODO set pluginID\r
                        }\r
                }\r
        }\r