From 5546bda83a1295c311ea36550e865b7bef6032c6 Mon Sep 17 00:00:00 2001 From: lucian Date: Fri, 17 Dec 2021 14:46:21 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-64434=E3=80=9011.0.2=E8=BF=AD=E4=BB=A3?= =?UTF-8?q?=E9=AA=8C=E6=94=B6=E3=80=91=E5=B8=A6=E6=A8=A1=E5=BC=8F=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E9=80=89=E4=B8=AD=E8=A1=A8=E5=86=8D?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=97=A0=E5=8C=B9=E9=85=8D=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/icombobox/SearchFRTreeComboBox.java | 69 ++++++++++--------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java b/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java index 06f50e211..ff6ebba02 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java @@ -10,6 +10,7 @@ import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.mainframe.DesignerContext; import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; +import com.fr.stable.Filter; import com.fr.stable.StringUtils; import javax.swing.JOptionPane; @@ -34,6 +35,7 @@ import java.util.Enumeration; */ public class SearchFRTreeComboBox extends FRTreeComboBox { + private static final String DOT = "."; // 持有父容器,需要实时获取其他组件值 private final ChoosePane parent; @@ -59,7 +61,7 @@ public class SearchFRTreeComboBox extends FRTreeComboBox { parent.getDSName(), parent.getConnection(), parent.getSchema(), - createFilter((String) searchEditor.getItem())); + createFilter((String) searchEditor.getItem(), parent.getSchema())); return null; } @@ -72,8 +74,8 @@ public class SearchFRTreeComboBox extends FRTreeComboBox { }.execute(); } - private TableNameFilter createFilter(String text) { - return StringUtils.isEmpty(text) ? EMPTY_FILTER : new TableNameFilter(text); + private TableNameFilter createFilter(String text, String schema) { + return StringUtils.isEmpty(text) ? EMPTY_FILTER : new TableNameFilter(text, schema); } /** @@ -142,27 +144,7 @@ public class SearchFRTreeComboBox extends FRTreeComboBox { } } - /** - * 重写输入框编辑器,实现输入框模糊搜索逻辑 - */ - private class SearchFRComboBoxEditor extends FrTreeSearchComboBoxEditor { - - public SearchFRComboBoxEditor(FRTreeComboBox comboBox) { - super(comboBox); - } - - @Override - protected void changeHandler() { - if (isSetting()) { - return; - } - setPopupVisible(true); - this.item = textField.getText(); - searchExecute(); - } - } - - private static final TableNameFilter EMPTY_FILTER = new TableNameFilter(StringUtils.EMPTY) { + private static final TableNameFilter EMPTY_FILTER = new TableNameFilter() { public boolean accept(TableProcedure procedure) { return true; } @@ -171,17 +153,22 @@ public class SearchFRTreeComboBox extends FRTreeComboBox { /** * 表名模糊搜索实现 */ - private static class TableNameFilter { - private final String searchFilter; + private static class TableNameFilter implements Filter { + private String searchFilter; + + public TableNameFilter() { + } - public TableNameFilter(String searchFilter) { - if (StringUtils.isNotEmpty(searchFilter)) { - searchFilter = searchFilter.toLowerCase().trim(); + public TableNameFilter(String searchFilter, String schema) { + // 有模式的截掉,不参与模糊搜索 + if (StringUtils.isNotEmpty(schema) && searchFilter.startsWith(schema + DOT)) { + searchFilter = searchFilter.substring(schema.length() + 1); } - this.searchFilter = searchFilter; + this.searchFilter = searchFilter.toLowerCase().trim(); } - // 字符串匹配 + // 表名匹配 + @Override public boolean accept(TableProcedure procedure) { return procedure.getName().toLowerCase().contains(searchFilter); } @@ -197,4 +184,24 @@ public class SearchFRTreeComboBox extends FRTreeComboBox { searchExecute(); } } + + /** + * 重写输入框编辑器,实现输入框模糊搜索逻辑 + */ + private class SearchFRComboBoxEditor extends FrTreeSearchComboBoxEditor { + + public SearchFRComboBoxEditor(FRTreeComboBox comboBox) { + super(comboBox); + } + + @Override + protected void changeHandler() { + if (isSetting()) { + return; + } + setPopupVisible(true); + this.item = textField.getText(); + searchExecute(); + } + } }