From: Ben Soares Date: Fri, 15 Jul 2022 17:38:33 +0000 (+0100) Subject: JAL-4034 Use the new non-modal JDialog for 3DBeacons uniprot lookup confirmation... X-Git-Tag: Release_2_11_2_6~35^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=bb5d9c75833e2d0b9ef8f66b8fcd7d5649a3271f;p=jalview.git JAL-4034 Use the new non-modal JDialog for 3DBeacons uniprot lookup confirmation. Link dialog to GStructureChooser's frame so it can moveToFront. Minor improvement to Search 3DB button appearance --- diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 246d162..6eb8d10 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -321,6 +321,7 @@ public class StructureChooser extends GStructureChooser @Override public void run() { + btn_queryTDB.setEnabled(false); populateSeqsWithoutSourceDBRef(); final int y = seqsWithoutSourceDBRef.size(); @@ -333,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 @@ -357,33 +359,31 @@ public class StructureChooser extends GStructureChooser int threshold = Cache.getDefault("UNIPROT_AUTOFETCH_THRESHOLD", THRESHOLD_WARN_UNIPROT_FETCH_NEEDED); Console.debug("Using Uniprot fetch threshold of " + threshold); - boolean runThread = false; if (ignoreGui || seqsWithoutSourceDBRef.size() < threshold) { - runThread = true; - } - // need cancel and no to result in the discoverPDB action - mocked is - // 'cancel' TODO: mock should be OK - if (!runThread) - { - int answer = JvOptionPane.showConfirmDialog(this, - MessageManager.formatMessage( - "label.fetch_references_for_3dbeacons", - seqsWithoutSourceDBRef.size()), - MessageManager.getString("label.3dbeacons"), - JvOptionPane.YES_NO_OPTION, JvOptionPane.PLAIN_MESSAGE); - runThread = (answer == JvOptionPane.OK_OPTION); - } - if (runThread) - { Executors.defaultThreadFactory().newThread(discoverCanonicalDBrefs) .start(); return; } - else - { - revertview.run(); - } + // need cancel and no to result in the discoverPDB action - mocked is + // 'cancel' TODO: mock should be OK + + StructureChooser thisSC = this; + JvOptionPane.newOptionDialog(thisSC.getFrame()) + .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"), false); } /** diff --git a/src/jalview/jbgui/GStructureChooser.java b/src/jalview/jbgui/GStructureChooser.java index d8101e3..08cfa03 100644 --- a/src/jalview/jbgui/GStructureChooser.java +++ b/src/jalview/jbgui/GStructureChooser.java @@ -28,6 +28,7 @@ import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import java.awt.GridLayout; +import java.awt.Insets; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -56,6 +57,7 @@ import javax.swing.JTabbedPane; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.ListCellRenderer; +import javax.swing.SwingConstants; import javax.swing.Timer; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -595,10 +597,15 @@ public abstract class GStructureChooser extends JPanel chk_invertFilter.addItemListener(this); btn_queryTDB = new JButton( MessageManager.getString("label.search_3dbeacons")); + btn_queryTDB.setIconTextGap(12); + btn_queryTDB.setIcon(tdbImage); + btn_queryTDB.setVerticalTextPosition(SwingConstants.CENTER); + btn_queryTDB.setHorizontalTextPosition(SwingConstants.TRAILING); btn_queryTDB.setFont(VERDANA_12); btn_queryTDB.setToolTipText( MessageManager.getString("label.find_models_from_3dbeacons")); - btn_queryTDB.setPreferredSize(new Dimension(300, 24)); + btn_queryTDB.setMargin(new Insets(2, 16, 2, 20)); + // btn_queryTDB.setPreferredSize(new Dimension(200, 32)); btn_queryTDB.setVisible(false); targetView.setVisible(false); @@ -612,10 +619,11 @@ public abstract class GStructureChooser extends JPanel JPanel pnl_main = new JPanel(new BorderLayout()); JPanel pnl_controls = new JPanel(); - pnl_queryTDB = new JPanel(new FlowLayout()); + pnl_queryTDB = new JPanel(); + pnl_queryTDB.setLayout(new FlowLayout(FlowLayout.CENTER, 4, 4)); pnl_queryTDB.setBackground(getBackground()); - pnl_queryTDB.add(new JLabel(tdbImage)); pnl_queryTDB.add(btn_queryTDB); + pnl_queryTDB.setVisible(false); pnl_main.add(pnl_queryTDB, BorderLayout.NORTH); pnl_controls.add(cmb_filterOption); @@ -945,4 +953,9 @@ public abstract class GStructureChooser extends JPanel protected abstract void tabRefresh(); protected abstract void validateSelections(); + + public JInternalFrame getFrame() + { + return mainFrame; + } } \ No newline at end of file