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.security.interfaces.DSAKey;
\r
21 import java.text.ParseException;
\r
23 import java.util.List;
\r
26 import java.awt.event.*;
\r
27 import javax.swing.*;
\r
28 import javax.swing.event.*;
\r
29 import javax.swing.table.*;
\r
31 import org.biodas.jdas.dassources.Capabilities;
\r
32 import org.biodas.jdas.dassources.utils.DasTimeFormat;
\r
33 import org.biodas.jdas.schema.sources.CAPABILITY;
\r
34 import org.biodas.jdas.schema.sources.COORDINATES;
\r
35 import org.biodas.jdas.schema.sources.MAINTAINER;
\r
36 import org.biodas.jdas.schema.sources.PROP;
\r
37 import org.biodas.jdas.schema.sources.SOURCE;
\r
38 import org.biodas.jdas.schema.sources.SOURCES;
\r
39 import org.biodas.jdas.schema.sources.VERSION;
\r
41 import jalview.jbgui.*;
\r
42 import jalview.util.*;
\r
44 public class DasSourceBrowser extends GDasSourceBrowser implements
\r
45 Runnable, ListSelectionListener
\r
47 static org.biodas.jdas.schema.sources.SOURCE[] dasSources = null;
\r
49 Hashtable localSources = null;
\r
51 Vector selectedSources;
\r
53 public static String DEFAULT_REGISTRY = "http://www.dasregistry.org/das1/sources/";
\r
56 * true if thread is running and we are talking to DAS registry service
\r
58 public boolean loadingDasSources = false;
\r
60 protected static String getDasRegistryURL()
\r
62 String registry = jalview.bin.Cache.getDefault("DAS_REGISTRY_URL",
\r
65 if (registry.indexOf("/registry/das1/sources/") > -1)
\r
67 jalview.bin.Cache.setProperty(jalview.bin.Cache.DAS_REGISTRY_URL,
\r
69 registry = DEFAULT_REGISTRY;
\r
74 public DasSourceBrowser(FeatureSettings featureSettings)
\r
76 fs = featureSettings;
\r
77 String registry = getDasRegistryURL();
\r
79 registryURL.setText(registry);
\r
81 setSelectedFromProperties();
\r
83 displayFullDetails(null);
\r
84 table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
\r
86 filter1.addListSelectionListener(this);
\r
87 filter2.addListSelectionListener(this);
\r
88 filter3.addListSelectionListener(this);
\r
90 // Ask to be notified of selection changes.
\r
91 ListSelectionModel rowSM = table.getSelectionModel();
\r
92 rowSM.addListSelectionListener(new ListSelectionListener()
\r
94 public void valueChanged(ListSelectionEvent e)
\r
96 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
\r
97 if (!lsm.isSelectionEmpty())
\r
99 int selectedRow = lsm.getMinSelectionIndex();
\r
100 displayFullDetails(table.getValueAt(selectedRow, 0).toString());
\r
105 table.addMouseListener(new MouseAdapter()
\r
107 public void mouseClicked(MouseEvent evt)
\r
109 if (evt.getClickCount() == 2
\r
110 || SwingUtilities.isRightMouseButton(evt))
\r
112 editRemoveLocalSource(evt);
\r
117 if (dasSources != null)
\r
123 FeatureSettings fs = null;
\r
125 public DasSourceBrowser()
\r
130 public void paintComponent(java.awt.Graphics g)
\r
132 if (dasSources == null && !loadingDasSources)
\r
134 Thread worker = new Thread(this);
\r
141 int dSize = dasSources.length;
\r
142 Object[][] data = new Object[dSize][2];
\r
143 for (int i = 0; i < dSize; i++)
\r
145 data[i][0] = dasSources[i].getTitle(); // what's equivalent of nickname
\r
146 data[i][1] = new Boolean(selectedSources.contains(dasSources[i]
\r
150 refreshTableData(data);
\r
151 setCapabilities(dasSources);
\r
153 javax.swing.SwingUtilities.invokeLater(new Runnable()
\r
157 TableSorter sorter = (TableSorter) table.getModel();
\r
158 sorter.setSortingStatus(1, TableSorter.DESCENDING);
\r
159 sorter.setSortingStatus(1, TableSorter.NOT_SORTED);
\r
163 progressBar.setIndeterminate(false);
\r
164 progressBar.setVisible(false);
\r
165 addLocal.setVisible(true);
\r
166 refresh.setVisible(true);
\r
169 public void refreshTableData(Object[][] data)
\r
171 TableSorter sorter = new TableSorter(new DASTableModel(data));
\r
172 sorter.setTableHeader(table.getTableHeader());
\r
173 table.setModel(sorter);
\r
176 void displayFullDetails(String nickName)
\r
179 StringBuffer text = new StringBuffer(
\r
180 "<HTML><font size=\"2\" face=\"Verdana, Arial, Helvetica, sans-serif\">");
\r
182 if (nickName == null)
\r
184 fullDetails.setText(text + "Select a DAS service from the table"
\r
185 + " to read a full description here.</font></html>");
\r
189 int dSize = dasSources.length;
\r
190 for (int i = 0; i < dSize; i++)
\r
192 if (!dasSources[i].getTitle().equals(nickName))
\r
197 SOURCE ds = dasSources[i];
\r
198 VERSION latest = getVersionFor(ds);
\r
199 text.append("<font color=\"#0000FF\">Id:</font> "
\r
200 + dasSources[i].getUri() + "<br>");
\r
201 text.append("<font color=\"#0000FF\">Nickname:</font> "
\r
202 + dasSources[i].getTitle() + "<br>");
\r
203 text.append("<font color=\"#0000FF\">URL:</font> "
\r
204 + latest.getUri() + "<br>");
\r
206 text.append("<font color=\"#0000FF\">Admin Email:</font> <a href=\"mailto:"
\r
207 + ds.getMAINTAINER().getEmail()
\r
209 + ds.getMAINTAINER().getEmail() + "</a>" + "<br>");
\r
211 text.append("<font color=\"#0000FF\">Registered at:</font> "
\r
212 + latest.getCreated() + "<br>");
\r
214 // TODO: Identify last successful test date
\r
215 // text.append("<font color=\"#0000FF\">Last successful test:</font> "
\r
216 // + latest.dasSources[i].getLeaseDate() + "<br>");
\r
218 text.append("<font color=\"#0000FF\">Labels:</font> ");
\r
219 for (int s = 0; s < latest.getPROP().length; s++)
\r
221 text.append(dasSources[i].getLabels()[s]);
\r
222 if (s < dasSources[i].getLabels().length - 1)
\r
228 text.append("<br>");
\r
230 text.append("<font color=\"#0000FF\">Capabilities:</font> ");
\r
231 CAPABILITY[] scap = latest.getCAPABILITY().toArray(new CAPABILITY[0]);
\r
232 for (int j = 0; j < scap.length; j++)
\r
234 text.append(scap[j]);
\r
235 if (j < scap.length - 1)
\r
240 text.append("<br>");
\r
242 text.append("<font color=\"#0000FF\">Coordinates:</font> ");
\r
243 DasCoordinateSystem[] dcs = ds.getCoordinateSystem();
\r
244 for (int j = 0; j < dcs.length; j++)
\r
246 text.append("(" + dcs[j].getUniqueId() + ") "
\r
247 + dcs[j].getCategory() + ", " + dcs[j].getName());
\r
248 if (dcs[j].getNCBITaxId() != 0)
\r
250 text.append(", " + dcs[j].getNCBITaxId());
\r
252 if (dcs[j].getOrganismName().length() > 0)
\r
254 text.append(", " + dcs[j].getOrganismName());
\r
257 text.append("<br>");
\r
260 text.append("<font color=\"#0000FF\">Description:</font> "
\r
261 + dasSources[i].getDescription() + "<br>");
\r
263 if (dasSources[i].getHelperurl() != null
\r
264 && dasSources[i].getHelperurl().length() > 0)
\r
266 text.append("<font color=\"#0000FF\"><a href=\""
\r
267 + dasSources[i].getHelperurl()
\r
268 + "\">Go to site</a></font<br>");
\r
271 text.append("</font></html>");
\r
276 fullDetails.setText(text.toString());
\r
277 javax.swing.SwingUtilities.invokeLater(new Runnable()
\r
281 fullDetailsScrollpane.getVerticalScrollBar().setValue(0);
\r
288 loadingDasSources = true;
\r
290 addLocal.setVisible(false);
\r
291 refresh.setVisible(false);
\r
292 progressBar.setVisible(true);
\r
293 progressBar.setIndeterminate(true);
\r
294 setParentGuiEnabled(false);
\r
295 // Refresh the source list.
\r
301 setParentGuiEnabled(true);
\r
302 loadingDasSources = false;
\r
306 private void setParentGuiEnabled(boolean b)
\r
310 fs.fetchDAS.setEnabled(b);
\r
311 fs.saveDAS.setEnabled(b);
\r
315 public Vector getSelectedSources()
\r
317 // wait around if we're still loading.
\r
318 while (dasSources == null)
\r
320 if (!loadingDasSources)
\r
322 new Thread(this).start();
\r
326 } catch (Exception e)
\r
330 while (loadingDasSources)
\r
335 } catch (Exception e)
\r
344 Vector selected = new Vector();
\r
345 for (int r = 0; r < selectedSources.size(); r++)
\r
347 for (int i = 0; i < dasSources.length; i++)
\r
349 if (dasSources[i].getTitle()
\r
350 .equals(selectedSources.elementAt(r)))
\r
352 selected.addElement(dasSources[i]);
\r
362 * retrieve das sources from registry and add local source list
\r
366 public SOURCE[] getDASSource()
\r
368 if (dasSources == null)
\r
370 dasSources = jalview.ws.DasSequenceFeatureFetcher.getDASSources();
\r
371 appendLocalSources();
\r
377 public void refresh_actionPerformed(ActionEvent e)
\r
379 saveProperties(jalview.bin.Cache.applicationProperties);
\r
381 Thread worker = new Thread(this);
\r
385 private boolean isLaterThan(String ref, String newer)
\r
387 Date refdate=null,newdate=null;
\r
389 refdate=DasTimeFormat.fromDASString(ref);
\r
392 catch (ParseException x)
\r
397 newdate = DasTimeFormat.fromDASString(newer);
\r
399 catch (ParseException e) {
\r
400 // TODO: handle exception
\r
406 return refdate.before(newdate);
\r
414 // assume first instance of source is newest in list. - TODO: check if natural ordering of source versions is newest first or oldest first
\r
417 private VERSION getVersionFor(SOURCE ds)
\r
419 VERSION latest=null;
\r
420 for (VERSION v:ds.getVERSION()) {
\r
421 if (latest==null || isLaterThan(latest.getCreated(),v.getCreated()))
\r
423 // TODO: das 1.6 - should just get the first version - ignore other versions since not specified how to construct URL from version's URI + source URI
\r
429 private void setCapabilities(SOURCE[] sources)
\r
431 Vector<String> authority = new Vector<String>();
\r
432 Vector<String> type = new Vector<String>();
\r
433 Vector<String> label = new Vector<String>();
\r
434 Vector<String> taxIds=new Vector<String>();
\r
435 authority.add("Any");
\r
440 for (int i = 0; i < sources.length; i++)
\r
442 SOURCE ds = sources[i];
\r
443 VERSION latest=getVersionFor(ds);
\r
445 for (COORDINATES cs: latest.getCOORDINATES())
\r
447 if (!type.contains(cs.getSource()))
\r
449 type.add(cs.getSource()); // source==category
\r
452 if (!authority.contains(cs.getAuthority()))
\r
454 authority.add(cs.getAuthority());
\r
458 for (PROP slabel:latest.getPROP())
\r
460 if (slabel.getName().equalsIgnoreCase("LABEL") && !label.contains(slabel.getValue()))
\r
462 label.add(slabel.getValue());
\r
468 filter1.setListData(authority);
\r
469 filter2.setListData(type);
\r
470 filter3.setListData(label);
\r
473 javax.swing.SwingUtilities.invokeLater(new Runnable()
\r
477 filter1.setSelectedIndex(0);
\r
478 filter2.setSelectedIndex(0);
\r
479 filter3.setSelectedIndex(0);
\r
484 public void amendLocal(boolean newSource)
\r
486 String url = "http://localhost:8080/", nickname = "";
\r
487 boolean seqsrc = false;
\r
490 int selectedRow = table.getSelectionModel().getMinSelectionIndex();
\r
491 nickname = table.getValueAt(selectedRow, 0).toString();
\r
492 url = ((SOURCE) localSources.get(nickname)).getUri();
\r
493 seqsrc = ((SOURCE) localSources.get(nickname)).getVERSION().get(0).getCAPABILITY().contains(Capabilities.SEQUENCE);
\r
496 JTextField nametf = new JTextField(nickname, 40);
\r
497 JTextField urltf = new JTextField(url, 40);
\r
498 JCheckBox seqs = new JCheckBox("Sequence Source");
\r
499 seqs.setSelected(seqsrc);
\r
500 JPanel panel = new JPanel(new BorderLayout());
\r
501 JPanel pane12 = new JPanel(new BorderLayout());
\r
502 pane12.add(new JLabel("Nickname: "), BorderLayout.CENTER);
\r
503 pane12.add(nametf, BorderLayout.EAST);
\r
504 panel.add(pane12, BorderLayout.NORTH);
\r
505 pane12 = new JPanel(new BorderLayout());
\r
506 pane12.add(new JLabel("URL: "), BorderLayout.NORTH);
\r
507 pane12.add(seqs, BorderLayout.SOUTH);
\r
508 pane12.add(urltf, BorderLayout.EAST);
\r
509 panel.add(pane12, BorderLayout.SOUTH);
\r
511 int reply = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
\r
512 panel, "Enter Nickname & URL of Local DAS Source",
\r
513 JOptionPane.OK_CANCEL_OPTION);
\r
515 if (reply != JOptionPane.OK_OPTION)
\r
520 if (!urltf.getText().endsWith("/"))
\r
522 urltf.setText(urltf.getText() + "/");
\r
525 // build using pattern from test: sourcesclientImplTest
\r
527 SOURCE source = new SOURCE();
\r
528 String uri = "http://das.sanger.ac.uk/das/dummysource";
\r
529 source.setUri("http://das.sanger.ac.uk/das/dummysource");
\r
530 source.setDescription("Dummy Test Source, should not be in a working registry sources doc");
\r
531 VERSION version = new VERSION();
\r
532 version.setUri(uri);
\r
533 COORDINATES coord = new COORDINATES();
\r
534 coord.setAuthority("NCBI");
\r
535 coord.setSource("Chromosome");
\r
536 coord.setTaxid("9606");
\r
537 coord.setVersion("35");
\r
538 version.getCOORDINATES().add(coord);
\r
539 CAPABILITY cap = new CAPABILITY();
\r
540 cap.setQueryUri(uri + "features");
\r
541 cap.setType("das1:" + Capabilities.FEATURES.getName());
\r
542 version.getCAPABILITY().add(cap);
\r
543 source.getVERSION().add(version);
\r
544 MAINTAINER m = new MAINTAINER();
\r
545 m.setEmail("jw12@sanger.ac.uk");
\r
546 source.setMAINTAINER(m);
\r
547 source.setTitle("dummy title");
\r
550 SOURCE local = new Das1Source();
\r
552 local.setUrl(urltf.getText());
\r
553 local.setNickname(nametf.getText());
\r
554 if (seqs.isSelected())
\r
556 local.setCapabilities(new String[]
\r
557 { "features", "sequence" });
\r
559 if (localSources == null)
\r
561 localSources = new Hashtable();
\r
564 localSources.put(local.getTitle(), local);
\r
566 if (!newSource && !nickname.equals(nametf.getText()))
\r
568 localSources.remove(nickname);
\r
571 int size = dasSources.length;
\r
572 int adjust = newSource ? 1 : 0;
\r
574 Object[][] data = new Object[size + adjust][2];
\r
575 for (int i = 0; i < size; i++)
\r
577 if (!newSource && dasSources[i].getTitle().equals(nickname))
\r
579 ((DasSource) dasSources[i]).setNickname(local.getTitle());
\r
580 ((DasSource) dasSources[i]).setUrl(local.getUrl());
\r
581 data[i][0] = local.getTitle();
\r
582 data[i][1] = new Boolean(true);
\r
586 data[i][0] = dasSources[i].getTitle();
\r
587 data[i][1] = new Boolean(selectedSources.contains(dasSources[i]
\r
594 data[size][0] = local.getTitle();
\r
595 data[size][1] = new Boolean(true);
\r
596 selectedSources.add(local.getTitle());
\r
599 DasSource[] tmp = new DasSource[size + adjust];
\r
601 System.arraycopy(dasSources, 0, tmp, 0, size);
\r
610 refreshTableData(data);
\r
612 SwingUtilities.invokeLater(new Runnable()
\r
616 scrollPane.getVerticalScrollBar().setValue(
\r
617 scrollPane.getVerticalScrollBar().getMaximum());
\r
621 displayFullDetails(local.getTitle());
\r
624 public void editRemoveLocalSource(MouseEvent evt)
\r
626 int selectedRow = table.getSelectionModel().getMinSelectionIndex();
\r
627 if (selectedRow == -1)
\r
632 String nickname = table.getValueAt(selectedRow, 0).toString();
\r
634 if (!localSources.containsKey(nickname))
\r
636 JOptionPane.showInternalMessageDialog(Desktop.desktop,
\r
637 "You can only edit or remove local DAS Sources!",
\r
638 "Public DAS source - not editable",
\r
639 JOptionPane.WARNING_MESSAGE);
\r
644 { "Edit", "Remove", "Cancel" };
\r
645 int choice = JOptionPane.showInternalOptionDialog(Desktop.desktop,
\r
646 "Do you want to edit or remove " + nickname + "?",
\r
647 "Edit / Remove Local DAS Source",
\r
648 JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,
\r
649 null, options, options[2]);
\r
657 localSources.remove(nickname);
\r
658 selectedSources.remove(nickname);
\r
659 Object[][] data = new Object[dasSources.length - 1][2];
\r
660 DasSource[] tmp = new DasSource[dasSources.length - 1];
\r
662 for (int i = 0; i < dasSources.length; i++)
\r
664 if (dasSources[i].getTitle().equals(nickname))
\r
670 tmp[index] = dasSources[i];
\r
671 data[index][0] = dasSources[i].getTitle();
\r
672 data[index][1] = new Boolean(
\r
673 selectedSources.contains(dasSources[i].getTitle()));
\r
678 refreshTableData(data);
\r
679 SwingUtilities.invokeLater(new Runnable()
\r
683 scrollPane.getVerticalScrollBar().setValue(
\r
684 scrollPane.getVerticalScrollBar().getMaximum());
\r
692 void appendLocalSources()
\r
694 if (localSources == null)
\r
698 // note - we add all das sources to list so they can be filtered for the
\r
699 // standard fetchDbRefs function
\r
700 int size = dasSources != null ? dasSources.length : 0;
\r
701 int lsize = localSources.size();
\r
703 Object[][] data = new Object[size + lsize][2];
\r
704 for (int i = 0; i < size; i++)
\r
706 data[i][0] = dasSources[i].getTitle();
\r
707 data[i][1] = new Boolean(selectedSources.contains(dasSources[i]
\r
711 DasSource[] tmp = new DasSource[size + lsize];
\r
712 if (dasSources != null)
\r
714 System.arraycopy(dasSources, 0, tmp, 0, size);
\r
717 Enumeration en = localSources.keys();
\r
719 while (en.hasMoreElements())
\r
721 String key = en.nextElement().toString();
\r
722 data[index][0] = key;
\r
723 data[index][1] = new Boolean(false);
\r
724 tmp[index] = new Das1Source();
\r
725 tmp[index].setNickname(key);
\r
726 tmp[index].setUrl(((DasSource) localSources.get(key)).getUrl());
\r
733 refreshTableData(data);
\r
736 public void valueChanged(ListSelectionEvent evt)
\r
738 // Called when the MainTable selection changes
\r
739 if (evt.getValueIsAdjusting())
\r
744 displayFullDetails(null);
\r
746 // Filter the displayed data sources
\r
747 int dSize = dasSources.length;
\r
749 ArrayList names = new ArrayList();
\r
750 ArrayList selected = new ArrayList();
\r
753 // The features filter is not visible, but we must still
\r
754 // filter the das source list here.
\r
755 // July 2006 - only 6 sources fo not serve features
\r
756 Object[] dummyFeatureList = new Object[]
\r
759 for (int i = 0; i < dSize; i++)
\r
761 ds = dasSources[i];
\r
762 DasCoordinateSystem[] dcs = ds.getCoordinateSystem();
\r
764 if (dcs.length == 0 && ds.getCapabilities().length == 0
\r
765 && filter1.getSelectedIndex() == 0
\r
766 && filter2.getSelectedIndex() == 0
\r
767 && filter3.getSelectedIndex() == 0)
\r
769 // THIS IS A FIX FOR LOCAL SOURCES WHICH DO NOT
\r
770 // HAVE COORDINATE SYSTEMS, INFO WHICH AT PRESENT
\r
771 // IS ADDED FROM THE REGISTRY
\r
772 names.add(ds.getTitle());
\r
773 selected.add(new Boolean(selectedSources.contains(ds.getTitle())));
\r
777 if (!selectedInList(dummyFeatureList, ds.getCapabilities())
\r
778 || !selectedInList(filter3.getSelectedValues(),
\r
784 for (int j = 0; j < dcs.length; j++)
\r
786 if (selectedInList(filter1.getSelectedValues(), new String[]
\r
787 { dcs[j].getName() })
\r
788 && selectedInList(filter2.getSelectedValues(), new String[]
\r
789 { dcs[j].getCategory() }))
\r
791 names.add(ds.getTitle());
\r
792 selected.add(new Boolean(selectedSources.contains(ds
\r
799 dSize = names.size();
\r
800 Object[][] data = new Object[dSize][2];
\r
801 for (int d = 0; d < dSize; d++)
\r
803 data[d][0] = names.get(d);
\r
804 data[d][1] = selected.get(d);
\r
807 refreshTableData(data);
\r
810 boolean selectedInList(Object[] selection, String[] items)
\r
812 for (int i = 0; i < selection.length; i++)
\r
814 if (selection[i].equals("Any"))
\r
819 for (int j = 0; j < items.length; j++)
\r
821 if (selection[i].equals(items[j]))
\r
831 void setSelectedFromProperties()
\r
833 String active = jalview.bin.Cache.getDefault("DAS_ACTIVE_SOURCE",
\r
835 StringTokenizer st = new StringTokenizer(active, "\t");
\r
836 selectedSources = new Vector();
\r
837 while (st.hasMoreTokens())
\r
839 selectedSources.addElement(st.nextToken());
\r
842 Vector _localSources = jalview.bin.Cache.getLocalDasSources();
\r
843 if (_localSources != null)
\r
845 if (localSources == null)
\r
847 localSources = new Hashtable();
\r
849 Enumeration sources = _localSources.elements();
\r
850 while (sources.hasMoreElements())
\r
852 Das1Source source = (Das1Source) sources.nextElement();
\r
853 localSources.put(source.getTitle(), source);
\r
858 public void reset_actionPerformed(ActionEvent e)
\r
860 registryURL.setText(DEFAULT_REGISTRY);
\r
864 * set the DAS source settings in the given jalview properties.
\r
866 * @param properties
\r
868 public void saveProperties(Properties properties)
\r
870 if (registryURL.getText() == null || registryURL.getText().length() < 1)
\r
872 properties.remove(jalview.bin.Cache.DAS_REGISTRY_URL);
\r
876 properties.setProperty(jalview.bin.Cache.DAS_REGISTRY_URL,
\r
877 registryURL.getText());
\r
880 StringBuffer sb = new StringBuffer();
\r
881 for (int r = 0; r < table.getModel().getRowCount(); r++)
\r
883 if (((Boolean) table.getValueAt(r, 1)).booleanValue())
\r
885 sb.append(table.getValueAt(r, 0) + "\t");
\r
889 properties.setProperty(jalview.bin.Cache.DAS_ACTIVE_SOURCE,
\r
892 if (localSources != null)
\r
894 sb = new StringBuffer();
\r
895 Enumeration en = localSources.keys();
\r
896 while (en.hasMoreElements())
\r
898 String token = en.nextElement().toString();
\r
901 + (((DasSource) localSources.get(token))
\r
902 .hasCapability("sequence") ? "sequence:" : "")
\r
903 + ((DasSource) localSources.get(token)).getUrl() + "\t");
\r
906 properties.setProperty(jalview.bin.Cache.DAS_LOCAL_SOURCE,
\r
912 class DASTableModel extends AbstractTableModel
\r
915 public DASTableModel(Object[][] data)
\r
920 private String[] columnNames = new String[]
\r
921 { "Nickname", "Use Source" };
\r
923 private Object[][] data;
\r
925 public int getColumnCount()
\r
927 return columnNames.length;
\r
930 public int getRowCount()
\r
932 return data.length;
\r
935 public String getColumnName(int col)
\r
937 return columnNames[col];
\r
940 public Object getValueAt(int row, int col)
\r
942 return data[row][col];
\r
946 * JTable uses this method to determine the default renderer/ editor for
\r
947 * each cell. If we didn't implement this method, then the last column would
\r
948 * contain text ("true"/"false"), rather than a check box.
\r
950 public Class getColumnClass(int c)
\r
952 return getValueAt(0, c).getClass();
\r
956 * Don't need to implement this method unless your table's editable.
\r
958 public boolean isCellEditable(int row, int col)
\r
960 // Note that the data/cell address is constant,
\r
961 // no matter where the cell appears onscreen.
\r
967 * Don't need to implement this method unless your table's data can change.
\r
969 public void setValueAt(Object value, int row, int col)
\r
971 data[row][col] = value;
\r
972 fireTableCellUpdated(row, col);
\r
974 String name = getValueAt(row, 0).toString();
\r
975 boolean selected = ((Boolean) value).booleanValue();
\r
977 if (selectedSources.contains(name) && !selected)
\r
979 selectedSources.remove(name);
\r
982 if (!selectedSources.contains(name) && selected)
\r
984 selectedSources.add(name);
\r
989 public void initDasSources()
\r
992 Thread thr = new Thread(new Runnable()
\r
996 // this actually initialises the das source list
\r
997 paintComponent(null); // yuk
\r
1001 while (loadingDasSources || dasSources == null)
\r
1006 } catch (Exception e)
\r
1013 public Vector resolveSourceNicknames(Vector sources)
\r
1016 Vector resolved = new Vector();
\r
1017 if (sources != null)
\r
1019 for (int i = 0; i < dasSources.length; i++)
\r
1021 if (sources.contains(dasSources[i].getTitle()))
\r
1023 if (!resolved.contains(dasSources[i]))
\r
1025 resolved.addElement(dasSources[i]);
\r
1034 * disable or enable the buttons on the source browser
\r
1038 public void setGuiEnabled(boolean b)
\r
1040 refresh.setEnabled(b);
\r
1041 addLocal.setEnabled(b);
\r