X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDasSourceBrowser.java;h=71efbd073ab55c0532b6a7fa5737416250c7e461;hb=9aae8c465483d78a6a0407774a86deb4b3b6416e;hp=807aa4b5cbc6b89b2ba36f526d66219dd6949085;hpb=3b24654f2ada868e8a3771427cc9b180f78f2020;p=jalview.git
diff --git a/src/jalview/gui/DasSourceBrowser.java b/src/jalview/gui/DasSourceBrowser.java
index 807aa4b..71efbd0 100755
--- a/src/jalview/gui/DasSourceBrowser.java
+++ b/src/jalview/gui/DasSourceBrowser.java
@@ -1,67 +1,67 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer
- * Copyright (C) 2007 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 java.util.*;
-
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.table.*;
-
-import org.biojava.dasobert.dasregistry.*;
-import jalview.jbgui.*;
-import jalview.util.*;
-
-public class DasSourceBrowser
- extends GDasSourceBrowser implements Runnable, ListSelectionListener
+import jalview.jbgui.GDasSourceBrowser;
+import jalview.util.TableSorter;
+import jalview.ws.dbsources.das.api.DasSourceRegistryI;
+import jalview.ws.dbsources.das.api.jalviewSourceI;
+
+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;
+
+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;
+
+public class DasSourceBrowser extends GDasSourceBrowser implements
+ Runnable, ListSelectionListener
{
- static DasSource[] dasSources = null;
+ DasSourceRegistryI sourceRegistry = null;
- Hashtable localSources = null;
+ Vector selectedSources;
- Vector selectedSources;
-
- 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()
+ public DasSourceBrowser(FeatureSettings featureSettings)
{
- String registry = jalview.bin.Cache.getDefault("DAS_REGISTRY_URL",
- DEFAULT_REGISTRY);
+ fs = featureSettings;
+ // TODO DasSourceRegistryProvider API
+ sourceRegistry = jalview.bin.Cache.getDasSourceRegistry();
+ String registry = sourceRegistry.getDasRegistryURL();
- if (registry.indexOf("/registry/das1/sources/") > -1)
- {
- jalview.bin.Cache.setProperty("DAS_REGISTRY_URL", DEFAULT_REGISTRY);
- registry = DEFAULT_REGISTRY;
- }
- return registry;
- }
- public DasSourceBrowser()
- {
- String registry = getDasRegistryURL();
-
registryURL.setText(registry);
setSelectedFromProperties();
@@ -73,7 +73,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,22 +93,31 @@ public class DasSourceBrowser
public void mouseClicked(MouseEvent evt)
{
if (evt.getClickCount() == 2
- || SwingUtilities.isRightMouseButton(evt))
+ || SwingUtilities.isRightMouseButton(evt))
{
editRemoveLocalSource(evt);
}
}
});
- if (dasSources != null)
+ if (sourceRegistry.getSources() != null)
{
init();
}
}
+ FeatureSettings fs = null;
+
+ private boolean loadingDasSources;
+
+ public DasSourceBrowser()
+ {
+ this(null);
+ }
+
public void paintComponent(java.awt.Graphics g)
{
- if (dasSources == null && !loadingDasSources)
+ if (sourceRegistry == null)
{
Thread worker = new Thread(this);
worker.start();
@@ -117,17 +126,18 @@ public class DasSourceBrowser
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()
{
@@ -156,64 +166,82 @@ 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;
}
- 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];
+ VERSION latest = ds.getVersion();
+ text.append("Id: " + ds.getUri()
+ + "
");
+ text.append("Nickname: "
+ + ds.getTitle() + "
");
- text.append("Id: " + dasSources[i].getId() +
- "
");
- text.append("Nickname: " +
- dasSources[i].getNickname() + "
");
- text.append("URL: " + dasSources[i].getUrl() +
- "
");
+ text.append("URL: " + ds.getSourceURL() + ""
+ + "
");
+ if (!ds.isLocal())
+ {
+ if (ds.getDocHref() != null && ds.getDocHref().length() > 0)
+ {
+ text.append("Site: " + ds.getDocHref() + ""
+ + "
");
+ }
- text.append(
- "Admin Email: " + dasSources[i].getAdminemail() + "" +
- "
");
+ 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 < dasSources[i].getLabels().length; s++)
+ boolean b = false;
+ for (PROP labl : latest.getPROP())
{
- text.append(dasSources[i].getLabels()[s]);
- if (s < dasSources[i].getLabels().length - 1)
+ if (labl.getName().equalsIgnoreCase("LABEL"))
{
- text.append(",");
+ if (b)
+ {
+ text.append(",");
+ }
+ text.append(" ");
+
+ text.append(labl.getValue());
+ b = true;
}
- text.append(" ");
+ ;
}
text.append("
");
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(", ");
@@ -221,35 +249,25 @@ public class DasSourceBrowser
}
text.append("
");
- text.append("Coordinates: ");
- DasCoordinateSystem[] dcs = ds.getCoordinateSystem();
- for (int j = 0; j < dcs.length; j++)
+ text.append("Coordinates:");
+ int i=1;
+ for (COORDINATES dcs : latest.getCOORDINATES())
{
- text.append("(" + dcs[j].getUniqueId() + ") "
- + dcs[j].getCategory() + ", " + dcs[j].getName());
- if (dcs[j].getNCBITaxId() != 0)
+ text.append("
"+i+++". ");
+ text.append(dcs.getAuthority()+" : "+dcs.getSource());
+ if (dcs.getTaxid() != null && dcs.getTaxid().trim().length() > 0)
{
- text.append(", " + dcs[j].getNCBITaxId());
+ text.append(" [TaxId:" + dcs.getTaxid()+"]");
}
- if (dcs[j].getOrganismName().length() > 0)
+ if (dcs.getVersion() != null
+ && dcs.getVersion().trim().length() > 0)
{
- text.append(", " + dcs[j].getOrganismName());
+ {
+ text.append(" {v. " + dcs.getVersion()+"}");
+ }
}
-
- text.append("
");
- }
-
- text.append("Description: " +
- dasSources[i].getDescription() + "
");
-
- if (dasSources[i].getHelperurl() != null
- && dasSources[i].getHelperurl().length() > 0)
- {
- text.append("Go to site");
+ text.append(" ("+dcs.getUri() + ")");
}
-
text.append("