Browse Source

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

Merge in DESIGN/design from ~LUCIAN.CHEN/design:feature/x to feature/x

* commit '5c73cfbe2e17c9fc4ac04d43ba58a0b00234498d':
  REPORT-64434【11.0.2迭代验收】带模式的数据库选中表再下拉无匹配内容
feature/x
Lucian.Chen 3 years ago
parent
commit
1388c227b6
  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.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<TableProcedure> {
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();
}
}
}

Loading…
Cancel
Save