+ // TODO Jalview 2.5 lots of this code should be in the gui package!\r
+ sfetcher = jalview.gui.SequenceFetcher.getSequenceFetcherSingleton(af);\r
+ if (sources == null)\r
+ {\r
+ // af.featureSettings_actionPerformed(null);\r
+ String[] defdb = null, otherdb = sfetcher\r
+ .getDbInstances(jalview.ws.dbsources.DasSequenceSource.class);\r
+ Vector selsources = new Vector(), dasselsrc = (af.featureSettings != null) ? af.featureSettings\r
+ .getSelectedSources() : new jalview.gui.DasSourceBrowser()\r
+ .getSelectedSources();\r
+ Enumeration en = dasselsrc.elements();\r
+ while (en.hasMoreElements())\r
+ {\r
+ DasSource src = (DasSource) en.nextElement();\r
+ selsources.addElement(src.getNickname());\r
+ }\r
+ int osel = 0;\r
+ for (int o = 0; otherdb != null && o < otherdb.length; o++)\r
+ {\r
+ if (!selsources.contains(otherdb[o]))\r
+ {\r
+ otherdb[o] = null;\r
+ }\r
+ else\r
+ {\r
+ osel++;\r
+ }\r
+ }\r
+ // select appropriate databases based on alignFrame context.\r
+ if (af.getViewport().getAlignment().isNucleotide())\r
+ {\r
+ defdb = DBRefSource.DNACODINGDBS;\r
+ }\r
+ else\r
+ {\r
+ defdb = DBRefSource.PROTEINDBS;\r
+ }\r
+ // append the selected sequence sources to the default dbs\r
+ dbSources = new String[defdb.length + osel];\r
+ System.arraycopy(defdb, 0, dbSources, 0, defdb.length);\r
+ for (int o = 0, op = defdb.length; otherdb != null\r
+ && o < otherdb.length; o++)\r
+ {\r
+ if (otherdb[o] != null)\r
+ {\r
+ dbSources[op++] = otherdb[o];\r
+ }\r
+ }\r
+ }\r
+ else\r
+ {\r
+ // we assume the caller knows what they're doing and ensured that all the\r
+ // db source names are valid\r
+ dbSources = sources;\r
+ }\r
+ }\r
+\r
+ /**\r
+ * retrieve all the das sequence sources and add them to the list of db\r
+ * sources to retrieve from\r
+ */\r
+ public void appendAllDasSources()\r
+ {\r
+ if (dbSources == null)\r
+ {\r
+ dbSources = new String[]\r
+ {};\r
+ }\r
+ // append additional sources\r
+ String[] otherdb = sfetcher\r
+ .getDbInstances(jalview.ws.dbsources.DasSequenceSource.class);\r
+ if (otherdb != null && otherdb.length > 0)\r
+ {\r
+ String[] newsrc = new String[dbSources.length + otherdb.length];\r
+ System.arraycopy(dbSources, 0, newsrc, 0, dbSources.length);\r
+ System.arraycopy(otherdb, 0, newsrc, dbSources.length, otherdb.length);\r
+ dbSources = newsrc;\r
+ }\r