+ protected void build_fetchdbmenu(JMenu webService) {
+ // Temporary hack - DBRef Fetcher always top level ws entry.
+ // TODO We probably want to store a sequence database checklist in preferences and have checkboxes.. rather than individual sources selected here
+ JMenu rfetch = new JMenu("Fetch DB References");
+ rfetch
+ .setToolTipText("Retrieve and parse sequence database records for the alignment or the currently selected sequences");
+ webService.add(rfetch);
+
+ JMenuItem fetchr = new JMenuItem("Standard Databases");
+ fetchr.setToolTipText("Fetch from EMBL/EMBLCDS or Uniprot/PDB and any selected DAS sources");
+ fetchr.addActionListener(new ActionListener()
+ {
+
+ public void actionPerformed(ActionEvent e)
+ {
+ new Thread(new Runnable()
+ {
+
+ public void run()
+ {
+ new jalview.ws.DBRefFetcher(alignPanel.av
+ .getSequenceSelection(), alignPanel.alignFrame)
+ .fetchDBRefs(false);
+ }
+ }).start();
+
+ }
+
+ });
+ rfetch.add(fetchr);
+ JMenu dfetch = new JMenu();
+ rfetch.add(dfetch);
+ jalview.ws.SequenceFetcher sf = SequenceFetcher.getSequenceFetcherSingleton(this);
+ String[] otherdb = sf.getOrderedSupportedSources();
+ // sf.getDbInstances(jalview.ws.dbsources.DasSequenceSource.class);
+ // jalview.util.QuickSort.sort(otherdb, otherdb);
+ int comp=0,mcomp=15;
+ String mname=null;
+ if (otherdb!=null && otherdb.length>0)
+ {
+ for (int i=0; i<otherdb.length; i++)
+ {
+ String dbname =sf.getSourceProxy(otherdb[i]).getDbName();
+ if (mname == null)
+ {
+ mname = "from '"+dbname+"'";
+ }
+ fetchr = new JMenuItem(otherdb[i]);
+ final String[] dassource = new String[] { otherdb[i] };
+ fetchr.addActionListener(new ActionListener()
+ {
+
+ public void actionPerformed(ActionEvent e)
+ {
+ new Thread(new Runnable()
+ {
+
+ public void run()
+ {
+ new jalview.ws.DBRefFetcher(alignPanel.av
+ .getSequenceSelection(), alignPanel.alignFrame, dassource)
+ .fetchDBRefs(false);
+ }
+ }).start();
+ }
+
+ });
+ fetchr.setToolTipText("Retrieve from "+dbname);
+ dfetch.add(fetchr);
+ if (comp++==mcomp || i==(otherdb.length-1))
+ {
+ dfetch.setText(mname+" to '"+dbname+"'");
+ rfetch.add(dfetch);
+ dfetch = new JMenu();
+ mname = null;
+ comp=0;
+ }
+ }
+ }
+ }