X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDasSourceBrowser.java;h=b58ce95ecbb02e88b1d3e4bd859310a0ea437fac;hb=27e04880edb301447f2e57b5156b8c685b853b68;hp=afacb41f3d9eab4c72664bf12b33227b083943f9;hpb=df9b85c1cf39894039018499fe802406cc37f209;p=jalview.git diff --git a/src/jalview/gui/DasSourceBrowser.java b/src/jalview/gui/DasSourceBrowser.java index afacb41..b58ce95 100755 --- a/src/jalview/gui/DasSourceBrowser.java +++ b/src/jalview/gui/DasSourceBrowser.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2006 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 @@ -41,10 +41,23 @@ public class DasSourceBrowser extends GDasSourceBrowser Vector selectedSources; + String DEFAULT_REGISTRY = "http://www.dasregistry.org/registry/das1/sources/"; + + boolean loadingDasSources = false; + + public DasSourceBrowser() { - registryURL.setText(jalview.bin.Cache.getDefault("DAS_REGISTRY_URL", - "http://www.spice-3d.org/dasregistry/das1/sources") ); + String registry = jalview.bin.Cache.getDefault("DAS_REGISTRY_URL", + DEFAULT_REGISTRY); + + if(registry.equals("http://das.sanger.ac.uk/registry/das1/sources/")) + { + jalview.bin.Cache.setProperty("DAS_REGISTRY_URL", DEFAULT_REGISTRY); + registry = DEFAULT_REGISTRY; + } + + registryURL.setText( registry ); setSelectedFromProperties(); @@ -61,10 +74,6 @@ public class DasSourceBrowser extends GDasSourceBrowser { public void valueChanged(ListSelectionEvent e) { - //Ignore extra messages. - if (e.getValueIsAdjusting()) - return; - ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (!lsm.isSelectionEmpty()) { @@ -84,15 +93,19 @@ public class DasSourceBrowser extends GDasSourceBrowser } }); - if(dasSources==null) + if(dasSources!=null) { - Thread worker = new Thread(this); - worker.start(); - } - else - { init(); - } + } + } + + public void paintComponent(java.awt.Graphics g) + { + if (dasSources == null && !loadingDasSources) + { + Thread worker = new Thread(this); + worker.start(); + } } void init() @@ -240,6 +253,8 @@ public class DasSourceBrowser extends GDasSourceBrowser public void run() { + loadingDasSources = true; + addLocal.setVisible(false); refresh.setVisible(false); progressBar.setVisible(true); @@ -250,6 +265,28 @@ public class DasSourceBrowser extends GDasSourceBrowser appendLocalSources(); init(); + + loadingDasSources = false; + + } + + public Vector getSelectedSources() + { + Vector selected = new Vector(); + for (int r = 0; r < selectedSources.size(); r++) + { + for (int i = 0; i < dasSources.length; i++) + { + if (dasSources[i].getNickname().equals( + selectedSources.elementAt(r))) + { + selected.addElement(dasSources[i]); + break; + } + } + } + + return selected; } public DasSource[] getDASSource() @@ -280,8 +317,6 @@ public class DasSourceBrowser extends GDasSourceBrowser 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++) { @@ -531,43 +566,69 @@ public class DasSourceBrowser extends GDasSourceBrowser index++; } - dasSources = tmp; + dasSources = tmp; - refreshTableData(data); + refreshTableData(data); } public void valueChanged(ListSelectionEvent evt) { //Called when the MainTable selection changes - if (evt.getValueIsAdjusting()) + if (evt.getValueIsAdjusting() ) { return; } + displayFullDetails(null); // Filter the displayed data sources int dSize = dasSources.length; + + ArrayList names = new ArrayList(); ArrayList selected = new ArrayList(); DasSource ds; - // capabilities.get + //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++) { ds = dasSources[i]; + DasCoordinateSystem[] dcs = ds.getCoordinateSystem(); - if (!selectedInList(filter3, ds.getLabels())) + if (dcs.length == 0 && ds.getCapabilities().length == 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()))); + continue; + } + + + if (!selectedInList(dummyFeatureList, ds.getCapabilities()) + || !selectedInList(filter3.getSelectedValues(), + ds.getLabels())) { continue; } - DasCoordinateSystem[] dcs = ds.getCoordinateSystem(); for (int j = 0; j < dcs.length; j++) { - if (selectedInList(filter1, new String[] + if ( selectedInList(filter1.getSelectedValues(), + new String[] {dcs[j].getName()}) - && selectedInList(filter2, new String[] + && selectedInList(filter2.getSelectedValues(), + new String[] {dcs[j].getCategory()})) { names.add(ds.getNickname()); @@ -589,12 +650,11 @@ public class DasSourceBrowser extends GDasSourceBrowser refreshTableData(data); } - boolean selectedInList(JList list, String[] items) + boolean selectedInList(Object [] selection, String[] items) { - Object[] selection = list.getSelectedValues(); for (int i = 0; i < selection.length; i++) { - if (selection[i].equals("Any")) + if (selection[i].equals("Any") ) return true; for (int j = 0; j < items.length; j++) @@ -638,9 +698,17 @@ public class DasSourceBrowser extends GDasSourceBrowser } } - void saveProperties(Properties properties) + public void reset_actionPerformed(ActionEvent e) + { + registryURL.setText(DEFAULT_REGISTRY); + } + + public void saveProperties(Properties properties) { - properties.setProperty("DAS_REGISTRY_URL", registryURL.getText()); + if (registryURL.getText() == null || registryURL.getText().length() < 1) + properties.remove("DAS_REGISTRY_URL"); + else + properties.setProperty("DAS_REGISTRY_URL", registryURL.getText()); StringBuffer sb = new StringBuffer(); for(int r=0; r