X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FStructureChooser.java;h=07eec2b684381910b5415939ed3995d6370b6ca8;hb=69b246bd6330f05271ca15a440c8442b03b7db6c;hp=5ea68fb5e2f825d838b7dc0233fc008eb08ca0ba;hpb=fa9da54fb97cb2eacb1af7859024d90166bddb8f;p=jalview.git diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 5ea68fb..07eec2b 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -35,7 +35,6 @@ 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; @@ -44,6 +43,7 @@ import javax.swing.table.AbstractTableModel; 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; @@ -81,6 +81,11 @@ public class StructureChooser extends GStructureChooser { 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; @@ -197,6 +202,7 @@ public class StructureChooser extends GStructureChooser Executors.defaultThreadFactory().newThread(new Runnable() { + @Override public void run() { populateSeqsWithoutSourceDBRef(); @@ -315,6 +321,7 @@ public class StructureChooser extends GStructureChooser @Override public void run() { + btn_queryTDB.setEnabled(false); populateSeqsWithoutSourceDBRef(); final int y = seqsWithoutSourceDBRef.size(); @@ -327,6 +334,7 @@ public class StructureChooser extends GStructureChooser { new jalview.ws.dbsources.Uniprot() }, null, false); dbRefFetcher.addListener(afterDbRefFetch); // ideally this would also gracefully run with callbacks + dbRefFetcher.fetchDBRefs(true); } else @@ -339,6 +347,7 @@ public class StructureChooser extends GStructureChooser }; final Runnable revertview = new Runnable() { + @Override public void run() { if (lastSelected != null) @@ -347,7 +356,10 @@ public class StructureChooser extends GStructureChooser } }; }; - 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(); @@ -355,7 +367,9 @@ public class StructureChooser extends GStructureChooser } // 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) @@ -369,7 +383,7 @@ public class StructureChooser extends GStructureChooser null, new Object[] { MessageManager.getString("action.ok"), MessageManager.getString("action.cancel") }, - MessageManager.getString("action.ok")); + MessageManager.getString("action.ok"), false); } /** @@ -866,6 +880,7 @@ public class StructureChooser extends GStructureChooser popup.add(viewUrl); SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { popup.show(getResultTable(), x, y); @@ -1376,6 +1391,7 @@ public class StructureChooser extends GStructureChooser { if (selectedSequences != null) { + lbl_loading.setVisible(true); Thread refreshThread = new Thread(new Runnable() { @Override @@ -1387,6 +1403,7 @@ public class StructureChooser extends GStructureChooser filterResultSet( ((FilterOption) cmb_filterOption.getSelectedItem()) .getValue()); + lbl_loading.setVisible(false); } }); refreshThread.start();