Browse Source

Pull request #7255: REPORT-64412 获取表名使用文本框内容,而非选择的值

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

* commit '3bab59843af0182ffbfbc7fd2b7970f8d48ff43e':
  REPORT-64412 获取表名使用文本框内容,而非选择的值
  REPORT-62876 表名显示时不用toString,会与初始化时不一致,统一为name
feature/x
Lucian.Chen 3 years ago
parent
commit
fb8d2da5c5
  1. 11
      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

11
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.data.tabledata.Prepare4DataSourceChange;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.icombobox.FilterableComboBoxModel; 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.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxEditor; import com.fr.design.gui.icombobox.UIComboBoxEditor;
import com.fr.design.gui.icombobox.UIComboBoxRenderer; 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; private SwingWorker populateWorker;
@ -146,7 +146,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
schemaBox = new StringUIComboBox(); schemaBox = new StringUIComboBox();
schemaBox.setEditor(new ComboBoxEditor()); 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.setEditable(true);
tableNameComboBox.setRenderer(listCellRenderer); tableNameComboBox.setRenderer(listCellRenderer);
registerDSChangeListener(); registerDSChangeListener();
@ -486,13 +486,10 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
protected String getTableName() { protected String getTableName() {
String tableName = ""; String tableName = "";
Object obj = this.tableNameComboBox.getSelectedItemObject(); Object obj = this.tableNameComboBox.getSelectedItem();
if (obj == null) {
obj = this.tableNameComboBox.getSelectedItem();
if (obj == null) { if (obj == null) {
obj = this.tableNameComboBox.getEditor().getItem(); obj = this.tableNameComboBox.getEditor().getItem();
} }
}
if (obj instanceof TreePath) { if (obj instanceof TreePath) {
Object tp = ((ExpandMutableTreeNode) ((TreePath) obj).getLastPathComponent()).getUserObject(); Object tp = ((ExpandMutableTreeNode) ((TreePath) obj).getLastPathComponent()).getUserObject();
if (tp instanceof TableProcedure) { if (tp instanceof TableProcedure) {

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