JAL-2089 patch broken merge to master for Release 2.10.0b1
[jalview.git] / src / jalview / gui / DasSourceBrowser.java
old mode 100755 (executable)
new mode 100644 (file)
index 71efbd0..e677084
-/*\r
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)\r
- * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle\r
- * \r
- * This file is part of Jalview.\r
- * \r
- * Jalview 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 3 of the License, or (at your option) any later version.\r
- * \r
- * Jalview is distributed in the hope that it will be useful, but \r
- * WITHOUT ANY WARRANTY; without even the implied warranty \r
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR \r
- * PURPOSE.  See the GNU General Public License for more details.\r
- * \r
- * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package jalview.gui;\r
-\r
-import jalview.jbgui.GDasSourceBrowser;\r
-import jalview.util.TableSorter;\r
-import jalview.ws.dbsources.das.api.DasSourceRegistryI;\r
-import jalview.ws.dbsources.das.api.jalviewSourceI;\r
-\r
-import java.awt.BorderLayout;\r
-import java.awt.event.ActionEvent;\r
-import java.awt.event.MouseAdapter;\r
-import java.awt.event.MouseEvent;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Properties;\r
-import java.util.StringTokenizer;\r
-import java.util.Vector;\r
-\r
-import javax.swing.JCheckBox;\r
-import javax.swing.JLabel;\r
-import javax.swing.JOptionPane;\r
-import javax.swing.JPanel;\r
-import javax.swing.JTextField;\r
-import javax.swing.ListSelectionModel;\r
-import javax.swing.SwingUtilities;\r
-import javax.swing.event.ListSelectionEvent;\r
-import javax.swing.event.ListSelectionListener;\r
-import javax.swing.table.AbstractTableModel;\r
-\r
-import org.biodas.jdas.schema.sources.CAPABILITY;\r
-import org.biodas.jdas.schema.sources.COORDINATES;\r
-import org.biodas.jdas.schema.sources.PROP;\r
-import org.biodas.jdas.schema.sources.VERSION;\r
-\r
-public class DasSourceBrowser extends GDasSourceBrowser implements\r
-        Runnable, ListSelectionListener\r
-{\r
-  DasSourceRegistryI sourceRegistry = null;\r
-\r
-  Vector<String> selectedSources;\r
-\r
-  public DasSourceBrowser(FeatureSettings featureSettings)\r
-  {\r
-    fs = featureSettings;\r
-    // TODO DasSourceRegistryProvider API\r
-    sourceRegistry = jalview.bin.Cache.getDasSourceRegistry();\r
-    String registry = sourceRegistry.getDasRegistryURL();\r
-\r
-    registryURL.setText(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
-        {\r
-          editRemoveLocalSource(evt);\r
-        }\r
-      }\r
-    });\r
-\r
-    if (sourceRegistry.getSources() != null)\r
-    {\r
-      init();\r
-    }\r
-  }\r
-\r
-  FeatureSettings fs = null;\r
-\r
-  private boolean loadingDasSources;\r
-\r
-  public DasSourceBrowser()\r
-  {\r
-    this(null);\r
-  }\r
-\r
-  public void paintComponent(java.awt.Graphics g)\r
-  {\r
-    if (sourceRegistry == null)\r
-    {\r
-      Thread worker = new Thread(this);\r
-      worker.start();\r
-    }\r
-  }\r
-\r
-  void init()\r
-  {\r
-    List<jalviewSourceI> sources = sourceRegistry.getSources();\r
-    int dSize = sources.size();\r
-    Object[][] data = new Object[dSize][2];\r
-    for (int i = 0; i < dSize; i++)\r
-    {\r
-      data[i][0] = sources.get(i).getTitle(); // what's equivalent of nickname\r
-      data[i][1] = new Boolean(selectedSources.contains(sources.get(i)\r
-              .getTitle()));\r
-    }\r
-\r
-    refreshTableData(data);\r
-    setCapabilities(sourceRegistry);\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
-  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 + "Select a DAS service from the table"\r
-              + " to read a full description here.</font></html>");\r
-      return;\r
-    }\r
-\r
-    int dSize = sourceRegistry.getSources().size();\r
-    for (jalviewSourceI ds : sourceRegistry.getSources())\r
-    {\r
-      if (!ds.getTitle().equals(nickName))\r
-      {\r
-        continue;\r
-      }\r
-\r
-      VERSION latest = ds.getVersion();\r
-      text.append("<font color=\"#0000FF\">Id:</font> " + ds.getUri()\r
-              + "<br>");\r
-      text.append("<font color=\"#0000FF\">Nickname:</font> "\r
-              + ds.getTitle() + "<br>");\r
-\r
-      text.append("<font color=\"#0000FF\">URL:</font> <a href=\""\r
-              + ds.getSourceURL() + "\">" + ds.getSourceURL() + "</a>"\r
-              + "<br>");\r
-      if (!ds.isLocal())\r
-      {\r
-        if (ds.getDocHref() != null && ds.getDocHref().length() > 0)\r
-        {\r
-          text.append("<font color=\"#0000FF\">Site:</font> <a href=\""\r
-                  + ds.getDocHref() + "\">" + ds.getDocHref() + "</a>"\r
-                  + "<br>");\r
-        }\r
-\r
-        text.append("<font color=\"#0000FF\">Description:</font> "\r
-                + ds.getDescription() + "<br>");\r
-\r
-        text.append("<font color=\"#0000FF\">Admin Email:</font> <a href=\"mailto:"\r
-                + ds.getEmail() + "\">" + ds.getEmail() + "</a>" + "<br>");\r
-\r
-        text.append("<font color=\"#0000FF\">Registered at:</font> "\r
-                + latest.getCreated() + "<br>");\r
-\r
-        // TODO: Identify last successful test date\r
-        // text.append("<font color=\"#0000FF\">Last successful test:</font> "\r
-        // + latest.dasSources[i].getLeaseDate() + "<br>");\r
-      }\r
-      else\r
-      {\r
-        text.append("Source was added manually.<br/>");\r
-      }\r
-      text.append("<font color=\"#0000FF\">Labels:</font> ");\r
-      boolean b = false;\r
-      for (PROP labl : latest.getPROP())\r
-      {\r
-        if (labl.getName().equalsIgnoreCase("LABEL"))\r
-        {\r
-          if (b)\r
-          {\r
-            text.append(",");\r
-          }\r
-          text.append(" ");\r
-\r
-          text.append(labl.getValue());\r
-          b = true;\r
-        }\r
-        ;\r
-      }\r
-      text.append("<br>");\r
-\r
-      text.append("<font color=\"#0000FF\">Capabilities:</font> ");\r
-      CAPABILITY[] scap = latest.getCAPABILITY().toArray(new CAPABILITY[0]);\r
-      for (int j = 0; j < scap.length; j++)\r
-      {\r
-        text.append(scap[j].getType());\r
-        if (j < scap.length - 1)\r
-        {\r
-          text.append(", ");\r
-        }\r
-      }\r
-      text.append("<br>");\r
-\r
-      text.append("<font color=\"#0000FF\">Coordinates:</font>");\r
-      int i=1;\r
-      for (COORDINATES dcs : latest.getCOORDINATES())\r
-      {\r
-        text.append("<br/>"+i+++". ");\r
-        text.append(dcs.getAuthority()+" : "+dcs.getSource());\r
-        if (dcs.getTaxid() != null && dcs.getTaxid().trim().length() > 0)\r
-        {\r
-          text.append(" [TaxId:" + dcs.getTaxid()+"]");\r
-        }\r
-        if (dcs.getVersion() != null\r
-                && dcs.getVersion().trim().length() > 0)\r
-        {\r
-          {\r
-            text.append(" {v. " + dcs.getVersion()+"}");\r
-          }\r
-        }\r
-        text.append(" (<a href=\""+dcs.getUri() +"\">"+dcs.getUri() + "</a>)");\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
-  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
-    setParentGuiEnabled(false);\r
-    // Refresh the source list.\r
-    sourceRegistry.refreshSources();\r
-\r
-    init();\r
-\r
-    setParentGuiEnabled(true);\r
-    loadingDasSources = false;\r
-\r
-  }\r
-\r
-  private void setParentGuiEnabled(boolean b)\r
-  {\r
-    if (fs != null)\r
-    {\r
-      fs.fetchDAS.setEnabled(b);\r
-      fs.saveDAS.setEnabled(b);\r
-    }\r
-  }\r
-\r
-  public Vector<jalviewSourceI> getSelectedSources()\r
-  {\r
-    // wait around if we're still loading.\r
-    while (sourceRegistry == null)\r
-    {\r
-      if (!loadingDasSources)\r
-      {\r
-        new Thread(this).start();\r
-        try\r
-        {\r
-          Thread.sleep(5);\r
-        } catch (Exception e)\r
-        {\r
-        }\r
-        ;\r
-        while (loadingDasSources)\r
-        {\r
-          try\r
-          {\r
-            Thread.sleep(5);\r
-          } catch (Exception e)\r
-          {\r
-          }\r
-          ;\r
-        }\r
-        ;\r
-      }\r
-    }\r
-\r
-    Vector<jalviewSourceI> selected = new Vector<jalviewSourceI>();\r
-    for (String source : selectedSources)\r
-    {\r
-      jalviewSourceI srce = sourceRegistry.getSource(source);\r
-      if (srce != null)\r
-      {\r
-        selected.addElement(srce);\r
-      }\r
-    }\r
-    return selected;\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(DasSourceRegistryI sourceRegistry2)\r
-  {\r
-    Vector<String> authority = new Vector<String>();\r
-    Vector<String> type = new Vector<String>();\r
-    Vector<String> label = new Vector<String>();\r
-    Vector<String> taxIds = new Vector<String>();\r
-    authority.add("Any");\r
-    type.add("Any");\r
-    label.add("Any");\r
-\r
-    for (jalviewSourceI ds : sourceRegistry2.getSources())\r
-    {\r
-      VERSION latest = ds.getVersion();\r
-\r
-      for (COORDINATES cs : latest.getCOORDINATES())\r
-      {\r
-        if (!type.contains(cs.getSource()))\r
-        {\r
-          type.add(cs.getSource()); // source==category\r
-        }\r
-\r
-        if (!authority.contains(cs.getAuthority()))\r
-        {\r
-          authority.add(cs.getAuthority());\r
-        }\r
-      }\r
-\r
-      for (PROP slabel : latest.getPROP())\r
-      {\r
-        if (slabel.getName().equalsIgnoreCase("LABEL")\r
-                && !label.contains(slabel.getValue()))\r
-        {\r
-          label.add(slabel.getValue());\r
-        }\r
-      }\r
-\r
-    }\r
-\r
-    filter1.setListData(authority);\r
-    filter2.setListData(type);\r
-    filter3.setListData(label);\r
-    // filter4 taxIds\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
-    boolean seqsrc = false;\r
-    if (!newSource)\r
-    {\r
-      int selectedRow = table.getSelectionModel().getMinSelectionIndex();\r
-      nickname = table.getValueAt(selectedRow, 0).toString();\r
-      jalviewSourceI source = sourceRegistry.getSource(nickname);\r
-      url = source.getUri();\r
-      seqsrc = source.isSequenceSource();\r
-    }\r
-\r
-    JTextField nametf = new JTextField(nickname, 40);\r
-    JTextField urltf = new JTextField(url, 40);\r
-    JCheckBox seqs = new JCheckBox("Sequence Source");\r
-    seqs.setSelected(seqsrc);\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.NORTH);\r
-    pane12.add(seqs, BorderLayout.SOUTH);\r
-    pane12.add(urltf, BorderLayout.EAST);\r
-    panel.add(pane12, BorderLayout.SOUTH);\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
-    {\r
-      urltf.setText(urltf.getText() + "/");\r
-    }\r
-\r
-    jalviewSourceI local = sourceRegistry.createLocalSource(\r
-            urltf.getText(), nametf.getText(), seqs.isSelected(), true);\r
-    List sources = sourceRegistry.getSources();\r
-    int osize = sources.size();\r
-    int size = osize + (newSource ? 1 : 0);\r
-\r
-    Object[][] data = new Object[size][2];\r
-    DASTableModel dtm = (table != null) ? (DASTableModel) ((TableSorter) table\r
-            .getModel()).getTableModel() : null;\r
-    for (int i = 0; i < osize; i++)\r
-    {\r
-      String osrc = (dtm == null || i >= osize) ? null : (String) dtm\r
-              .getValueAt(i, 0);\r
-      if (!newSource && osrc != null\r
-              && dtm.getValueAt(i, 0).equals(nickname))\r
-      {\r
-        data[i][0] = local.getTitle();\r
-        data[i][1] = new Boolean(true);\r
-      }\r
-      else\r
-      {\r
-        data[i][0] = osrc;\r
-        data[i][1] = new Boolean(selectedSources.contains(osrc));\r
-      }\r
-    }\r
-    // Always add a new source at the end\r
-    if (newSource)\r
-    {\r
-      data[osize][0] = local.getTitle();\r
-      data[osize][1] = new Boolean(true);\r
-      selectedSources.add(local.getTitle());\r
-    }\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
-    displayFullDetails(local.getTitle());\r
-  }\r
-\r
-  public void editRemoveLocalSource(MouseEvent evt)\r
-  {\r
-    int selectedRow = table.getSelectionModel().getMinSelectionIndex();\r
-    if (selectedRow == -1)\r
-    {\r
-      return;\r
-    }\r
-\r
-    String nickname = table.getValueAt(selectedRow, 0).toString();\r
-\r
-    if (!sourceRegistry.getSource(nickname).isLocal())\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
-    Object[] options =\r
-    { "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, JOptionPane.QUESTION_MESSAGE,\r
-            null, options, options[2]);\r
-\r
-    switch (choice)\r
-    {\r
-    case 0:\r
-      amendLocal(false);\r
-      break;\r
-    case 1:\r
-      sourceRegistry.removeLocalSource(sourceRegistry.getSource(nickname));\r
-      selectedSources.remove(nickname);\r
-      Object[][] data = new Object[sourceRegistry.getSources().size()][2];\r
-      int index = 0,\r
-      l = table.getRowCount();\r
-\r
-      for (int i = 0; i < l; i++)\r
-      {\r
-        String nm;\r
-        if ((nm = (String) table.getValueAt(i, 0)).equals(nickname))\r
-        {\r
-          continue;\r
-        }\r
-        else\r
-        {\r
-          data[index][0] = nm;\r
-          data[index][1] = new Boolean(selectedSources.contains(nm));\r
-          index++;\r
-        }\r
-      }\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
-      break;\r
-    }\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
-    displayFullDetails(null);\r
-\r
-    // Filter the displayed data sources\r
-\r
-    ArrayList names = new ArrayList();\r
-    ArrayList selected = new ArrayList();\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[]\r
-    { "features" };\r
-    List<jalviewSourceI> srcs = sourceRegistry.getSources();\r
-    for (jalviewSourceI ds : srcs)\r
-    {\r
-\r
-      VERSION v = ds.getVersion();\r
-      List<COORDINATES> coords = v.getCOORDINATES();\r
-      if (ds.isLocal()\r
-              || ((coords == null || coords.size() == 0)\r
-                      && filter1.getSelectedIndex() == 0\r
-                      && filter2.getSelectedIndex() == 0 && filter3\r
-                      .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.getTitle());\r
-        selected.add(new Boolean(selectedSources.contains(ds.getTitle())));\r
-        continue;\r
-      }\r
-\r
-      if (!selectedInList(dummyFeatureList, ds.getCapabilityList(v))\r
-              || !selectedInList(filter3.getSelectedValues(),\r
-                      ds.getLabelsFor(v)))\r
-      {\r
-        continue;\r
-      }\r
-\r
-      for (int j = 0; j < coords.size(); j++)\r
-      {\r
-        if (selectedInList(filter1.getSelectedValues(), new String[]\r
-        { coords.get(j).getAuthority() })\r
-                && selectedInList(filter2.getSelectedValues(), new String[]\r
-                { coords.get(j).getSource() }))\r
-        {\r
-          names.add(ds.getTitle());\r
-          selected.add(new Boolean(selectedSources.contains(ds.getTitle())));\r
-          break;\r
-        }\r
-      }\r
-    }\r
-\r
-    int 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
-  private boolean selectedInList(Object[] selection, String[] items)\r
-  {\r
-    for (int i = 0; i < selection.length; i++)\r
-    {\r
-      if (selection[i].equals("Any"))\r
-      {\r
-        return true;\r
-      }\r
-      if (items == null || items.length == 0)\r
-      {\r
-        return false;\r
-      }\r
-      String sel = (items[0].startsWith("das1:") ? "das1:" : "")\r
-              + selection[i];\r
-      for (int j = 0; j < items.length; j++)\r
-      {\r
-        if (sel.equals(items[j]))\r
-        {\r
-          return true;\r
-        }\r
-      }\r
-    }\r
-\r
-    return false;\r
-  }\r
-\r
-  void setSelectedFromProperties()\r
-  {\r
-    String active = jalview.bin.Cache.getDefault("DAS_ACTIVE_SOURCE",\r
-            "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
-\r
-  public void reset_actionPerformed(ActionEvent e)\r
-  {\r
-    registryURL.setText(sourceRegistry.getDasRegistryURL());\r
-  }\r
-\r
-  /**\r
-   * set the DAS source settings in the given jalview properties.\r
-   * \r
-   * @param properties\r
-   */\r
-  public void saveProperties(Properties properties)\r
-  {\r
-    if (registryURL.getText() == null || registryURL.getText().length() < 1)\r
-    {\r
-      properties.remove(jalview.bin.Cache.DAS_REGISTRY_URL);\r
-    }\r
-    else\r
-    {\r
-      properties.setProperty(jalview.bin.Cache.DAS_REGISTRY_URL,\r
-              registryURL.getText());\r
-    }\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(jalview.bin.Cache.DAS_ACTIVE_SOURCE,\r
-            sb.toString());\r
-\r
-    String sourceprop = sourceRegistry.getLocalSourceString();\r
-    properties.setProperty(jalview.bin.Cache.DAS_LOCAL_SOURCE, sourceprop);\r
-  }\r
-\r
-  class DASTableModel extends AbstractTableModel\r
-  {\r
-\r
-    public DASTableModel(Object[][] data)\r
-    {\r
-      this.data = data;\r
-    }\r
-\r
-    private String[] columnNames = new String[]\r
-    { "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/ editor for\r
-     * each cell. If we didn't implement this method, then the last column would\r
-     * contain text ("true"/"false"), 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 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 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
-      {\r
-        selectedSources.remove(name);\r
-      }\r
-\r
-      if (!selectedSources.contains(name) && selected)\r
-      {\r
-        selectedSources.add(name);\r
-      }\r
-    }\r
-  }\r
-\r
-  public void initDasSources()\r
-  {\r
-\r
-    Thread thr = new Thread(new Runnable()\r
-    {\r
-      public void run()\r
-      {\r
-        // this actually initialises the das source list\r
-        paintComponent(null); // yuk\r
-      }\r
-    });\r
-    thr.start();\r
-    while (loadingDasSources || sourceRegistry == null)\r
-    {\r
-      try\r
-      {\r
-        Thread.sleep(10);\r
-      } catch (Exception e)\r
-      {\r
-      }\r
-      ;\r
-    }\r
-  }\r
-\r
-  /**\r
-   * disable or enable the buttons on the source browser\r
-   * \r
-   * @param b\r
-   */\r
-  public void setGuiEnabled(boolean b)\r
-  {\r
-    refresh.setEnabled(b);\r
-    addLocal.setEnabled(b);\r
-  }\r
-}\r
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ * 
+ * This file is part of Jalview.
+ * 
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
+ * Jalview is distributed in the hope that it will be useful, but 
+ * WITHOUT ANY WARRANTY; without even the implied warranty 
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
+ * PURPOSE.  See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+package jalview.gui;
+
+import jalview.jbgui.GDasSourceBrowser;
+import jalview.util.MessageManager;
+import jalview.util.TableSorter;
+import jalview.ws.dbsources.das.api.DasSourceRegistryI;
+import jalview.ws.dbsources.das.api.jalviewSourceI;
+
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.ListSelectionModel;
+import javax.swing.SwingUtilities;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.AbstractTableModel;
+
+import org.biodas.jdas.schema.sources.CAPABILITY;
+import org.biodas.jdas.schema.sources.COORDINATES;
+import org.biodas.jdas.schema.sources.PROP;
+import org.biodas.jdas.schema.sources.VERSION;
+
+public class DasSourceBrowser extends GDasSourceBrowser implements
+        Runnable, ListSelectionListener
+{
+  DasSourceRegistryI sourceRegistry = null;
+
+  Vector<String> selectedSources;
+
+  public DasSourceBrowser(FeatureSettings featureSettings)
+  {
+    fs = featureSettings;
+    // TODO DasSourceRegistryProvider API
+    sourceRegistry = jalview.bin.Cache.getDasSourceRegistry();
+    String registry = sourceRegistry.getDasRegistryURL();
+
+    registryURL.setText(registry);
+
+    setSelectedFromProperties();
+
+    displayFullDetails(null);
+    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+
+    filter1.addListSelectionListener(this);
+    filter2.addListSelectionListener(this);
+    filter3.addListSelectionListener(this);
+
+    // Ask to be notified of selection changes.
+    ListSelectionModel rowSM = table.getSelectionModel();
+    rowSM.addListSelectionListener(new ListSelectionListener()
+    {
+      @Override
+      public void valueChanged(ListSelectionEvent e)
+      {
+        ListSelectionModel lsm = (ListSelectionModel) e.getSource();
+        if (!lsm.isSelectionEmpty())
+        {
+          int selectedRow = lsm.getMinSelectionIndex();
+          displayFullDetails(table.getValueAt(selectedRow, 0).toString());
+        }
+      }
+    });
+
+    table.addMouseListener(new MouseAdapter()
+    {
+      @Override
+      public void mouseClicked(MouseEvent evt)
+      {
+        if (evt.getClickCount() == 2 || evt.isPopupTrigger())
+        {
+          editRemoveLocalSource(evt);
+        }
+      }
+    });
+
+    if (sourceRegistry.getSources() != null)
+    {
+      init();
+    }
+  }
+
+  FeatureSettings fs = null;
+
+  private boolean loadingDasSources;
+
+  public DasSourceBrowser()
+  {
+    this(null);
+  }
+
+  @Override
+  public void paintComponent(java.awt.Graphics g)
+  {
+    if (sourceRegistry == null)
+    {
+      Thread worker = new Thread(this);
+      worker.start();
+    }
+  }
+
+  void init()
+  {
+    List<jalviewSourceI> sources = sourceRegistry.getSources();
+    int dSize = sources.size();
+    Object[][] data = new Object[dSize][2];
+    for (int i = 0; i < dSize; i++)
+    {
+      data[i][0] = sources.get(i).getTitle(); // what's equivalent of nickname
+      data[i][1] = new Boolean(selectedSources.contains(sources.get(i)
+              .getTitle()));
+    }
+
+    refreshTableData(data);
+    setCapabilities(sourceRegistry);
+
+    javax.swing.SwingUtilities.invokeLater(new Runnable()
+    {
+      @Override
+      public void run()
+      {
+        TableSorter sorter = (TableSorter) table.getModel();
+        sorter.setSortingStatus(1, TableSorter.DESCENDING);
+        sorter.setSortingStatus(1, TableSorter.NOT_SORTED);
+      }
+    });
+
+    progressBar.setIndeterminate(false);
+    progressBar.setVisible(false);
+    addLocal.setVisible(true);
+    refresh.setVisible(true);
+  }
+
+  public void refreshTableData(Object[][] data)
+  {
+    TableSorter sorter = new TableSorter(new DASTableModel(data));
+    sorter.setTableHeader(table.getTableHeader());
+    table.setModel(sorter);
+  }
+
+  void displayFullDetails(String nickName)
+  {
+
+    StringBuffer text = new StringBuffer(
+            "<HTML><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">");
+
+    if (nickName == null)
+    {
+      fullDetails.setText(text
+              + MessageManager
+                      .getString("label.select_das_service_from_table"));
+      return;
+    }
+
+    int dSize = sourceRegistry.getSources().size();
+    for (jalviewSourceI ds : sourceRegistry.getSources())
+    {
+      if (!ds.getTitle().equals(nickName))
+      {
+        continue;
+      }
+
+      VERSION latest = ds.getVersion();
+      text.append("<font color=\"#0000FF\">Id:</font> " + ds.getUri()
+              + "<br>");
+      text.append("<font color=\"#0000FF\">Nickname:</font> "
+              + ds.getTitle() + "<br>");
+
+      text.append("<font color=\"#0000FF\">URL:</font> <a href=\""
+              + ds.getSourceURL() + "\">" + ds.getSourceURL() + "</a>"
+              + "<br>");
+      if (!ds.isLocal())
+      {
+        if (ds.getDocHref() != null && ds.getDocHref().length() > 0)
+        {
+          text.append("<font color=\"#0000FF\">Site:</font> <a href=\""
+                  + ds.getDocHref() + "\">" + ds.getDocHref() + "</a>"
+                  + "<br>");
+        }
+
+        text.append("<font color=\"#0000FF\">Description:</font> "
+                + ds.getDescription() + "<br>");
+
+        text.append("<font color=\"#0000FF\">Admin Email:</font> <a href=\"mailto:"
+                + ds.getEmail() + "\">" + ds.getEmail() + "</a>" + "<br>");
+
+        text.append("<font color=\"#0000FF\">Registered at:</font> "
+                + latest.getCreated() + "<br>");
+
+        // TODO: Identify last successful test date
+        // text.append("<font color=\"#0000FF\">Last successful test:</font> "
+        // + latest.dasSources[i].getLeaseDate() + "<br>");
+      }
+      else
+      {
+        text.append("Source was added manually.<br/>");
+      }
+      text.append("<font color=\"#0000FF\">Labels:</font> ");
+      boolean b = false;
+      for (PROP labl : latest.getPROP())
+      {
+        if (labl.getName().equalsIgnoreCase("LABEL"))
+        {
+          if (b)
+          {
+            text.append(",");
+          }
+          text.append(" ");
+
+          text.append(labl.getValue());
+          b = true;
+        }
+        ;
+      }
+      text.append("<br>");
+
+      text.append("<font color=\"#0000FF\">Capabilities:</font> ");
+      CAPABILITY[] scap = latest.getCAPABILITY().toArray(new CAPABILITY[0]);
+      for (int j = 0; j < scap.length; j++)
+      {
+        text.append(scap[j].getType());
+        if (j < scap.length - 1)
+        {
+          text.append(", ");
+        }
+      }
+      text.append("<br>");
+
+      text.append("<font color=\"#0000FF\">Coordinates:</font>");
+      int i = 1;
+      for (COORDINATES dcs : latest.getCOORDINATES())
+      {
+        text.append("<br/>" + i++ + ". ");
+        text.append(dcs.getAuthority() + " : " + dcs.getSource());
+        if (dcs.getTaxid() != null && dcs.getTaxid().trim().length() > 0)
+        {
+          text.append(" [TaxId:" + dcs.getTaxid() + "]");
+        }
+        if (dcs.getVersion() != null
+                && dcs.getVersion().trim().length() > 0)
+        {
+          {
+            text.append(" {v. " + dcs.getVersion() + "}");
+          }
+        }
+        text.append(" (<a href=\"" + dcs.getUri() + "\">" + dcs.getUri()
+                + "</a>)");
+      }
+      text.append("</font></html>");
+
+      break;
+    }
+
+    fullDetails.setText(text.toString());
+    javax.swing.SwingUtilities.invokeLater(new Runnable()
+    {
+      @Override
+      public void run()
+      {
+        fullDetailsScrollpane.getVerticalScrollBar().setValue(0);
+      }
+    });
+  }
+
+  @Override
+  public void run()
+  {
+    loadingDasSources = true;
+
+    addLocal.setVisible(false);
+    refresh.setVisible(false);
+    progressBar.setVisible(true);
+    progressBar.setIndeterminate(true);
+    setParentGuiEnabled(false);
+    // Refresh the source list.
+    sourceRegistry.refreshSources();
+
+    init();
+
+    setParentGuiEnabled(true);
+    loadingDasSources = false;
+
+  }
+
+  private void setParentGuiEnabled(boolean b)
+  {
+    if (fs != null)
+    {
+      fs.fetchDAS.setEnabled(b);
+      fs.saveDAS.setEnabled(b);
+    }
+  }
+
+  public Vector<jalviewSourceI> getSelectedSources()
+  {
+    // wait around if we're still loading.
+    while (sourceRegistry == null)
+    {
+      if (!loadingDasSources)
+      {
+        new Thread(this).start();
+        try
+        {
+          Thread.sleep(5);
+        } catch (Exception e)
+        {
+        }
+        ;
+        while (loadingDasSources)
+        {
+          try
+          {
+            Thread.sleep(5);
+          } catch (Exception e)
+          {
+          }
+          ;
+        }
+        ;
+      }
+    }
+
+    Vector<jalviewSourceI> selected = new Vector<jalviewSourceI>();
+    for (String source : selectedSources)
+    {
+      jalviewSourceI srce = sourceRegistry.getSource(source);
+      if (srce != null)
+      {
+        selected.addElement(srce);
+      }
+    }
+    return selected;
+  }
+
+  @Override
+  public void refresh_actionPerformed(ActionEvent e)
+  {
+    saveProperties(jalview.bin.Cache.applicationProperties);
+
+    Thread worker = new Thread(this);
+    worker.start();
+  }
+
+  private void setCapabilities(DasSourceRegistryI sourceRegistry2)
+  {
+    Vector<String> authority = new Vector<String>();
+    Vector<String> type = new Vector<String>();
+    Vector<String> label = new Vector<String>();
+    Vector<String> taxIds = new Vector<String>();
+    authority.add("Any");
+    type.add("Any");
+    label.add("Any");
+
+    for (jalviewSourceI ds : sourceRegistry2.getSources())
+    {
+      VERSION latest = ds.getVersion();
+
+      for (COORDINATES cs : latest.getCOORDINATES())
+      {
+        if (!type.contains(cs.getSource()))
+        {
+          type.add(cs.getSource()); // source==category
+        }
+
+        if (!authority.contains(cs.getAuthority()))
+        {
+          authority.add(cs.getAuthority());
+        }
+      }
+
+      for (PROP slabel : latest.getPROP())
+      {
+        if (slabel.getName().equalsIgnoreCase("LABEL")
+                && !label.contains(slabel.getValue()))
+        {
+          label.add(slabel.getValue());
+        }
+      }
+
+    }
+
+    filter1.setListData(authority);
+    filter2.setListData(type);
+    filter3.setListData(label);
+    // filter4 taxIds
+
+    javax.swing.SwingUtilities.invokeLater(new Runnable()
+    {
+      @Override
+      public void run()
+      {
+        filter1.setSelectedIndex(0);
+        filter2.setSelectedIndex(0);
+        filter3.setSelectedIndex(0);
+      }
+    });
+  }
+
+  @Override
+  public void amendLocal(boolean newSource)
+  {
+    String url = "http://localhost:8080/", nickname = "";
+    boolean seqsrc = false;
+    if (!newSource)
+    {
+      int selectedRow = table.getSelectionModel().getMinSelectionIndex();
+      nickname = table.getValueAt(selectedRow, 0).toString();
+      jalviewSourceI source = sourceRegistry.getSource(nickname);
+      url = source.getUri();
+      seqsrc = source.isSequenceSource();
+    }
+
+    JTextField nametf = new JTextField(nickname, 40);
+    JTextField urltf = new JTextField(url, 40);
+    JCheckBox seqs = new JCheckBox(
+            MessageManager.getString("label.sequence_source"));
+    seqs.setSelected(seqsrc);
+    JPanel panel = new JPanel(new BorderLayout());
+    JPanel pane12 = new JPanel(new BorderLayout());
+    pane12.add(new JLabel(MessageManager.getString("label.name:")),
+            BorderLayout.CENTER);
+    pane12.add(nametf, BorderLayout.EAST);
+    panel.add(pane12, BorderLayout.NORTH);
+    pane12 = new JPanel(new BorderLayout());
+    pane12.add(new JLabel(MessageManager.getString("label.url")),
+            BorderLayout.NORTH);
+    pane12.add(seqs, BorderLayout.SOUTH);
+    pane12.add(urltf, BorderLayout.EAST);
+    panel.add(pane12, BorderLayout.SOUTH);
+
+    int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
+            panel,
+            MessageManager.getString("label.enter_local_das_source"),
+            JOptionPane.OK_CANCEL_OPTION);
+
+    if (reply != JOptionPane.OK_OPTION)
+    {
+      return;
+    }
+
+    if (!urltf.getText().endsWith("/"))
+    {
+      urltf.setText(urltf.getText() + "/");
+    }
+
+    jalviewSourceI local = sourceRegistry.createLocalSource(
+            urltf.getText(), nametf.getText(), seqs.isSelected(), true);
+    List sources = sourceRegistry.getSources();
+    int osize = sources.size();
+    int size = osize + (newSource ? 1 : 0);
+
+    Object[][] data = new Object[size][2];
+    DASTableModel dtm = (table != null) ? (DASTableModel) ((TableSorter) table
+            .getModel()).getTableModel() : null;
+    for (int i = 0; i < osize; i++)
+    {
+      String osrc = (dtm == null || i >= osize) ? null : (String) dtm
+              .getValueAt(i, 0);
+      if (!newSource && osrc != null
+              && dtm.getValueAt(i, 0).equals(nickname))
+      {
+        data[i][0] = local.getTitle();
+        data[i][1] = new Boolean(true);
+      }
+      else
+      {
+        data[i][0] = osrc;
+        data[i][1] = new Boolean(selectedSources.contains(osrc));
+      }
+    }
+    // Always add a new source at the end
+    if (newSource)
+    {
+      data[osize][0] = local.getTitle();
+      data[osize][1] = new Boolean(true);
+      selectedSources.add(local.getTitle());
+    }
+
+    refreshTableData(data);
+
+    SwingUtilities.invokeLater(new Runnable()
+    {
+      @Override
+      public void run()
+      {
+        scrollPane.getVerticalScrollBar().setValue(
+                scrollPane.getVerticalScrollBar().getMaximum());
+      }
+    });
+
+    displayFullDetails(local.getTitle());
+  }
+
+  public void editRemoveLocalSource(MouseEvent evt)
+  {
+    int selectedRow = table.getSelectionModel().getMinSelectionIndex();
+    if (selectedRow == -1)
+    {
+      return;
+    }
+
+    String nickname = table.getValueAt(selectedRow, 0).toString();
+
+    if (!sourceRegistry.getSource(nickname).isLocal())
+    {
+      JOptionPane
+              .showInternalMessageDialog(
+                      Desktop.desktop,
+                      MessageManager
+                              .getString("label.you_can_only_edit_or_remove_local_das_sources"),
+                      MessageManager.getString("label.public_das_source"),
+                      JOptionPane.WARNING_MESSAGE);
+      return;
+    }
+
+    Object[] options = { "Edit", "Remove", "Cancel" };
+    int choice = JOptionPane.showInternalOptionDialog(Desktop.desktop,
+            "Do you want to edit or remove " + nickname + "?",
+            "Edit / Remove Local DAS Source",
+            JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,
+            null, options, options[2]);
+
+    switch (choice)
+    {
+    case 0:
+      amendLocal(false);
+      break;
+    case 1:
+      sourceRegistry.removeLocalSource(sourceRegistry.getSource(nickname));
+      selectedSources.remove(nickname);
+      Object[][] data = new Object[sourceRegistry.getSources().size()][2];
+      int index = 0,
+      l = table.getRowCount();
+
+      for (int i = 0; i < l; i++)
+      {
+        String nm;
+        if ((nm = (String) table.getValueAt(i, 0)).equals(nickname))
+        {
+          continue;
+        }
+        else
+        {
+          data[index][0] = nm;
+          data[index][1] = new Boolean(selectedSources.contains(nm));
+          index++;
+        }
+      }
+      refreshTableData(data);
+      SwingUtilities.invokeLater(new Runnable()
+      {
+        @Override
+        public void run()
+        {
+          scrollPane.getVerticalScrollBar().setValue(
+                  scrollPane.getVerticalScrollBar().getMaximum());
+        }
+      });
+
+      break;
+    }
+  }
+
+  @Override
+  public void valueChanged(ListSelectionEvent evt)
+  {
+    // Called when the MainTable selection changes
+    if (evt.getValueIsAdjusting())
+    {
+      return;
+    }
+
+    displayFullDetails(null);
+
+    // Filter the displayed data sources
+
+    ArrayList names = new ArrayList();
+    ArrayList selected = new ArrayList();
+
+    // The features filter is not visible, but we must still
+    // filter the das source list here.
+    // July 2006 - only 6 sources fo not serve features
+    Object[] dummyFeatureList = new Object[] { "features" };
+    List<jalviewSourceI> srcs = sourceRegistry.getSources();
+    for (jalviewSourceI ds : srcs)
+    {
+
+      VERSION v = ds.getVersion();
+      List<COORDINATES> coords = v.getCOORDINATES();
+      if (ds.isLocal()
+              || ((coords == null || coords.size() == 0)
+                      && filter1.getSelectedIndex() == 0
+                      && filter2.getSelectedIndex() == 0 && filter3
+                      .getSelectedIndex() == 0))
+      {
+        // THIS IS A FIX FOR LOCAL SOURCES WHICH DO NOT
+        // HAVE COORDINATE SYSTEMS, INFO WHICH AT PRESENT
+        // IS ADDED FROM THE REGISTRY
+        names.add(ds.getTitle());
+        selected.add(new Boolean(selectedSources.contains(ds.getTitle())));
+        continue;
+      }
+
+      if (!selectedInList(dummyFeatureList, ds.getCapabilityList(v))
+              || !selectedInList(filter3.getSelectedValues(),
+                      ds.getLabelsFor(v)))
+      {
+        continue;
+      }
+
+      for (int j = 0; j < coords.size(); j++)
+      {
+        if (selectedInList(filter1.getSelectedValues(),
+                new String[] { coords.get(j).getAuthority() })
+                && selectedInList(filter2.getSelectedValues(), new String[]
+                { coords.get(j).getSource() }))
+        {
+          names.add(ds.getTitle());
+          selected.add(new Boolean(selectedSources.contains(ds.getTitle())));
+          break;
+        }
+      }
+    }
+
+    int dSize = names.size();
+    Object[][] data = new Object[dSize][2];
+    for (int d = 0; d < dSize; d++)
+    {
+      data[d][0] = names.get(d);
+      data[d][1] = selected.get(d);
+    }
+
+    refreshTableData(data);
+  }
+
+  private boolean selectedInList(Object[] selection, String[] items)
+  {
+    for (int i = 0; i < selection.length; i++)
+    {
+      if (selection[i].equals("Any"))
+      {
+        return true;
+      }
+      if (items == null || items.length == 0)
+      {
+        return false;
+      }
+      String sel = (items[0].startsWith("das1:") ? "das1:" : "")
+              + selection[i];
+      for (int j = 0; j < items.length; j++)
+      {
+        if (sel.equals(items[j]))
+        {
+          return true;
+        }
+      }
+    }
+
+    return false;
+  }
+
+  void setSelectedFromProperties()
+  {
+    String active = jalview.bin.Cache.getDefault("DAS_ACTIVE_SOURCE",
+            "uniprot");
+    StringTokenizer st = new StringTokenizer(active, "\t");
+    selectedSources = new Vector();
+    while (st.hasMoreTokens())
+    {
+      selectedSources.addElement(st.nextToken());
+    }
+  }
+
+  @Override
+  public void reset_actionPerformed(ActionEvent e)
+  {
+    registryURL.setText(sourceRegistry.getDasRegistryURL());
+  }
+
+  /**
+   * set the DAS source settings in the given jalview properties.
+   * 
+   * @param properties
+   */
+  public void saveProperties(Properties properties)
+  {
+    if (registryURL.getText() == null || registryURL.getText().length() < 1)
+    {
+      properties.remove(jalview.bin.Cache.DAS_REGISTRY_URL);
+    }
+    else
+    {
+      properties.setProperty(jalview.bin.Cache.DAS_REGISTRY_URL,
+              registryURL.getText());
+    }
+
+    StringBuffer sb = new StringBuffer();
+    for (int r = 0; r < table.getModel().getRowCount(); r++)
+    {
+      if (((Boolean) table.getValueAt(r, 1)).booleanValue())
+      {
+        sb.append(table.getValueAt(r, 0) + "\t");
+      }
+    }
+
+    properties.setProperty(jalview.bin.Cache.DAS_ACTIVE_SOURCE,
+            sb.toString());
+
+    String sourceprop = sourceRegistry.getLocalSourceString();
+    properties.setProperty(jalview.bin.Cache.DAS_LOCAL_SOURCE, sourceprop);
+  }
+
+  class DASTableModel extends AbstractTableModel
+  {
+
+    public DASTableModel(Object[][] data)
+    {
+      this.data = data;
+    }
+
+    private String[] columnNames = new String[] {
+        MessageManager.getString("label.nickname"),
+        MessageManager.getString("label.use_source") };
+
+    private Object[][] data;
+
+    @Override
+    public int getColumnCount()
+    {
+      return columnNames.length;
+    }
+
+    @Override
+    public int getRowCount()
+    {
+      return data.length;
+    }
+
+    @Override
+    public String getColumnName(int col)
+    {
+      return columnNames[col];
+    }
+
+    @Override
+    public Object getValueAt(int row, int col)
+    {
+      return data[row][col];
+    }
+
+    /*
+     * JTable uses this method to determine the default renderer/ editor for
+     * each cell. If we didn't implement this method, then the last column would
+     * contain text ("true"/"false"), rather than a check box.
+     */
+    @Override
+    public Class getColumnClass(int c)
+    {
+      return getValueAt(0, c).getClass();
+    }
+
+    /*
+     * Don't need to implement this method unless your table's editable.
+     */
+    @Override
+    public boolean isCellEditable(int row, int col)
+    {
+      // Note that the data/cell address is constant,
+      // no matter where the cell appears onscreen.
+      return col == 1;
+
+    }
+
+    /*
+     * Don't need to implement this method unless your table's data can change.
+     */
+    @Override
+    public void setValueAt(Object value, int row, int col)
+    {
+      data[row][col] = value;
+      fireTableCellUpdated(row, col);
+
+      String name = getValueAt(row, 0).toString();
+      boolean selected = ((Boolean) value).booleanValue();
+
+      if (selectedSources.contains(name) && !selected)
+      {
+        selectedSources.remove(name);
+      }
+
+      if (!selectedSources.contains(name) && selected)
+      {
+        selectedSources.add(name);
+      }
+    }
+  }
+
+  public void initDasSources()
+  {
+
+    Thread thr = new Thread(new Runnable()
+    {
+      @Override
+      public void run()
+      {
+        // this actually initialises the das source list
+        paintComponent(null); // yuk
+      }
+    });
+    thr.start();
+    while (loadingDasSources || sourceRegistry == null)
+    {
+      try
+      {
+        Thread.sleep(10);
+      } catch (Exception e)
+      {
+      }
+      ;
+    }
+  }
+
+  /**
+   * disable or enable the buttons on the source browser
+   * 
+   * @param b
+   */
+  public void setGuiEnabled(boolean b)
+  {
+    refresh.setEnabled(b);
+    addLocal.setEnabled(b);
+  }
+}