This commit was manufactured by cvs2svn to create branch 'VamJalview'.
[jalview.git] / src / jalview / gui / DasSourceBrowser.java
diff --git a/src/jalview/gui/DasSourceBrowser.java b/src/jalview/gui/DasSourceBrowser.java
new file mode 100755 (executable)
index 0000000..fc2b387
--- /dev/null
@@ -0,0 +1,810 @@
+/*\r
+ * Jalview - A Sequence Alignment Editor and Viewer\r
+ * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
+ */\r
+package jalview.gui;\r
+\r
+import jalview.jbgui.*;\r
+import javax.swing.table.AbstractTableModel;\r
+import javax.swing.event.*;\r
+import jalview.util.TableSorter;\r
+import java.awt.event.*;\r
+import javax.swing.*;\r
+import java.util.*;\r
+\r
+\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
+    implements Runnable, ListSelectionListener\r
+{\r
+  static DasSource[] dasSources = null;\r
+\r
+  Hashtable localSources = null;\r
+\r
+  Vector selectedSources;\r
+\r
+  String DEFAULT_REGISTRY = "http://das.sanger.ac.uk/registry/das1/sources/";\r
+\r
+  boolean loadingDasSources = false;\r
+\r
+\r
+  public DasSourceBrowser()\r
+  {\r
+    registryURL.setText(jalview.bin.Cache.getDefault("DAS_REGISTRY_URL",\r
+        DEFAULT_REGISTRY) );\r
+\r
+    setSelectedFromProperties();\r
+\r
+    displayFullDetails(null);\r
+    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
+\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
+    rowSM.addListSelectionListener(new ListSelectionListener()\r
+    {\r
+      public void valueChanged(ListSelectionEvent e)\r
+      {\r
+        ListSelectionModel lsm = (ListSelectionModel) e.getSource();\r
+        if (!lsm.isSelectionEmpty())\r
+        {\r
+          int selectedRow = lsm.getMinSelectionIndex();\r
+          displayFullDetails(table.getValueAt(selectedRow, 0).toString());\r
+        }\r
+      }\r
+    });\r
+\r
+    table.addMouseListener(new MouseAdapter()\r
+        {\r
+          public void mouseClicked(MouseEvent evt)\r
+          {\r
+            if(evt.getClickCount()==2\r
+               || SwingUtilities.isRightMouseButton(evt))\r
+              editRemoveLocalSource(evt);\r
+          }\r
+        });\r
+\r
+    if(dasSources!=null)\r
+    {\r
+       init();\r
+    }\r
+  }\r
+\r
+  public void paintComponent(java.awt.Graphics g)\r
+  {\r
+    if (dasSources == null && !loadingDasSources)\r
+    {\r
+      Thread worker = new Thread(this);\r
+      worker.start();\r
+    }\r
+  }\r
+\r
+  void init()\r
+  {\r
+    int dSize = dasSources.length;\r
+    Object[][] data = new Object[dSize][2];\r
+    for (int i = 0; i < dSize; i++)\r
+    {\r
+      data[i][0] = dasSources[i].getNickname();\r
+      data[i][1] = new Boolean(selectedSources.contains(dasSources[i].\r
+          getNickname()));\r
+    }\r
+\r
+    refreshTableData(data);\r
+    setCapabilities(dasSources);\r
+\r
+    javax.swing.SwingUtilities.invokeLater(new Runnable()\r
+        {\r
+          public void run()\r
+          {\r
+            TableSorter sorter = (TableSorter)table.getModel();\r
+            sorter.setSortingStatus(1, TableSorter.DESCENDING);\r
+            sorter.setSortingStatus(1, TableSorter.NOT_SORTED);\r
+          }\r
+        });\r
+\r
+    progressBar.setIndeterminate(false);\r
+    progressBar.setVisible(false);\r
+    addLocal.setVisible(true);\r
+    refresh.setVisible(true);\r
+  }\r
+\r
+\r
+  public void refreshTableData(Object[][] data)\r
+  {\r
+    TableSorter sorter = new TableSorter(new DASTableModel(data));\r
+    sorter.setTableHeader(table.getTableHeader());\r
+    table.setModel(sorter);\r
+  }\r
+\r
+  void displayFullDetails(String nickName)\r
+  {\r
+\r
+    StringBuffer text = new StringBuffer(\r
+        "<HTML><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">");\r
+\r
+    if (nickName == null)\r
+    {\r
+      fullDetails.setText(text +\r
+                          "Select a DAS service from the table"\r
+                          + " to read a full description here.</font></html>");\r
+      return;\r
+    }\r
+\r
+    int dSize = dasSources.length;\r
+    for (int i = 0; i < dSize; i++)\r
+    {\r
+      if (!dasSources[i].getNickname().equals(nickName))\r
+        continue;\r
+\r
+      DasSource ds = dasSources[i];\r
+\r
+      text.append("<font color=\"#0000FF\">Id:</font> " + dasSources[i].getId() +\r
+                  "<br>");\r
+      text.append("<font color=\"#0000FF\">Nickname:</font> " +\r
+                  dasSources[i].getNickname() + "<br>");\r
+      text.append("<font color=\"#0000FF\">URL:</font> " + dasSources[i].getUrl() +\r
+                  "<br>");\r
+\r
+      text.append("<font color=\"#0000FF\">Admin Email:</font> <a href=\"mailto:"\r
+                  +dasSources[i].getAdminemail()\r
+                  +"\">"+dasSources[i].getAdminemail()+"</a>" +\r
+                  "<br>");\r
+\r
+\r
+      text.append("<font color=\"#0000FF\">Registered at:</font> " + dasSources[i].getRegisterDate() +\r
+                        "<br>");\r
+\r
+      text.append("<font color=\"#0000FF\">Last successful test:</font> " + dasSources[i].getLeaseDate() +\r
+                        "<br>");\r
+\r
+      text.append("<font color=\"#0000FF\">Labels:</font> ");\r
+      for(int s=0; s<dasSources[i].getLabels().length; s++)\r
+      {\r
+        text.append( dasSources[i].getLabels()[s]);\r
+        if(s<dasSources[i].getLabels().length-1)\r
+          text.append(",");\r
+        text.append(" ");\r
+      }\r
+      text.append("<br>");\r
+\r
+\r
+\r
+      text.append("<font color=\"#0000FF\">Capabilities:</font> ");\r
+      String[] scap = dasSources[i].getCapabilities();\r
+      for (int j = 0; j < scap.length; j++)\r
+      {\r
+        text.append(scap[j]);\r
+        if (j < scap.length - 1)\r
+          text.append(", ");\r
+      }\r
+      text.append("<br>");\r
+\r
+      text.append("<font color=\"#0000FF\">Coordinates:</font> ");\r
+      DasCoordinateSystem[] dcs = ds.getCoordinateSystem();\r
+      for (int j = 0; j < dcs.length; j++)\r
+      {\r
+        text.append("(" + dcs[j].getUniqueId() + ") "\r
+                    + dcs[j].getCategory() + ", " + dcs[j].getName());\r
+        if (dcs[j].getNCBITaxId() != 0)\r
+          text.append(", " + dcs[j].getNCBITaxId());\r
+        if (dcs[j].getOrganismName().length() > 0)\r
+          text.append(", " + dcs[j].getOrganismName());\r
+\r
+        text.append("<br>");\r
+      }\r
+\r
+      text.append("<font color=\"#0000FF\">Description:</font> " +\r
+                  dasSources[i].getDescription() + "<br>");\r
+\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
+                    + "\">Go to site</a></font<br>");\r
+      }\r
+\r
+      text.append("</font></html>");\r
+\r
+      break;\r
+    }\r
+\r
+    fullDetails.setText(text.toString());\r
+    javax.swing.SwingUtilities.invokeLater(new Runnable()\r
+    {\r
+      public void run()\r
+      {\r
+        fullDetailsScrollpane.getVerticalScrollBar().setValue(0);\r
+      }\r
+    });\r
+  }\r
+\r
+\r
+  public void run()\r
+  {\r
+    loadingDasSources = true;\r
+\r
+    addLocal.setVisible(false);\r
+    refresh.setVisible(false);\r
+    progressBar.setVisible(true);\r
+    progressBar.setIndeterminate(true);\r
+\r
+    dasSources = jalview.io.DasSequenceFeatureFetcher.getDASSources();\r
+\r
+    appendLocalSources();\r
+\r
+    init();\r
+\r
+    loadingDasSources = false;\r
+\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
+    {\r
+     dasSources = jalview.io.DasSequenceFeatureFetcher.getDASSources();\r
+     appendLocalSources();\r
+    }\r
+\r
+    return dasSources;\r
+  }\r
+\r
+  public void refresh_actionPerformed(ActionEvent e)\r
+  {\r
+    saveProperties(jalview.bin.Cache.applicationProperties);\r
+\r
+    Thread worker = new Thread(this);\r
+    worker.start();\r
+  }\r
+\r
+  private void setCapabilities(DasSource[] sources)\r
+  {\r
+    Vector authority = new Vector();\r
+    Vector type = new Vector();\r
+    Vector label = new Vector();\r
+\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
+\r
+      DasCoordinateSystem[] dcs = ds.getCoordinateSystem();\r
+\r
+      for (int j = 0; j < dcs.length; j++)\r
+      {\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
+      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
+    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
+        filter1.setSelectedIndex(0);\r
+        filter2.setSelectedIndex(0);\r
+        filter3.setSelectedIndex(0);\r
+      }\r
+    });\r
+  }\r
+\r
+  public void amendLocal(boolean newSource)\r
+  {\r
+    String url = "http://localhost:8080/", nickname = "";\r
+\r
+    if(!newSource)\r
+    {\r
+      int selectedRow = table.getSelectionModel().getMinSelectionIndex();\r
+      nickname = table.getValueAt(selectedRow, 0).toString();\r
+      url = ((DasSource)localSources.get(nickname)).getUrl();\r
+    }\r
+\r
+    JTextField nametf = new JTextField(nickname, 40);\r
+    JTextField urltf = new JTextField(url, 40);\r
+\r
+    JPanel panel = new JPanel(new BorderLayout());\r
+    JPanel pane12 = new JPanel(new BorderLayout());\r
+    pane12.add(new JLabel("Nickname: "), BorderLayout.CENTER);\r
+    pane12.add(nametf, BorderLayout.EAST);\r
+    panel.add(pane12, BorderLayout.NORTH);\r
+    pane12 = new JPanel(new BorderLayout());\r
+    pane12.add(new JLabel("URL: "), BorderLayout.CENTER);\r
+    pane12.add(urltf, BorderLayout.EAST);\r
+    panel.add(pane12, BorderLayout.SOUTH);\r
+\r
+\r
+    int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,\r
+        panel, "Enter Nickname & URL of Local DAS Source",\r
+        JOptionPane.OK_CANCEL_OPTION);\r
+\r
+       if (reply != JOptionPane.OK_OPTION )\r
+       {\r
+           return;\r
+       }\r
+\r
+       if(!urltf.getText().endsWith("/"))\r
+         urltf.setText(urltf.getText()+"/");\r
+\r
+       Das1Source local = new Das1Source();\r
+\r
+       local.setUrl(urltf.getText());\r
+       local.setNickname(nametf.getText());\r
+\r
+\r
+       if(localSources==null)\r
+         localSources = new Hashtable();\r
+\r
+       localSources.put(local.getNickname(), local);\r
+\r
+       if(!newSource && !nickname.equals(nametf.getText()))\r
+       {\r
+         localSources.remove(nickname);\r
+       }\r
+\r
+       int size = dasSources.length;\r
+       int adjust = newSource ? 1 : 0;\r
+\r
+       Object[][] data = new Object[size+adjust][2];\r
+       for (int i = 0; i < size; i++)\r
+       {\r
+         if(!newSource && dasSources[i].getNickname().equals(nickname))\r
+         {\r
+           ((DasSource)dasSources[i]).setNickname(local.getNickname());\r
+           ((DasSource)dasSources[i]).setUrl(local.getUrl());\r
+           data[i][0] = local.getNickname();\r
+           data[i][1] = new Boolean(true);\r
+         }\r
+         else\r
+         {\r
+           data[i][0] = dasSources[i].getNickname();\r
+           data[i][1] = new Boolean(selectedSources.contains(dasSources[i].\r
+               getNickname()));\r
+         }\r
+       }\r
+\r
+       if(newSource)\r
+       {\r
+         data[size][0] = local.getNickname();\r
+         data[size][1] = new Boolean(true);\r
+         selectedSources.add(local.getNickname());\r
+       }\r
+\r
+       DasSource [] tmp = new DasSource[size+adjust];\r
+\r
+       System.arraycopy(dasSources, 0, tmp, 0, size);\r
+\r
+       if(newSource)\r
+         tmp[size] = local;\r
+\r
+       dasSources = tmp;\r
+\r
+       refreshTableData(data);\r
+\r
+       SwingUtilities.invokeLater(new Runnable()\r
+       {\r
+         public void run()\r
+         {\r
+           scrollPane.getVerticalScrollBar().setValue(\r
+               scrollPane.getVerticalScrollBar().getMaximum()\r
+               );\r
+         }\r
+       });\r
+\r
+       displayFullDetails(local.getNickname());\r
+     }\r
+\r
+    public void editRemoveLocalSource(MouseEvent evt)\r
+    {\r
+      int selectedRow = table.getSelectionModel().getMinSelectionIndex();\r
+      if(selectedRow==-1)\r
+        return;\r
+\r
+      String nickname = table.getValueAt(selectedRow, 0).toString();\r
+\r
+      if (!localSources.containsKey(nickname))\r
+      {\r
+        JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
+        "You can only edit or remove local DAS Sources!",\r
+         "Public DAS source - not editable",\r
+         JOptionPane.WARNING_MESSAGE);\r
+        return;\r
+      }\r
+\r
+\r
+      Object[] options = {"Edit", "Remove", "Cancel"};\r
+      int choice = JOptionPane.showInternalOptionDialog(Desktop.desktop,\r
+    "Do you want to edit or remove "+nickname+"?",\r
+    "Edit / Remove Local DAS Source",\r
+    JOptionPane.YES_NO_CANCEL_OPTION,\r
+    JOptionPane.QUESTION_MESSAGE,\r
+    null,\r
+    options,\r
+    options[2]);\r
+\r
+      switch(choice)\r
+      {\r
+        case 0: amendLocal(false);   break;\r
+        case 1:\r
+          localSources.remove(nickname);\r
+          selectedSources.remove(nickname);\r
+          Object[][] data = new Object[dasSources.length-1][2];\r
+          DasSource [] tmp = new DasSource[dasSources.length-1];\r
+          int index = 0;\r
+          for (int i = 0; i < dasSources.length; i++)\r
+          {\r
+            if (dasSources[i].getNickname().equals(nickname))\r
+            {\r
+              continue;\r
+            }\r
+            else\r
+            {\r
+              tmp[index] = dasSources[i];\r
+              data[index][0] = dasSources[i].getNickname();\r
+              data[index][1] = new Boolean(selectedSources.contains(dasSources[i].\r
+                  getNickname()));\r
+              index++;\r
+            }\r
+          }\r
+           dasSources = tmp;\r
+           refreshTableData(data);\r
+           SwingUtilities.invokeLater(new Runnable()\r
+           {\r
+             public void run()\r
+             {\r
+               scrollPane.getVerticalScrollBar().setValue(\r
+                   scrollPane.getVerticalScrollBar().getMaximum()\r
+                   );\r
+             }\r
+           });\r
+\r
+          break;\r
+      }\r
+    }\r
+\r
+    void appendLocalSources()\r
+    {\r
+      if(localSources==null)\r
+        return;\r
+\r
+      int size = dasSources!=null ? dasSources.length : 0;\r
+      int lsize = localSources.size();\r
+\r
+      Object[][] data = new Object[size+lsize][2];\r
+      for (int i = 0; i < size; i++)\r
+      {\r
+        data[i][0] = dasSources[i].getNickname();\r
+        data[i][1] = new Boolean(selectedSources.contains(dasSources[i].\r
+            getNickname()));\r
+      }\r
+\r
+      DasSource [] tmp = new DasSource[size+lsize];\r
+      if(dasSources!=null)\r
+        System.arraycopy(dasSources, 0, tmp, 0, size);\r
+\r
+      Enumeration en = localSources.keys();\r
+      int index = size;\r
+      while(en.hasMoreElements())\r
+      {\r
+        String key = en.nextElement().toString();\r
+        data[index][0] = key;\r
+        data[index][1] = new Boolean(false);\r
+        tmp[index] = new Das1Source();\r
+        tmp[index].setNickname(key);\r
+        tmp[index].setUrl( ((DasSource)localSources.get(key)).getUrl() );\r
+\r
+        index++;\r
+      }\r
+\r
+      dasSources = tmp;\r
+\r
+      refreshTableData(data);\r
+  }\r
+\r
+  public void valueChanged(ListSelectionEvent evt)\r
+  {\r
+    //Called when the MainTable selection changes\r
+    if (evt.getValueIsAdjusting() )\r
+    {\r
+      return;\r
+    }\r
+\r
+\r
+    displayFullDetails(null);\r
+\r
+    // Filter the displayed data sources\r
+    int dSize = dasSources.length;\r
+\r
+\r
+    ArrayList names = new ArrayList();\r
+    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
+    for (int i = 0; i < dSize; i++)\r
+    {\r
+      ds = dasSources[i];\r
+      DasCoordinateSystem[] dcs = ds.getCoordinateSystem();\r
+\r
+      if (dcs.length == 0 && ds.getCapabilities().length == 0\r
+          && filter1.getSelectedIndex() == 0\r
+          && filter2.getSelectedIndex() == 0\r
+          && filter3.getSelectedIndex() == 0)\r
+      {\r
+        //THIS IS A FIX FOR LOCAL SOURCES WHICH DO NOT\r
+        //HAVE COORDINATE SYSTEMS, INFO WHICH AT PRESENT\r
+        //IS ADDED FROM THE REGISTRY\r
+        names.add(ds.getNickname());\r
+        selected.add(new Boolean(\r
+              selectedSources.contains(ds.getNickname())));\r
+        continue;\r
+      }\r
+\r
+\r
+      if (!selectedInList(dummyFeatureList, ds.getCapabilities())\r
+      ||  !selectedInList(filter3.getSelectedValues(),\r
+                          ds.getLabels()))\r
+      {\r
+        continue;\r
+      }\r
+\r
+      for (int j = 0; j < dcs.length; j++)\r
+      {\r
+        if (   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
+              selectedSources.contains(ds.getNickname())));\r
+          break;\r
+        }\r
+      }\r
+    }\r
+\r
+    dSize = names.size();\r
+    Object[][] data = new Object[dSize][2];\r
+    for (int d = 0; d < dSize; d++)\r
+    {\r
+      data[d][0] = names.get(d);\r
+      data[d][1] = selected.get(d);\r
+    }\r
+\r
+    refreshTableData(data);\r
+  }\r
+\r
+  boolean selectedInList(Object [] selection, String[] items)\r
+  {\r
+    for (int i = 0; i < selection.length; i++)\r
+    {\r
+      if (selection[i].equals("Any") )\r
+        return true;\r
+\r
+      for (int j = 0; j < items.length; j++)\r
+      {\r
+        if (selection[i].equals(items[j]))\r
+          return true;\r
+      }\r
+    }\r
+\r
+    return false;\r
+  }\r
+\r
+  void setSelectedFromProperties()\r
+  {\r
+     String active = jalview.bin.Cache.getDefault("DAS_ACTIVE_SOURCE", "uniprot");\r
+     StringTokenizer st = new StringTokenizer(active, "\t");\r
+     selectedSources = new Vector();\r
+     while(st.hasMoreTokens())\r
+     {\r
+       selectedSources.addElement(st.nextToken());\r
+     }\r
+\r
+     String local = jalview.bin.Cache.getProperty("DAS_LOCAL_SOURCE");\r
+     if(local!=null)\r
+     {\r
+       if(localSources == null)\r
+         localSources = new Hashtable();\r
+\r
+       st = new StringTokenizer(local, "\t");\r
+       while(st.hasMoreTokens())\r
+       {\r
+         String token = st.nextToken();\r
+         int bar = token.indexOf("|");\r
+         Das1Source source = new Das1Source();\r
+\r
+         source.setUrl(token.substring(bar + 1));\r
+         source.setNickname(token.substring(0, bar));\r
+\r
+         localSources.put(source.getNickname(), source);\r
+       }\r
+     }\r
+  }\r
+\r
+  public void reset_actionPerformed(ActionEvent e)\r
+  {\r
+    registryURL.setText(DEFAULT_REGISTRY);\r
+  }\r
+\r
+  public void saveProperties(Properties properties)\r
+  {\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
+    {\r
+      if( ((Boolean)table.getValueAt(r,1)).booleanValue())\r
+      {\r
+        sb.append(table.getValueAt(r,0)+"\t");\r
+      }\r
+    }\r
+\r
+    properties.setProperty("DAS_ACTIVE_SOURCE", sb.toString() );\r
+\r
+    if(localSources!=null)\r
+    {\r
+      sb = new StringBuffer();\r
+      Enumeration en = localSources.keys();\r
+      while(en.hasMoreElements())\r
+      {\r
+        String token = en.nextElement().toString();\r
+        sb.append(token+"|"\r
+                  + ((DasSource)localSources.get(token)).getUrl()\r
+                  +"\t");\r
+      }\r
+\r
+      properties.setProperty("DAS_LOCAL_SOURCE", sb.toString());\r
+    }\r
+\r
+  }\r
+\r
+  class DASTableModel\r
+      extends AbstractTableModel\r
+  {\r
+\r
+    public DASTableModel(Object[][] data)\r
+    {\r
+      this.data = data;\r
+    }\r
+\r
+    private String[] columnNames = new String[]  {"Nickname", "Use Source"};\r
+\r
+    private Object[][] data;\r
+\r
+    public int getColumnCount()\r
+    {\r
+      return columnNames.length;\r
+    }\r
+\r
+    public int getRowCount()\r
+    {\r
+      return data.length;\r
+    }\r
+\r
+    public String getColumnName(int col)\r
+    {\r
+      return columnNames[col];\r
+    }\r
+\r
+    public Object getValueAt(int row, int col)\r
+    {\r
+      return data[row][col];\r
+    }\r
+\r
+    /*\r
+     * JTable uses this method to determine the default renderer/\r
+     * editor for each cell.  If we didn't implement this method,\r
+     * then the last column would contain text ("true"/"false"),\r
+     * rather than a check box.\r
+     */\r
+    public Class getColumnClass(int c)\r
+    {\r
+      return getValueAt(0, c).getClass();\r
+    }\r
+\r
+    /*\r
+     * Don't need to implement this method unless your table's\r
+     * editable.\r
+     */\r
+    public boolean isCellEditable(int row, int col)\r
+    {\r
+      //Note that the data/cell address is constant,\r
+      //no matter where the cell appears onscreen.\r
+      return col == 1;\r
+\r
+    }\r
+\r
+    /*\r
+     * Don't need to implement this method unless your table's\r
+     * data can change.\r
+     */\r
+    public void setValueAt(Object value, int row, int col)\r
+    {\r
+      data[row][col] = value;\r
+      fireTableCellUpdated(row, col);\r
+\r
+      String name = getValueAt(row,0).toString();\r
+      boolean selected = ((Boolean)value).booleanValue();\r
+\r
+      if(selectedSources.contains(name) && !selected)\r
+        selectedSources.remove(name);\r
+\r
+      if(!selectedSources.contains(name) && selected)\r
+        selectedSources.add(name);\r
+    }\r
+  }\r
+}\r
+\r
+\r