From e20b3a89cbd6dd4c9a1c222695822c78ece6aa1c Mon Sep 17 00:00:00 2001 From: lucian Date: Wed, 14 Sep 2022 16:04:36 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-80276=20=E5=A1=AB=E6=8A=A5-=E5=A1=AB?= =?UTF-8?q?=E6=8A=A5=E5=B1=9E=E6=80=A7=E8=AE=BE=E7=BD=AE-=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=A1=A8=E6=90=9C=E7=B4=A2=E6=97=B6=E6=A6=82=E7=8E=87?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E5=A4=9A=E4=B8=AA=E9=87=8D=E5=A4=8D=E7=9A=84?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/icombobox/TableSearchTreeComboBox.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 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 7198eeef0..916cd3cf6 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 @@ -1,5 +1,6 @@ package com.fr.design.gui.icombobox; +import com.fr.concurrent.NamedThreadFactory; import com.fr.data.core.DataCoreUtils; import com.fr.data.core.db.TableProcedure; import com.fr.data.impl.Connection; @@ -9,6 +10,7 @@ import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.mainframe.DesignerContext; import com.fr.log.FineLoggerFactory; +import com.fr.module.ModuleContext; import com.fr.stable.ArrayUtils; import com.fr.stable.Filter; import com.fr.stable.StringUtils; @@ -24,6 +26,7 @@ import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; import java.util.Enumeration; +import java.util.concurrent.ExecutorService; /** * 实现模糊搜索表名的FRTreeComboBox @@ -37,6 +40,10 @@ import java.util.Enumeration; public class TableSearchTreeComboBox extends FRTreeComboBox { // 持有父容器,需要实时获取其他组件值 private final ChoosePane parent; + /** + * 保证模糊搜索的原子性操作 + */ + private final ExecutorService singleExecutor = ModuleContext.getExecutor().newSingleThreadScheduledExecutor(new NamedThreadFactory("TableSearchTreeComboBox")); public TableSearchTreeComboBox(ChoosePane parent, JTree tree, TreeCellRenderer renderer) { super(tree, renderer); @@ -69,14 +76,15 @@ public class TableSearchTreeComboBox extends FRTreeComboBox { */ private void searchExecute() { UIComboBoxEditor searchEditor = (UIComboBoxEditor) this.getEditor(); - new SwingWorker() { + String searchText = (String) searchEditor.getItem(); + singleExecutor.execute(new SwingWorker() { @Override protected Void doInBackground() { processTableDataNames( parent.getDSName(), parent.getConnection(), parent.getSchema(), - createFilter((String) searchEditor.getItem())); + createFilter(searchText)); return null; } @@ -86,7 +94,7 @@ public class TableSearchTreeComboBox extends FRTreeComboBox { // 输入框获取焦点 searchEditor.getEditorComponent().requestFocus(); } - }.execute(); + }); } private TableNameFilter createFilter(String text) {