Browse Source

无jira 解决冲突

feature/10.0
Henry.Wang 4 years ago
parent
commit
09f5031719
  1. 21
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java
  2. 7
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java
  3. 13
      designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java
  4. 73
      designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java

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

@ -1,6 +1,7 @@
package com.fr.design.data.datapane; package com.fr.design.data.datapane;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.data.core.DataCoreUtils; import com.fr.data.core.DataCoreUtils;
import com.fr.data.core.db.DBUtils; import com.fr.data.core.db.DBUtils;
import com.fr.data.core.db.TableProcedure; import com.fr.data.core.db.TableProcedure;
@ -17,7 +18,7 @@ import com.fr.design.data.datapane.preview.PreviewLabel.Previewable;
import com.fr.design.data.datapane.preview.PreviewTablePane; 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.FRTreeComboBox; import com.fr.design.gui.icombobox.SearchPreTaskTreeComboBox;
import com.fr.design.gui.icombobox.FilterableComboBoxModel; import com.fr.design.gui.icombobox.FilterableComboBoxModel;
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;
@ -59,6 +60,10 @@ import java.util.Collection;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
/** /**
* @author zhou * @author zhou
@ -80,21 +85,25 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
/** /**
* 表名 * 表名
*/ */
protected FRTreeComboBox tableNameComboBox; protected SearchPreTaskTreeComboBox tableNameComboBox;
private SwingWorker populateWorker; private SwingWorker populateWorker;
private static final ExecutorService SERVICE = Executors.newSingleThreadExecutor(new NamedThreadFactory("ChoosePaneThread"));
private PopupMenuListener popupMenuListener = new PopupMenuListener() { private PopupMenuListener popupMenuListener = new PopupMenuListener() {
@Override @Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
new Thread() { FutureTask<Void> task = new FutureTask<Void>(new Callable() {
@Override @Override
public void run() { public Object call() {
calculateTableDataNames(); calculateTableDataNames();
return null;
} }
}.start(); });
SERVICE.submit(task);
tableNameComboBox.setPreSearchTask(task);
} }
@Override @Override
@ -158,7 +167,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 FRTreeComboBox(new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer, false); tableNameComboBox = new SearchPreTaskTreeComboBox(new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer, false);
tableNameComboBox.setEditable(true); tableNameComboBox.setEditable(true);
tableNameComboBox.setRenderer(listCellRenderer); tableNameComboBox.setRenderer(listCellRenderer);
registerDSChangeListener(); registerDSChangeListener();

7
designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java

@ -98,6 +98,7 @@ public class JDBCDefPane extends JPanel {
private JDBCDatabaseConnection jdbcDatabase; private JDBCDatabaseConnection jdbcDatabase;
private boolean needRefresh = true;
public JDBCDefPane() { public JDBCDefPane() {
this.setBorder(UITitledBorder.createBorderWithTitle("JDBC" + ":")); this.setBorder(UITitledBorder.createBorderWithTitle("JDBC" + ":"));
@ -223,6 +224,7 @@ public class JDBCDefPane extends JPanel {
} }
public void populate(JDBCDatabaseConnection jdbcDatabase) { public void populate(JDBCDatabaseConnection jdbcDatabase) {
needRefresh = false;
if (jdbcDatabase == null) { if (jdbcDatabase == null) {
jdbcDatabase = new JDBCDatabaseConnection(); jdbcDatabase = new JDBCDatabaseConnection();
} }
@ -261,6 +263,7 @@ public class JDBCDefPane extends JPanel {
} else { } else {
this.charSetComboBox.setSelectedItem(jdbcDatabase.getOriginalCharsetName()); this.charSetComboBox.setSelectedItem(jdbcDatabase.getOriginalCharsetName());
} }
needRefresh = false;
} }
protected JDBCDatabaseConnection getJDBCDatabase() { protected JDBCDatabaseConnection getJDBCDatabase() {
@ -321,7 +324,9 @@ public class JDBCDefPane extends JPanel {
} }
} }
// 更改数据库类型后 数据库名称置空和之前逻辑保持一致 // 更改数据库类型后 数据库名称置空和之前逻辑保持一致
jdbcDatabase.setDatabase(StringUtils.EMPTY); if (needRefresh) {
jdbcDatabase.setDatabase(StringUtils.EMPTY);
}
changePane(dbtypeComboBox.getSelectedItem()); changePane(dbtypeComboBox.getSelectedItem());
} }
}; };

13
designer-base/src/main/java/com/fr/design/gui/icombobox/FRTreeComboBox.java

@ -597,6 +597,10 @@ public class FRTreeComboBox extends UIComboBox {
return this.item; return this.item;
} }
public boolean isSetting() {
return setting;
}
public void insertUpdate(DocumentEvent e) { public void insertUpdate(DocumentEvent e) {
changeHandler(); changeHandler();
} }
@ -614,11 +618,18 @@ public class FRTreeComboBox extends UIComboBox {
return; return;
} }
setPopupVisible(true); setPopupVisible(true);
search();
}
/**
* 模糊搜索选中首个匹配项
*/
protected void search() {
this.item = textField.getText(); this.item = textField.getText();
TreeNode root = (TreeNode) tree.getModel().getRoot(); TreeNode root = (TreeNode) tree.getModel().getRoot();
TreePath parent = new TreePath(root); TreePath parent = new TreePath(root);
TreeNode node = (TreeNode) parent.getLastPathComponent(); TreeNode node = (TreeNode) parent.getLastPathComponent();
dealSamePath(parent,node,textField); dealSamePath(parent, node, textField);
this.getEditorComponent().requestFocus(); this.getEditorComponent().requestFocus();
} }

73
designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java

@ -0,0 +1,73 @@
package com.fr.design.gui.icombobox;
import com.fr.log.FineLoggerFactory;
import javax.swing.JTree;
import javax.swing.SwingWorker;
import javax.swing.tree.TreeCellRenderer;
import java.util.concurrent.FutureTask;
/**
* 模糊搜索前需执行完前置任务的TreeComboBox
* @author Lucian.Chen
* @version 10.0
* Created by Lucian.Chen on 2021/4/14
*/
public class SearchPreTaskTreeComboBox extends FRTreeComboBox {
/**
* 模糊搜索前任务
*/
private FutureTask<Void> preSearchTask;
public SearchPreTaskTreeComboBox(JTree tree, TreeCellRenderer renderer, boolean editable) {
super(tree, renderer, editable);
}
public FutureTask<Void> getPreSearchTask() {
return preSearchTask;
}
public void setPreSearchTask(FutureTask<Void> preSearchTask) {
this.preSearchTask = preSearchTask;
}
protected UIComboBoxEditor createEditor() {
return new SearchPreTaskComboBoxEditor(this);
}
private class SearchPreTaskComboBoxEditor extends FrTreeSearchComboBoxEditor {
public SearchPreTaskComboBoxEditor(FRTreeComboBox comboBox) {
super(comboBox);
}
protected void changeHandler() {
if (isSetting()) {
return;
}
setPopupVisible(true);
// 模糊搜索异步
new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() {
FutureTask<Void> task = getPreSearchTask();
try {
// 确保模糊搜索前任务执行完成后,再进行模糊搜索
if (task != null) {
task.get();
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
if (task != null) {
// 任务执行后置空,否则会被别的操作重复触发
setPreSearchTask(null);
}
search();
return null;
}
}.execute();
}
}
}
Loading…
Cancel
Save