X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDasSourceBrowser.java;h=8ce09955227ebe3a517c1a08a34ebe77ad40ec7c;hb=aaf78c2f304b237a9c800137126967ace9437c99;hp=90741056628fb623232c2fd6f841a1f11184d626;hpb=c2d22d00716c6865d4d090ba1db5f7c063166e77;p=jalview.git diff --git a/src/jalview/gui/DasSourceBrowser.java b/src/jalview/gui/DasSourceBrowser.java index 9074105..8ce0995 100755 --- a/src/jalview/gui/DasSourceBrowser.java +++ b/src/jalview/gui/DasSourceBrowser.java @@ -1,20 +1,19 @@ /* - * 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.6) + * Copyright (C) 2010 J Procter, AM Waterhouse, 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; @@ -53,14 +52,16 @@ public class DasSourceBrowser extends GDasSourceBrowser implements if (registry.indexOf("/registry/das1/sources/") > -1) { - jalview.bin.Cache.setProperty(jalview.bin.Cache.DAS_REGISTRY_URL, DEFAULT_REGISTRY); + jalview.bin.Cache.setProperty(jalview.bin.Cache.DAS_REGISTRY_URL, + DEFAULT_REGISTRY); registry = DEFAULT_REGISTRY; } return registry; } - public DasSourceBrowser() + public DasSourceBrowser(FeatureSettings featureSettings) { + fs = featureSettings; String registry = getDasRegistryURL(); registryURL.setText(registry); @@ -107,6 +108,13 @@ public class DasSourceBrowser extends GDasSourceBrowser implements } } + FeatureSettings fs = null; + + public DasSourceBrowser() + { + this(null); + } + public void paintComponent(java.awt.Graphics g) { if (dasSources == null && !loadingDasSources) @@ -183,11 +191,10 @@ public class DasSourceBrowser extends GDasSourceBrowser implements text.append("URL: " + dasSources[i].getUrl() + "
"); - text - .append("Admin Email: " - + dasSources[i].getAdminemail() + "" + "
"); + text.append("Admin Email: " + + dasSources[i].getAdminemail() + "" + "
"); text.append("Registered at: " + dasSources[i].getRegisterDate() + "
"); @@ -271,31 +278,56 @@ public class DasSourceBrowser extends GDasSourceBrowser implements refresh.setVisible(false); progressBar.setVisible(true); progressBar.setIndeterminate(true); + setParentGuiEnabled(false); // Refresh the source list. dasSources = null; getDASSource(); init(); + setParentGuiEnabled(true); loadingDasSources = false; } + 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 (dasSources == 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++) { @@ -395,13 +427,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"); + seqsrc = ((DasSource) localSources.get(nickname)) + .hasCapability("sequence"); } JTextField nametf = new JTextField(nickname, 40); @@ -418,7 +451,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); @@ -439,7 +472,8 @@ public class DasSourceBrowser extends GDasSourceBrowser implements local.setNickname(nametf.getText()); if (seqs.isSelected()) { - local.setCapabilities(new String[] {"features","sequence"}); + local.setCapabilities(new String[] + { "features", "sequence" }); } if (localSources == null) { @@ -554,8 +588,8 @@ public class DasSourceBrowser extends GDasSourceBrowser implements { tmp[index] = dasSources[i]; data[index][0] = dasSources[i].getNickname(); - data[index][1] = new Boolean(selectedSources - .contains(dasSources[i].getNickname())); + data[index][1] = new Boolean( + selectedSources.contains(dasSources[i].getNickname())); index++; } } @@ -580,7 +614,8 @@ public class DasSourceBrowser extends GDasSourceBrowser implements { return; } - // note - we add all das sources to list so they can be filtered for the standard fetchDbRefs function + // 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(); @@ -654,14 +689,13 @@ public class DasSourceBrowser extends GDasSourceBrowser implements // HAVE COORDINATE SYSTEMS, INFO WHICH AT PRESENT // IS ADDED FROM THE REGISTRY names.add(ds.getNickname()); - selected - .add(new Boolean(selectedSources.contains(ds.getNickname()))); + selected.add(new Boolean(selectedSources.contains(ds.getNickname()))); continue; } if (!selectedInList(dummyFeatureList, ds.getCapabilities()) - || !selectedInList(filter3.getSelectedValues(), ds - .getLabels())) + || !selectedInList(filter3.getSelectedValues(), + ds.getLabels())) { continue; } @@ -723,11 +757,11 @@ public class DasSourceBrowser extends GDasSourceBrowser implements { selectedSources.addElement(st.nextToken()); } - + Vector _localSources = jalview.bin.Cache.getLocalDasSources(); - if (_localSources!=null) + if (_localSources != null) { - if (localSources==null) + if (localSources == null) { localSources = new Hashtable(); } @@ -747,6 +781,7 @@ public class DasSourceBrowser extends GDasSourceBrowser implements /** * set the DAS source settings in the given jalview properties. + * * @param properties */ public void saveProperties(Properties properties) @@ -757,7 +792,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,7 +805,8 @@ public class DasSourceBrowser extends GDasSourceBrowser implements } } - properties.setProperty(jalview.bin.Cache.DAS_ACTIVE_SOURCE, sb.toString()); + properties.setProperty(jalview.bin.Cache.DAS_ACTIVE_SOURCE, + sb.toString()); if (localSources != null) { @@ -778,12 +815,15 @@ public class DasSourceBrowser extends GDasSourceBrowser implements while (en.hasMoreElements()) { String token = en.nextElement().toString(); - sb.append(token + "|" - +(((DasSource) localSources.get(token)).hasCapability("sequence") ? "sequence:" : "") + 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_LOCAL_SOURCE, + sb.toString()); } } @@ -877,8 +917,7 @@ public class DasSourceBrowser extends GDasSourceBrowser implements } }); thr.start(); - while (loadingDasSources - || dasSources == null) + while (loadingDasSources || dasSources == null) { try { @@ -909,4 +948,15 @@ public class DasSourceBrowser extends GDasSourceBrowser implements } return resolved; } + + /** + * disable or enable the buttons on the source browser + * + * @param b + */ + public void setGuiEnabled(boolean b) + { + refresh.setEnabled(b); + addLocal.setEnabled(b); + } }