Set wrapped mode even if false
[jalview.git] / src / jalview / gui / DasSourceBrowser.java
index f57967c..e8109c7 100755 (executable)
@@ -27,8 +27,9 @@ import javax.swing.*;
 import java.util.*;\r
 \r
 \r
-import org.biojava.services.das.registry.DasCoordinateSystem;\r
-import org.biojava.services.das.registry.DasSource;\r
+import org.biojava.dasobert.dasregistry.DasCoordinateSystem;\r
+import org.biojava.dasobert.dasregistry.DasSource;\r
+import org.biojava.dasobert.dasregistry.Das1Source;\r
 import java.awt.BorderLayout;\r
 \r
 public class DasSourceBrowser extends GDasSourceBrowser\r
@@ -43,16 +44,16 @@ public class DasSourceBrowser extends GDasSourceBrowser
   public DasSourceBrowser()\r
   {\r
     registryURL.setText(jalview.bin.Cache.getDefault("DAS_REGISTRY_URL",\r
-        "http://servlet.sanger.ac.uk/dasregistry/services/das_registry") );\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
@@ -212,7 +213,9 @@ public class DasSourceBrowser extends GDasSourceBrowser
       text.append("<font color=\"#0000FF\">Description:</font> " +\r
                   dasSources[i].getDescription() + "<br>");\r
 \r
-      if (dasSources[i].getHelperurl().length() > 0)\r
+\r
+      if (dasSources[i].getHelperurl()!=null\r
+          && dasSources[i].getHelperurl().length() > 0)\r
       {\r
         text.append("<font color=\"#0000FF\"><a href=\"" +\r
                     dasSources[i].getHelperurl()\r
@@ -237,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
@@ -249,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
@@ -270,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 (!authority.contains(dcs[j].getName()))\r
+          authority.addElement(dcs[j].getName());\r
+      }\r
 \r
-        if (!vcoords2.contains(dcs[j].getName()))\r
-          vcoords2.addElement(dcs[j].getName());\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
@@ -354,7 +379,7 @@ public class DasSourceBrowser extends GDasSourceBrowser
        if(!urltf.getText().endsWith("/"))\r
          urltf.setText(urltf.getText()+"/");\r
 \r
-       DasSource local = new DasSource();\r
+       Das1Source local = new Das1Source();\r
 \r
        local.setUrl(urltf.getText());\r
        local.setNickname(nametf.getText());\r
@@ -517,7 +542,7 @@ public class DasSourceBrowser extends GDasSourceBrowser
         String key = en.nextElement().toString();\r
         data[index][0] = key;\r
         data[index][1] = new Boolean(false);\r
-        tmp[index] = new DasSource();\r
+        tmp[index] = new Das1Source();\r
         tmp[index].setNickname(key);\r
         tmp[index].setUrl( ((DasSource)localSources.get(key)).getUrl() );\r
 \r
@@ -545,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
@@ -558,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
@@ -582,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
@@ -621,7 +656,7 @@ public class DasSourceBrowser extends GDasSourceBrowser
        {\r
          String token = st.nextToken();\r
          int bar = token.indexOf("|");\r
-         DasSource source = new DasSource();\r
+         Das1Source source = new Das1Source();\r
 \r
          source.setUrl(token.substring(bar + 1));\r
          source.setNickname(token.substring(0, bar));\r
@@ -631,9 +666,12 @@ 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
+    if (registryURL.getText() == null || registryURL.getText().length() < 1)\r
+      properties.remove("DAS_REGISTRY_URL");\r
+    else\r
+      properties.setProperty("DAS_REGISTRY_URL", registryURL.getText());\r
 \r
     StringBuffer sb = new StringBuffer();\r
     for(int r=0; r<table.getModel().getRowCount(); r++)\r