Browse Source

REPORT-64434【11.0.2迭代验收】带模式的数据库选中表再下拉无匹配内容

feature/x
lucian 3 years ago
parent
commit
5546bda83a
  1. 69
      designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java

69
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.design.mainframe.DesignerContext;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Filter;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -34,6 +35,7 @@ import java.util.Enumeration;
*/ */
public class SearchFRTreeComboBox extends FRTreeComboBox { public class SearchFRTreeComboBox extends FRTreeComboBox {
private static final String DOT = ".";
// 持有父容器,需要实时获取其他组件值 // 持有父容器,需要实时获取其他组件值
private final ChoosePane parent; private final ChoosePane parent;
@ -59,7 +61,7 @@ public class SearchFRTreeComboBox extends FRTreeComboBox {
parent.getDSName(), parent.getDSName(),
parent.getConnection(), parent.getConnection(),
parent.getSchema(), parent.getSchema(),
createFilter((String) searchEditor.getItem())); createFilter((String) searchEditor.getItem(), parent.getSchema()));
return null; return null;
} }
@ -72,8 +74,8 @@ public class SearchFRTreeComboBox extends FRTreeComboBox {
}.execute(); }.execute();
} }
private TableNameFilter createFilter(String text) { private TableNameFilter createFilter(String text, String schema) {
return StringUtils.isEmpty(text) ? EMPTY_FILTER : new TableNameFilter(text); return StringUtils.isEmpty(text) ? EMPTY_FILTER : new TableNameFilter(text, schema);
} }
/** /**
@ -142,27 +144,7 @@ public class SearchFRTreeComboBox extends FRTreeComboBox {
} }
} }
/** private static final TableNameFilter EMPTY_FILTER = new TableNameFilter() {
* 重写输入框编辑器实现输入框模糊搜索逻辑
*/
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) {
public boolean accept(TableProcedure procedure) { public boolean accept(TableProcedure procedure) {
return true; return true;
} }
@ -171,17 +153,22 @@ public class SearchFRTreeComboBox extends FRTreeComboBox {
/** /**
* 表名模糊搜索实现 * 表名模糊搜索实现
*/ */
private static class TableNameFilter { private static class TableNameFilter implements Filter<TableProcedure> {
private final String searchFilter; private String searchFilter;
public TableNameFilter() {
}
public TableNameFilter(String searchFilter) { public TableNameFilter(String searchFilter, String schema) {
if (StringUtils.isNotEmpty(searchFilter)) { // 有模式的截掉,不参与模糊搜索
searchFilter = searchFilter.toLowerCase().trim(); 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) { public boolean accept(TableProcedure procedure) {
return procedure.getName().toLowerCase().contains(searchFilter); return procedure.getName().toLowerCase().contains(searchFilter);
} }
@ -197,4 +184,24 @@ public class SearchFRTreeComboBox extends FRTreeComboBox {
searchExecute(); 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();
}
}
} }

Loading…
Cancel
Save