X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDasSourceBrowser.java;h=e336d9a649615696069e791fe87ccb21a0876c95;hb=506d60f0e188723ddc91c26824b41ac7034df3fe;hp=807aa4b5cbc6b89b2ba36f526d66219dd6949085;hpb=60f2d6c034560415fd0139c8bc7df0c19cae1186;p=jalview.git diff --git a/src/jalview/gui/DasSourceBrowser.java b/src/jalview/gui/DasSourceBrowser.java index 807aa4b..e336d9a 100755 --- a/src/jalview/gui/DasSourceBrowser.java +++ b/src/jalview/gui/DasSourceBrowser.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 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 @@ -30,8 +30,8 @@ import org.biojava.dasobert.dasregistry.*; import jalview.jbgui.*; import jalview.util.*; -public class DasSourceBrowser - extends GDasSourceBrowser implements Runnable, ListSelectionListener +public class DasSourceBrowser extends GDasSourceBrowser implements + Runnable, ListSelectionListener { static DasSource[] dasSources = null; @@ -39,17 +39,17 @@ public class DasSourceBrowser Vector selectedSources; - public static String DEFAULT_REGISTRY = - "http://www.dasregistry.org/das1/sources/"; + 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; + protected static String getDasRegistryURL() { String registry = jalview.bin.Cache.getDefault("DAS_REGISTRY_URL", - DEFAULT_REGISTRY); + DEFAULT_REGISTRY); if (registry.indexOf("/registry/das1/sources/") > -1) { @@ -58,10 +58,11 @@ public class DasSourceBrowser } return registry; } + public DasSourceBrowser() { String registry = getDasRegistryURL(); - + registryURL.setText(registry); setSelectedFromProperties(); @@ -73,7 +74,7 @@ public class DasSourceBrowser 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() { @@ -93,7 +94,7 @@ public class DasSourceBrowser public void mouseClicked(MouseEvent evt) { if (evt.getClickCount() == 2 - || SwingUtilities.isRightMouseButton(evt)) + || SwingUtilities.isRightMouseButton(evt)) { editRemoveLocalSource(evt); } @@ -122,8 +123,8 @@ public class DasSourceBrowser 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][1] = new Boolean(selectedSources.contains(dasSources[i] + .getNickname())); } refreshTableData(data); @@ -156,13 +157,12 @@ public class DasSourceBrowser { 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; } @@ -176,26 +176,24 @@ public class DasSourceBrowser DasSource ds = dasSources[i]; - text.append("Id: " + dasSources[i].getId() + - "
"); - text.append("Nickname: " + - dasSources[i].getNickname() + "
"); - text.append("URL: " + dasSources[i].getUrl() + - "
"); + text.append("Id: " + + dasSources[i].getId() + "
"); + text.append("Nickname: " + + dasSources[i].getNickname() + "
"); + 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() + - "
"); + text.append("Registered at: " + + dasSources[i].getRegisterDate() + "
"); - text.append("Last successful test: " + - dasSources[i].getLeaseDate() + - "
"); + text.append("Last successful test: " + + dasSources[i].getLeaseDate() + "
"); text.append("Labels: "); for (int s = 0; s < dasSources[i].getLabels().length; s++) @@ -226,7 +224,7 @@ public class DasSourceBrowser for (int j = 0; j < dcs.length; j++) { text.append("(" + dcs[j].getUniqueId() + ") " - + dcs[j].getCategory() + ", " + dcs[j].getName()); + + dcs[j].getCategory() + ", " + dcs[j].getName()); if (dcs[j].getNCBITaxId() != 0) { text.append(", " + dcs[j].getNCBITaxId()); @@ -239,15 +237,15 @@ public class DasSourceBrowser text.append("
"); } - text.append("Description: " + - dasSources[i].getDescription() + "
"); + text.append("Description: " + + dasSources[i].getDescription() + "
"); if (dasSources[i].getHelperurl() != null - && dasSources[i].getHelperurl().length() > 0) + && dasSources[i].getHelperurl().length() > 0) { - text.append("Go to site"); + text.append("Go to site"); } text.append(""); @@ -274,9 +272,9 @@ public class DasSourceBrowser progressBar.setVisible(true); progressBar.setIndeterminate(true); // Refresh the source list. - dasSources=null; + dasSources = null; getDASSource(); - + init(); loadingDasSources = false; @@ -290,8 +288,8 @@ public class DasSourceBrowser { for (int i = 0; i < dasSources.length; i++) { - if (dasSources[i].getNickname().equals( - selectedSources.elementAt(r))) + if (dasSources[i].getNickname() + .equals(selectedSources.elementAt(r))) { selected.addElement(dasSources[i]); break; @@ -301,8 +299,10 @@ public class DasSourceBrowser return selected; } + /** * retrieve das sources from registry and add local source list + * * @return */ public DasSource[] getDASSource() @@ -387,7 +387,7 @@ public class DasSourceBrowser { int selectedRow = table.getSelectionModel().getMinSelectionIndex(); nickname = table.getValueAt(selectedRow, 0).toString(); - url = ( (DasSource) localSources.get(nickname)).getUrl(); + url = ((DasSource) localSources.get(nickname)).getUrl(); } JTextField nametf = new JTextField(nickname, 40); @@ -404,8 +404,8 @@ public class DasSourceBrowser panel.add(pane12, BorderLayout.SOUTH); int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop, - panel, "Enter Nickname & URL of Local DAS Source", - JOptionPane.OK_CANCEL_OPTION); + panel, "Enter Nickname & URL of Local DAS Source", + JOptionPane.OK_CANCEL_OPTION); if (reply != JOptionPane.OK_OPTION) { @@ -442,16 +442,16 @@ public class DasSourceBrowser { if (!newSource && dasSources[i].getNickname().equals(nickname)) { - ( (DasSource) dasSources[i]).setNickname(local.getNickname()); - ( (DasSource) dasSources[i]).setUrl(local.getUrl()); + ((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())); + data[i][1] = new Boolean(selectedSources.contains(dasSources[i] + .getNickname())); } } @@ -480,8 +480,7 @@ public class DasSourceBrowser public void run() { scrollPane.getVerticalScrollBar().setValue( - scrollPane.getVerticalScrollBar().getMaximum() - ); + scrollPane.getVerticalScrollBar().getMaximum()); } }); @@ -501,63 +500,58 @@ public class DasSourceBrowser if (!localSources.containsKey(nickname)) { JOptionPane.showInternalMessageDialog(Desktop.desktop, - "You can only edit or remove local DAS Sources!", - "Public DAS source - not editable", - JOptionPane.WARNING_MESSAGE); + "You can only edit or remove local DAS Sources!", + "Public DAS source - not editable", + JOptionPane.WARNING_MESSAGE); return; } Object[] options = - { - "Edit", "Remove", "Cancel"}; + { "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]); + "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: - 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++) + 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 { - 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++; - } + 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() + } + dasSources = tmp; + refreshTableData(data); + SwingUtilities.invokeLater(new Runnable() + { + public void run() { - public void run() - { - scrollPane.getVerticalScrollBar().setValue( - scrollPane.getVerticalScrollBar().getMaximum() - ); - } - }); + scrollPane.getVerticalScrollBar().setValue( + scrollPane.getVerticalScrollBar().getMaximum()); + } + }); - break; + break; } } @@ -575,8 +569,8 @@ public class DasSourceBrowser for (int i = 0; i < size; i++) { data[i][0] = dasSources[i].getNickname(); - data[i][1] = new Boolean(selectedSources.contains(dasSources[i]. - getNickname())); + data[i][1] = new Boolean(selectedSources.contains(dasSources[i] + .getNickname())); } DasSource[] tmp = new DasSource[size + lsize]; @@ -594,7 +588,7 @@ public class DasSourceBrowser data[index][1] = new Boolean(false); tmp[index] = new Das1Source(); tmp[index].setNickname(key); - tmp[index].setUrl( ( (DasSource) localSources.get(key)).getUrl()); + tmp[index].setUrl(((DasSource) localSources.get(key)).getUrl()); index++; } @@ -606,7 +600,7 @@ public class DasSourceBrowser public void valueChanged(ListSelectionEvent evt) { - //Called when the MainTable selection changes + // Called when the MainTable selection changes if (evt.getValueIsAdjusting()) { return; @@ -621,12 +615,11 @@ public class DasSourceBrowser 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 + // 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"}; + { "features" }; for (int i = 0; i < dSize; i++) { @@ -634,38 +627,36 @@ public class DasSourceBrowser DasCoordinateSystem[] dcs = ds.getCoordinateSystem(); if (dcs.length == 0 && ds.getCapabilities().length == 0 - && filter1.getSelectedIndex() == 0 - && filter2.getSelectedIndex() == 0 - && filter3.getSelectedIndex() == 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 + // 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()))); + 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; } for (int j = 0; j < dcs.length; j++) { - if (selectedInList(filter1.getSelectedValues(), - new String[] - {dcs[j].getName()}) - && selectedInList(filter2.getSelectedValues(), - new String[] - {dcs[j].getCategory()})) + if (selectedInList(filter1.getSelectedValues(), new String[] + { dcs[j].getName() }) + && selectedInList(filter2.getSelectedValues(), new String[] + { dcs[j].getCategory() })) { names.add(ds.getNickname()); - selected.add(new Boolean( - selectedSources.contains(ds.getNickname()))); + selected.add(new Boolean(selectedSources.contains(ds + .getNickname()))); break; } } @@ -705,7 +696,8 @@ public class DasSourceBrowser void setSelectedFromProperties() { - String active = jalview.bin.Cache.getDefault("DAS_ACTIVE_SOURCE", "uniprot"); + String active = jalview.bin.Cache.getDefault("DAS_ACTIVE_SOURCE", + "uniprot"); StringTokenizer st = new StringTokenizer(active, "\t"); selectedSources = new Vector(); while (st.hasMoreTokens()) @@ -755,7 +747,7 @@ public class DasSourceBrowser StringBuffer sb = new StringBuffer(); for (int r = 0; r < table.getModel().getRowCount(); r++) { - if ( ( (Boolean) table.getValueAt(r, 1)).booleanValue()) + if (((Boolean) table.getValueAt(r, 1)).booleanValue()) { sb.append(table.getValueAt(r, 0) + "\t"); } @@ -771,8 +763,7 @@ public class DasSourceBrowser { String token = en.nextElement().toString(); sb.append(token + "|" - + ( (DasSource) localSources.get(token)).getUrl() - + "\t"); + + ((DasSource) localSources.get(token)).getUrl() + "\t"); } properties.setProperty("DAS_LOCAL_SOURCE", sb.toString()); @@ -780,8 +771,7 @@ public class DasSourceBrowser } - class DASTableModel - extends AbstractTableModel + class DASTableModel extends AbstractTableModel { public DASTableModel(Object[][] data) @@ -790,8 +780,7 @@ public class DasSourceBrowser } private String[] columnNames = new String[] - { - "Nickname", "Use Source"}; + { "Nickname", "Use Source" }; private Object[][] data; @@ -816,10 +805,9 @@ public class DasSourceBrowser } /* - * JTable uses this method to determine the default renderer/ - * editor for each cell. If we didn't implement this method, - * then the last column would contain text ("true"/"false"), - * rather than a check box. + * JTable uses this method to determine the default renderer/ editor for + * each cell. If we didn't implement this method, then the last column would + * contain text ("true"/"false"), rather than a check box. */ public Class getColumnClass(int c) { @@ -827,20 +815,18 @@ public class DasSourceBrowser } /* - * Don't need to implement this method unless your table's - * editable. + * Don't need to implement this method unless your table's editable. */ public boolean isCellEditable(int row, int col) { - //Note that the data/cell address is constant, - //no matter where the cell appears onscreen. + // Note that the data/cell address is constant, + // no matter where the cell appears onscreen. return col == 1; } /* - * Don't need to implement this method unless your table's - * data can change. + * Don't need to implement this method unless your table's data can change. */ public void setValueAt(Object value, int row, int col) { @@ -848,7 +834,7 @@ public class DasSourceBrowser fireTableCellUpdated(row, col); String name = getValueAt(row, 0).toString(); - boolean selected = ( (Boolean) value).booleanValue(); + boolean selected = ((Boolean) value).booleanValue(); if (selectedSources.contains(name) && !selected) {