Browse Source

REPORT-62876 表名显示时不用toString,会与初始化时不一致,统一为name

feature/x
lucian 3 years ago
parent
commit
2eaf3b057c
  1. 6
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java
  2. 39
      designer-base/src/main/java/com/fr/design/gui/icombobox/TableSearchTreeComboBox.java

6
designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java

@ -19,7 +19,7 @@ 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.FilterableComboBoxModel;
import com.fr.design.gui.icombobox.SearchFRTreeComboBox;
import com.fr.design.gui.icombobox.TableSearchTreeComboBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxEditor;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
@ -91,7 +91,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
/**
* 表名
*/
protected SearchFRTreeComboBox tableNameComboBox;
protected TableSearchTreeComboBox tableNameComboBox;
private SwingWorker populateWorker;
@ -146,7 +146,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
schemaBox = new StringUIComboBox();
schemaBox.setEditor(new ComboBoxEditor());
tableNameComboBox = new SearchFRTreeComboBox(this, new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer);
tableNameComboBox = new TableSearchTreeComboBox(this, new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer);
tableNameComboBox.setEditable(true);
tableNameComboBox.setRenderer(listCellRenderer);
registerDSChangeListener();

39
designer-base/src/main/java/com/fr/design/gui/icombobox/SearchFRTreeComboBox.java → designer-base/src/main/java/com/fr/design/gui/icombobox/TableSearchTreeComboBox.java

@ -25,7 +25,7 @@ import java.awt.event.MouseEvent;
import java.util.Enumeration;
/**
* 实现模糊搜索的FRTreeComboBox
* 实现模糊搜索表名的FRTreeComboBox
* FRTreeComboBox搜索后滚动到首个匹配节点
* SearchFRTreeComboBox显示所有匹配的节点
*
@ -33,20 +33,27 @@ import java.util.Enumeration;
* @version 10.0
* Created by Lucian.Chen on 2021/4/14
*/
public class SearchFRTreeComboBox extends FRTreeComboBox {
private static final String DOT = ".";
public class TableSearchTreeComboBox extends FRTreeComboBox {
// 持有父容器,需要实时获取其他组件值
private final ChoosePane parent;
public SearchFRTreeComboBox(ChoosePane parent, JTree tree, TreeCellRenderer renderer) {
public TableSearchTreeComboBox(ChoosePane parent, JTree tree, TreeCellRenderer renderer) {
super(tree, renderer);
this.parent = parent;
setUI(new SearchFRTreeComboBoxUI());
setUI(new TableSearchTreeComboBoxUI());
}
protected UIComboBoxEditor createEditor() {
return new SearchFRComboBoxEditor(this);
return new TableSearchComboBoxEditor(this);
}
@Override
protected String pathToString(TreePath path) {
Object obj = ((DefaultMutableTreeNode) path.getLastPathComponent()).getUserObject();
if (obj instanceof TableProcedure) {
return ((TableProcedure) obj).getName();
}
return super.pathToString(path);
}
/**
@ -61,7 +68,7 @@ public class SearchFRTreeComboBox extends FRTreeComboBox {
parent.getDSName(),
parent.getConnection(),
parent.getSchema(),
createFilter((String) searchEditor.getItem(), parent.getSchema()));
createFilter((String) searchEditor.getItem()));
return null;
}
@ -74,8 +81,8 @@ public class SearchFRTreeComboBox extends FRTreeComboBox {
}.execute();
}
private TableNameFilter createFilter(String text, String schema) {
return StringUtils.isEmpty(text) ? EMPTY_FILTER : new TableNameFilter(text, schema);
private TableNameFilter createFilter(String text) {
return StringUtils.isEmpty(text) ? EMPTY_FILTER : new TableNameFilter(text);
}
/**
@ -159,11 +166,7 @@ public class SearchFRTreeComboBox extends FRTreeComboBox {
public TableNameFilter() {
}
public TableNameFilter(String searchFilter, String schema) {
// 有模式的截掉,不参与模糊搜索
if (StringUtils.isNotEmpty(schema) && searchFilter.startsWith(schema + DOT)) {
searchFilter = searchFilter.substring(schema.length() + 1);
}
public TableNameFilter(String searchFilter) {
this.searchFilter = searchFilter.toLowerCase().trim();
}
@ -177,7 +180,7 @@ public class SearchFRTreeComboBox extends FRTreeComboBox {
/**
* 重写FRTreeComboBoxUI实现点击下拉时触发模糊搜索
*/
private class SearchFRTreeComboBoxUI extends FRTreeComboBoxUI {
private class TableSearchTreeComboBoxUI extends FRTreeComboBoxUI {
@Override
public void mouseClicked(MouseEvent e) {
@ -188,9 +191,9 @@ public class SearchFRTreeComboBox extends FRTreeComboBox {
/**
* 重写输入框编辑器实现输入框模糊搜索逻辑
*/
private class SearchFRComboBoxEditor extends FrTreeSearchComboBoxEditor {
private class TableSearchComboBoxEditor extends FrTreeSearchComboBoxEditor {
public SearchFRComboBoxEditor(FRTreeComboBox comboBox) {
public TableSearchComboBoxEditor(FRTreeComboBox comboBox) {
super(comboBox);
}
Loading…
Cancel
Save