Browse Source

REPORT-48318 刷新时才去更新缓存

feature/big-screen
xiqiu 4 years ago
parent
commit
37d7fabfee
  1. 36
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionTableProcedurePane.java
  2. 18
      designer-base/src/main/java/com/fr/design/gui/ilist/TableViewList.java

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

@ -1,27 +1,33 @@
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.log.FineLoggerFactory;
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 +54,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(); searchForRefresh();
} }
} }
}; };
@ -190,13 +197,22 @@ public class ConnectionTableProcedurePane extends BasicPane {
tableViewList.populate(selectedObj, searchField.getText().trim(), types); tableViewList.populate(selectedObj, searchField.getText().trim(), types);
} }
protected void searchForRefresh() {
String databaseName = connectionComboBox.getSelectedItem();
if (databaseName != null) {
tableViewList.clearCache(databaseName);
} else {
FineLoggerFactory.getLogger().warn("database name is null");
}
search();
}
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return "Connection"; return "Connection";
} }
/** /**
*
* @param l * @param l
*/ */
public void addDoubleClickListener(DoubleClickSelectedNodeOnTreeListener l) { public void addDoubleClickListener(DoubleClickSelectedNodeOnTreeListener l) {

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

@ -106,12 +106,6 @@ 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);
schemas = (schemas == null || schemas.length == 0) ? new String[]{null} : schemas;
for (String schema : schemas) {
clearCache(datasource, schema);
}
clearCache(datasource, null);
return processDataInAnotherThread(databaseName, searchFilter, typesFilter); return processDataInAnotherThread(databaseName, searchFilter, typesFilter);
} }
@ -132,7 +126,17 @@ public class TableViewList extends UIList {
} }
} }
private void clearCache(Connection datasource, String schema) { public void clearCache(String databaseName) {
Connection datasource = ConnectionConfig.getInstance().getConnection(databaseName);
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