From 6b1d4e765d7a6beafcc1eb1fec38e041f3fb780f Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 27 Aug 2013 15:42:06 +0100 Subject: [PATCH] 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) --- .../structure/StructureSelectionManager.java | 28 ++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) 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; } -- 1.7.10.2