|
|
|
@ -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); |
|
|
|
|
} |
|
|
|
|
|