Browse Source

Merge pull request #8233 in DESIGN/design from bugfix/10.0 to feature/10.0

* commit '8f780e4809e173265a5679c8f6ecd66db420dc15':
  REPORT-66767 存储过程数据集报错提示窗口没有内容的问题
  REPORT-67954 远程设计时数据集面板数据连接空白的问题
feature/10.0
superman 3 years ago
parent
commit
334320ae80
  1. 12
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java
  2. 75
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java

12
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java

@ -14,14 +14,13 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UILockButton; import com.fr.design.gui.ibutton.UILockButton;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.file.ConnectionConfig; import com.fr.file.ConnectionConfig;
import com.fr.general.ComparatorUtils; import com.fr.report.LockItem;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.transaction.CallBackAdaptor; import com.fr.transaction.CallBackAdaptor;
import com.fr.transaction.Configurations; import com.fr.transaction.Configurations;
import com.fr.transaction.WorkerFacade; import com.fr.transaction.WorkerFacade;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.connection.DBConnectAuth; import com.fr.workspace.server.connection.DBConnectAuth;
import com.fr.report.LockItem;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import java.awt.Dimension; import java.awt.Dimension;
@ -103,6 +102,7 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel {
continue; continue;
} }
Connection connection = mgr.getConnection(conName); Connection connection = mgr.getConnection(conName);
// nameList依赖items方法初始化,父类ItemEditableComboBoxPanel里异步执行item方法
filterConnection(connection, conName, nameList); filterConnection(connection, conName, nameList);
} }
@ -188,12 +188,10 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel {
} else { } else {
String s = DesignerEnvManager.getEnvManager().getRecentSelectedConnection(); String s = DesignerEnvManager.getEnvManager().getRecentSelectedConnection();
if (StringUtils.isNotBlank(s)) { if (StringUtils.isNotBlank(s)) {
for (int i = 0; i < this.getConnectionSize(); i++) { // 之前的写法有多线程问题,nameList异步尚未初始化完成的时候,这里可能无法匹配设置数据连接名称,导致DBTableDataPane打开后连接面板空白
String t = this.getConnection(i); // 这里的需求无非是设置上一次使用的数据连接,做个简单检查这个连接是否存在即可,存在就设置
if (ComparatorUtils.equals(s, t)) { if (ConnectionConfig.getInstance().getConnection(s) != null) {
this.setSelectedItem(s); this.setSelectedItem(s);
break;
}
} }
} }
// alex:如果这个ComboBox还是没有选中,那么选中第一个 // alex:如果这个ComboBox还是没有选中,那么选中第一个

75
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java

@ -65,24 +65,25 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
} }
/** /**
* @param: component loadingBar的父弹框如果不设置父弹框的话可能出现loadingBar隐藏在一个弹框后的情况 * @param component loadingBar的父弹框如果不设置父弹框的话可能出现loadingBar隐藏在一个弹框后的情况
* @param: storeProcedure 存储过程 * @param storeProcedure 存储过程
* @param: storeprocedureName 存储过程的名字(某些情况下可以为空) * @param storeprocedureName 存储过程的名字(某些情况下可以为空)
* @param: dsName 存储过程一个返回数据集的名字 * @param dsName 存储过程一个返回数据集的名字
* @param: needLoad 是否要加载 * @param needLoad 是否要加载
**/ **/
public StoreProcedureDataWrapper(Component component, StoreProcedure storeProcedure, String storeprocedureName, String dsName, boolean needLoad) { public StoreProcedureDataWrapper(Component component, StoreProcedure storeProcedure, String storeprocedureName, String dsName, boolean needLoad) {
this.dsName = dsName; this.dsName = dsName;
this.storeProcedure = storeProcedure; this.storeProcedure = storeProcedure;
this.storeProcedure.setCalculating(false); this.storeProcedure.setCalculating(false);
this.storeprocedureName = storeprocedureName; this.storeprocedureName = storeprocedureName;
if (needLoad) {
setWorker();
}
if (component == null) { if (component == null) {
component = new JFrame(); component = new JFrame();
} }
if (needLoad) {
setWorker(component);
}
loadingBar = new AutoProgressBar(component, Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) { loadingBar = new AutoProgressBar(component, Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) {
@Override
public void doMonitorCanceled() { public void doMonitorCanceled() {
getWorker().cancel(true); getWorker().cancel(true);
} }
@ -93,16 +94,17 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
* 数据集执行结果返回的所有字段 * 数据集执行结果返回的所有字段
* *
* @return 数据集执行结果返回的所有字段 * @return 数据集执行结果返回的所有字段
*
*
* @date 2014-12-3-下午7:43:17 * @date 2014-12-3-下午7:43:17
*
*/ */
@Override
public List<String> calculateColumnNameList() { public List<String> calculateColumnNameList() {
if (columnNameList != null) { if (columnNameList != null) {
return columnNameList; return columnNameList;
} }
if (!createStore(false)) {
try {
createStore(false);
} catch (Exception e) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Engine_No_TableData")); FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Engine_No_TableData"));
return new ArrayList<String>(); return new ArrayList<String>();
} }
@ -114,11 +116,9 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
* 生成子节点 * 生成子节点
* *
* @return 节点数组 * @return 节点数组
*
*
* @date 2014-12-3-下午7:06:47 * @date 2014-12-3-下午7:06:47
*
*/ */
@Override
public ExpandMutableTreeNode[] load() { public ExpandMutableTreeNode[] load() {
List<String> namelist; List<String> namelist;
if (storeProcedure.isCalculating()) { if (storeProcedure.isCalculating()) {
@ -134,23 +134,16 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
return res; return res;
} }
private boolean createStore(boolean needLoadingBar) { private void createStore(boolean needLoadingBar) throws Exception {
try {
dataModels = DesignTableDataManager.createLazyDataModel(storeProcedure, needLoadingBar); dataModels = DesignTableDataManager.createLazyDataModel(storeProcedure, needLoadingBar);
if (dataModels == null || dataModels.length == 0) { if (dataModels != null && dataModels.length != 0) {
return false; for (ProcedureDataModel dataModel : dataModels) {
} if (ComparatorUtils.equals(this.dsName, storeprocedureName + "_" + dataModel.getName())) {
for (int i = 0; i < dataModels.length; i++) { procedureDataModel = dataModel;
if (ComparatorUtils.equals(this.dsName, storeprocedureName + "_" + dataModels[i].getName())) {
procedureDataModel = dataModels[i];
break; break;
} }
} }
return true;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
return false;
} }
@Override @Override
@ -162,14 +155,12 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
* 预览数据 * 预览数据
* *
* @param previewModel 预览模式, 全部还是一个 * @param previewModel 预览模式, 全部还是一个
*
*
* @date 2014-12-3-下午7:05:50 * @date 2014-12-3-下午7:05:50
*
*/ */
public void previewData(final int previewModel) { public void previewData(final int previewModel) {
this.previewModel = previewModel; this.previewModel = previewModel;
connectionBar = new AutoProgressBar(new JFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Now_Create_Connection"), "", 0, 100) { connectionBar = new AutoProgressBar(new JFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Now_Create_Connection"), "", 0, 100) {
@Override
public void doMonitorCanceled() { public void doMonitorCanceled() {
connectionBar.close(); connectionBar.close();
worker.cancel(true); worker.cancel(true);
@ -178,8 +169,9 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
worker.execute(); worker.execute();
} }
private void setWorker() { private void setWorker(final Component parent) {
worker = new SwingWorker<Void, Void>() { worker = new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception { protected Void doInBackground() throws Exception {
loadingBar.close(); loadingBar.close();
PreviewTablePane.resetPreviewTable(); PreviewTablePane.resetPreviewTable();
@ -195,6 +187,7 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
return null; return null;
} }
@Override
public void done() { public void done() {
try { try {
get(); get();
@ -206,13 +199,15 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
case StoreProcedureDataWrapper.PREVIEW_ONE: case StoreProcedureDataWrapper.PREVIEW_ONE:
previewData(); previewData();
break; break;
default:
break;
} }
} catch (Exception e) { } catch (Exception e) {
loadingBar.close();
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(parent, e.getMessage());
} }
loadingBar.close();
} }
} }
}; };
@ -226,11 +221,10 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
/** /**
* 预览返回的一个数据集 * 预览返回的一个数据集
*
* *
* @date 2014-12-3-下午7:42:53 * @date 2014-12-3-下午7:42:53
*
*/ */
@Override
public void previewData() { public void previewData() {
previewData(-1, -1); previewData(-1, -1);
} }
@ -242,11 +236,9 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
* *
* @param keyIndex 实际值 * @param keyIndex 实际值
* @param valueIndex 显示值 * @param valueIndex 显示值
*
*
* @date 2014-12-3-下午7:42:27 * @date 2014-12-3-下午7:42:27
*
*/ */
@Override
public void previewData(final int keyIndex, final int valueIndex) { public void previewData(final int keyIndex, final int valueIndex) {
PreviewTablePane.previewStoreData(procedureDataModel, keyIndex, valueIndex); PreviewTablePane.previewStoreData(procedureDataModel, keyIndex, valueIndex);
} }
@ -257,7 +249,9 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
*/ */
public void previewAllTable() { public void previewAllTable() {
if (procedureDataModel == null) { if (procedureDataModel == null) {
if (!createStore(true)) { try {
createStore(true);
} catch (Exception e) {
return; return;
} }
} }
@ -269,6 +263,7 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
return dsName; return dsName;
} }
@Override
public TableData getTableData() { public TableData getTableData() {
return storeProcedure; return storeProcedure;
} }
@ -282,10 +277,12 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
* *
* @return 是否异常 * @return 是否异常
*/ */
@Override
public boolean isUnusual() { public boolean isUnusual() {
return false; return false;
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
return obj instanceof StoreProcedureDataWrapper return obj instanceof StoreProcedureDataWrapper
&& ComparatorUtils.equals(this.dsName, ((StoreProcedureDataWrapper) obj).getTableDataName()) && ComparatorUtils.equals(this.dsName, ((StoreProcedureDataWrapper) obj).getTableDataName())

Loading…
Cancel
Save