From 9752d1b92be43f54768cb5c2a731679b36d72ebb Mon Sep 17 00:00:00 2001 From: lucian Date: Wed, 19 Jan 2022 10:07:03 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-65975=20=E5=A1=AB=E6=8A=A5-=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6-=E6=8E=A7=E4=BB=B6=E4=BA=8B=E4=BB=B6=E4=B8=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8F=90=E4=BA=A4=E4=BA=8B=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E8=A1=A8=E5=90=8D=E5=90=8E=E4=BC=9A=E9=80=80?= =?UTF-8?q?=E5=87=BA=E5=BD=93=E5=89=8D=E9=80=89=E6=8B=A9=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../icombobox/TableSearchTreeComboBox.java | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/TableSearchTreeComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/TableSearchTreeComboBox.java index 6b4198693..7198eeef0 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/TableSearchTreeComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/TableSearchTreeComboBox.java @@ -16,12 +16,13 @@ import com.fr.stable.StringUtils; import javax.swing.JOptionPane; import javax.swing.JTree; import javax.swing.SwingWorker; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; -import java.awt.event.MouseEvent; import java.util.Enumeration; /** @@ -40,7 +41,7 @@ public class TableSearchTreeComboBox extends FRTreeComboBox { public TableSearchTreeComboBox(ChoosePane parent, JTree tree, TreeCellRenderer renderer) { super(tree, renderer); this.parent = parent; - setUI(new TableSearchTreeComboBoxUI()); + initPopupListener(); } protected UIComboBoxEditor createEditor() { @@ -158,12 +159,6 @@ public class TableSearchTreeComboBox extends FRTreeComboBox { } } - private static final TableNameFilter EMPTY_FILTER = new TableNameFilter() { - public boolean accept(TableProcedure procedure) { - return true; - } - }; - /** * 表名模糊搜索实现 */ @@ -184,15 +179,31 @@ public class TableSearchTreeComboBox extends FRTreeComboBox { } } - /** - * 重写FRTreeComboBoxUI,实现点击下拉时触发模糊搜索 - */ - private class TableSearchTreeComboBoxUI extends FRTreeComboBoxUI { - - @Override - public void mouseClicked(MouseEvent e) { - searchExecute(); + private static final TableNameFilter EMPTY_FILTER = new TableNameFilter() { + public boolean accept(TableProcedure procedure) { + return true; } + }; + + private void initPopupListener() { + // 点击下拉时触发模糊搜索 + this.addPopupMenuListener(new PopupMenuListener() { + + @Override + public void popupMenuWillBecomeVisible(PopupMenuEvent e) { + searchExecute(); + } + + @Override + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { + + } + + @Override + public void popupMenuCanceled(PopupMenuEvent e) { + + } + }); } /**