import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
+import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
-import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JTable;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
+import jalview.bin.Console;
import jalview.bin.Jalview;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
{
private static final String AUTOSUPERIMPOSE = "AUTOSUPERIMPOSE";
+ /**
+ * warn user if need to fetch more than this many uniprot records at once
+ */
+ private static final int THRESHOLD_WARN_UNIPROT_FETCH_NEEDED = 20;
+
private SequenceI selectedSequence;
private SequenceI[] selectedSequences;
Executors.defaultThreadFactory().newThread(new Runnable()
{
+ @Override
public void run()
{
populateSeqsWithoutSourceDBRef();
progressBar.setProgressBar(
MessageManager.getString("status.searching_3d_beacons"),
progressId);
+ btn_queryTDB.setEnabled(false);
// TODO: warn if no accessions discovered
populateSeqsWithoutSourceDBRef();
// redo initial discovery - this time with 3d beacons
btn_queryTDB.setToolTipText(MessageManager.getString(
"status.no_structures_discovered_from_3d_beacons"));
btn_queryTDB.setEnabled(false);
+ pnl_queryTDB.setVisible(false);
}
else
{
cmb_filterOption.setSelectedIndex(0); // select 'best'
btn_queryTDB.setVisible(false);
+ pnl_queryTDB.setVisible(false);
progressBar.setProgressBar(null, progressId);
}
mainFrame.setEnabled(true);
};
// fetch db refs if OK pressed
- final Runnable discoverCanonicalDBrefs = new Runnable()
- {
- @Override
- public void run()
+ final Callable discoverCanonicalDBrefs = () -> {
+ btn_queryTDB.setEnabled(false);
+ populateSeqsWithoutSourceDBRef();
+
+ final int y = seqsWithoutSourceDBRef.size();
+ if (y > 0)
{
- populateSeqsWithoutSourceDBRef();
+ final SequenceI[] seqWithoutSrcDBRef = seqsWithoutSourceDBRef
+ .toArray(new SequenceI[y]);
+ DBRefFetcher dbRefFetcher = new DBRefFetcher(seqWithoutSrcDBRef,
+ progressBar, new DbSourceProxy[]
+ { new jalview.ws.dbsources.Uniprot() }, null, false);
+ dbRefFetcher.addListener(afterDbRefFetch);
+ // ideally this would also gracefully run with callbacks
- final int y = seqsWithoutSourceDBRef.size();
- if (y > 0)
- {
- final SequenceI[] seqWithoutSrcDBRef = seqsWithoutSourceDBRef
- .toArray(new SequenceI[y]);
- DBRefFetcher dbRefFetcher = new DBRefFetcher(seqWithoutSrcDBRef,
- progressBar, new DbSourceProxy[]
- { new jalview.ws.dbsources.Uniprot() }, null, false);
- dbRefFetcher.addListener(afterDbRefFetch);
- // ideally this would also gracefully run with callbacks
- dbRefFetcher.fetchDBRefs(true);
- }
- else
- {
- // call finished action directly
- afterDbRefFetch.finished();
- }
+ dbRefFetcher.fetchDBRefs(true);
}
-
+ else
+ {
+ // call finished action directly
+ afterDbRefFetch.finished();
+ }
+ return null;
};
- final Runnable revertview = new Runnable()
- {
- public void run()
+ final Callable revertview = () -> {
+ if (lastSelected != null)
{
- if (lastSelected != null)
- {
- cmb_filterOption.setSelectedItem(lastSelected);
- }
- };
+ cmb_filterOption.setSelectedItem(lastSelected);
+ }
+ return null;
};
- if (ignoreGui)
+ int threshold = Cache.getDefault("UNIPROT_AUTOFETCH_THRESHOLD",
+ THRESHOLD_WARN_UNIPROT_FETCH_NEEDED);
+ Console.debug("Using Uniprot fetch threshold of " + threshold);
+ if (ignoreGui || seqsWithoutSourceDBRef.size() < threshold)
{
- Executors.defaultThreadFactory().newThread(discoverCanonicalDBrefs)
- .start();
+ Executors.newSingleThreadExecutor().submit(discoverCanonicalDBrefs);
return;
}
// need cancel and no to result in the discoverPDB action - mocked is
// 'cancel' TODO: mock should be OK
- JvOptionPane.newOptionDialog(this)
+
+ StructureChooser thisSC = this;
+ JvOptionPane.newOptionDialog(thisSC.getFrame())
.setResponseHandler(JvOptionPane.OK_OPTION,
discoverCanonicalDBrefs)
.setResponseHandler(JvOptionPane.CANCEL_OPTION, revertview)
null, new Object[]
{ MessageManager.getString("action.ok"),
MessageManager.getString("action.cancel") },
- MessageManager.getString("action.ok"));
+ MessageManager.getString("action.ok"), false);
}
/**
if (canQueryTDB && notQueriedTDBYet)
{
btn_queryTDB.setVisible(true);
+ pnl_queryTDB.setVisible(true);
}
if (cachedPDBExist)
popup.add(viewUrl);
SwingUtilities.invokeLater(new Runnable()
{
+ @Override
public void run()
{
popup.show(getResultTable(), x, y);
{
if (selectedSequences != null)
{
+ lbl_loading.setVisible(true);
Thread refreshThread = new Thread(new Runnable()
{
@Override
filterResultSet(
((FilterOption) cmb_filterOption.getSelectedItem())
.getValue());
+ lbl_loading.setVisible(false);
}
});
refreshThread.start();