X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FDasSourceBrowser.java;h=8ce09955227ebe3a517c1a08a34ebe77ad40ec7c;hb=8a6fa9ea9900d0f106529c3f6283e7f9d76dd2cb;hp=5b1adb1d16dbcfa10c84ce4b104eef72865d5e36;hpb=07af649391c1b952c268b8e5776531ab6f3d2f0e;p=jalview.git
diff --git a/src/jalview/gui/DasSourceBrowser.java b/src/jalview/gui/DasSourceBrowser.java
index 5b1adb1..8ce0995 100755
--- a/src/jalview/gui/DasSourceBrowser.java
+++ b/src/jalview/gui/DasSourceBrowser.java
@@ -1,39 +1,36 @@
/*
- * 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.6)
+ * Copyright (C) 2010 J Procter, AM Waterhouse, 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.util.TableSorter;
-import java.awt.event.*;
-import javax.swing.*;
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.DasCoordinateSystem;
-import org.biojava.dasobert.dasregistry.DasSource;
-import org.biojava.dasobert.dasregistry.Das1Source;
-import java.awt.BorderLayout;
+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;
@@ -41,30 +38,49 @@ public class DasSourceBrowser extends GDasSourceBrowser
Vector selectedSources;
- public DasSourceBrowser()
+ 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()
{
- registryURL.setText(jalview.bin.Cache.getDefault("DAS_REGISTRY_URL",
- "http://servlet.sanger.ac.uk/dasregistry/services/das_registry") );
+ String registry = jalview.bin.Cache.getDefault("DAS_REGISTRY_URL",
+ DEFAULT_REGISTRY);
+
+ if (registry.indexOf("/registry/das1/sources/") > -1)
+ {
+ jalview.bin.Cache.setProperty(jalview.bin.Cache.DAS_REGISTRY_URL,
+ DEFAULT_REGISTRY);
+ registry = DEFAULT_REGISTRY;
+ }
+ return registry;
+ }
+
+ public DasSourceBrowser(FeatureSettings featureSettings)
+ {
+ fs = featureSettings;
+ String registry = 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())
{
@@ -75,24 +91,37 @@ 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 (dasSources != null)
{
- Thread worker = new Thread(this);
- worker.start();
+ init();
+ }
+ }
+
+ FeatureSettings fs = null;
+
+ public DasSourceBrowser()
+ {
+ this(null);
+ }
+
+ public void paintComponent(java.awt.Graphics g)
+ {
+ if (dasSources == null && !loadingDasSources)
+ {
+ Thread worker = new Thread(this);
+ worker.start();
}
- else
- {
- init();
- }
}
void init()
@@ -102,22 +131,22 @@ public class DasSourceBrowser extends GDasSourceBrowser
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);
setCapabilities(dasSources);
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);
@@ -125,7 +154,6 @@ public class DasSourceBrowser extends GDasSourceBrowser
refresh.setVisible(true);
}
-
public void refreshTableData(Object[][] data)
{
TableSorter sorter = new TableSorter(new DASTableModel(data));
@@ -137,13 +165,12 @@ 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;
}
@@ -151,48 +178,51 @@ public class DasSourceBrowser extends GDasSourceBrowser
for (int i = 0; i < dSize; i++)
{
if (!dasSources[i].getNickname().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() +
- "
");
+ 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()+"" +
- "
");
-
+ + dasSources[i].getAdminemail()
+ + "\">"
+ + 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");
-
-
text.append("Capabilities: ");
String[] scap = dasSources[i].getCapabilities();
for (int j = 0; j < scap.length; j++)
{
text.append(scap[j]);
if (j < scap.length - 1)
+ {
text.append(", ");
+ }
}
text.append("
");
@@ -201,25 +231,28 @@ public class DasSourceBrowser extends GDasSourceBrowser
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());
+ }
if (dcs[j].getOrganismName().length() > 0)
+ {
text.append(", " + dcs[j].getOrganismName());
+ }
text.append("
");
}
- text.append("Description: " +
- dasSources[i].getDescription() + "
");
-
+ text.append("Description: "
+ + dasSources[i].getDescription() + "
");
- if (dasSources[i].getHelperurl()!=null
- && dasSources[i].getHelperurl().length() > 0)
+ if (dasSources[i].getHelperurl() != null
+ && dasSources[i].getHelperurl().length() > 0)
{
- text.append("Go to site");
+ text.append("Go to site");
}
text.append("