Browse Source

Pull request #8736: REPORT-70504 填报-填报属性设置-数据表搜索时有较大概率多个重复的搜索结果

Merge in DESIGN/design from ~LUCIAN.CHEN/design:release/11.0 to release/11.0

* commit 'c91aee4e861fa32cbf4a0c4460341b960e555db2':
  REPORT-70504 线程池管理
  REPORT-70504 填报-填报属性设置-数据表搜索时有较大概率多个重复的搜索结果
  REPORT-70504 填报-填报属性设置-数据表搜索时有较大概率多个重复的搜索结果
bugfix/11.0
Lucian.Chen 3 years ago
parent
commit
10dfbbf22b
  1. 14
      designer-base/src/main/java/com/fr/design/gui/icombobox/TableSearchTreeComboBox.java

14
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<Void, Void>() {
String searchText = (String) searchEditor.getItem();
singleExecutor.execute(new SwingWorker<Void, Void>() {
@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) {

Loading…
Cancel
Save