From 9ff620c0cadb4faaa4d2fb335067ed34cdfef525 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 27 Oct 2017 16:18:48 +0100 Subject: [PATCH] JAL-2804 checkbox to enable/disable auto search (with tooltip) --- resources/lang/Messages.properties | 1 + src/jalview/fts/core/GFTSPanel.java | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 5d9bdff..7459d31 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1319,3 +1319,4 @@ label.select_hidden_colour = Select hidden colour label.overview = Overview label.reset_to_defaults = Reset to defaults label.oview_calc = Recalculating overview... +option.enable_disable_autosearch = Enable or disable automatic update of search results diff --git a/src/jalview/fts/core/GFTSPanel.java b/src/jalview/fts/core/GFTSPanel.java index c0d005f..67cbb53 100644 --- a/src/jalview/fts/core/GFTSPanel.java +++ b/src/jalview/fts/core/GFTSPanel.java @@ -56,6 +56,7 @@ import java.util.List; import javax.swing.ImageIcon; import javax.swing.JButton; +import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JInternalFrame; @@ -98,6 +99,8 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI protected JButton btn_cancel = new JButton(); + protected JCheckBox btn_autosearch = new JCheckBox(); + protected JvCacheableInputBox txt_search; protected SequenceFetcher seqFetcher; @@ -331,6 +334,9 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI } }); + btn_autosearch.setText(""); + btn_autosearch.setToolTipText( + MessageManager.getString("option.enable_disable_autosearch")); btn_back.setFont(new java.awt.Font("Verdana", 0, 12)); btn_back.setText(MessageManager.getString("action.back")); btn_back.addActionListener(new java.awt.event.ActionListener() @@ -522,12 +528,10 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI @Override public void actionPerformed(ActionEvent e) { - String typed = getTypedText(); - if (!typed.equalsIgnoreCase(lastSearchTerm)) + if (btn_autosearch.isSelected() + || txt_search.wasEnterPressed()) { - searchAction(true); - paginatorCart.clear(); - lastSearchTerm = typed; + performSearchAction(); } } }, false); @@ -613,6 +617,7 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI pnl_results.add(tabbedPane); pnl_inputs.add(cmb_searchTarget); pnl_inputs.add(txt_search); + pnl_inputs.add(btn_autosearch); pnl_inputs.add(lbl_loading); pnl_inputs.add(lbl_warning); pnl_inputs.add(lbl_blank); @@ -698,6 +703,18 @@ public abstract class GFTSPanel extends JPanel implements GFTSPanelI } + void performSearchAction() + { + String typed = getTypedText(); + if (typed != null && typed.length() > 0 + && !typed.equalsIgnoreCase(lastSearchTerm)) + { + searchAction(true); + paginatorCart.clear(); + lastSearchTerm = typed; + } + } + public boolean wantedFieldsUpdated() { if (previousWantedFields == null) -- 1.7.10.2