X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fgui%2FDasSourceBrowser.java;h=71efbd073ab55c0532b6a7fa5737416250c7e461;hb=9aae8c465483d78a6a0407774a86deb4b3b6416e;hp=f57967c6900c78c5f58300383ef517a98c21b510;hpb=42ed2d813b3b8e7c9c80d79e1c8e1ded61ec6dd9;p=jalview.git
diff --git a/src/jalview/gui/DasSourceBrowser.java b/src/jalview/gui/DasSourceBrowser.java
index f57967c..71efbd0 100755
--- a/src/jalview/gui/DasSourceBrowser.java
+++ b/src/jalview/gui/DasSourceBrowser.java
@@ -1,69 +1,84 @@
/*
- * 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.services.das.registry.DasCoordinateSystem;
-import org.biojava.services.das.registry.DasSource;
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://servlet.sanger.ac.uk/dasregistry/services/das_registry") );
+ fs = featureSettings;
+ // TODO DasSourceRegistryProvider API
+ sourceRegistry = jalview.bin.Cache.getDasSourceRegistry();
+ String registry = sourceRegistry.getDasRegistryURL();
+
+ registryURL.setText(registry);
setSelectedFromProperties();
displayFullDetails(null);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- capabilities.addListSelectionListener(this);
- coords1.addListSelectionListener(this);
- coords2.addListSelectionListener(this);
+ filter1.addListSelectionListener(this);
+ 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())
{
@@ -74,49 +89,65 @@ 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);
@@ -124,7 +155,6 @@ public class DasSourceBrowser extends GDasSourceBrowser
refresh.setVisible(true);
}
-
public void refreshTableData(Object[][] data)
{
TableSorter sorter = new TableSorter(new DASTableModel(data));
@@ -136,89 +166,108 @@ 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() + "
");
- text.append("Admin Email: "+dasSources[i].getAdminemail()+"" +
- "
");
+ text.append("URL: " + ds.getSourceURL() + ""
+ + "
");
+ if (!ds.isLocal())
+ {
+ if (ds.getDocHref() != null && ds.getDocHref().length() > 0)
+ {
+ text.append("Site: " + ds.getDocHref() + ""
+ + "
");
+ }
+ text.append("Description: "
+ + ds.getDescription() + "
");
- text.append("Registered at: " + dasSources[i].getRegisterDate() +
- "
");
+ text.append("Admin Email: " + ds.getEmail() + "" + "
");
- text.append("Last successful test: " + dasSources[i].getLeaseDate() +
- "
");
+ text.append("Registered at: "
+ + latest.getCreated() + "
");
+ // 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++)
- {
- 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("Description: " +
- dasSources[i].getDescription() + "
");
-
- if (dasSources[i].getHelperurl().length() > 0)
+ text.append("Coordinates:");
+ int i=1;
+ for (COORDINATES dcs : latest.getCOORDINATES())
{
- text.append("Go to site");
+ text.append("
"+i+++". ");
+ text.append(dcs.getAuthority()+" : "+dcs.getSource());
+ if (dcs.getTaxid() != null && dcs.getTaxid().trim().length() > 0)
+ {
+ text.append(" [TaxId:" + dcs.getTaxid()+"]");
+ }
+ if (dcs.getVersion() != null
+ && dcs.getVersion().trim().length() > 0)
+ {
+ {
+ text.append(" {v. " + dcs.getVersion()+"}");
+ }
+ }
+ text.append(" ("+dcs.getUri() + ")");
}
-
text.append("