/*\r
* Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)\r
- * Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle\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
*/\r
package jalview.gui;\r
\r
-import java.text.ParseException;\r
-import java.util.*;\r
-import java.util.List;\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.*;\r
-import java.awt.event.*;\r
-import javax.swing.*;\r
-import javax.swing.event.*;\r
-import javax.swing.table.*;\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.dassources.Capabilities;\r
-import org.biodas.jdas.dassources.utils.DasCoordinateSystemCollector;\r
-import org.biodas.jdas.dassources.utils.DasTimeFormat;\r
-import org.biodas.jdas.schema.registrycoordinates.DASCOORDINATESYSTEM;\r
import org.biodas.jdas.schema.sources.CAPABILITY;\r
import org.biodas.jdas.schema.sources.COORDINATES;\r
-import org.biodas.jdas.schema.sources.MAINTAINER;\r
import org.biodas.jdas.schema.sources.PROP;\r
-import org.biodas.jdas.schema.sources.SOURCE;\r
-import org.biodas.jdas.schema.sources.SOURCES;\r
import org.biodas.jdas.schema.sources.VERSION;\r
\r
-import jalview.jbgui.*;\r
-import jalview.util.*;\r
-\r
public class DasSourceBrowser extends GDasSourceBrowser implements\r
Runnable, ListSelectionListener\r
{\r
- static org.biodas.jdas.schema.sources.SOURCE[] dasSources = null;\r
+ DasSourceRegistryI sourceRegistry = null;\r
\r
- Hashtable<String, SOURCE> localSources = null;\r
-\r
- Vector selectedSources;\r
-\r
- public static String DEFAULT_REGISTRY = "http://www.dasregistry.org/das1/sources/";\r
-\r
- /**\r
- * true if thread is running and we are talking to DAS registry service\r
- */\r
- public boolean loadingDasSources = false;\r
-\r
- protected static String getDasRegistryURL()\r
- {\r
- String registry = jalview.bin.Cache.getDefault("DAS_REGISTRY_URL",\r
- DEFAULT_REGISTRY);\r
-\r
- if (registry.indexOf("/registry/das1/sources/") > -1)\r
- {\r
- jalview.bin.Cache.setProperty(jalview.bin.Cache.DAS_REGISTRY_URL,\r
- DEFAULT_REGISTRY);\r
- registry = DEFAULT_REGISTRY;\r
- }\r
- return registry;\r
- }\r
+ Vector<String> selectedSources;\r
\r
public DasSourceBrowser(FeatureSettings featureSettings)\r
{\r
fs = featureSettings;\r
- String registry = getDasRegistryURL();\r
+ // TODO DasSourceRegistryProvider API\r
+ sourceRegistry = jalview.bin.Cache.getDasSourceRegistry();\r
+ String registry = sourceRegistry.getDasRegistryURL();\r
\r
registryURL.setText(registry);\r
\r
}\r
});\r
\r
- if (dasSources != null)\r
+ if (sourceRegistry.getSources() != null)\r
{\r
init();\r
}\r
\r
FeatureSettings fs = null;\r
\r
+ private boolean loadingDasSources;\r
+\r
public DasSourceBrowser()\r
{\r
this(null);\r
\r
public void paintComponent(java.awt.Graphics g)\r
{\r
- if (dasSources == null && !loadingDasSources)\r
+ if (sourceRegistry == null)\r
{\r
Thread worker = new Thread(this);\r
worker.start();\r
\r
void init()\r
{\r
- int dSize = dasSources.length;\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] = dasSources[i].getTitle(); // what's equivalent of nickname\r
- data[i][1] = new Boolean(selectedSources.contains(dasSources[i]\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(dasSources);\r
+ setCapabilities(sourceRegistry);\r
\r
javax.swing.SwingUtilities.invokeLater(new Runnable()\r
{\r
return;\r
}\r
\r
- int dSize = dasSources.length;\r
- for (int i = 0; i < dSize; i++)\r
+ int dSize = sourceRegistry.getSources().size();\r
+ for (jalviewSourceI ds : sourceRegistry.getSources())\r
{\r
- if (!dasSources[i].getTitle().equals(nickName))\r
+ if (!ds.getTitle().equals(nickName))\r
{\r
continue;\r
}\r
\r
- SOURCE ds = dasSources[i];\r
- VERSION latest = getVersionFor(ds);\r
- text.append("<font color=\"#0000FF\">Id:</font> "\r
- + dasSources[i].getUri() + "<br>");\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
- + dasSources[i].getTitle() + "<br>");\r
- text.append("<font color=\"#0000FF\">URL:</font> " + latest.getUri()\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\">Admin Email:</font> <a href=\"mailto:"\r
- + ds.getMAINTAINER().getEmail()\r
- + "\">"\r
- + ds.getMAINTAINER().getEmail() + "</a>" + "<br>");\r
+ text.append("<font color=\"#0000FF\">Description:</font> "\r
+ + ds.getDescription() + "<br>");\r
\r
- text.append("<font color=\"#0000FF\">Registered at:</font> "\r
- + latest.getCreated() + "<br>");\r
+ text.append("<font color=\"#0000FF\">Admin Email:</font> <a href=\"mailto:"\r
+ + ds.getEmail() + "\">" + ds.getEmail() + "</a>" + "<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
+ 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
+ if (b)\r
{\r
text.append(",");\r
}\r
CAPABILITY[] scap = latest.getCAPABILITY().toArray(new CAPABILITY[0]);\r
for (int j = 0; j < scap.length; j++)\r
{\r
- text.append(scap[j]);\r
+ text.append(scap[j].getType());\r
if (j < scap.length - 1)\r
{\r
text.append(", ");\r
}\r
text.append("<br>");\r
\r
- text.append("<font color=\"#0000FF\">Coordinates:</font> ");\r
+ text.append("<font color=\"#0000FF\">Coordinates:</font>");\r
+ int i=1;\r
for (COORDINATES dcs : latest.getCOORDINATES())\r
{\r
- text.append("(" + dcs.getUri() + ") "\r
-\r
- + dcs.getSource() + ", " + dcs.getAuthority());\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(", " + dcs.getTaxid());\r
+ text.append(" [TaxId:" + dcs.getTaxid()+"]");\r
}\r
- if (dcs.getVersion().trim().length() > 0)\r
+ if (dcs.getVersion() != null\r
+ && dcs.getVersion().trim().length() > 0)\r
{\r
{\r
- text.append(", " + dcs.getVersion());\r
+ text.append(" {v. " + dcs.getVersion()+"}");\r
}\r
-\r
- text.append("<br>");\r
}\r
-\r
- text.append("<font color=\"#0000FF\">Description:</font> "\r
- + dasSources[i].getDescription() + "<br>");\r
-\r
- if (dasSources[i].getDocHref() != null\r
- && dasSources[i].getDocHref().length() > 0)\r
- {\r
- text.append("<font color=\"#0000FF\"><a href=\""\r
- + dasSources[i].getDocHref()\r
- + "\">Go to site</a></font<br>");\r
- }\r
-\r
- text.append("</font></html>");\r
-\r
- break;\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
progressBar.setIndeterminate(true);\r
setParentGuiEnabled(false);\r
// Refresh the source list.\r
- dasSources = null;\r
- getDASSource();\r
+ sourceRegistry.refreshSources();\r
\r
init();\r
\r
}\r
}\r
\r
- public Vector getSelectedSources()\r
+ public Vector<jalviewSourceI> getSelectedSources()\r
{\r
// wait around if we're still loading.\r
- while (dasSources == null)\r
+ while (sourceRegistry == null)\r
{\r
if (!loadingDasSources)\r
{\r
}\r
}\r
\r
- Vector selected = new Vector();\r
- for (int r = 0; r < selectedSources.size(); r++)\r
+ Vector<jalviewSourceI> selected = new Vector<jalviewSourceI>();\r
+ for (String source : selectedSources)\r
{\r
- for (int i = 0; i < dasSources.length; i++)\r
+ jalviewSourceI srce = sourceRegistry.getSource(source);\r
+ if (srce != null)\r
{\r
- if (dasSources[i].getTitle().equals(selectedSources.elementAt(r)))\r
- {\r
- selected.addElement(dasSources[i]);\r
- break;\r
- }\r
+ selected.addElement(srce);\r
}\r
}\r
-\r
return selected;\r
}\r
\r
- /**\r
- * retrieve das sources from registry and add local source list\r
- * \r
- * @return\r
- */\r
- public SOURCE[] getDASSource()\r
- {\r
- if (dasSources == null)\r
- {\r
- dasSources = jalview.ws.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
worker.start();\r
}\r
\r
- private boolean isLaterThan(String ref, String newer)\r
- {\r
- Date refdate = null, newdate = null;\r
- try\r
- {\r
- refdate = DasTimeFormat.fromDASString(ref);\r
-\r
- } catch (ParseException x)\r
- {\r
- return false;\r
- }\r
- try\r
- {\r
- newdate = DasTimeFormat.fromDASString(newer);\r
- } catch (ParseException e)\r
- {\r
- // TODO: handle exception\r
- }\r
- if (refdate != null)\r
- {\r
- if (newdate != null)\r
- {\r
- return refdate.before(newdate);\r
- }\r
- return false;\r
- }\r
- if (newdate != null)\r
- {\r
- return true;\r
- }\r
- // assume first instance of source is newest in list. - TODO: check if\r
- // natural ordering of source versions is newest first or oldest first\r
- return false;\r
- }\r
-\r
- private VERSION getVersionFor(SOURCE ds)\r
- {\r
- VERSION latest = null;\r
- for (VERSION v : ds.getVERSION())\r
- {\r
- if (latest == null\r
- || isLaterThan(latest.getCreated(), v.getCreated()))\r
- {\r
- // TODO: das 1.6 - should just get the first version - ignore other\r
- // versions since not specified how to construct URL from version's URI\r
- // + source URI\r
- latest = v;\r
- }\r
- }\r
- return latest;\r
- }\r
-\r
- private void setCapabilities(SOURCE[] sources)\r
+ private void setCapabilities(DasSourceRegistryI sourceRegistry2)\r
{\r
Vector<String> authority = new Vector<String>();\r
Vector<String> type = new Vector<String>();\r
type.add("Any");\r
label.add("Any");\r
\r
- for (int i = 0; i < sources.length; i++)\r
+ for (jalviewSourceI ds : sourceRegistry2.getSources())\r
{\r
- SOURCE ds = sources[i];\r
- VERSION latest = getVersionFor(ds);\r
+ VERSION latest = ds.getVersion();\r
\r
for (COORDINATES cs : latest.getCOORDINATES())\r
{\r
{\r
int selectedRow = table.getSelectionModel().getMinSelectionIndex();\r
nickname = table.getValueAt(selectedRow, 0).toString();\r
- url = ((SOURCE) localSources.get(nickname)).getUri();\r
- seqsrc = ((SOURCE) localSources.get(nickname)).getVERSION().get(0)\r
- .getCAPABILITY().contains(Capabilities.SEQUENCE);\r
+ jalviewSourceI source = sourceRegistry.getSource(nickname);\r
+ url = source.getUri();\r
+ seqsrc = source.isSequenceSource();\r
}\r
\r
JTextField nametf = new JTextField(nickname, 40);\r
urltf.setText(urltf.getText() + "/");\r
}\r
\r
- SOURCE local = createLocalSource(urltf.getText(), nametf.getText(), seqs.isSelected(), true);\r
- \r
- if (localSources == null)\r
- {\r
- localSources = new Hashtable();\r
- }\r
-\r
- localSources.put(local.getTitle(), local);\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
- if (!newSource && !nickname.equals(nametf.getText()))\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
- 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].getTitle().equals(nickname))\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
- dasSources[i] = local;\r
data[i][0] = local.getTitle();\r
data[i][1] = new Boolean(true);\r
}\r
else\r
{\r
- data[i][0] = dasSources[i].getTitle();\r
- data[i][1] = new Boolean(selectedSources.contains(dasSources[i]\r
- .getTitle()));\r
+ data[i][0] = osrc;\r
+ data[i][1] = new Boolean(selectedSources.contains(osrc));\r
}\r
}\r
-\r
+ // Always add a new source at the end\r
if (newSource)\r
{\r
- data[size][0] = local.getTitle();\r
- data[size][1] = new Boolean(true);\r
+ data[osize][0] = local.getTitle();\r
+ data[osize][1] = new Boolean(true);\r
selectedSources.add(local.getTitle());\r
}\r
\r
- SOURCE[] tmp = new SOURCE[size + adjust];\r
-\r
- System.arraycopy(dasSources, 0, tmp, 0, size);\r
-\r
- if (newSource)\r
- {\r
- tmp[size] = local;\r
- }\r
-\r
- dasSources = tmp;\r
-\r
refreshTableData(data);\r
\r
SwingUtilities.invokeLater(new Runnable()\r
displayFullDetails(local.getTitle());\r
}\r
\r
- private SOURCE createLocalSource(String url, String name,\r
- boolean sequence, boolean features)\r
- {\r
- SOURCE local = new SOURCE();\r
-\r
- local.setUri(url);\r
- local.setTitle(name);\r
- local.setVERSION(new ArrayList<VERSION>());\r
- VERSION v = new VERSION();\r
- List<CAPABILITY> cp = new ArrayList<CAPABILITY>();\r
- if (sequence)\r
- {\r
-/* Could try and synthesize a coordinate system for the source if needbe\r
- * COORDINATES coord = new COORDINATES();\r
- coord.setAuthority("NCBI");\r
- coord.setSource("Chromosome");\r
- coord.setTaxid("9606");\r
- coord.setVersion("35");\r
- version.getCOORDINATES().add(coord);*/\r
- CAPABILITY cap=new CAPABILITY();\r
- cap.setType("das1:"+Capabilities.SEQUENCE.getName());\r
- cp.add(cap);\r
- }\r
- if (features)\r
- {\r
- CAPABILITY cap = new CAPABILITY();\r
- cap.setType("das1:"+Capabilities.FEATURES.getName());\r
- cp.add(cap);\r
- }\r
- \r
- v.getCAPABILITY().addAll(cp);\r
- local.getVERSION().add(v);\r
-\r
- return local;\r
- }\r
-\r
public void editRemoveLocalSource(MouseEvent evt)\r
{\r
int selectedRow = table.getSelectionModel().getMinSelectionIndex();\r
\r
String nickname = table.getValueAt(selectedRow, 0).toString();\r
\r
- if (!localSources.containsKey(nickname))\r
+ if (!sourceRegistry.getSource(nickname).isLocal())\r
{\r
JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
"You can only edit or remove local DAS Sources!",\r
amendLocal(false);\r
break;\r
case 1:\r
- localSources.remove(nickname);\r
+ sourceRegistry.removeLocalSource(sourceRegistry.getSource(nickname));\r
selectedSources.remove(nickname);\r
- Object[][] data = new Object[dasSources.length - 1][2];\r
- SOURCE[] tmp = new SOURCE[dasSources.length - 1];\r
- int index = 0;\r
- for (int i = 0; i < dasSources.length; i++)\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
- if (dasSources[i].getTitle().equals(nickname))\r
+ String nm;\r
+ if ((nm = (String) table.getValueAt(i, 0)).equals(nickname))\r
{\r
continue;\r
}\r
else\r
{\r
- tmp[index] = dasSources[i];\r
- data[index][0] = dasSources[i].getTitle();\r
- data[index][1] = new Boolean(\r
- selectedSources.contains(dasSources[i].getTitle()));\r
+ data[index][0] = nm;\r
+ data[index][1] = new Boolean(selectedSources.contains(nm));\r
index++;\r
}\r
}\r
- dasSources = tmp;\r
refreshTableData(data);\r
SwingUtilities.invokeLater(new Runnable()\r
{\r
}\r
}\r
\r
- void appendLocalSources()\r
- {\r
- if (localSources == null)\r
- {\r
- return;\r
- }\r
- // note - we add all das sources to list so they can be filtered for the\r
- // standard fetchDbRefs function\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].getTitle();\r
- data[i][1] = new Boolean(selectedSources.contains(dasSources[i]\r
- .getTitle()));\r
- }\r
-\r
- SOURCE[] tmp = new SOURCE[size + lsize];\r
- if (dasSources != null)\r
- {\r
- System.arraycopy(dasSources, 0, tmp, 0, size);\r
- }\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] = createLocalSource(localSources.get(key).getUri(), key, false, true);\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
displayFullDetails(null);\r
\r
// Filter the displayed data sources\r
- int dSize = dasSources.length;\r
\r
ArrayList names = new ArrayList();\r
ArrayList selected = new ArrayList();\r
- SOURCE 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[]\r
{ "features" };\r
-\r
- for (int i = 0; i < dSize; i++)\r
+ List<jalviewSourceI> srcs = sourceRegistry.getSources();\r
+ for (jalviewSourceI ds : srcs)\r
{\r
- ds = dasSources[i];\r
- VERSION v=getVersionFor(ds);\r
+\r
+ VERSION v = ds.getVersion();\r
List<COORDINATES> coords = v.getCOORDINATES();\r
- if ((coords==null || coords.size()==0)\r
- && filter1.getSelectedIndex() == 0\r
- && filter2.getSelectedIndex() == 0\r
- && filter3.getSelectedIndex() == 0)\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
continue;\r
}\r
\r
- if (!selectedInList(dummyFeatureList, getCapabilityKeys(v))\r
+ if (!selectedInList(dummyFeatureList, ds.getCapabilityList(v))\r
|| !selectedInList(filter3.getSelectedValues(),\r
- getLabelsFor(v)))\r
+ ds.getLabelsFor(v)))\r
{\r
continue;\r
}\r
\r
- for (int j = 0; j <coords.size(); j++)\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
+ { coords.get(j).getSource() }))\r
{\r
names.add(ds.getTitle());\r
selected.add(new Boolean(selectedSources.contains(ds.getTitle())));\r
}\r
}\r
\r
- dSize = names.size();\r
+ int dSize = names.size();\r
Object[][] data = new Object[dSize][2];\r
for (int d = 0; d < dSize; d++)\r
{\r
refreshTableData(data);\r
}\r
\r
- private String[] getLabelsFor(VERSION v)\r
- {\r
- ArrayList<String> labels=new ArrayList<String>();\r
- for (PROP p: v.getPROP())\r
- {\r
- if (p.getName().equalsIgnoreCase("LABEL"))\r
- {\r
- labels.add(p.getValue());\r
- }\r
- }\r
- return labels.toArray(new String[0]);\r
- }\r
-\r
- private String[] getCapabilityKeys(VERSION v)\r
- {\r
-\r
- ArrayList<String> labels=new ArrayList<String>();\r
- for (CAPABILITY p: v.getCAPABILITY())\r
- {\r
- // TODO: work out what to do with namespace prefix \r
- // does SEQUENCE == das1:SEQUENCE and das2:SEQUENCE ?\r
- // for moment, just show all capabilities...\r
- if (p.getType().startsWith("das1:"))\r
- {\r
- labels.add(p.getType());\r
- }\r
- }\r
- return labels.toArray(new String[0]);\r
- }\r
-\r
- boolean selectedInList(Object[] selection, String[] items)\r
+ private boolean selectedInList(Object[] selection, String[] items)\r
{\r
for (int i = 0; i < selection.length; i++)\r
{\r
{\r
return true;\r
}\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 (selection[i].equals(items[j]))\r
+ if (sel.equals(items[j]))\r
{\r
return true;\r
}\r
{\r
selectedSources.addElement(st.nextToken());\r
}\r
-\r
- Vector _localSources = jalview.bin.Cache.getLocalDasSources();\r
- if (_localSources != null)\r
- {\r
- if (localSources == null)\r
- {\r
- localSources = new Hashtable<String, SOURCE>();\r
- }\r
- Enumeration sources = _localSources.elements();\r
- while (sources.hasMoreElements())\r
- {\r
- SOURCE source = (SOURCE) sources.nextElement();\r
- localSources.put(source.getTitle(), source);\r
- }\r
- }\r
}\r
\r
public void reset_actionPerformed(ActionEvent e)\r
{\r
- registryURL.setText(DEFAULT_REGISTRY);\r
+ registryURL.setText(sourceRegistry.getDasRegistryURL());\r
}\r
\r
/**\r
properties.setProperty(jalview.bin.Cache.DAS_ACTIVE_SOURCE,\r
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
- + "|"\r
- + (selectedInList(getCapabilityKeys(getVersionFor(localSources.get(token))),\r
- new String[] { "das1:"+Capabilities.SEQUENCE.getName()}) ? "sequence:" : "")\r
- + getVersionFor(localSources.get(token)).getUri() + "\t");\r
- }\r
-\r
- properties.setProperty(jalview.bin.Cache.DAS_LOCAL_SOURCE,\r
- sb.toString());\r
- }\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
thr.start();\r
- while (loadingDasSources || dasSources == null)\r
+ while (loadingDasSources || sourceRegistry == null)\r
{\r
try\r
{\r
}\r
}\r
\r
- public Vector resolveSourceNicknames(Vector sources)\r
- {\r
-\r
- Vector resolved = new Vector();\r
- if (sources != null)\r
- {\r
- for (int i = 0; i < dasSources.length; i++)\r
- {\r
- if (sources.contains(dasSources[i].getTitle()))\r
- {\r
- if (!resolved.contains(dasSources[i]))\r
- {\r
- resolved.addElement(dasSources[i]);\r
- }\r
- }\r
- }\r
- }\r
- return resolved;\r
- }\r
-\r
/**\r
* disable or enable the buttons on the source browser\r
* \r