Browse Source

Pull request #3677: REPORT-48318 刷新时才去更新缓存

Merge in DESIGN/design from ~XIQIU/design:release/10.0 to release/10.0

* commit 'c829390f0c31d8c7765aea700cb8e20e15f9630c':
  REPORT-48318   改成给search传参,避免造成卡顿问题
  REPORT-48318   刷新时才去更新缓存
feature/big-screen
Xiqiu 4 years ago
parent
commit
0251a5f178
  1. 37
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionTableProcedurePane.java
  2. 20
      designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java

37
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionTableProcedurePane.java

@ -1,27 +1,32 @@
package com.fr.design.data.datapane.connect; package com.fr.design.data.datapane.connect;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.data.core.db.TableProcedure;
import com.fr.data.impl.AbstractDatabaseConnection; import com.fr.data.impl.AbstractDatabaseConnection;
import com.fr.data.impl.Connection; import com.fr.data.impl.Connection;
import com.fr.design.constants.UIConstants;
import com.fr.data.core.db.TableProcedure;
import com.fr.design.border.UIRoundedBorder; import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.ilist.TableViewList; import com.fr.design.gui.ilist.TableViewList;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.dialog.BasicPane;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import javax.swing.*; import javax.swing.JPanel;
import javax.swing.ToolTipManager;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.event.*; import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List; import java.util.List;
/** /**
@ -48,10 +53,11 @@ public class ConnectionTableProcedurePane extends BasicPane {
filter(connection, conName, nameList); filter(connection, conName, nameList);
} }
@Override
protected void refreshItems() { protected void refreshItems() {
super.refreshItems(); super.refreshItems();
if (tableViewList != null) { if (tableViewList != null) {
search(); search(true);
} }
} }
}; };
@ -148,17 +154,17 @@ public class ConnectionTableProcedurePane extends BasicPane {
@Override @Override
public void removeUpdate(DocumentEvent e) { public void removeUpdate(DocumentEvent e) {
search(); search(false);
} }
@Override @Override
public void insertUpdate(DocumentEvent e) { public void insertUpdate(DocumentEvent e) {
search(); search(false);
} }
@Override @Override
public void changedUpdate(DocumentEvent e) { public void changedUpdate(DocumentEvent e) {
search(); search(false);
} }
}; };
@ -166,14 +172,14 @@ public class ConnectionTableProcedurePane extends BasicPane {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
search(); search(false);
} }
}; };
/** /**
* 选项改变需要重新刷新下拉列表里面的项 * 选项改变需要重新刷新下拉列表里面的项
*/ */
protected void search() { protected void search(boolean refresh) {
String selectedObj = connectionComboBox.getSelectedItem(); String selectedObj = connectionComboBox.getSelectedItem();
String[] types = ArrayUtils.EMPTY_STRING_ARRAY; String[] types = ArrayUtils.EMPTY_STRING_ARRAY;
@ -187,7 +193,7 @@ public class ConnectionTableProcedurePane extends BasicPane {
} else { } else {
types = (String[]) ArrayUtils.add(types, TableProcedure.PROCEDURE); types = (String[]) ArrayUtils.add(types, TableProcedure.PROCEDURE);
} }
tableViewList.populate(selectedObj, searchField.getText().trim(), types); tableViewList.populate(selectedObj, searchField.getText().trim(), refresh, types);
} }
@Override @Override
@ -196,7 +202,6 @@ public class ConnectionTableProcedurePane extends BasicPane {
} }
/** /**
*
* @param l * @param l
*/ */
public void addDoubleClickListener(DoubleClickSelectedNodeOnTreeListener l) { public void addDoubleClickListener(DoubleClickSelectedNodeOnTreeListener l) {

20
designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java

@ -82,7 +82,7 @@ public class TableViewList extends UIList {
* @param searchFilter * @param searchFilter
* @param typesFilter * @param typesFilter
*/ */
public void populate(final String databaseName, final String searchFilter, final String... typesFilter) { public void populate(final String databaseName, final String searchFilter, boolean refresh, final String... typesFilter) {
DefaultListModel defaultListModel = new DefaultListModel(); DefaultListModel defaultListModel = new DefaultListModel();
defaultListModel.addElement(UIConstants.PENDING); defaultListModel.addElement(UIConstants.PENDING);
final DefaultListModel failed = new DefaultListModel(); final DefaultListModel failed = new DefaultListModel();
@ -106,12 +106,9 @@ public class TableViewList extends UIList {
if (!status) { if (!status) {
throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed")); throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"));
} }
String[] schemas = DataCoreUtils.getDatabaseSchema(datasource); if (refresh) {
schemas = (schemas == null || schemas.length == 0) ? new String[]{null} : schemas; clearCache(datasource);
for (String schema : schemas) {
clearCache(datasource, schema);
} }
clearCache(datasource, null);
return processDataInAnotherThread(databaseName, searchFilter, typesFilter); return processDataInAnotherThread(databaseName, searchFilter, typesFilter);
} }
@ -132,7 +129,16 @@ public class TableViewList extends UIList {
} }
} }
private void clearCache(Connection datasource, String schema) { private void clearCache(Connection datasource) {
String[] schemas = DataCoreUtils.getDatabaseSchema(datasource);
schemas = (schemas == null || schemas.length == 0) ? new String[]{null} : schemas;
for (String schema : schemas) {
doClearCache(datasource, schema);
}
doClearCache(datasource, null);
}
private void doClearCache(Connection datasource, String schema) {
DataCoreUtils.refreshTables(datasource, TableProcedure.TABLE, schema); DataCoreUtils.refreshTables(datasource, TableProcedure.TABLE, schema);
DataCoreUtils.refreshTables(datasource, TableProcedure.VIEW, schema); DataCoreUtils.refreshTables(datasource, TableProcedure.VIEW, schema);
DataCoreUtils.refreshTables(datasource, TableProcedure.PROCEDURE, schema); DataCoreUtils.refreshTables(datasource, TableProcedure.PROCEDURE, schema);

Loading…
Cancel
Save