From 54aee8313f6e19410ac41d96c0e87fe76d0c3103 Mon Sep 17 00:00:00 2001 From: lucian Date: Thu, 28 Apr 2022 17:39:00 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-70504=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=9C=89=E8=BE=83?= =?UTF-8?q?=E5=A4=A7=E6=A6=82=E7=8E=87=E5=A4=9A=E4=B8=AA=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E7=9A=84=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 | 15 ++++++++++++--- 1 file changed, 12 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..63a0d7186 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; @@ -24,6 +25,8 @@ import javax.swing.tree.TreeCellRenderer; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; import java.util.Enumeration; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; /** * 实现模糊搜索表名的FRTreeComboBox @@ -37,6 +40,10 @@ import java.util.Enumeration; public class TableSearchTreeComboBox extends FRTreeComboBox { // 持有父容器,需要实时获取其他组件值 private final ChoosePane parent; + /** + * 保证模糊搜索的原子性操作 + */ + private final ExecutorService singleExecutor = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("TableSearchTreeComboBox")); public TableSearchTreeComboBox(ChoosePane parent, JTree tree, TreeCellRenderer renderer) { super(tree, renderer); @@ -69,14 +76,16 @@ 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 +95,7 @@ public class TableSearchTreeComboBox extends FRTreeComboBox { // 输入框获取焦点 searchEditor.getEditorComponent().requestFocus(); } - }.execute(); + }); } private TableNameFilter createFilter(String text) { From 3d82f964be81f5ca8fbd68d6858980896ec1a385 Mon Sep 17 00:00:00 2001 From: lucian Date: Thu, 28 Apr 2022 17:47:27 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-70504=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=9C=89=E8=BE=83?= =?UTF-8?q?=E5=A4=A7=E6=A6=82=E7=8E=87=E5=A4=9A=E4=B8=AA=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E7=9A=84=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 --- .../com/fr/design/gui/icombobox/TableSearchTreeComboBox.java | 3 +-- 1 file changed, 1 insertion(+), 2 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 63a0d7186..f4b21c3fe 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 @@ -77,8 +77,7 @@ public class TableSearchTreeComboBox extends FRTreeComboBox { private void searchExecute() { UIComboBoxEditor searchEditor = (UIComboBoxEditor) this.getEditor(); String searchText = (String) searchEditor.getItem(); - singleExecutor.execute( - new SwingWorker() { + singleExecutor.execute(new SwingWorker() { @Override protected Void doInBackground() { processTableDataNames( From c91aee4e861fa32cbf4a0c4460341b960e555db2 Mon Sep 17 00:00:00 2001 From: lucian Date: Fri, 29 Apr 2022 10:43:09 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-70504=20=E7=BA=BF=E7=A8=8B=E6=B1=A0?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/icombobox/TableSearchTreeComboBox.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 f4b21c3fe..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 @@ -10,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; @@ -26,7 +27,6 @@ import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; import java.util.Enumeration; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; /** * 实现模糊搜索表名的FRTreeComboBox @@ -43,7 +43,7 @@ public class TableSearchTreeComboBox extends FRTreeComboBox { /** * 保证模糊搜索的原子性操作 */ - private final ExecutorService singleExecutor = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("TableSearchTreeComboBox")); + private final ExecutorService singleExecutor = ModuleContext.getExecutor().newSingleThreadScheduledExecutor(new NamedThreadFactory("TableSearchTreeComboBox")); public TableSearchTreeComboBox(ChoosePane parent, JTree tree, TreeCellRenderer renderer) { super(tree, renderer);