X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDasSourceBrowser.java;h=71efbd073ab55c0532b6a7fa5737416250c7e461;hb=af563e083b2a94e50f23d317f260fb734c52c266;hp=90741056628fb623232c2fd6f841a1f11184d626;hpb=c2d22d00716c6865d4d090ba1db5f7c063166e77;p=jalview.git diff --git a/src/jalview/gui/DasSourceBrowser.java b/src/jalview/gui/DasSourceBrowser.java index 9074105..71efbd0 100755 --- a/src/jalview/gui/DasSourceBrowser.java +++ b/src/jalview/gui/DasSourceBrowser.java @@ -1,67 +1,66 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) - * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7) + * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle * - * This program 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 2 - * of the License, or (at your option) any later version. + * This file is part of Jalview. * - * This program 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. + * 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. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * 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 . */ package jalview.gui; -import java.util.*; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.table.*; - -import org.biojava.dasobert.dasregistry.*; -import jalview.jbgui.*; -import jalview.util.*; +import jalview.jbgui.GDasSourceBrowser; +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 { - static DasSource[] dasSources = null; - - Hashtable localSources = null; - - Vector selectedSources; - - public static String DEFAULT_REGISTRY = "http://www.dasregistry.org/das1/sources/"; - - /** - * true if thread is running and we are talking to DAS registry service - */ - public boolean loadingDasSources = false; + DasSourceRegistryI sourceRegistry = null; - protected static String getDasRegistryURL() - { - String registry = jalview.bin.Cache.getDefault("DAS_REGISTRY_URL", - DEFAULT_REGISTRY); - - if (registry.indexOf("/registry/das1/sources/") > -1) - { - jalview.bin.Cache.setProperty(jalview.bin.Cache.DAS_REGISTRY_URL, DEFAULT_REGISTRY); - registry = DEFAULT_REGISTRY; - } - return registry; - } + Vector selectedSources; - public DasSourceBrowser() + public DasSourceBrowser(FeatureSettings featureSettings) { - String registry = getDasRegistryURL(); + fs = featureSettings; + // TODO DasSourceRegistryProvider API + sourceRegistry = jalview.bin.Cache.getDasSourceRegistry(); + String registry = sourceRegistry.getDasRegistryURL(); registryURL.setText(registry); @@ -101,15 +100,24 @@ public class DasSourceBrowser extends GDasSourceBrowser implements } }); - if (dasSources != null) + if (sourceRegistry.getSources() != null) { init(); } } + FeatureSettings fs = null; + + private boolean loadingDasSources; + + public DasSourceBrowser() + { + this(null); + } + public void paintComponent(java.awt.Graphics g) { - if (dasSources == null && !loadingDasSources) + if (sourceRegistry == null) { Thread worker = new Thread(this); worker.start(); @@ -118,17 +126,18 @@ public class DasSourceBrowser extends GDasSourceBrowser implements void init() { - int dSize = dasSources.length; + List sources = sourceRegistry.getSources(); + int dSize = sources.size(); Object[][] data = new Object[dSize][2]; for (int i = 0; i < dSize; i++) { - data[i][0] = dasSources[i].getNickname(); - data[i][1] = new Boolean(selectedSources.contains(dasSources[i] - .getNickname())); + 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(dasSources); + setCapabilities(sourceRegistry); javax.swing.SwingUtilities.invokeLater(new Runnable() { @@ -166,52 +175,73 @@ public class DasSourceBrowser extends GDasSourceBrowser implements return; } - int dSize = dasSources.length; - for (int i = 0; i < dSize; i++) + int dSize = sourceRegistry.getSources().size(); + for (jalviewSourceI ds : sourceRegistry.getSources()) { - if (!dasSources[i].getNickname().equals(nickName)) + if (!ds.getTitle().equals(nickName)) { continue; } - DasSource ds = dasSources[i]; - - text.append("Id: " - + dasSources[i].getId() + "
"); + VERSION latest = ds.getVersion(); + text.append("Id: " + ds.getUri() + + "
"); text.append("Nickname: " - + dasSources[i].getNickname() + "
"); - text.append("URL: " - + dasSources[i].getUrl() + "
"); + + ds.getTitle() + "
"); + + text.append("URL: " + ds.getSourceURL() + "" + + "
"); + if (!ds.isLocal()) + { + if (ds.getDocHref() != null && ds.getDocHref().length() > 0) + { + text.append("Site: " + ds.getDocHref() + "" + + "
"); + } - text - .append("Admin Email: " - + dasSources[i].getAdminemail() + "" + "
"); + text.append("Description: " + + ds.getDescription() + "
"); - text.append("Registered at: " - + dasSources[i].getRegisterDate() + "
"); + text.append("Admin Email: " + ds.getEmail() + "" + "
"); - text.append("Last successful test: " - + dasSources[i].getLeaseDate() + "
"); + text.append("Registered at: " + + latest.getCreated() + "
"); + // TODO: Identify last successful test date + // text.append("Last successful test: " + // + latest.dasSources[i].getLeaseDate() + "
"); + } + else + { + text.append("Source was added manually.
"); + } text.append("Labels: "); - for (int s = 0; s < dasSources[i].getLabels().length; s++) + boolean b = false; + for (PROP labl : latest.getPROP()) { - text.append(dasSources[i].getLabels()[s]); - if (s < dasSources[i].getLabels().length - 1) + if (labl.getName().equalsIgnoreCase("LABEL")) { - text.append(","); + if (b) + { + text.append(","); + } + text.append(" "); + + text.append(labl.getValue()); + b = true; } - text.append(" "); + ; } text.append("
"); text.append("Capabilities: "); - String[] scap = dasSources[i].getCapabilities(); + CAPABILITY[] scap = latest.getCAPABILITY().toArray(new CAPABILITY[0]); for (int j = 0; j < scap.length; j++) { - text.append(scap[j]); + text.append(scap[j].getType()); if (j < scap.length - 1) { text.append(", "); @@ -219,35 +249,25 @@ public class DasSourceBrowser extends GDasSourceBrowser implements } text.append("
"); - text.append("Coordinates: "); - DasCoordinateSystem[] dcs = ds.getCoordinateSystem(); - for (int j = 0; j < dcs.length; j++) + text.append("Coordinates:"); + int i=1; + for (COORDINATES dcs : latest.getCOORDINATES()) { - text.append("(" + dcs[j].getUniqueId() + ") " - + dcs[j].getCategory() + ", " + dcs[j].getName()); - if (dcs[j].getNCBITaxId() != 0) + text.append("
"+i+++". "); + text.append(dcs.getAuthority()+" : "+dcs.getSource()); + if (dcs.getTaxid() != null && dcs.getTaxid().trim().length() > 0) { - text.append(", " + dcs[j].getNCBITaxId()); + text.append(" [TaxId:" + dcs.getTaxid()+"]"); } - if (dcs[j].getOrganismName().length() > 0) + if (dcs.getVersion() != null + && dcs.getVersion().trim().length() > 0) { - text.append(", " + dcs[j].getOrganismName()); + { + text.append(" {v. " + dcs.getVersion()+"}"); + } } - - text.append("
"); + text.append(" ("+dcs.getUri() + ")"); } - - text.append("Description: " - + dasSources[i].getDescription() + "
"); - - if (dasSources[i].getHelperurl() != null - && dasSources[i].getHelperurl().length() > 0) - { - text.append("Go to site"); - } - text.append(""); break; @@ -271,64 +291,67 @@ public class DasSourceBrowser extends GDasSourceBrowser implements refresh.setVisible(false); progressBar.setVisible(true); progressBar.setIndeterminate(true); + setParentGuiEnabled(false); // Refresh the source list. - dasSources = null; - getDASSource(); + sourceRegistry.refreshSources(); init(); + setParentGuiEnabled(true); loadingDasSources = false; } - public Vector getSelectedSources() + private void setParentGuiEnabled(boolean b) + { + if (fs != null) + { + fs.fetchDAS.setEnabled(b); + fs.saveDAS.setEnabled(b); + } + } + + public Vector getSelectedSources() { // wait around if we're still loading. - while (dasSources ==null) { + while (sourceRegistry == null) + { if (!loadingDasSources) { new Thread(this).start(); - try { Thread.sleep(5); } catch (Exception e) {}; + try + { + Thread.sleep(5); + } catch (Exception e) + { + } + ; while (loadingDasSources) { - try { Thread.sleep(5); } catch (Exception e) {}; - }; + try + { + Thread.sleep(5); + } catch (Exception e) + { + } + ; + } + ; } } - - Vector selected = new Vector(); - for (int r = 0; r < selectedSources.size(); r++) + + Vector selected = new Vector(); + for (String source : selectedSources) { - for (int i = 0; i < dasSources.length; i++) + jalviewSourceI srce = sourceRegistry.getSource(source); + if (srce != null) { - if (dasSources[i].getNickname() - .equals(selectedSources.elementAt(r))) - { - selected.addElement(dasSources[i]); - break; - } + selected.addElement(srce); } } - return selected; } - /** - * retrieve das sources from registry and add local source list - * - * @return - */ - public DasSource[] getDASSource() - { - if (dasSources == null) - { - dasSources = jalview.ws.DasSequenceFeatureFetcher.getDASSources(); - appendLocalSources(); - } - - return dasSources; - } - public void refresh_actionPerformed(ActionEvent e) { saveProperties(jalview.bin.Cache.applicationProperties); @@ -337,41 +360,39 @@ public class DasSourceBrowser extends GDasSourceBrowser implements worker.start(); } - private void setCapabilities(DasSource[] sources) + private void setCapabilities(DasSourceRegistryI sourceRegistry2) { - Vector authority = new Vector(); - Vector type = new Vector(); - Vector label = new Vector(); - - authority.addElement("Any"); - type.addElement("Any"); - label.addElement("Any"); + Vector authority = new Vector(); + Vector type = new Vector(); + Vector label = new Vector(); + Vector taxIds = new Vector(); + authority.add("Any"); + type.add("Any"); + label.add("Any"); - for (int i = 0; i < sources.length; i++) + for (jalviewSourceI ds : sourceRegistry2.getSources()) { - DasSource ds = sources[i]; + VERSION latest = ds.getVersion(); - DasCoordinateSystem[] dcs = ds.getCoordinateSystem(); - - for (int j = 0; j < dcs.length; j++) + for (COORDINATES cs : latest.getCOORDINATES()) { - if (!type.contains(dcs[j].getCategory())) + if (!type.contains(cs.getSource())) { - type.addElement(dcs[j].getCategory()); + type.add(cs.getSource()); // source==category } - if (!authority.contains(dcs[j].getName())) + if (!authority.contains(cs.getAuthority())) { - authority.addElement(dcs[j].getName()); + authority.add(cs.getAuthority()); } } - String[] slabels = ds.getLabels(); - for (int s = 0; s < slabels.length; s++) + for (PROP slabel : latest.getPROP()) { - if (!label.contains(slabels[s])) + if (slabel.getName().equalsIgnoreCase("LABEL") + && !label.contains(slabel.getValue())) { - label.addElement(slabels[s]); + label.add(slabel.getValue()); } } @@ -380,6 +401,7 @@ public class DasSourceBrowser extends GDasSourceBrowser implements filter1.setListData(authority); filter2.setListData(type); filter3.setListData(label); + // filter4 taxIds javax.swing.SwingUtilities.invokeLater(new Runnable() { @@ -395,13 +417,14 @@ public class DasSourceBrowser extends GDasSourceBrowser implements public void amendLocal(boolean newSource) { String url = "http://localhost:8080/", nickname = ""; - boolean seqsrc=false; + boolean seqsrc = false; if (!newSource) { int selectedRow = table.getSelectionModel().getMinSelectionIndex(); nickname = table.getValueAt(selectedRow, 0).toString(); - url = ((DasSource) localSources.get(nickname)).getUrl(); - seqsrc = ((DasSource)localSources.get(nickname)).hasCapability("sequence"); + jalviewSourceI source = sourceRegistry.getSource(nickname); + url = source.getUri(); + seqsrc = source.isSequenceSource(); } JTextField nametf = new JTextField(nickname, 40); @@ -418,7 +441,7 @@ public class DasSourceBrowser extends GDasSourceBrowser implements pane12.add(seqs, BorderLayout.SOUTH); pane12.add(urltf, BorderLayout.EAST); panel.add(pane12, BorderLayout.SOUTH); - + int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop, panel, "Enter Nickname & URL of Local DAS Source", JOptionPane.OK_CANCEL_OPTION); @@ -433,65 +456,39 @@ public class DasSourceBrowser extends GDasSourceBrowser implements urltf.setText(urltf.getText() + "/"); } - Das1Source local = new Das1Source(); - - local.setUrl(urltf.getText()); - local.setNickname(nametf.getText()); - if (seqs.isSelected()) - { - local.setCapabilities(new String[] {"features","sequence"}); - } - if (localSources == null) - { - localSources = new Hashtable(); - } - - localSources.put(local.getNickname(), local); - - if (!newSource && !nickname.equals(nametf.getText())) - { - localSources.remove(nickname); - } - - int size = dasSources.length; - int adjust = newSource ? 1 : 0; + 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 + adjust][2]; - for (int i = 0; i < size; i++) + Object[][] data = new Object[size][2]; + DASTableModel dtm = (table != null) ? (DASTableModel) ((TableSorter) table + .getModel()).getTableModel() : null; + for (int i = 0; i < osize; i++) { - if (!newSource && dasSources[i].getNickname().equals(nickname)) + String osrc = (dtm == null || i >= osize) ? null : (String) dtm + .getValueAt(i, 0); + if (!newSource && osrc != null + && dtm.getValueAt(i, 0).equals(nickname)) { - ((DasSource) dasSources[i]).setNickname(local.getNickname()); - ((DasSource) dasSources[i]).setUrl(local.getUrl()); - data[i][0] = local.getNickname(); + data[i][0] = local.getTitle(); data[i][1] = new Boolean(true); } else { - data[i][0] = dasSources[i].getNickname(); - data[i][1] = new Boolean(selectedSources.contains(dasSources[i] - .getNickname())); + data[i][0] = osrc; + data[i][1] = new Boolean(selectedSources.contains(osrc)); } } - + // Always add a new source at the end if (newSource) { - data[size][0] = local.getNickname(); - data[size][1] = new Boolean(true); - selectedSources.add(local.getNickname()); + data[osize][0] = local.getTitle(); + data[osize][1] = new Boolean(true); + selectedSources.add(local.getTitle()); } - DasSource[] tmp = new DasSource[size + adjust]; - - System.arraycopy(dasSources, 0, tmp, 0, size); - - if (newSource) - { - tmp[size] = local; - } - - dasSources = tmp; - refreshTableData(data); SwingUtilities.invokeLater(new Runnable() @@ -503,7 +500,7 @@ public class DasSourceBrowser extends GDasSourceBrowser implements } }); - displayFullDetails(local.getNickname()); + displayFullDetails(local.getTitle()); } public void editRemoveLocalSource(MouseEvent evt) @@ -516,7 +513,7 @@ public class DasSourceBrowser extends GDasSourceBrowser implements String nickname = table.getValueAt(selectedRow, 0).toString(); - if (!localSources.containsKey(nickname)) + if (!sourceRegistry.getSource(nickname).isLocal()) { JOptionPane.showInternalMessageDialog(Desktop.desktop, "You can only edit or remove local DAS Sources!", @@ -539,27 +536,26 @@ public class DasSourceBrowser extends GDasSourceBrowser implements amendLocal(false); break; case 1: - localSources.remove(nickname); + sourceRegistry.removeLocalSource(sourceRegistry.getSource(nickname)); selectedSources.remove(nickname); - Object[][] data = new Object[dasSources.length - 1][2]; - DasSource[] tmp = new DasSource[dasSources.length - 1]; - int index = 0; - for (int i = 0; i < dasSources.length; i++) + Object[][] data = new Object[sourceRegistry.getSources().size()][2]; + int index = 0, + l = table.getRowCount(); + + for (int i = 0; i < l; i++) { - if (dasSources[i].getNickname().equals(nickname)) + String nm; + if ((nm = (String) table.getValueAt(i, 0)).equals(nickname)) { continue; } else { - tmp[index] = dasSources[i]; - data[index][0] = dasSources[i].getNickname(); - data[index][1] = new Boolean(selectedSources - .contains(dasSources[i].getNickname())); + data[index][0] = nm; + data[index][1] = new Boolean(selectedSources.contains(nm)); index++; } } - dasSources = tmp; refreshTableData(data); SwingUtilities.invokeLater(new Runnable() { @@ -574,49 +570,6 @@ public class DasSourceBrowser extends GDasSourceBrowser implements } } - void appendLocalSources() - { - if (localSources == null) - { - return; - } - // note - we add all das sources to list so they can be filtered for the standard fetchDbRefs function - int size = dasSources != null ? dasSources.length : 0; - int lsize = localSources.size(); - - Object[][] data = new Object[size + lsize][2]; - for (int i = 0; i < size; i++) - { - data[i][0] = dasSources[i].getNickname(); - data[i][1] = new Boolean(selectedSources.contains(dasSources[i] - .getNickname())); - } - - DasSource[] tmp = new DasSource[size + lsize]; - if (dasSources != null) - { - System.arraycopy(dasSources, 0, tmp, 0, size); - } - - Enumeration en = localSources.keys(); - int index = size; - while (en.hasMoreElements()) - { - String key = en.nextElement().toString(); - data[index][0] = key; - data[index][1] = new Boolean(false); - tmp[index] = new Das1Source(); - tmp[index].setNickname(key); - tmp[index].setUrl(((DasSource) localSources.get(key)).getUrl()); - - index++; - } - - dasSources = tmp; - - refreshTableData(data); - } - public void valueChanged(ListSelectionEvent evt) { // Called when the MainTable selection changes @@ -628,60 +581,57 @@ public class DasSourceBrowser extends GDasSourceBrowser implements displayFullDetails(null); // Filter the displayed data sources - int dSize = dasSources.length; ArrayList names = new ArrayList(); ArrayList selected = new ArrayList(); - DasSource ds; // 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" }; - - for (int i = 0; i < dSize; i++) + List srcs = sourceRegistry.getSources(); + for (jalviewSourceI ds : srcs) { - ds = dasSources[i]; - DasCoordinateSystem[] dcs = ds.getCoordinateSystem(); - if (dcs.length == 0 && ds.getCapabilities().length == 0 - && filter1.getSelectedIndex() == 0 - && filter2.getSelectedIndex() == 0 - && filter3.getSelectedIndex() == 0) + VERSION v = ds.getVersion(); + List 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.getNickname()); - selected - .add(new Boolean(selectedSources.contains(ds.getNickname()))); + names.add(ds.getTitle()); + selected.add(new Boolean(selectedSources.contains(ds.getTitle()))); continue; } - if (!selectedInList(dummyFeatureList, ds.getCapabilities()) - || !selectedInList(filter3.getSelectedValues(), ds - .getLabels())) + if (!selectedInList(dummyFeatureList, ds.getCapabilityList(v)) + || !selectedInList(filter3.getSelectedValues(), + ds.getLabelsFor(v))) { continue; } - for (int j = 0; j < dcs.length; j++) + for (int j = 0; j < coords.size(); j++) { if (selectedInList(filter1.getSelectedValues(), new String[] - { dcs[j].getName() }) + { coords.get(j).getAuthority() }) && selectedInList(filter2.getSelectedValues(), new String[] - { dcs[j].getCategory() })) + { coords.get(j).getSource() })) { - names.add(ds.getNickname()); - selected.add(new Boolean(selectedSources.contains(ds - .getNickname()))); + names.add(ds.getTitle()); + selected.add(new Boolean(selectedSources.contains(ds.getTitle()))); break; } } } - dSize = names.size(); + int dSize = names.size(); Object[][] data = new Object[dSize][2]; for (int d = 0; d < dSize; d++) { @@ -692,7 +642,7 @@ public class DasSourceBrowser extends GDasSourceBrowser implements refreshTableData(data); } - boolean selectedInList(Object[] selection, String[] items) + private boolean selectedInList(Object[] selection, String[] items) { for (int i = 0; i < selection.length; i++) { @@ -700,10 +650,15 @@ public class DasSourceBrowser extends GDasSourceBrowser implements { 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 (selection[i].equals(items[j])) + if (sel.equals(items[j])) { return true; } @@ -723,30 +678,16 @@ public class DasSourceBrowser extends GDasSourceBrowser implements { selectedSources.addElement(st.nextToken()); } - - Vector _localSources = jalview.bin.Cache.getLocalDasSources(); - if (_localSources!=null) - { - if (localSources==null) - { - localSources = new Hashtable(); - } - Enumeration sources = _localSources.elements(); - while (sources.hasMoreElements()) - { - Das1Source source = (Das1Source) sources.nextElement(); - localSources.put(source.getNickname(), source); - } - } } public void reset_actionPerformed(ActionEvent e) { - registryURL.setText(DEFAULT_REGISTRY); + registryURL.setText(sourceRegistry.getDasRegistryURL()); } /** * set the DAS source settings in the given jalview properties. + * * @param properties */ public void saveProperties(Properties properties) @@ -757,7 +698,8 @@ public class DasSourceBrowser extends GDasSourceBrowser implements } else { - properties.setProperty(jalview.bin.Cache.DAS_REGISTRY_URL, registryURL.getText()); + properties.setProperty(jalview.bin.Cache.DAS_REGISTRY_URL, + registryURL.getText()); } StringBuffer sb = new StringBuffer(); @@ -769,23 +711,11 @@ public class DasSourceBrowser extends GDasSourceBrowser implements } } - properties.setProperty(jalview.bin.Cache.DAS_ACTIVE_SOURCE, sb.toString()); - - if (localSources != null) - { - sb = new StringBuffer(); - Enumeration en = localSources.keys(); - while (en.hasMoreElements()) - { - String token = en.nextElement().toString(); - sb.append(token + "|" - +(((DasSource) localSources.get(token)).hasCapability("sequence") ? "sequence:" : "") - + ((DasSource) localSources.get(token)).getUrl() + "\t"); - } - - properties.setProperty(jalview.bin.Cache.DAS_LOCAL_SOURCE, sb.toString()); - } + 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 @@ -877,8 +807,7 @@ public class DasSourceBrowser extends GDasSourceBrowser implements } }); thr.start(); - while (loadingDasSources - || dasSources == null) + while (loadingDasSources || sourceRegistry == null) { try { @@ -890,23 +819,14 @@ public class DasSourceBrowser extends GDasSourceBrowser implements } } - public Vector resolveSourceNicknames(Vector sources) + /** + * disable or enable the buttons on the source browser + * + * @param b + */ + public void setGuiEnabled(boolean b) { - - Vector resolved = new Vector(); - if (sources != null) - { - for (int i = 0; i < dasSources.length; i++) - { - if (sources.contains(dasSources[i].getNickname())) - { - if (!resolved.contains(dasSources[i])) - { - resolved.addElement(dasSources[i]); - } - } - } - } - return resolved; + refresh.setEnabled(b); + addLocal.setEnabled(b); } }