debug local source management buttons and formatting
authorjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 1 Mar 2012 11:05:17 +0000 (11:05 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Thu, 1 Mar 2012 11:05:17 +0000 (11:05 +0000)
src/jalview/gui/DasSourceBrowser.java
src/jalview/ws/dbsources/das/datamodel/DasSourceRegistry.java

index 9edb8b0..40d936e 100755 (executable)
@@ -538,10 +538,8 @@ public class DasSourceBrowser extends GDasSourceBrowser implements
       sourceRegistry.removeLocalSource(sourceRegistry.getSource(nickname));\r
       selectedSources.remove(nickname);\r
       Object[][] data = new Object[sourceRegistry.getSources().size()][2];\r
-      DASTableModel dtm = (table != null) ? (DASTableModel) table\r
-              .getModel() : null;\r
       int index = 0,\r
-      l = dtm.getRowCount();\r
+      l = table.getRowCount();\r
 \r
       for (int i = 0; i < l; i++)\r
       {\r
index cf78202..7257d0c 100644 (file)
@@ -98,7 +98,8 @@ public class DasSourceRegistry implements DasSourceRegistryI,
       URL url = new URL(registryURL);
       org.biodas.jdas.client.SourcesClientInterface client = new SourcesClient();
 
-      SOURCES sources = client.fetchDataRegistry(registryURL, null, null, null, null, null, null);
+      SOURCES sources = client.fetchDataRegistry(registryURL, null, null,
+              null, null, null, null);
 
       List<SOURCE> dassources = sources.getSOURCE();
       ArrayList<jalviewSourceI> dsrc = new ArrayList<jalviewSourceI>();
@@ -116,7 +117,6 @@ public class DasSourceRegistry implements DasSourceRegistryI,
     }
   }
 
-
   public void run()
   {
     getSources();
@@ -138,30 +138,35 @@ public class DasSourceRegistry implements DasSourceRegistryI,
    */
   private void addLocalDasSources()
   {
-    String local = jalview.bin.Cache.getProperty("DAS_LOCAL_SOURCE");
-    if (local != null)
+    if (localSources == null)
     {
-      StringTokenizer st = new StringTokenizer(local, "\t");
-      while (st.hasMoreTokens())
+      // get local sources from properties and initialise the local source list
+      String local = jalview.bin.Cache.getProperty("DAS_LOCAL_SOURCE");
+      if (local != null)
       {
-        String token = st.nextToken();
-        int bar = token.indexOf("|");
-        String url = token.substring(bar + 1);
-        boolean features = true, sequence = false;
-        if (url.startsWith("sequence:"))
+        StringTokenizer st = new StringTokenizer(local, "\t");
+        while (st.hasMoreTokens())
         {
-          url = url.substring(9);
-          // this source also serves sequences as well as features
-          sequence = true;
+          String token = st.nextToken();
+          int bar = token.indexOf("|");
+          String url = token.substring(bar + 1);
+          boolean features = true, sequence = false;
+          if (url.startsWith("sequence:"))
+          {
+            url = url.substring(9);
+            // this source also serves sequences as well as features
+            sequence = true;
+          }
+          createLocalSource(url, token.substring(0, bar), sequence,
+                  features);
         }
-        createLocalSource(url, token.substring(0, bar), sequence, features);
       }
     }
   }
 
   private List<jalviewSourceI> appendLocalSources()
   {
-    List<jalviewSourceI> srclist=new ArrayList<jalviewSourceI>();
+    List<jalviewSourceI> srclist = new ArrayList<jalviewSourceI>();
     addLocalDasSources();
     sourceNames = new Hashtable<String, jalviewSourceI>();
     if (dasSources != null)
@@ -202,7 +207,7 @@ public class DasSourceRegistry implements DasSourceRegistryI,
     {
       localSources = new Hashtable<String, jalviewSourceI>();
     }
-    jalviewSourceI src=new JalviewSource(local, true);
+    jalviewSourceI src = new JalviewSource(local, true);
     localSources.put(local.getTitle(), src);
     return src;
   }
@@ -227,14 +232,14 @@ public class DasSourceRegistry implements DasSourceRegistryI,
        */
       CAPABILITY cap = new CAPABILITY();
       cap.setType("das1:" + Capabilities.SEQUENCE.getName());
-      cap.setQueryUri(url+"/sequence");
+      cap.setQueryUri(url + "/sequence");
       cp.add(cap);
     }
     if (features)
     {
       CAPABILITY cap = new CAPABILITY();
       cap.setType("das1:" + Capabilities.FEATURES.getName());
-      cap.setQueryUri(url+"/features");
+      cap.setQueryUri(url + "/features");
       cp.add(cap);
     }
 
@@ -258,6 +263,9 @@ public class DasSourceRegistry implements DasSourceRegistryI,
       localSources.remove(source.getTitle());
       sourceNames.remove(source.getTitle());
       dasSources.remove(source);
+      jalview.bin.Cache.setProperty("DAS_LOCAL_SOURCE",
+              getLocalSourceString());
+
       return true;
     }
     return false;