Browse Source

Pull request #2591: REPORT-41135 【冒烟】第一次预览数据模板数据集,加载弹窗不消失

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

* commit '74a6126df3fd7e32f9bfe240d16b658c57763b55':
  REPORT-41135 【冒烟】第一次预览数据模板数据集,加载弹窗不消失 【问题原因】这个加载弹窗是个AutoProgressBar进度条,之前的逻辑中,进度条在SwingWorker线程中start并且close,而与进度条显示更新相关的逻辑在EDT中,所以有时候会出现SwingWorker中AutoProgressBar先close掉了,但是AutoProgressBar中还在继续对进度条进行赋值操作,又因为没有设置ProgressMonitor的millsToDecideToPopup,导致赋值操作会进入某个判断分支并使弹窗再度弹出,弹出后就不会自动关闭了 【改动方案】将close操作放入EDT线程中执行(顺便修复一些导包问题与过时方法)
feature/big-screen
Yvan 4 years ago
parent
commit
e43be22767
  1. 46
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java

46
designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java

@ -15,20 +15,31 @@ import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.frpane.UITabbedPane; import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iprogressbar.AutoProgressBar; import com.fr.design.gui.iprogressbar.AutoProgressBar;
import com.fr.design.gui.itable.SortableJTable; import com.fr.design.gui.itable.SortableJTable;
import com.fr.design.gui.itable.TableSorter; import com.fr.design.gui.itable.TableSorter;
import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.ui.util.UIUtil;
import com.fr.function.TIME; import com.fr.function.TIME;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import javax.swing.*; import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn; import javax.swing.table.TableColumn;
import javax.swing.table.TableModel; import javax.swing.table.TableModel;
@ -81,7 +92,7 @@ public class PreviewTablePane extends BasicPane {
JPanel currentPreviewPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel currentPreviewPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
previewNumberPanel.add(currentPreviewPanel); previewNumberPanel.add(currentPreviewPanel);
currentPreviewPanel.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Current_Preview_Rows") + ":")); currentPreviewPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Current_Preview_Rows") + ":"));
currentRowsField = new UINumberField(); currentRowsField = new UINumberField();
currentPreviewPanel.add(currentRowsField); currentPreviewPanel.add(currentRowsField);
@ -91,7 +102,7 @@ public class PreviewTablePane extends BasicPane {
JPanel maxPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel maxPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
previewNumberPanel.add(maxPanel); previewNumberPanel.add(maxPanel);
maxPanel.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Maximum_Number_of_Preview_Rows") + ":")); maxPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Basic_Datasource_Maximum_Number_of_Preview_Rows") + ":"));
maxPreviewNumberField = new UINumberField(); maxPreviewNumberField = new UINumberField();
maxPanel.add(maxPreviewNumberField); maxPanel.add(maxPreviewNumberField);
@ -158,7 +169,7 @@ public class PreviewTablePane extends BasicPane {
if (this.dialog == null) { if (this.dialog == null) {
this.dialog = this.showWindow(new JFrame()); this.dialog = this.showWindow(new JFrame());
} }
progressBar = new AutoProgressBar(this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) { progressBar = new AutoProgressBar(this, Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) {
public void doMonitorCanceled() { public void doMonitorCanceled() {
if (getWorker() != null) { if (getWorker() != null) {
getWorker().cancel(true); getWorker().cancel(true);
@ -174,7 +185,7 @@ public class PreviewTablePane extends BasicPane {
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"); return Toolkit.i18nText("Fine-Design_Basic_Preview");
} }
private void addLoadedListener(LoadedEventListener l) { private void addLoadedListener(LoadedEventListener l) {
@ -268,7 +279,7 @@ public class PreviewTablePane extends BasicPane {
*/ */
public static EmbeddedTableData previewTableData(TableData tableData, final int keyIndex, final int valueIndex) { public static EmbeddedTableData previewTableData(TableData tableData, final int keyIndex, final int valueIndex) {
PreviewTablePane previewTablePane = new PreviewTablePane(); PreviewTablePane previewTablePane = new PreviewTablePane();
previewTablePane.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Data"))); previewTablePane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Data")));
try { try {
previewTablePane.populate(tableData); previewTablePane.populate(tableData);
previewTablePane.resetPreviewTableColumnColor(); previewTablePane.resetPreviewTableColumnColor();
@ -298,13 +309,13 @@ public class PreviewTablePane extends BasicPane {
try { try {
int choiceColumn = Integer.parseInt(columnErrMessage.trim()); int choiceColumn = Integer.parseInt(columnErrMessage.trim());
int tatalColumn = Integer.parseInt(tatolColumnErrMessage.trim()); int tatalColumn = Integer.parseInt(tatolColumnErrMessage.trim());
columnErrMessage = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Preview_Warn_Text", choiceColumn + 1, tatalColumn); columnErrMessage = Toolkit.i18nText("Fine-Design_Basic_Tabledata_Preview_Warn_Text", choiceColumn + 1, tatalColumn);
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
return; return;
} }
FineLoggerFactory.getLogger().error(exp.getMessage(), exp); FineLoggerFactory.getLogger().error(exp.getMessage(), exp);
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), columnErrMessage, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE); FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), columnErrMessage, Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE);
} }
private void populate(TableData tableData) throws Exception { private void populate(TableData tableData) throws Exception {
@ -317,7 +328,7 @@ public class PreviewTablePane extends BasicPane {
} }
private void previewTableDataSQL() throws Exception { private void previewTableDataSQL() throws Exception {
connectionBar = new AutoProgressBar(this, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Now_Create_Connection"), "", 0, 100) { connectionBar = new AutoProgressBar(this, Toolkit.i18nText("Fine-Design_Basic_Utils_Now_Create_Connection"), "", 0, 100) {
public void doMonitorCanceled() { public void doMonitorCanceled() {
getWorker().cancel(true); getWorker().cancel(true);
getDialog().setVisible(false); getDialog().setVisible(false);
@ -365,13 +376,14 @@ public class PreviewTablePane extends BasicPane {
if (tableData instanceof DBTableData) { if (tableData instanceof DBTableData) {
boolean status = DataOperator.getInstance().testConnection(((DBTableData) tableData).getDatabase()); boolean status = DataOperator.getInstance().testConnection(((DBTableData) tableData).getDatabase());
if (!status) { if (!status) {
throw new Exception(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed")); throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"));
} }
} }
} finally { } finally {
connectionBar.close(); // 将close操作放到EDT线程中
UIUtil.invokeLaterIfNeeded(() -> connectionBar.close());
} }
TableDataSource dataSource = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getTarget(); TableDataSource dataSource = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget();
previewTableData = DesignTableDataManager.previewTableDataNeedInputParameters(dataSource, tableData, (int) maxPreviewNumberField.getValue(), true, progressBar); previewTableData = DesignTableDataManager.previewTableDataNeedInputParameters(dataSource, tableData, (int) maxPreviewNumberField.getValue(), true, progressBar);
// parameterInputDialog // parameterInputDialog
// update之后的parameters,转成一个parameterMap,用于预览TableData // update之后的parameters,转成一个parameterMap,用于预览TableData
@ -396,7 +408,7 @@ public class PreviewTablePane extends BasicPane {
if (!(e instanceof CancellationException)) { if (!(e instanceof CancellationException)) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(), FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), e.getMessage(),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon")); Toolkit.i18nText("Fine-Design_Basic_Error"), JOptionPane.ERROR_MESSAGE, UIManager.getIcon("OptionPane.errorIcon"));
} }
dialog.setVisible(false); dialog.setVisible(false);
} finally { } finally {
@ -425,7 +437,7 @@ public class PreviewTablePane extends BasicPane {
public static void previewStoreData(final ProcedureDataModel storeProcedureDataModel, final int keyIndex, final int valueIndex) { public static void previewStoreData(final ProcedureDataModel storeProcedureDataModel, final int keyIndex, final int valueIndex) {
final PreviewTablePane previewTablePane = new PreviewTablePane(); final PreviewTablePane previewTablePane = new PreviewTablePane();
previewTablePane.storeProcedureDataModel = storeProcedureDataModel; previewTablePane.storeProcedureDataModel = storeProcedureDataModel;
previewTablePane.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Data"))); previewTablePane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Data")));
try { try {
previewTablePane.populateStoreDataSQL(); previewTablePane.populateStoreDataSQL();
@ -456,7 +468,7 @@ public class PreviewTablePane extends BasicPane {
for (int i = 0; i < tableSize; i++) { for (int i = 0; i < tableSize; i++) {
PreviewTablePane previewTablePane = new PreviewTablePane(); PreviewTablePane previewTablePane = new PreviewTablePane();
previewTablePane.storeProcedureDataModel = storeProcedureDataModels[i]; previewTablePane.storeProcedureDataModel = storeProcedureDataModels[i];
previewTablePane.setBorder(BorderFactory.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Data"))); previewTablePane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Data")));
try { try {
previewTablePane.populateStoreDataSQL(); previewTablePane.populateStoreDataSQL();
} catch (Exception e) { } catch (Exception e) {
@ -469,7 +481,7 @@ public class PreviewTablePane extends BasicPane {
@Override @Override
protected String title4PopupWindow() { protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"); return Toolkit.i18nText("Fine-Design_Basic_Preview");
} }
}; };

Loading…
Cancel
Save