+ };
+
+ // fetch db refs if OK pressed
+ final Runnable discoverCanonicalDBrefs = new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ populateSeqsWithoutSourceDBRef();
+
+ final int y = seqsWithoutSourceDBRef.size();
+ if (y > 0)
+ {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run()
+ {
+ updateProgressIndicator(MessageManager.formatMessage(
+ "status.fetching_dbrefs_for_sequences_without_valid_refs",
+ y), progressId);
+
+ }
+ });
+
+ final SequenceI[] seqWithoutSrcDBRef = seqsWithoutSourceDBRef
+ .toArray(new SequenceI[y]);
+ DBRefFetcher dbRefFetcher = new DBRefFetcher(seqWithoutSrcDBRef,
+ progressBar, new DbSourceProxy[]
+ { new jalview.ws.dbsources.Uniprot() }, null, false);
+
+ // ideally this would also gracefully run with callbacks
+ dbRefFetcher.fetchDBRefs(true);
+ }
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run()
+ {
+ if (y>0) {
+ updateProgressIndicator("Fetch complete.", progressId); // todo i18n
+ }
+ // filter has been selected, so we set flag to remove ourselves
+ notQueriedTDBYet = false;
+
+ Executors.defaultThreadFactory().newThread(strucDiscovery).start();
+
+ }
+ });
+
+ }
+ };
+ final Runnable revertview = new Runnable() {
+ public void run() {
+ if (lastSelected!=null) {
+ cmb_filterOption.setSelectedItem(lastSelected);
+ }
+ };
+ };
+ // need cancel and no to result in the discoverPDB action - mocked is
+ // 'cancel'
+ JvOptionPane.newOptionDialog(this)
+ .setResponseHandler(JvOptionPane.OK_OPTION,
+ discoverCanonicalDBrefs)
+ .setResponseHandler(JvOptionPane.CANCEL_OPTION, revertview)
+ .setResponseHandler(JvOptionPane.NO_OPTION, revertview)
+ .showDialog(
+ MessageManager.formatMessage(
+ "label.fetch_references_for_3dbeacons",
+ seqsWithoutSourceDBRef.size()),
+ MessageManager
+ .getString("label.3dbeacons"),
+ JvOptionPane.YES_NO_OPTION, JvOptionPane.PLAIN_MESSAGE,
+ null, new Object[]
+ { MessageManager.getString("action.ok"),
+ MessageManager.getString("action.cancel") },
+ MessageManager.getString("action.ok"));
+ }
+
+ /**
+ * Builds a drop-down choice list of existing structure viewers to which new
+ * structures may be added. If this list is empty then it, and the 'Add'
+ * button, are hidden.
+ */
+ private void discoverStructureViews()
+ {
+ if (Desktop.instance != null)
+ {
+ targetView.removeAllItems();
+ if (lastTargetedView != null && !lastTargetedView.isVisible())
+ {
+ lastTargetedView = null;
+ }
+ int linkedViewsAt = 0;
+ for (StructureViewerBase view : Desktop.instance
+ .getStructureViewers(null, null))
+ {
+ StructureViewer viewHandler = (lastTargetedView != null
+ && lastTargetedView.sview == view) ? lastTargetedView
+ : StructureViewer.reconfigure(view);
+
+ if (view.isLinkedWith(ap))
+ {
+ targetView.insertItemAt(viewHandler, linkedViewsAt++);
+ }
+ else
+ {
+ targetView.addItem(viewHandler);
+ }
+ }
+
+ /*
+ * show option to Add to viewer if at least 1 viewer found
+ */
+ targetView.setVisible(false);
+ if (targetView.getItemCount() > 0)
+ {
+ targetView.setVisible(true);
+ if (lastTargetedView != null)
+ {
+ targetView.setSelectedItem(lastTargetedView);
+ }
+ else
+ {
+ targetView.setSelectedIndex(0);
+ }
+ }
+ btn_add.setVisible(targetView.isVisible());
+ }