moved to org.biojava
[jalview.git] / src / jalview / gui / DasSourceBrowser.java
index 0f4cf5f..7875d7b 100755 (executable)
@@ -44,16 +44,16 @@ public class DasSourceBrowser extends GDasSourceBrowser
   public DasSourceBrowser()\r
   {\r
     registryURL.setText(jalview.bin.Cache.getDefault("DAS_REGISTRY_URL",\r
-        "http://www.spice-3d.org/dasregistry/das1/sources") );\r
+        "http://das.sanger.ac.uk/registry/das1/sources/") );\r
 \r
     setSelectedFromProperties();\r
 \r
     displayFullDetails(null);\r
     table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
 \r
-    capabilities.addListSelectionListener(this);\r
-    coords1.addListSelectionListener(this);\r
-    coords2.addListSelectionListener(this);\r
+    filter1.addListSelectionListener(this);\r
+    filter2.addListSelectionListener(this);\r
+    filter3.addListSelectionListener(this);\r
 \r
     //Ask to be notified of selection changes.\r
     ListSelectionModel rowSM = table.getSelectionModel();\r
@@ -240,6 +240,7 @@ public class DasSourceBrowser extends GDasSourceBrowser
 \r
   public void run()\r
   {\r
+\r
     addLocal.setVisible(false);\r
     refresh.setVisible(false);\r
     progressBar.setVisible(true);\r
@@ -252,6 +253,25 @@ public class DasSourceBrowser extends GDasSourceBrowser
     init();\r
   }\r
 \r
+  public Vector getSelectedSources()\r
+  {\r
+    Vector selected = new Vector();\r
+    for (int r = 0; r < selectedSources.size(); r++)\r
+    {\r
+        for (int i = 0; i < dasSources.length; i++)\r
+        {\r
+          if (dasSources[i].getNickname().equals(\r
+              selectedSources.elementAt(r)))\r
+          {\r
+            selected.addElement(dasSources[i]);\r
+            break;\r
+          }\r
+        }\r
+    }\r
+\r
+    return selected;\r
+  }\r
+\r
   public DasSource[] getDASSource()\r
   {\r
     if(dasSources==null)\r
@@ -273,49 +293,51 @@ public class DasSourceBrowser extends GDasSourceBrowser
 \r
   private void setCapabilities(DasSource[] sources)\r
   {\r
-    Vector vcapabilities = new Vector();\r
-    Vector vcoords = new Vector();\r
-    Vector vcoords2 = new Vector();\r
+    Vector authority = new Vector();\r
+    Vector type = new Vector();\r
+    Vector label = new Vector();\r
 \r
-    vcapabilities.addElement("All");\r
-    vcoords.addElement("All");\r
-    vcoords2.addElement("All");\r
+    authority.addElement("Any");\r
+    type.addElement("Any");\r
+    label.addElement("Any");\r
 \r
     for (int i = 0; i < sources.length; i++)\r
     {\r
       DasSource ds = sources[i];\r
-      String[] scap = ds.getCapabilities();\r
-      for (int s = 0; s < scap.length; s++)\r
-      {\r
-        if (!vcapabilities.contains(scap[s]))\r
-        {\r
-          vcapabilities.addElement(scap[s]);\r
-        }\r
-      }\r
 \r
       DasCoordinateSystem[] dcs = ds.getCoordinateSystem();\r
 \r
       for (int j = 0; j < dcs.length; j++)\r
       {\r
-        if (!vcoords.contains(dcs[j].getCategory()))\r
-          vcoords.addElement(dcs[j].getCategory());\r
+        if (!type.contains(dcs[j].getCategory()))\r
+          type.addElement(dcs[j].getCategory());\r
 \r
-        if (!vcoords2.contains(dcs[j].getName()))\r
-          vcoords2.addElement(dcs[j].getName());\r
+        if (!authority.contains(dcs[j].getName()))\r
+          authority.addElement(dcs[j].getName());\r
       }\r
+\r
+      String[] slabels = ds.getLabels();\r
+      for (int s = 0; s < slabels.length; s++)\r
+      {\r
+        if (!label.contains(slabels[s]))\r
+        {\r
+          label.addElement(slabels[s]);\r
+        }\r
+      }\r
+\r
     }\r
 \r
-    capabilities.setListData(vcapabilities);\r
-    coords1.setListData(vcoords);\r
-    coords2.setListData(vcoords2);\r
+    filter1.setListData(authority);\r
+    filter2.setListData(type);\r
+    filter3.setListData(label);\r
 \r
     javax.swing.SwingUtilities.invokeLater(new Runnable()\r
     {\r
       public void run()\r
       {\r
-        capabilities.setSelectedIndex(0);\r
-        coords1.setSelectedIndex(0);\r
-        coords2.setSelectedIndex(0);\r
+        filter1.setSelectedIndex(0);\r
+        filter2.setSelectedIndex(0);\r
+        filter3.setSelectedIndex(0);\r
       }\r
     });\r
   }\r
@@ -548,12 +570,19 @@ public class DasSourceBrowser extends GDasSourceBrowser
     ArrayList selected = new ArrayList();\r
     DasSource ds;\r
 \r
+    //The features filter is not visible, but we must still\r
+    //filter the das source list here.\r
+    //July 2006 - only 6 sources fo not serve features\r
+    Object [] dummyFeatureList = new Object[]{"features"};\r
+\r
     // capabilities.get\r
     for (int i = 0; i < dSize; i++)\r
     {\r
       ds = dasSources[i];\r
 \r
-      if (!selectedInList(capabilities, ds.getCapabilities()))\r
+      if (!selectedInList(dummyFeatureList, ds.getCapabilities())\r
+      ||  !selectedInList(filter3.getSelectedValues(),\r
+                          ds.getLabels()))\r
       {\r
         continue;\r
       }\r
@@ -561,10 +590,14 @@ public class DasSourceBrowser extends GDasSourceBrowser
       DasCoordinateSystem[] dcs = ds.getCoordinateSystem();\r
       for (int j = 0; j < dcs.length; j++)\r
       {\r
-        if (selectedInList(coords1, new String[]\r
-                           {dcs[j].getCategory()})\r
-            && selectedInList(coords2, new String[]\r
-                              {dcs[j].getName()}))\r
+        if (selectedInList(dummyFeatureList,ds.getCapabilities())\r
+        &&\r
+            selectedInList(filter1.getSelectedValues(),\r
+                           new String[]\r
+                           {dcs[j].getName()})\r
+            && selectedInList(filter2.getSelectedValues(),\r
+                              new String[]\r
+                              {dcs[j].getCategory()}))\r
         {\r
           names.add(ds.getNickname());\r
           selected.add(new Boolean(\r
@@ -585,12 +618,11 @@ public class DasSourceBrowser extends GDasSourceBrowser
     refreshTableData(data);\r
   }\r
 \r
-  boolean selectedInList(JList list, String[] items)\r
+  boolean selectedInList(Object [] selection, String[] items)\r
   {\r
-    Object[] selection = list.getSelectedValues();\r
     for (int i = 0; i < selection.length; i++)\r
     {\r
-      if (selection[i].equals("All"))\r
+      if (selection[i].equals("Any"))\r
         return true;\r
 \r
       for (int j = 0; j < items.length; j++)\r
@@ -634,7 +666,7 @@ public class DasSourceBrowser extends GDasSourceBrowser
      }\r
   }\r
 \r
-  void saveProperties(Properties properties)\r
+  public void saveProperties(Properties properties)\r
   {\r
     properties.setProperty("DAS_REGISTRY_URL", registryURL.getText());\r
 \r