ShowPherogramHandler now also handles single reads without attached pherograms.
authorb.stoever <b.stoever@localhost>
Wed, 1 Jul 2015 16:03:18 +0000 (16:03 +0000)
committerb.stoever <b.stoever@localhost>
Wed, 1 Jul 2015 16:03:18 +0000 (16:03 +0000)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/handler/ShowPherogramHandler.java

index 8d7d2b242617a4e868ad3ab37e3b2b888374c9b6..d6d2cdb841dba88301435a78a074bf0a61e71dc2 100644 (file)
@@ -37,13 +37,17 @@ public class ShowPherogramHandler extends AbstractHandler {
                ISelection currentSelection = HandlerUtil.getCurrentSelection(event);\r
                TreeNode treeNodeOfSelection = EditorUtil.getTreeNodeOfSelection(currentSelection);\r
                if (treeNodeOfSelection != null && treeNodeOfSelection.getValue() instanceof SingleRead) {\r
-//                 SingleRead singleRead = (SingleRead)treeNodeOfSelection.getValue();\r
-//                 singleRead.get\r
                    //TODO Can the parent node (containing the cut positions) be extracted from SingleRead?\r
-\r
                        try {\r
-                           showPherogram(new PherogramComponentModel(AlignmentEditor.readPherogram(MediaUtils.getFirstMediaRepresentationPart(\r
-                           ((SingleRead)treeNodeOfSelection.getValue()).getPherogram()).getUri())));\r
+                           SingleRead singleRead = (SingleRead)treeNodeOfSelection.getValue();\r
+                           if (singleRead.getPherogram() == null) {\r
+                       MessagingUtils.messageDialog("No pherogram available", this,\r
+                               "The selected read does not have an associated pherogram.");\r
+                           }\r
+                           else {\r
+                     showPherogram(new PherogramComponentModel(AlignmentEditor.readPherogram(\r
+                             MediaUtils.getFirstMediaRepresentationPart(singleRead.getPherogram()).getUri())));\r
+                           }\r
                        }\r
                catch (Exception e) {\r
                    MessagingUtils.errorDialog("Error", null, e.getLocalizedMessage(), "eu.etaxonomy.taxeditor.editor",  //TODO Is null a valid value here?\r