X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDasSourceBrowser.java;h=10f5f953fc98e766d39077aa08ce8fa9a7c0fc60;hb=2a5cbe264ec842c1a0f93e6bd78294607a94e686;hp=afacb41f3d9eab4c72664bf12b33227b083943f9;hpb=df9b85c1cf39894039018499fe802406cc37f209;p=jalview.git diff --git a/src/jalview/gui/DasSourceBrowser.java b/src/jalview/gui/DasSourceBrowser.java index afacb41..10f5f95 100755 --- a/src/jalview/gui/DasSourceBrowser.java +++ b/src/jalview/gui/DasSourceBrowser.java @@ -1,50 +1,68 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, 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 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. - * - * 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 - 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 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 . */ package jalview.gui; -import jalview.jbgui.*; -import javax.swing.table.AbstractTableModel; -import javax.swing.event.*; +import jalview.jbgui.GDasSourceBrowser; import jalview.util.TableSorter; -import java.awt.event.*; -import javax.swing.*; -import java.util.*; - +import jalview.ws.dbsources.das.api.DasSourceRegistryI; +import jalview.ws.dbsources.das.api.jalviewSourceI; -import org.biojava.dasobert.dasregistry.DasCoordinateSystem; -import org.biojava.dasobert.dasregistry.DasSource; -import org.biojava.dasobert.dasregistry.Das1Source; 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; -public class DasSourceBrowser extends GDasSourceBrowser - implements Runnable, ListSelectionListener -{ - static DasSource[] dasSources = null; +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; - Hashtable localSources = null; +public class DasSourceBrowser extends GDasSourceBrowser implements + Runnable, ListSelectionListener +{ + DasSourceRegistryI sourceRegistry = null; - Vector selectedSources; + Vector selectedSources; - public DasSourceBrowser() + public DasSourceBrowser(FeatureSettings featureSettings) { - registryURL.setText(jalview.bin.Cache.getDefault("DAS_REGISTRY_URL", - "http://www.spice-3d.org/dasregistry/das1/sources") ); + fs = featureSettings; + // TODO DasSourceRegistryProvider API + sourceRegistry = jalview.bin.Cache.getDasSourceRegistry(); + String registry = sourceRegistry.getDasRegistryURL(); + + registryURL.setText(registry); setSelectedFromProperties(); @@ -55,16 +73,12 @@ public class DasSourceBrowser extends GDasSourceBrowser filter2.addListSelectionListener(this); filter3.addListSelectionListener(this); - //Ask to be notified of selection changes. + // Ask to be notified of selection changes. ListSelectionModel rowSM = table.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { - //Ignore extra messages. - if (e.getValueIsAdjusting()) - return; - ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (!lsm.isSelectionEmpty()) { @@ -75,49 +89,64 @@ public class DasSourceBrowser extends GDasSourceBrowser }); table.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent evt) + { + if (evt.getClickCount() == 2 + || SwingUtilities.isRightMouseButton(evt)) { - public void mouseClicked(MouseEvent evt) - { - if(evt.getClickCount()==2 - || SwingUtilities.isRightMouseButton(evt)) - editRemoveLocalSource(evt); - } - }); + editRemoveLocalSource(evt); + } + } + }); - if(dasSources==null) + if (sourceRegistry.getSources() != null) { - Thread worker = new Thread(this); - worker.start(); + init(); + } + } + + FeatureSettings fs = null; + + private boolean loadingDasSources; + + public DasSourceBrowser() + { + this(null); + } + + public void paintComponent(java.awt.Graphics g) + { + if (sourceRegistry == null) + { + Thread worker = new Thread(this); + worker.start(); } - else - { - init(); - } } 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() - { - public void run() - { - TableSorter sorter = (TableSorter)table.getModel(); - sorter.setSortingStatus(1, TableSorter.DESCENDING); - sorter.setSortingStatus(1, TableSorter.NOT_SORTED); - } - }); + { + 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); @@ -125,7 +154,6 @@ public class DasSourceBrowser extends GDasSourceBrowser refresh.setVisible(true); } - public void refreshTableData(Object[][] data) { TableSorter sorter = new TableSorter(new DASTableModel(data)); @@ -137,96 +165,113 @@ public class DasSourceBrowser extends GDasSourceBrowser { StringBuffer text = new StringBuffer( - ""); + ""); if (nickName == null) { - fullDetails.setText(text + - "Select a DAS service from the table" - + " to read a full description here."); + fullDetails.setText(text + "Select a DAS service from the table" + + " to read a full description here."); 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() + - "
"); - text.append("Nickname: " + - dasSources[i].getNickname() + "
"); - text.append("URL: " + dasSources[i].getUrl() + - "
"); - + VERSION latest = ds.getVersion(); + text.append("Id: " + ds.getUri() + + "
"); + text.append("Nickname: " + + ds.getTitle() + "
"); + + if (!ds.isLocal()) + { + // TODO: IMMEDIATE verify that URI + ds.URI point to latest version for non-local sources. + if (ds.getDocHref()!=null) { + text.append("URL: " + ds.getDocHref() + + "
"); + } + text.append("Admin Email: "+dasSources[i].getAdminemail()+"" + - "
"); + + ds.getEmail() + "\">" + ds.getEmail() + "" + "
"); + text.append("Registered at: " + + latest.getCreated() + "
"); - text.append("Registered at: " + dasSources[i].getRegisterDate() + - "
"); - - text.append("Last successful test: " + dasSources[i].getLeaseDate() + - "
"); - + // 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"); - - 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(", "); + } } text.append("
"); text.append("Coordinates: "); - DasCoordinateSystem[] dcs = ds.getCoordinateSystem(); - for (int j = 0; j < dcs.length; j++) + for (COORDINATES dcs : latest.getCOORDINATES()) { - text.append("(" + dcs[j].getUniqueId() + ") " - + dcs[j].getCategory() + ", " + dcs[j].getName()); - if (dcs[j].getNCBITaxId() != 0) - text.append(", " + dcs[j].getNCBITaxId()); - if (dcs[j].getOrganismName().length() > 0) - text.append(", " + dcs[j].getOrganismName()); - - text.append("
"); - } + text.append("(" + dcs.getUri() + ") " - text.append("Description: " + - dasSources[i].getDescription() + "
"); + + dcs.getSource() + ", " + dcs.getAuthority()); + if (dcs.getTaxid() != null && dcs.getTaxid().trim().length() > 0) + { + text.append(", " + dcs.getTaxid()); + } + if (dcs.getVersion()!=null && dcs.getVersion().trim().length() > 0) + { + { + text.append(", " + dcs.getVersion()); + } + text.append("
"); + } - if (dasSources[i].getHelperurl()!=null - && dasSources[i].getHelperurl().length() > 0) - { - text.append("Go to site"); - } + text.append("Description: " + + ds.getDescription() + "
"); - text.append("
"); + if (ds.getDocHref() != null && ds.getDocHref().length() > 0) + { + text.append("Go to site"); + } - break; - } + text.append(""); + break; + } + } fullDetails.setText(text.toString()); javax.swing.SwingUtilities.invokeLater(new Runnable() { @@ -237,30 +282,73 @@ public class DasSourceBrowser extends GDasSourceBrowser }); } - 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(); - dasSources = jalview.io.DasSequenceFeatureFetcher.getDASSources(); + init(); - appendLocalSources(); + setParentGuiEnabled(true); + loadingDasSources = false; - init(); } - public DasSource[] getDASSource() + private void setParentGuiEnabled(boolean b) { - if(dasSources==null) + if (fs != null) { - dasSources = jalview.io.DasSequenceFeatureFetcher.getDASSources(); - appendLocalSources(); + fs.fetchDAS.setEnabled(b); + fs.saveDAS.setEnabled(b); } + } - return dasSources; + public Vector 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 selected = new Vector(); + for (String source : selectedSources) + { + jalviewSourceI srce = sourceRegistry.getSource(source); + if (srce != null) + { + selected.addElement(srce); + } + } + return selected; } public void refresh_actionPerformed(ActionEvent e) @@ -271,39 +359,39 @@ public class DasSourceBrowser extends GDasSourceBrowser 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"); - label.addElement("NOT IMPLEMENTED YET"); - filter3.setEnabled(false); - - for (int i = 0; i < sources.length; i++) + 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 (jalviewSourceI ds : sourceRegistry2.getSources()) { - DasSource ds = sources[i]; - - DasCoordinateSystem[] dcs = ds.getCoordinateSystem(); + VERSION latest = ds.getVersion(); - for (int j = 0; j < dcs.length; j++) + for (COORDINATES cs : latest.getCOORDINATES()) { - if (!type.contains(dcs[j].getCategory())) - type.addElement(dcs[j].getCategory()); + if (!type.contains(cs.getSource())) + { + type.add(cs.getSource()); // source==category + } - if (!authority.contains(dcs[j].getName())) - authority.addElement(dcs[j].getName()); + if (!authority.contains(cs.getAuthority())) + { + 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()); } } @@ -312,6 +400,7 @@ public class DasSourceBrowser extends GDasSourceBrowser filter1.setListData(authority); filter2.setListData(type); filter3.setListData(label); + // filter4 taxIds javax.swing.SwingUtilities.invokeLater(new Runnable() { @@ -327,218 +416,162 @@ public class DasSourceBrowser extends GDasSourceBrowser public void amendLocal(boolean newSource) { String url = "http://localhost:8080/", nickname = ""; - - if(!newSource) + boolean seqsrc = false; + if (!newSource) { int selectedRow = table.getSelectionModel().getMinSelectionIndex(); nickname = table.getValueAt(selectedRow, 0).toString(); - url = ((DasSource)localSources.get(nickname)).getUrl(); + 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("Sequence Source"); + seqs.setSelected(seqsrc); JPanel panel = new JPanel(new BorderLayout()); JPanel pane12 = new JPanel(new BorderLayout()); pane12.add(new JLabel("Nickname: "), BorderLayout.CENTER); pane12.add(nametf, BorderLayout.EAST); panel.add(pane12, BorderLayout.NORTH); pane12 = new JPanel(new BorderLayout()); - pane12.add(new JLabel("URL: "), BorderLayout.CENTER); + pane12.add(new JLabel("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, "Enter Nickname & URL of Local DAS Source", - JOptionPane.OK_CANCEL_OPTION); - - if (reply != JOptionPane.OK_OPTION ) - { - return; - } - - if(!urltf.getText().endsWith("/")) - urltf.setText(urltf.getText()+"/"); + panel, "Enter Nickname & URL of Local DAS Source", + JOptionPane.OK_CANCEL_OPTION); - Das1Source local = new Das1Source(); - - local.setUrl(urltf.getText()); - local.setNickname(nametf.getText()); - - - 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; - - Object[][] data = new Object[size+adjust][2]; - for (int i = 0; i < size; i++) - { - if(!newSource && dasSources[i].getNickname().equals(nickname)) - { - ((DasSource)dasSources[i]).setNickname(local.getNickname()); - ((DasSource)dasSources[i]).setUrl(local.getUrl()); - data[i][0] = local.getNickname(); - data[i][1] = new Boolean(true); - } - else - { - data[i][0] = dasSources[i].getNickname(); - data[i][1] = new Boolean(selectedSources.contains(dasSources[i]. - getNickname())); - } - } - - if(newSource) - { - data[size][0] = local.getNickname(); - data[size][1] = new Boolean(true); - selectedSources.add(local.getNickname()); - } - - 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() - { - public void run() - { - scrollPane.getVerticalScrollBar().setValue( - scrollPane.getVerticalScrollBar().getMaximum() - ); - } - }); - - displayFullDetails(local.getNickname()); - } + if (reply != JOptionPane.OK_OPTION) + { + return; + } - public void editRemoveLocalSource(MouseEvent evt) + if (!urltf.getText().endsWith("/")) { - int selectedRow = table.getSelectionModel().getMinSelectionIndex(); - if(selectedRow==-1) - return; + urltf.setText(urltf.getText() + "/"); + } - String nickname = table.getValueAt(selectedRow, 0).toString(); + 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); - if (!localSources.containsKey(nickname)) + 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)) { - JOptionPane.showInternalMessageDialog(Desktop.desktop, - "You can only edit or remove local DAS Sources!", - "Public DAS source - not editable", - JOptionPane.WARNING_MESSAGE); - return; + data[i][0] = local.getTitle(); + data[i][1] = new Boolean(true); } - - - 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) + else { - case 0: amendLocal(false); break; - case 1: - localSources.remove(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++) - { - if (dasSources[i].getNickname().equals(nickname)) - { - continue; - } - else - { - tmp[index] = dasSources[i]; - data[index][0] = dasSources[i].getNickname(); - data[index][1] = new Boolean(selectedSources.contains(dasSources[i]. - getNickname())); - index++; - } - } - dasSources = tmp; - refreshTableData(data); - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - scrollPane.getVerticalScrollBar().setValue( - scrollPane.getVerticalScrollBar().getMaximum() - ); - } - }); - - break; + data[i][0] = osrc; + data[i][1] = new Boolean(selectedSources.contains(osrc)); } } - - void appendLocalSources() + // Always add a new source at the end + if (newSource) { - if(localSources==null) - return; + data[osize][0] = local.getTitle(); + data[osize][1] = new Boolean(true); + selectedSources.add(local.getTitle()); + } - int size = dasSources!=null ? dasSources.length : 0; - int lsize = localSources.size(); + refreshTableData(data); - Object[][] data = new Object[size+lsize][2]; - for (int i = 0; i < size; i++) + SwingUtilities.invokeLater(new Runnable() + { + public void run() { - data[i][0] = dasSources[i].getNickname(); - data[i][1] = new Boolean(selectedSources.contains(dasSources[i]. - getNickname())); + scrollPane.getVerticalScrollBar().setValue( + scrollPane.getVerticalScrollBar().getMaximum()); } + }); + + displayFullDetails(local.getTitle()); + } + + public void editRemoveLocalSource(MouseEvent evt) + { + int selectedRow = table.getSelectionModel().getMinSelectionIndex(); + if (selectedRow == -1) + { + return; + } - DasSource [] tmp = new DasSource[size+lsize]; - if(dasSources!=null) - System.arraycopy(dasSources, 0, tmp, 0, size); + String nickname = table.getValueAt(selectedRow, 0).toString(); - Enumeration en = localSources.keys(); - int index = size; - while(en.hasMoreElements()) + if (!sourceRegistry.getSource(nickname).isLocal()) + { + JOptionPane.showInternalMessageDialog(Desktop.desktop, + "You can only edit or remove local DAS Sources!", + "Public DAS source - not editable", + 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 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++; + 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() + { + public void run() + { + scrollPane.getVerticalScrollBar().setValue( + scrollPane.getVerticalScrollBar().getMaximum()); + } + }); - dasSources = tmp; - - refreshTableData(data); + break; + } } public void valueChanged(ListSelectionEvent evt) { - //Called when the MainTable selection changes + // Called when the MainTable selection changes if (evt.getValueIsAdjusting()) { return; @@ -547,38 +580,56 @@ public class DasSourceBrowser extends GDasSourceBrowser displayFullDetails(null); // Filter the displayed data sources - int dSize = dasSources.length; + ArrayList names = new ArrayList(); ArrayList selected = new ArrayList(); - DasSource ds; - // capabilities.get - for (int i = 0; i < dSize; i++) + // 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 srcs=sourceRegistry.getSources(); + for (jalviewSourceI ds : srcs) { - ds = dasSources[i]; - if (!selectedInList(filter3, ds.getLabels())) + 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.getTitle()); + selected.add(new Boolean(selectedSources.contains(ds.getTitle()))); continue; } - DasCoordinateSystem[] dcs = ds.getCoordinateSystem(); - for (int j = 0; j < dcs.length; j++) + if (!selectedInList(dummyFeatureList, ds.getCapabilityList(v)) + || !selectedInList(filter3.getSelectedValues(), + ds.getLabelsFor(v))) { - if (selectedInList(filter1, new String[] - {dcs[j].getName()}) - && selectedInList(filter2, new String[] - {dcs[j].getCategory()})) + 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.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++) { @@ -589,18 +640,25 @@ public class DasSourceBrowser extends GDasSourceBrowser refreshTableData(data); } - boolean selectedInList(JList list, String[] items) + private boolean selectedInList(Object[] selection, String[] items) { - Object[] selection = list.getSelectedValues(); 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 (selection[i].equals(items[j])) + if (sel.equals(items[j])) + { return true; + } } } @@ -609,69 +667,55 @@ public class DasSourceBrowser extends GDasSourceBrowser 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()); - } - - String local = jalview.bin.Cache.getProperty("DAS_LOCAL_SOURCE"); - if(local!=null) - { - if(localSources == null) - localSources = new Hashtable(); - - st = new StringTokenizer(local, "\t"); - while(st.hasMoreTokens()) - { - String token = st.nextToken(); - int bar = token.indexOf("|"); - Das1Source source = new Das1Source(); - - source.setUrl(token.substring(bar + 1)); - source.setNickname(token.substring(0, bar)); - - localSources.put(source.getNickname(), source); - } - } + 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()); + } } - void saveProperties(Properties properties) + public void reset_actionPerformed(ActionEvent e) { - properties.setProperty("DAS_REGISTRY_URL", registryURL.getText()); + registryURL.setText(sourceRegistry.getDasRegistryURL()); + } - StringBuffer sb = new StringBuffer(); - for(int r=0; r