X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fgui%2FDasSourceBrowser.java;h=c0fefd1df7be7227b55a7cb3a04dd44a8a7d85df;hb=9876fdccf311378e690c1f9e18db52675d427b89;hp=acc9b09576bd6c75d7d05ee66a1456a0e75250dc;hpb=b57a02c25e335d033c97f8a6bacd6b54f62bd2b6;p=jalview.git
diff --git a/src/jalview/gui/DasSourceBrowser.java b/src/jalview/gui/DasSourceBrowser.java
old mode 100755
new mode 100644
index acc9b09..c0fefd1
--- a/src/jalview/gui/DasSourceBrowser.java
+++ b/src/jalview/gui/DasSourceBrowser.java
@@ -1,833 +1,844 @@
-/*
- * 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.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
-{
- DasSourceRegistryI sourceRegistry = null;
-
- Vector selectedSources;
-
- public DasSourceBrowser(FeatureSettings featureSettings)
- {
- 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);
-
- filter1.addListSelectionListener(this);
- filter2.addListSelectionListener(this);
- filter3.addListSelectionListener(this);
-
- // Ask to be notified of selection changes.
- ListSelectionModel rowSM = table.getSelectionModel();
- rowSM.addListSelectionListener(new ListSelectionListener()
- {
- public void valueChanged(ListSelectionEvent e)
- {
- ListSelectionModel lsm = (ListSelectionModel) e.getSource();
- if (!lsm.isSelectionEmpty())
- {
- int selectedRow = lsm.getMinSelectionIndex();
- displayFullDetails(table.getValueAt(selectedRow, 0).toString());
- }
- }
- });
-
- table.addMouseListener(new MouseAdapter()
- {
- public void mouseClicked(MouseEvent evt)
- {
- if (evt.getClickCount() == 2
- || SwingUtilities.isRightMouseButton(evt))
- {
- editRemoveLocalSource(evt);
- }
- }
- });
-
- if (sourceRegistry.getSources() != null)
- {
- 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();
- }
- }
-
- void init()
- {
- List sources = sourceRegistry.getSources();
- int dSize = sources.size();
- Object[][] data = new Object[dSize][2];
- for (int i = 0; i < dSize; i++)
- {
- 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(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);
- }
- });
-
- progressBar.setIndeterminate(false);
- progressBar.setVisible(false);
- addLocal.setVisible(true);
- refresh.setVisible(true);
- }
-
- public void refreshTableData(Object[][] data)
- {
- TableSorter sorter = new TableSorter(new DASTableModel(data));
- sorter.setTableHeader(table.getTableHeader());
- table.setModel(sorter);
- }
-
- void displayFullDetails(String nickName)
- {
-
- StringBuffer text = new StringBuffer(
- "");
-
- if (nickName == null)
- {
- fullDetails.setText(text + "Select a DAS service from the table"
- + " to read a full description here.");
- return;
- }
-
- int dSize = sourceRegistry.getSources().size();
- for (jalviewSourceI ds : sourceRegistry.getSources())
- {
- if (!ds.getTitle().equals(nickName))
- {
- continue;
- }
-
- VERSION latest = ds.getVersion();
- text.append("Id: " + ds.getUri()
- + "
");
- text.append("Nickname: "
- + ds.getTitle() + "
");
-
- 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("Admin Email: " + ds.getEmail() + "" + "
");
-
- 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: ");
- boolean b = false;
- for (PROP labl : latest.getPROP())
- {
- if (labl.getName().equalsIgnoreCase("LABEL"))
- {
- if (b)
- {
- text.append(",");
- }
- text.append(" ");
-
- text.append(labl.getValue());
- b = true;
- }
- ;
- }
- text.append("
");
-
- text.append("Capabilities: ");
- CAPABILITY[] scap = latest.getCAPABILITY().toArray(new CAPABILITY[0]);
- for (int j = 0; j < scap.length; j++)
- {
- text.append(scap[j].getType());
- if (j < scap.length - 1)
- {
- text.append(", ");
- }
- }
- text.append("
");
-
- text.append("Coordinates:");
- int i = 1;
- for (COORDINATES dcs : latest.getCOORDINATES())
- {
- 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("