Fixed NPE when loading single reads without attached pherogram.
authorb.stoever <b.stoever@localhost>
Mon, 17 Aug 2015 10:56:22 +0000 (10:56 +0000)
committerb.stoever <b.stoever@localhost>
Mon, 17 Aug 2015 10:56:22 +0000 (10:56 +0000)
eu.etaxonomy.taxeditor.molecular/src/main/java/eu/etaxonomy/taxeditor/molecular/editor/AlignmentEditor.java

index 315e92d..f967fc8 100644 (file)
@@ -692,30 +692,32 @@ public class AlignmentEditor extends EditorPart {
 
                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);
-               }
+                   
+                   if (pherogramProvider != null) {
+                       // 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