From: Jim Procter Date: Tue, 27 Aug 2013 14:42:06 +0000 (+0100) Subject: JAL-1332 regression from 7ce72ca7fadf35a249427ecb836b22abb04ab653 - allow 'null'... X-Git-Tag: Jalview_2_9~224^2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6b1d4e765d7a6beafcc1eb1fec38e041f3fb780f;p=jalview.git JAL-1332 regression from 7ce72ca7fadf35a249427ecb836b22abb04ab653 - allow 'null' context to be used (for test/src/jalview/ws/jabaws/TestDisorderAnnotExportImport where Desktop is not created before an AlignFrame is constructed) --- diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index 7415712..8d684c1 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -53,13 +53,25 @@ public class StructureSelectionManager } Hashtable mappingData = new Hashtable(); - + private static StructureSelectionManager nullProvider = null; public static StructureSelectionManager getStructureSelectionManager( StructureSelectionManagerProvider context) { - if (context==null) - { - throw new Error("Implementation error. Structure selection manager's context is 'null'", new NullPointerException("SSM context is null")); + if (context==null) { + if (nullProvider == null) + { + if (instances != null) + { + throw new Error( + "Implementation error. Structure selection manager's context is 'null'", + new NullPointerException("SSM context is null")); + } + else + { + nullProvider = new StructureSelectionManager(); + } + return nullProvider; + } } if (instances == null) { @@ -68,7 +80,13 @@ public class StructureSelectionManager StructureSelectionManager instance = instances.get(context); if (instance == null) { - instances.put(context, instance = new StructureSelectionManager()); + if (nullProvider!=null) + { + instance = nullProvider; + } else { + instance = new StructureSelectionManager(); + } + instances.put(context, instance); } return instance; }