/*\r
- * Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
- *\r
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)\r
+ * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * \r
* This program is free software; you can redistribute it and/or\r
* modify it under the terms of the GNU General Public License\r
* as published by the Free Software Foundation; either version 2\r
* of the License, or (at your option) any later version.\r
- *\r
+ * \r
* This program is distributed in the hope that it will be useful,\r
* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
* GNU General Public License for more details.\r
- *\r
+ * \r
* You should have received a copy of the GNU General Public License\r
* along with this program; if not, write to the Free Software\r
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
import jalview.jbgui.*;\r
import jalview.util.*;\r
\r
-public class DasSourceBrowser\r
- extends GDasSourceBrowser implements Runnable, ListSelectionListener\r
+public class DasSourceBrowser extends GDasSourceBrowser implements\r
+ Runnable, ListSelectionListener\r
{\r
static DasSource[] dasSources = null;\r
\r
\r
Vector selectedSources;\r
\r
- public static String DEFAULT_REGISTRY =\r
- "http://www.dasregistry.org/das1/sources/";\r
+ public static String DEFAULT_REGISTRY = "http://www.dasregistry.org/das1/sources/";\r
\r
/**\r
* true if thread is running and we are talking to DAS registry service\r
*/\r
public boolean loadingDasSources = false;\r
+\r
protected static String getDasRegistryURL()\r
{\r
String registry = jalview.bin.Cache.getDefault("DAS_REGISTRY_URL",\r
- DEFAULT_REGISTRY);\r
+ DEFAULT_REGISTRY);\r
\r
if (registry.indexOf("/registry/das1/sources/") > -1)\r
{\r
}\r
return registry;\r
}\r
+\r
public DasSourceBrowser()\r
{\r
String registry = getDasRegistryURL();\r
- \r
+\r
registryURL.setText(registry);\r
\r
setSelectedFromProperties();\r
filter2.addListSelectionListener(this);\r
filter3.addListSelectionListener(this);\r
\r
- //Ask to be notified of selection changes.\r
+ // Ask to be notified of selection changes.\r
ListSelectionModel rowSM = table.getSelectionModel();\r
rowSM.addListSelectionListener(new ListSelectionListener()\r
{\r
public void mouseClicked(MouseEvent evt)\r
{\r
if (evt.getClickCount() == 2\r
- || SwingUtilities.isRightMouseButton(evt))\r
+ || SwingUtilities.isRightMouseButton(evt))\r
{\r
editRemoveLocalSource(evt);\r
}\r
for (int i = 0; i < dSize; i++)\r
{\r
data[i][0] = dasSources[i].getNickname();\r
- data[i][1] = new Boolean(selectedSources.contains(dasSources[i].\r
- getNickname()));\r
+ data[i][1] = new Boolean(selectedSources.contains(dasSources[i]\r
+ .getNickname()));\r
}\r
\r
refreshTableData(data);\r
{\r
\r
StringBuffer text = new StringBuffer(\r
- "<HTML><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">");\r
+ "<HTML><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">");\r
\r
if (nickName == null)\r
{\r
- fullDetails.setText(text +\r
- "Select a DAS service from the table"\r
- + " to read a full description here.</font></html>");\r
+ fullDetails.setText(text + "Select a DAS service from the table"\r
+ + " to read a full description here.</font></html>");\r
return;\r
}\r
\r
\r
DasSource ds = dasSources[i];\r
\r
- text.append("<font color=\"#0000FF\">Id:</font> " + dasSources[i].getId() +\r
- "<br>");\r
- text.append("<font color=\"#0000FF\">Nickname:</font> " +\r
- dasSources[i].getNickname() + "<br>");\r
- text.append("<font color=\"#0000FF\">URL:</font> " + dasSources[i].getUrl() +\r
- "<br>");\r
+ text.append("<font color=\"#0000FF\">Id:</font> "\r
+ + dasSources[i].getId() + "<br>");\r
+ text.append("<font color=\"#0000FF\">Nickname:</font> "\r
+ + dasSources[i].getNickname() + "<br>");\r
+ text.append("<font color=\"#0000FF\">URL:</font> "\r
+ + dasSources[i].getUrl() + "<br>");\r
\r
- text.append(\r
- "<font color=\"#0000FF\">Admin Email:</font> <a href=\"mailto:"\r
- + dasSources[i].getAdminemail()\r
- + "\">" + dasSources[i].getAdminemail() + "</a>" +\r
- "<br>");\r
+ text\r
+ .append("<font color=\"#0000FF\">Admin Email:</font> <a href=\"mailto:"\r
+ + dasSources[i].getAdminemail()\r
+ + "\">"\r
+ + dasSources[i].getAdminemail() + "</a>" + "<br>");\r
\r
- text.append("<font color=\"#0000FF\">Registered at:</font> " +\r
- dasSources[i].getRegisterDate() +\r
- "<br>");\r
+ text.append("<font color=\"#0000FF\">Registered at:</font> "\r
+ + dasSources[i].getRegisterDate() + "<br>");\r
\r
- text.append("<font color=\"#0000FF\">Last successful test:</font> " +\r
- dasSources[i].getLeaseDate() +\r
- "<br>");\r
+ text.append("<font color=\"#0000FF\">Last successful test:</font> "\r
+ + dasSources[i].getLeaseDate() + "<br>");\r
\r
text.append("<font color=\"#0000FF\">Labels:</font> ");\r
for (int s = 0; s < dasSources[i].getLabels().length; s++)\r
for (int j = 0; j < dcs.length; j++)\r
{\r
text.append("(" + dcs[j].getUniqueId() + ") "\r
- + dcs[j].getCategory() + ", " + dcs[j].getName());\r
+ + dcs[j].getCategory() + ", " + dcs[j].getName());\r
if (dcs[j].getNCBITaxId() != 0)\r
{\r
text.append(", " + dcs[j].getNCBITaxId());\r
text.append("<br>");\r
}\r
\r
- text.append("<font color=\"#0000FF\">Description:</font> " +\r
- dasSources[i].getDescription() + "<br>");\r
+ text.append("<font color=\"#0000FF\">Description:</font> "\r
+ + dasSources[i].getDescription() + "<br>");\r
\r
if (dasSources[i].getHelperurl() != null\r
- && dasSources[i].getHelperurl().length() > 0)\r
+ && dasSources[i].getHelperurl().length() > 0)\r
{\r
- text.append("<font color=\"#0000FF\"><a href=\"" +\r
- dasSources[i].getHelperurl()\r
- + "\">Go to site</a></font<br>");\r
+ text.append("<font color=\"#0000FF\"><a href=\""\r
+ + dasSources[i].getHelperurl()\r
+ + "\">Go to site</a></font<br>");\r
}\r
\r
text.append("</font></html>");\r
progressBar.setVisible(true);\r
progressBar.setIndeterminate(true);\r
// Refresh the source list.\r
- dasSources=null;\r
+ dasSources = null;\r
getDASSource();\r
- \r
+\r
init();\r
\r
loadingDasSources = false;\r
{\r
for (int i = 0; i < dasSources.length; i++)\r
{\r
- if (dasSources[i].getNickname().equals(\r
- selectedSources.elementAt(r)))\r
+ if (dasSources[i].getNickname()\r
+ .equals(selectedSources.elementAt(r)))\r
{\r
selected.addElement(dasSources[i]);\r
break;\r
\r
return selected;\r
}\r
+\r
/**\r
* retrieve das sources from registry and add local source list\r
+ * \r
* @return\r
*/\r
public DasSource[] getDASSource()\r
{\r
int selectedRow = table.getSelectionModel().getMinSelectionIndex();\r
nickname = table.getValueAt(selectedRow, 0).toString();\r
- url = ( (DasSource) localSources.get(nickname)).getUrl();\r
+ url = ((DasSource) localSources.get(nickname)).getUrl();\r
}\r
\r
JTextField nametf = new JTextField(nickname, 40);\r
panel.add(pane12, BorderLayout.SOUTH);\r
\r
int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,\r
- panel, "Enter Nickname & URL of Local DAS Source",\r
- JOptionPane.OK_CANCEL_OPTION);\r
+ panel, "Enter Nickname & URL of Local DAS Source",\r
+ JOptionPane.OK_CANCEL_OPTION);\r
\r
if (reply != JOptionPane.OK_OPTION)\r
{\r
{\r
if (!newSource && dasSources[i].getNickname().equals(nickname))\r
{\r
- ( (DasSource) dasSources[i]).setNickname(local.getNickname());\r
- ( (DasSource) dasSources[i]).setUrl(local.getUrl());\r
+ ((DasSource) dasSources[i]).setNickname(local.getNickname());\r
+ ((DasSource) dasSources[i]).setUrl(local.getUrl());\r
data[i][0] = local.getNickname();\r
data[i][1] = new Boolean(true);\r
}\r
else\r
{\r
data[i][0] = dasSources[i].getNickname();\r
- data[i][1] = new Boolean(selectedSources.contains(dasSources[i].\r
- getNickname()));\r
+ data[i][1] = new Boolean(selectedSources.contains(dasSources[i]\r
+ .getNickname()));\r
}\r
}\r
\r
public void run()\r
{\r
scrollPane.getVerticalScrollBar().setValue(\r
- scrollPane.getVerticalScrollBar().getMaximum()\r
- );\r
+ scrollPane.getVerticalScrollBar().getMaximum());\r
}\r
});\r
\r
if (!localSources.containsKey(nickname))\r
{\r
JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
- "You can only edit or remove local DAS Sources!",\r
- "Public DAS source - not editable",\r
- JOptionPane.WARNING_MESSAGE);\r
+ "You can only edit or remove local DAS Sources!",\r
+ "Public DAS source - not editable",\r
+ JOptionPane.WARNING_MESSAGE);\r
return;\r
}\r
\r
Object[] options =\r
- {\r
- "Edit", "Remove", "Cancel"};\r
+ { "Edit", "Remove", "Cancel" };\r
int choice = JOptionPane.showInternalOptionDialog(Desktop.desktop,\r
- "Do you want to edit or remove " + nickname + "?",\r
- "Edit / Remove Local DAS Source",\r
- JOptionPane.YES_NO_CANCEL_OPTION,\r
- JOptionPane.QUESTION_MESSAGE,\r
- null,\r
- options,\r
- options[2]);\r
+ "Do you want to edit or remove " + nickname + "?",\r
+ "Edit / Remove Local DAS Source",\r
+ JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,\r
+ null, options, options[2]);\r
\r
switch (choice)\r
{\r
- case 0:\r
- amendLocal(false);\r
- break;\r
- case 1:\r
- localSources.remove(nickname);\r
- selectedSources.remove(nickname);\r
- Object[][] data = new Object[dasSources.length - 1][2];\r
- DasSource[] tmp = new DasSource[dasSources.length - 1];\r
- int index = 0;\r
- for (int i = 0; i < dasSources.length; i++)\r
+ case 0:\r
+ amendLocal(false);\r
+ break;\r
+ case 1:\r
+ localSources.remove(nickname);\r
+ selectedSources.remove(nickname);\r
+ Object[][] data = new Object[dasSources.length - 1][2];\r
+ DasSource[] tmp = new DasSource[dasSources.length - 1];\r
+ int index = 0;\r
+ for (int i = 0; i < dasSources.length; i++)\r
+ {\r
+ if (dasSources[i].getNickname().equals(nickname))\r
+ {\r
+ continue;\r
+ }\r
+ else\r
{\r
- if (dasSources[i].getNickname().equals(nickname))\r
- {\r
- continue;\r
- }\r
- else\r
- {\r
- tmp[index] = dasSources[i];\r
- data[index][0] = dasSources[i].getNickname();\r
- data[index][1] = new Boolean(selectedSources.contains(dasSources[i].\r
- getNickname()));\r
- index++;\r
- }\r
+ tmp[index] = dasSources[i];\r
+ data[index][0] = dasSources[i].getNickname();\r
+ data[index][1] = new Boolean(selectedSources\r
+ .contains(dasSources[i].getNickname()));\r
+ index++;\r
}\r
- dasSources = tmp;\r
- refreshTableData(data);\r
- SwingUtilities.invokeLater(new Runnable()\r
+ }\r
+ dasSources = tmp;\r
+ refreshTableData(data);\r
+ SwingUtilities.invokeLater(new Runnable()\r
+ {\r
+ public void run()\r
{\r
- public void run()\r
- {\r
- scrollPane.getVerticalScrollBar().setValue(\r
- scrollPane.getVerticalScrollBar().getMaximum()\r
- );\r
- }\r
- });\r
+ scrollPane.getVerticalScrollBar().setValue(\r
+ scrollPane.getVerticalScrollBar().getMaximum());\r
+ }\r
+ });\r
\r
- break;\r
+ break;\r
}\r
}\r
\r
for (int i = 0; i < size; i++)\r
{\r
data[i][0] = dasSources[i].getNickname();\r
- data[i][1] = new Boolean(selectedSources.contains(dasSources[i].\r
- getNickname()));\r
+ data[i][1] = new Boolean(selectedSources.contains(dasSources[i]\r
+ .getNickname()));\r
}\r
\r
DasSource[] tmp = new DasSource[size + lsize];\r
data[index][1] = new Boolean(false);\r
tmp[index] = new Das1Source();\r
tmp[index].setNickname(key);\r
- tmp[index].setUrl( ( (DasSource) localSources.get(key)).getUrl());\r
+ tmp[index].setUrl(((DasSource) localSources.get(key)).getUrl());\r
\r
index++;\r
}\r
\r
public void valueChanged(ListSelectionEvent evt)\r
{\r
- //Called when the MainTable selection changes\r
+ // Called when the MainTable selection changes\r
if (evt.getValueIsAdjusting())\r
{\r
return;\r
ArrayList selected = new ArrayList();\r
DasSource ds;\r
\r
- //The features filter is not visible, but we must still\r
- //filter the das source list here.\r
- //July 2006 - only 6 sources fo not serve features\r
+ // The features filter is not visible, but we must still\r
+ // filter the das source list here.\r
+ // July 2006 - only 6 sources fo not serve features\r
Object[] dummyFeatureList = new Object[]\r
- {\r
- "features"};\r
+ { "features" };\r
\r
for (int i = 0; i < dSize; i++)\r
{\r
DasCoordinateSystem[] dcs = ds.getCoordinateSystem();\r
\r
if (dcs.length == 0 && ds.getCapabilities().length == 0\r
- && filter1.getSelectedIndex() == 0\r
- && filter2.getSelectedIndex() == 0\r
- && filter3.getSelectedIndex() == 0)\r
+ && filter1.getSelectedIndex() == 0\r
+ && filter2.getSelectedIndex() == 0\r
+ && filter3.getSelectedIndex() == 0)\r
{\r
- //THIS IS A FIX FOR LOCAL SOURCES WHICH DO NOT\r
- //HAVE COORDINATE SYSTEMS, INFO WHICH AT PRESENT\r
- //IS ADDED FROM THE REGISTRY\r
+ // THIS IS A FIX FOR LOCAL SOURCES WHICH DO NOT\r
+ // HAVE COORDINATE SYSTEMS, INFO WHICH AT PRESENT\r
+ // IS ADDED FROM THE REGISTRY\r
names.add(ds.getNickname());\r
- selected.add(new Boolean(\r
- selectedSources.contains(ds.getNickname())));\r
+ selected\r
+ .add(new Boolean(selectedSources.contains(ds.getNickname())));\r
continue;\r
}\r
\r
if (!selectedInList(dummyFeatureList, ds.getCapabilities())\r
- || !selectedInList(filter3.getSelectedValues(),\r
- ds.getLabels()))\r
+ || !selectedInList(filter3.getSelectedValues(), ds\r
+ .getLabels()))\r
{\r
continue;\r
}\r
\r
for (int j = 0; j < dcs.length; j++)\r
{\r
- if (selectedInList(filter1.getSelectedValues(),\r
- new String[]\r
- {dcs[j].getName()})\r
- && selectedInList(filter2.getSelectedValues(),\r
- new String[]\r
- {dcs[j].getCategory()}))\r
+ if (selectedInList(filter1.getSelectedValues(), new String[]\r
+ { dcs[j].getName() })\r
+ && selectedInList(filter2.getSelectedValues(), new String[]\r
+ { dcs[j].getCategory() }))\r
{\r
names.add(ds.getNickname());\r
- selected.add(new Boolean(\r
- selectedSources.contains(ds.getNickname())));\r
+ selected.add(new Boolean(selectedSources.contains(ds\r
+ .getNickname())));\r
break;\r
}\r
}\r
\r
void setSelectedFromProperties()\r
{\r
- String active = jalview.bin.Cache.getDefault("DAS_ACTIVE_SOURCE", "uniprot");\r
+ String active = jalview.bin.Cache.getDefault("DAS_ACTIVE_SOURCE",\r
+ "uniprot");\r
StringTokenizer st = new StringTokenizer(active, "\t");\r
selectedSources = new Vector();\r
while (st.hasMoreTokens())\r
StringBuffer sb = new StringBuffer();\r
for (int r = 0; r < table.getModel().getRowCount(); r++)\r
{\r
- if ( ( (Boolean) table.getValueAt(r, 1)).booleanValue())\r
+ if (((Boolean) table.getValueAt(r, 1)).booleanValue())\r
{\r
sb.append(table.getValueAt(r, 0) + "\t");\r
}\r
{\r
String token = en.nextElement().toString();\r
sb.append(token + "|"\r
- + ( (DasSource) localSources.get(token)).getUrl()\r
- + "\t");\r
+ + ((DasSource) localSources.get(token)).getUrl() + "\t");\r
}\r
\r
properties.setProperty("DAS_LOCAL_SOURCE", sb.toString());\r
\r
}\r
\r
- class DASTableModel\r
- extends AbstractTableModel\r
+ class DASTableModel extends AbstractTableModel\r
{\r
\r
public DASTableModel(Object[][] data)\r
}\r
\r
private String[] columnNames = new String[]\r
- {\r
- "Nickname", "Use Source"};\r
+ { "Nickname", "Use Source" };\r
\r
private Object[][] data;\r
\r
}\r
\r
/*\r
- * JTable uses this method to determine the default renderer/\r
- * editor for each cell. If we didn't implement this method,\r
- * then the last column would contain text ("true"/"false"),\r
- * rather than a check box.\r
+ * JTable uses this method to determine the default renderer/ editor for\r
+ * each cell. If we didn't implement this method, then the last column would\r
+ * contain text ("true"/"false"), rather than a check box.\r
*/\r
public Class getColumnClass(int c)\r
{\r
}\r
\r
/*\r
- * Don't need to implement this method unless your table's\r
- * editable.\r
+ * Don't need to implement this method unless your table's editable.\r
*/\r
public boolean isCellEditable(int row, int col)\r
{\r
- //Note that the data/cell address is constant,\r
- //no matter where the cell appears onscreen.\r
+ // Note that the data/cell address is constant,\r
+ // no matter where the cell appears onscreen.\r
return col == 1;\r
\r
}\r
\r
/*\r
- * Don't need to implement this method unless your table's\r
- * data can change.\r
+ * Don't need to implement this method unless your table's data can change.\r
*/\r
public void setValueAt(Object value, int row, int col)\r
{\r
fireTableCellUpdated(row, col);\r
\r
String name = getValueAt(row, 0).toString();\r
- boolean selected = ( (Boolean) value).booleanValue();\r
+ boolean selected = ((Boolean) value).booleanValue();\r
\r
if (selectedSources.contains(name) && !selected)\r
{\r