From d88687d9888e43d1afc2b51c20d9135bb13fba9a Mon Sep 17 00:00:00 2001 From: lucian Date: Tue, 27 Apr 2021 17:01:57 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-50908=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-=E5=A1=AB?= =?UTF-8?q?=E6=8A=A5=E5=B1=9E=E6=80=A7=E4=B8=AD=E5=AF=B9=E8=A1=A8=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=AE=9A=E4=BD=8D=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/data/datapane/ChoosePane.java | 23 ++++++++++++++----- .../design/gui/icombobox/FRTreeComboBox.java | 1 + .../icombobox/SearchPreTaskTreeComboBox.java | 14 +++++------ 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java index 2a8446f893..572b65287b 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java @@ -1,6 +1,7 @@ package com.fr.design.data.datapane; import com.fr.base.TableData; +import com.fr.concurrent.NamedThreadFactory; import com.fr.data.core.DataCoreUtils; import com.fr.data.core.db.DBUtils; import com.fr.data.core.db.TableProcedure; @@ -17,8 +18,8 @@ import com.fr.design.data.datapane.preview.PreviewLabel.Previewable; import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.dialog.FineJOptionPane; -import com.fr.design.gui.icombobox.FRTreeComboBox; import com.fr.design.gui.icombobox.FilterableComboBoxModel; +import com.fr.design.gui.icombobox.SearchPreTaskTreeComboBox; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBoxEditor; import com.fr.design.gui.icombobox.UIComboBoxRenderer; @@ -59,6 +60,10 @@ import java.util.Collection; import java.util.Enumeration; import java.util.List; import java.util.Set; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.FutureTask; /** * @author zhou @@ -80,7 +85,9 @@ public class ChoosePane extends BasicBeanPane implements Refresha /** * 表名 */ - protected FRTreeComboBox tableNameComboBox; + protected SearchPreTaskTreeComboBox tableNameComboBox; + + private static final ExecutorService SERVICE = Executors.newSingleThreadExecutor(new NamedThreadFactory("ChoosePane")); private SwingWorker populateWorker; @@ -88,12 +95,16 @@ public class ChoosePane extends BasicBeanPane implements Refresha @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { - new Thread() { + FutureTask task = new FutureTask(new Callable() { @Override - public void run() { + public Void call() throws Exception { + Thread.sleep(4000); calculateTableDataNames(); + return null; } - }.start(); + }); + tableNameComboBox.setPreSearchTask(task); + SERVICE.submit(task); } @Override @@ -157,7 +168,7 @@ public class ChoosePane extends BasicBeanPane implements Refresha schemaBox = new StringUIComboBox(); schemaBox.setEditor(new ComboBoxEditor()); - tableNameComboBox = new FRTreeComboBox(new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer, false); + tableNameComboBox = new SearchPreTaskTreeComboBox(new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer, false); tableNameComboBox.setEditable(true); tableNameComboBox.setRenderer(listCellRenderer); registerDSChangeListener(); diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java index f0c60d2e8a..8fe79d41ed 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java @@ -626,6 +626,7 @@ public class FRTreeComboBox extends UIComboBox { */ protected void search() { this.item = textField.getText(); + tree.updateUI(); TreeNode root = (TreeNode) tree.getModel().getRoot(); TreePath parent = new TreePath(root); TreeNode node = (TreeNode) parent.getLastPathComponent(); diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java index 9ee2a59495..2d936d8964 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java @@ -1,6 +1,5 @@ package com.fr.design.gui.icombobox; -import com.fr.design.ui.util.UIUtil; import com.fr.log.FineLoggerFactory; import javax.swing.JTree; @@ -48,7 +47,6 @@ public class SearchPreTaskTreeComboBox extends FRTreeComboBox { return; } setPopupVisible(true); - // 模糊搜索异步 new SwingWorker() { @Override protected Void doInBackground() { @@ -65,14 +63,14 @@ public class SearchPreTaskTreeComboBox extends FRTreeComboBox { // 任务执行后置空,否则会被别的操作重复触发 setPreSearchTask(null); } - UIUtil.invokeLaterIfNeeded(new Runnable() { - @Override - public void run() { - search(); - } - }); return null; } + + @Override + protected void done() { + // 模糊搜索 + search(); + } }.execute(); } } From 67f2694862ed2a2216df19e3874c45c5c7189572 Mon Sep 17 00:00:00 2001 From: lucian Date: Tue, 27 Apr 2021 17:06:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-50908=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-=E5=A1=AB?= =?UTF-8?q?=E6=8A=A5=E5=B1=9E=E6=80=A7=E4=B8=AD=E5=AF=B9=E8=A1=A8=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=AE=9A=E4=BD=8D=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/data/datapane/ChoosePane.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java index 572b65287b..b5bc39e4eb 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java @@ -98,7 +98,6 @@ public class ChoosePane extends BasicBeanPane implements Refresha FutureTask task = new FutureTask(new Callable() { @Override public Void call() throws Exception { - Thread.sleep(4000); calculateTableDataNames(); return null; }