2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
\r
3 * Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
\r
5 * This file is part of Jalview.
\r
7 * Jalview is free software: you can redistribute it and/or
\r
8 * modify it under the terms of the GNU General Public License
\r
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
\r
11 * Jalview is distributed in the hope that it will be useful, but
\r
12 * WITHOUT ANY WARRANTY; without even the implied warranty
\r
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
14 * PURPOSE. See the GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
\r
18 package jalview.gui;
\r
20 import java.text.ParseException;
\r
22 import java.util.List;
\r
25 import java.awt.event.*;
\r
26 import javax.swing.*;
\r
27 import javax.swing.event.*;
\r
28 import javax.swing.table.*;
\r
30 import org.biodas.jdas.dassources.Capabilities;
\r
31 import org.biodas.jdas.dassources.utils.DasCoordinateSystemCollector;
\r
32 import org.biodas.jdas.dassources.utils.DasTimeFormat;
\r
33 import org.biodas.jdas.schema.registrycoordinates.DASCOORDINATESYSTEM;
\r
34 import org.biodas.jdas.schema.sources.CAPABILITY;
\r
35 import org.biodas.jdas.schema.sources.COORDINATES;
\r
36 import org.biodas.jdas.schema.sources.MAINTAINER;
\r
37 import org.biodas.jdas.schema.sources.PROP;
\r
38 import org.biodas.jdas.schema.sources.SOURCE;
\r
39 import org.biodas.jdas.schema.sources.SOURCES;
\r
40 import org.biodas.jdas.schema.sources.VERSION;
\r
42 import jalview.jbgui.*;
\r
43 import jalview.util.*;
\r
45 public class DasSourceBrowser extends GDasSourceBrowser implements
\r
46 Runnable, ListSelectionListener
\r
48 static org.biodas.jdas.schema.sources.SOURCE[] dasSources = null;
\r
50 Hashtable<String, SOURCE> localSources = null;
\r
52 Vector selectedSources;
\r
54 public static String DEFAULT_REGISTRY = "http://www.dasregistry.org/das1/sources/";
\r
57 * true if thread is running and we are talking to DAS registry service
\r
59 public boolean loadingDasSources = false;
\r
61 protected static String getDasRegistryURL()
\r
63 String registry = jalview.bin.Cache.getDefault("DAS_REGISTRY_URL",
\r
66 if (registry.indexOf("/registry/das1/sources/") > -1)
\r
68 jalview.bin.Cache.setProperty(jalview.bin.Cache.DAS_REGISTRY_URL,
\r
70 registry = DEFAULT_REGISTRY;
\r
75 public DasSourceBrowser(FeatureSettings featureSettings)
\r
77 fs = featureSettings;
\r
78 String registry = getDasRegistryURL();
\r
80 registryURL.setText(registry);
\r
82 setSelectedFromProperties();
\r
84 displayFullDetails(null);
\r
85 table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
\r
87 filter1.addListSelectionListener(this);
\r
88 filter2.addListSelectionListener(this);
\r
89 filter3.addListSelectionListener(this);
\r
91 // Ask to be notified of selection changes.
\r
92 ListSelectionModel rowSM = table.getSelectionModel();
\r
93 rowSM.addListSelectionListener(new ListSelectionListener()
\r
95 public void valueChanged(ListSelectionEvent e)
\r
97 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
\r
98 if (!lsm.isSelectionEmpty())
\r
100 int selectedRow = lsm.getMinSelectionIndex();
\r
101 displayFullDetails(table.getValueAt(selectedRow, 0).toString());
\r
106 table.addMouseListener(new MouseAdapter()
\r
108 public void mouseClicked(MouseEvent evt)
\r
110 if (evt.getClickCount() == 2
\r
111 || SwingUtilities.isRightMouseButton(evt))
\r
113 editRemoveLocalSource(evt);
\r
118 if (dasSources != null)
\r
124 FeatureSettings fs = null;
\r
126 public DasSourceBrowser()
\r
131 public void paintComponent(java.awt.Graphics g)
\r
133 if (dasSources == null && !loadingDasSources)
\r
135 Thread worker = new Thread(this);
\r
142 int dSize = dasSources.length;
\r
143 Object[][] data = new Object[dSize][2];
\r
144 for (int i = 0; i < dSize; i++)
\r
146 data[i][0] = dasSources[i].getTitle(); // what's equivalent of nickname
\r
147 data[i][1] = new Boolean(selectedSources.contains(dasSources[i]
\r
151 refreshTableData(data);
\r
152 setCapabilities(dasSources);
\r
154 javax.swing.SwingUtilities.invokeLater(new Runnable()
\r
158 TableSorter sorter = (TableSorter) table.getModel();
\r
159 sorter.setSortingStatus(1, TableSorter.DESCENDING);
\r
160 sorter.setSortingStatus(1, TableSorter.NOT_SORTED);
\r
164 progressBar.setIndeterminate(false);
\r
165 progressBar.setVisible(false);
\r
166 addLocal.setVisible(true);
\r
167 refresh.setVisible(true);
\r
170 public void refreshTableData(Object[][] data)
\r
172 TableSorter sorter = new TableSorter(new DASTableModel(data));
\r
173 sorter.setTableHeader(table.getTableHeader());
\r
174 table.setModel(sorter);
\r
177 void displayFullDetails(String nickName)
\r
180 StringBuffer text = new StringBuffer(
\r
181 "<HTML><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">");
\r
183 if (nickName == null)
\r
185 fullDetails.setText(text + "Select a DAS service from the table"
\r
186 + " to read a full description here.</font></html>");
\r
190 int dSize = dasSources.length;
\r
191 for (int i = 0; i < dSize; i++)
\r
193 if (!dasSources[i].getTitle().equals(nickName))
\r
198 SOURCE ds = dasSources[i];
\r
199 VERSION latest = getVersionFor(ds);
\r
200 text.append("<font color=\"#0000FF\">Id:</font> "
\r
201 + dasSources[i].getUri() + "<br>");
\r
202 text.append("<font color=\"#0000FF\">Nickname:</font> "
\r
203 + dasSources[i].getTitle() + "<br>");
\r
204 text.append("<font color=\"#0000FF\">URL:</font> " + latest.getUri()
\r
207 text.append("<font color=\"#0000FF\">Admin Email:</font> <a href=\"mailto:"
\r
208 + ds.getMAINTAINER().getEmail()
\r
210 + ds.getMAINTAINER().getEmail() + "</a>" + "<br>");
\r
212 text.append("<font color=\"#0000FF\">Registered at:</font> "
\r
213 + latest.getCreated() + "<br>");
\r
215 // TODO: Identify last successful test date
\r
216 // text.append("<font color=\"#0000FF\">Last successful test:</font> "
\r
217 // + latest.dasSources[i].getLeaseDate() + "<br>");
\r
219 text.append("<font color=\"#0000FF\">Labels:</font> ");
\r
221 for (PROP labl : latest.getPROP())
\r
223 if (labl.getName().equalsIgnoreCase("LABEL"))
\r
231 text.append(labl.getValue());
\r
236 text.append("<br>");
\r
238 text.append("<font color=\"#0000FF\">Capabilities:</font> ");
\r
239 CAPABILITY[] scap = latest.getCAPABILITY().toArray(new CAPABILITY[0]);
\r
240 for (int j = 0; j < scap.length; j++)
\r
242 text.append(scap[j]);
\r
243 if (j < scap.length - 1)
\r
248 text.append("<br>");
\r
250 text.append("<font color=\"#0000FF\">Coordinates:</font> ");
\r
251 for (COORDINATES dcs : latest.getCOORDINATES())
\r
253 text.append("(" + dcs.getUri() + ") "
\r
255 + dcs.getSource() + ", " + dcs.getAuthority());
\r
256 if (dcs.getTaxid() != null && dcs.getTaxid().trim().length() > 0)
\r
258 text.append(", " + dcs.getTaxid());
\r
260 if (dcs.getVersion().trim().length() > 0)
\r
263 text.append(", " + dcs.getVersion());
\r
266 text.append("<br>");
\r
269 text.append("<font color=\"#0000FF\">Description:</font> "
\r
270 + dasSources[i].getDescription() + "<br>");
\r
272 if (dasSources[i].getDocHref() != null
\r
273 && dasSources[i].getDocHref().length() > 0)
\r
275 text.append("<font color=\"#0000FF\"><a href=\""
\r
276 + dasSources[i].getDocHref()
\r
277 + "\">Go to site</a></font<br>");
\r
280 text.append("</font></html>");
\r
285 fullDetails.setText(text.toString());
\r
286 javax.swing.SwingUtilities.invokeLater(new Runnable()
\r
290 fullDetailsScrollpane.getVerticalScrollBar().setValue(0);
\r
297 loadingDasSources = true;
\r
299 addLocal.setVisible(false);
\r
300 refresh.setVisible(false);
\r
301 progressBar.setVisible(true);
\r
302 progressBar.setIndeterminate(true);
\r
303 setParentGuiEnabled(false);
\r
304 // Refresh the source list.
\r
310 setParentGuiEnabled(true);
\r
311 loadingDasSources = false;
\r
315 private void setParentGuiEnabled(boolean b)
\r
319 fs.fetchDAS.setEnabled(b);
\r
320 fs.saveDAS.setEnabled(b);
\r
324 public Vector getSelectedSources()
\r
326 // wait around if we're still loading.
\r
327 while (dasSources == null)
\r
329 if (!loadingDasSources)
\r
331 new Thread(this).start();
\r
335 } catch (Exception e)
\r
339 while (loadingDasSources)
\r
344 } catch (Exception e)
\r
353 Vector selected = new Vector();
\r
354 for (int r = 0; r < selectedSources.size(); r++)
\r
356 for (int i = 0; i < dasSources.length; i++)
\r
358 if (dasSources[i].getTitle().equals(selectedSources.elementAt(r)))
\r
360 selected.addElement(dasSources[i]);
\r
370 * retrieve das sources from registry and add local source list
\r
374 public SOURCE[] getDASSource()
\r
376 if (dasSources == null)
\r
378 dasSources = jalview.ws.DasSequenceFeatureFetcher.getDASSources();
\r
379 appendLocalSources();
\r
385 public void refresh_actionPerformed(ActionEvent e)
\r
387 saveProperties(jalview.bin.Cache.applicationProperties);
\r
389 Thread worker = new Thread(this);
\r
393 private boolean isLaterThan(String ref, String newer)
\r
395 Date refdate = null, newdate = null;
\r
398 refdate = DasTimeFormat.fromDASString(ref);
\r
400 } catch (ParseException x)
\r
406 newdate = DasTimeFormat.fromDASString(newer);
\r
407 } catch (ParseException e)
\r
409 // TODO: handle exception
\r
411 if (refdate != null)
\r
413 if (newdate != null)
\r
415 return refdate.before(newdate);
\r
419 if (newdate != null)
\r
423 // assume first instance of source is newest in list. - TODO: check if
\r
424 // natural ordering of source versions is newest first or oldest first
\r
428 private VERSION getVersionFor(SOURCE ds)
\r
430 VERSION latest = null;
\r
431 for (VERSION v : ds.getVERSION())
\r
434 || isLaterThan(latest.getCreated(), v.getCreated()))
\r
436 // TODO: das 1.6 - should just get the first version - ignore other
\r
437 // versions since not specified how to construct URL from version's URI
\r
445 private void setCapabilities(SOURCE[] sources)
\r
447 Vector<String> authority = new Vector<String>();
\r
448 Vector<String> type = new Vector<String>();
\r
449 Vector<String> label = new Vector<String>();
\r
450 Vector<String> taxIds = new Vector<String>();
\r
451 authority.add("Any");
\r
455 for (int i = 0; i < sources.length; i++)
\r
457 SOURCE ds = sources[i];
\r
458 VERSION latest = getVersionFor(ds);
\r
460 for (COORDINATES cs : latest.getCOORDINATES())
\r
462 if (!type.contains(cs.getSource()))
\r
464 type.add(cs.getSource()); // source==category
\r
467 if (!authority.contains(cs.getAuthority()))
\r
469 authority.add(cs.getAuthority());
\r
473 for (PROP slabel : latest.getPROP())
\r
475 if (slabel.getName().equalsIgnoreCase("LABEL")
\r
476 && !label.contains(slabel.getValue()))
\r
478 label.add(slabel.getValue());
\r
484 filter1.setListData(authority);
\r
485 filter2.setListData(type);
\r
486 filter3.setListData(label);
\r
489 javax.swing.SwingUtilities.invokeLater(new Runnable()
\r
493 filter1.setSelectedIndex(0);
\r
494 filter2.setSelectedIndex(0);
\r
495 filter3.setSelectedIndex(0);
\r
500 public void amendLocal(boolean newSource)
\r
502 String url = "http://localhost:8080/", nickname = "";
\r
503 boolean seqsrc = false;
\r
506 int selectedRow = table.getSelectionModel().getMinSelectionIndex();
\r
507 nickname = table.getValueAt(selectedRow, 0).toString();
\r
508 url = ((SOURCE) localSources.get(nickname)).getUri();
\r
509 seqsrc = ((SOURCE) localSources.get(nickname)).getVERSION().get(0)
\r
510 .getCAPABILITY().contains(Capabilities.SEQUENCE);
\r
513 JTextField nametf = new JTextField(nickname, 40);
\r
514 JTextField urltf = new JTextField(url, 40);
\r
515 JCheckBox seqs = new JCheckBox("Sequence Source");
\r
516 seqs.setSelected(seqsrc);
\r
517 JPanel panel = new JPanel(new BorderLayout());
\r
518 JPanel pane12 = new JPanel(new BorderLayout());
\r
519 pane12.add(new JLabel("Nickname: "), BorderLayout.CENTER);
\r
520 pane12.add(nametf, BorderLayout.EAST);
\r
521 panel.add(pane12, BorderLayout.NORTH);
\r
522 pane12 = new JPanel(new BorderLayout());
\r
523 pane12.add(new JLabel("URL: "), BorderLayout.NORTH);
\r
524 pane12.add(seqs, BorderLayout.SOUTH);
\r
525 pane12.add(urltf, BorderLayout.EAST);
\r
526 panel.add(pane12, BorderLayout.SOUTH);
\r
528 int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
\r
529 panel, "Enter Nickname & URL of Local DAS Source",
\r
530 JOptionPane.OK_CANCEL_OPTION);
\r
532 if (reply != JOptionPane.OK_OPTION)
\r
537 if (!urltf.getText().endsWith("/"))
\r
539 urltf.setText(urltf.getText() + "/");
\r
542 SOURCE local = createLocalSource(urltf.getText(), nametf.getText(), seqs.isSelected(), true);
\r
544 if (localSources == null)
\r
546 localSources = new Hashtable();
\r
549 localSources.put(local.getTitle(), local);
\r
551 if (!newSource && !nickname.equals(nametf.getText()))
\r
553 localSources.remove(nickname);
\r
556 int size = dasSources.length;
\r
557 int adjust = newSource ? 1 : 0;
\r
559 Object[][] data = new Object[size + adjust][2];
\r
560 for (int i = 0; i < size; i++)
\r
562 if (!newSource && dasSources[i].getTitle().equals(nickname))
\r
564 dasSources[i] = local;
\r
565 data[i][0] = local.getTitle();
\r
566 data[i][1] = new Boolean(true);
\r
570 data[i][0] = dasSources[i].getTitle();
\r
571 data[i][1] = new Boolean(selectedSources.contains(dasSources[i]
\r
578 data[size][0] = local.getTitle();
\r
579 data[size][1] = new Boolean(true);
\r
580 selectedSources.add(local.getTitle());
\r
583 SOURCE[] tmp = new SOURCE[size + adjust];
\r
585 System.arraycopy(dasSources, 0, tmp, 0, size);
\r
594 refreshTableData(data);
\r
596 SwingUtilities.invokeLater(new Runnable()
\r
600 scrollPane.getVerticalScrollBar().setValue(
\r
601 scrollPane.getVerticalScrollBar().getMaximum());
\r
605 displayFullDetails(local.getTitle());
\r
608 private SOURCE createLocalSource(String url, String name,
\r
609 boolean sequence, boolean features)
\r
611 SOURCE local = new SOURCE();
\r
614 local.setTitle(name);
\r
615 local.setVERSION(new ArrayList<VERSION>());
\r
616 VERSION v = new VERSION();
\r
617 List<CAPABILITY> cp = new ArrayList<CAPABILITY>();
\r
620 /* Could try and synthesize a coordinate system for the source if needbe
\r
621 * COORDINATES coord = new COORDINATES();
\r
622 coord.setAuthority("NCBI");
\r
623 coord.setSource("Chromosome");
\r
624 coord.setTaxid("9606");
\r
625 coord.setVersion("35");
\r
626 version.getCOORDINATES().add(coord);*/
\r
627 CAPABILITY cap=new CAPABILITY();
\r
628 cap.setType("das1:"+Capabilities.SEQUENCE.getName());
\r
633 CAPABILITY cap = new CAPABILITY();
\r
634 cap.setType("das1:"+Capabilities.FEATURES.getName());
\r
638 v.getCAPABILITY().addAll(cp);
\r
639 local.getVERSION().add(v);
\r
644 public void editRemoveLocalSource(MouseEvent evt)
\r
646 int selectedRow = table.getSelectionModel().getMinSelectionIndex();
\r
647 if (selectedRow == -1)
\r
652 String nickname = table.getValueAt(selectedRow, 0).toString();
\r
654 if (!localSources.containsKey(nickname))
\r
656 JOptionPane.showInternalMessageDialog(Desktop.desktop,
\r
657 "You can only edit or remove local DAS Sources!",
\r
658 "Public DAS source - not editable",
\r
659 JOptionPane.WARNING_MESSAGE);
\r
664 { "Edit", "Remove", "Cancel" };
\r
665 int choice = JOptionPane.showInternalOptionDialog(Desktop.desktop,
\r
666 "Do you want to edit or remove " + nickname + "?",
\r
667 "Edit / Remove Local DAS Source",
\r
668 JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,
\r
669 null, options, options[2]);
\r
677 localSources.remove(nickname);
\r
678 selectedSources.remove(nickname);
\r
679 Object[][] data = new Object[dasSources.length - 1][2];
\r
680 SOURCE[] tmp = new SOURCE[dasSources.length - 1];
\r
682 for (int i = 0; i < dasSources.length; i++)
\r
684 if (dasSources[i].getTitle().equals(nickname))
\r
690 tmp[index] = dasSources[i];
\r
691 data[index][0] = dasSources[i].getTitle();
\r
692 data[index][1] = new Boolean(
\r
693 selectedSources.contains(dasSources[i].getTitle()));
\r
698 refreshTableData(data);
\r
699 SwingUtilities.invokeLater(new Runnable()
\r
703 scrollPane.getVerticalScrollBar().setValue(
\r
704 scrollPane.getVerticalScrollBar().getMaximum());
\r
712 void appendLocalSources()
\r
714 if (localSources == null)
\r
718 // note - we add all das sources to list so they can be filtered for the
\r
719 // standard fetchDbRefs function
\r
720 int size = dasSources != null ? dasSources.length : 0;
\r
721 int lsize = localSources.size();
\r
723 Object[][] data = new Object[size + lsize][2];
\r
724 for (int i = 0; i < size; i++)
\r
726 data[i][0] = dasSources[i].getTitle();
\r
727 data[i][1] = new Boolean(selectedSources.contains(dasSources[i]
\r
731 SOURCE[] tmp = new SOURCE[size + lsize];
\r
732 if (dasSources != null)
\r
734 System.arraycopy(dasSources, 0, tmp, 0, size);
\r
737 Enumeration en = localSources.keys();
\r
739 while (en.hasMoreElements())
\r
741 String key = en.nextElement().toString();
\r
742 data[index][0] = key;
\r
743 data[index][1] = new Boolean(false);
\r
744 tmp[index] = createLocalSource(localSources.get(key).getUri(), key, false, true);
\r
751 refreshTableData(data);
\r
754 public void valueChanged(ListSelectionEvent evt)
\r
756 // Called when the MainTable selection changes
\r
757 if (evt.getValueIsAdjusting())
\r
762 displayFullDetails(null);
\r
764 // Filter the displayed data sources
\r
765 int dSize = dasSources.length;
\r
767 ArrayList names = new ArrayList();
\r
768 ArrayList selected = new ArrayList();
\r
771 // The features filter is not visible, but we must still
\r
772 // filter the das source list here.
\r
773 // July 2006 - only 6 sources fo not serve features
\r
774 Object[] dummyFeatureList = new Object[]
\r
777 for (int i = 0; i < dSize; i++)
\r
779 ds = dasSources[i];
\r
780 VERSION v=getVersionFor(ds);
\r
781 List<COORDINATES> coords = v.getCOORDINATES();
\r
782 if ((coords==null || coords.size()==0)
\r
783 && filter1.getSelectedIndex() == 0
\r
784 && filter2.getSelectedIndex() == 0
\r
785 && filter3.getSelectedIndex() == 0)
\r
787 // THIS IS A FIX FOR LOCAL SOURCES WHICH DO NOT
\r
788 // HAVE COORDINATE SYSTEMS, INFO WHICH AT PRESENT
\r
789 // IS ADDED FROM THE REGISTRY
\r
790 names.add(ds.getTitle());
\r
791 selected.add(new Boolean(selectedSources.contains(ds.getTitle())));
\r
795 if (!selectedInList(dummyFeatureList, getCapabilityKeys(v))
\r
796 || !selectedInList(filter3.getSelectedValues(),
\r
802 for (int j = 0; j <coords.size(); j++)
\r
804 if (selectedInList(filter1.getSelectedValues(), new String[]
\r
805 { coords.get(j).getAuthority() })
\r
806 && selectedInList(filter2.getSelectedValues(), new String[]
\r
807 { coords.get(j).getSource()}))
\r
809 names.add(ds.getTitle());
\r
810 selected.add(new Boolean(selectedSources.contains(ds.getTitle())));
\r
816 dSize = names.size();
\r
817 Object[][] data = new Object[dSize][2];
\r
818 for (int d = 0; d < dSize; d++)
\r
820 data[d][0] = names.get(d);
\r
821 data[d][1] = selected.get(d);
\r
824 refreshTableData(data);
\r
827 private String[] getLabelsFor(VERSION v)
\r
829 ArrayList<String> labels=new ArrayList<String>();
\r
830 for (PROP p: v.getPROP())
\r
832 if (p.getName().equalsIgnoreCase("LABEL"))
\r
834 labels.add(p.getValue());
\r
837 return labels.toArray(new String[0]);
\r
840 private String[] getCapabilityKeys(VERSION v)
\r
843 ArrayList<String> labels=new ArrayList<String>();
\r
844 for (CAPABILITY p: v.getCAPABILITY())
\r
846 // TODO: work out what to do with namespace prefix
\r
847 // does SEQUENCE == das1:SEQUENCE and das2:SEQUENCE ?
\r
848 // for moment, just show all capabilities...
\r
849 if (p.getType().startsWith("das1:"))
\r
851 labels.add(p.getType());
\r
854 return labels.toArray(new String[0]);
\r
857 boolean selectedInList(Object[] selection, String[] items)
\r
859 for (int i = 0; i < selection.length; i++)
\r
861 if (selection[i].equals("Any"))
\r
866 for (int j = 0; j < items.length; j++)
\r
868 if (selection[i].equals(items[j]))
\r
878 void setSelectedFromProperties()
\r
880 String active = jalview.bin.Cache.getDefault("DAS_ACTIVE_SOURCE",
\r
882 StringTokenizer st = new StringTokenizer(active, "\t");
\r
883 selectedSources = new Vector();
\r
884 while (st.hasMoreTokens())
\r
886 selectedSources.addElement(st.nextToken());
\r
889 Vector _localSources = jalview.bin.Cache.getLocalDasSources();
\r
890 if (_localSources != null)
\r
892 if (localSources == null)
\r
894 localSources = new Hashtable<String, SOURCE>();
\r
896 Enumeration sources = _localSources.elements();
\r
897 while (sources.hasMoreElements())
\r
899 SOURCE source = (SOURCE) sources.nextElement();
\r
900 localSources.put(source.getTitle(), source);
\r
905 public void reset_actionPerformed(ActionEvent e)
\r
907 registryURL.setText(DEFAULT_REGISTRY);
\r
911 * set the DAS source settings in the given jalview properties.
\r
913 * @param properties
\r
915 public void saveProperties(Properties properties)
\r
917 if (registryURL.getText() == null || registryURL.getText().length() < 1)
\r
919 properties.remove(jalview.bin.Cache.DAS_REGISTRY_URL);
\r
923 properties.setProperty(jalview.bin.Cache.DAS_REGISTRY_URL,
\r
924 registryURL.getText());
\r
927 StringBuffer sb = new StringBuffer();
\r
928 for (int r = 0; r < table.getModel().getRowCount(); r++)
\r
930 if (((Boolean) table.getValueAt(r, 1)).booleanValue())
\r
932 sb.append(table.getValueAt(r, 0) + "\t");
\r
936 properties.setProperty(jalview.bin.Cache.DAS_ACTIVE_SOURCE,
\r
939 if (localSources != null)
\r
941 sb = new StringBuffer();
\r
942 Enumeration en = localSources.keys();
\r
943 while (en.hasMoreElements())
\r
945 String token = en.nextElement().toString();
\r
948 + (selectedInList(getCapabilityKeys(getVersionFor(localSources.get(token))),
\r
949 new String[] { "das1:"+Capabilities.SEQUENCE.getName()}) ? "sequence:" : "")
\r
950 + getVersionFor(localSources.get(token)).getUri() + "\t");
\r
953 properties.setProperty(jalview.bin.Cache.DAS_LOCAL_SOURCE,
\r
959 class DASTableModel extends AbstractTableModel
\r
962 public DASTableModel(Object[][] data)
\r
967 private String[] columnNames = new String[]
\r
968 { "Nickname", "Use Source" };
\r
970 private Object[][] data;
\r
972 public int getColumnCount()
\r
974 return columnNames.length;
\r
977 public int getRowCount()
\r
979 return data.length;
\r
982 public String getColumnName(int col)
\r
984 return columnNames[col];
\r
987 public Object getValueAt(int row, int col)
\r
989 return data[row][col];
\r
993 * JTable uses this method to determine the default renderer/ editor for
\r
994 * each cell. If we didn't implement this method, then the last column would
\r
995 * contain text ("true"/"false"), rather than a check box.
\r
997 public Class getColumnClass(int c)
\r
999 return getValueAt(0, c).getClass();
\r
1003 * Don't need to implement this method unless your table's editable.
\r
1005 public boolean isCellEditable(int row, int col)
\r
1007 // Note that the data/cell address is constant,
\r
1008 // no matter where the cell appears onscreen.
\r
1014 * Don't need to implement this method unless your table's data can change.
\r
1016 public void setValueAt(Object value, int row, int col)
\r
1018 data[row][col] = value;
\r
1019 fireTableCellUpdated(row, col);
\r
1021 String name = getValueAt(row, 0).toString();
\r
1022 boolean selected = ((Boolean) value).booleanValue();
\r
1024 if (selectedSources.contains(name) && !selected)
\r
1026 selectedSources.remove(name);
\r
1029 if (!selectedSources.contains(name) && selected)
\r
1031 selectedSources.add(name);
\r
1036 public void initDasSources()
\r
1039 Thread thr = new Thread(new Runnable()
\r
1043 // this actually initialises the das source list
\r
1044 paintComponent(null); // yuk
\r
1048 while (loadingDasSources || dasSources == null)
\r
1053 } catch (Exception e)
\r
1060 public Vector resolveSourceNicknames(Vector sources)
\r
1063 Vector resolved = new Vector();
\r
1064 if (sources != null)
\r
1066 for (int i = 0; i < dasSources.length; i++)
\r
1068 if (sources.contains(dasSources[i].getTitle()))
\r
1070 if (!resolved.contains(dasSources[i]))
\r
1072 resolved.addElement(dasSources[i]);
\r
1081 * disable or enable the buttons on the source browser
\r
1085 public void setGuiEnabled(boolean b)
\r
1087 refresh.setEnabled(b);
\r
1088 addLocal.setEnabled(b);
\r