|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
package com.fr.design.data.tabledata.wrapper; |
|
|
|
|
|
|
|
|
|
import com.fr.base.BaseUtils; |
|
|
|
|
import com.fr.base.TableData; |
|
|
|
|
import com.fr.data.MultiResultTableData; |
|
|
|
|
import com.fr.data.impl.NameDataModel; |
|
|
|
@ -16,6 +15,7 @@ import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
|
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
|
import com.fr.general.IOUtils; |
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
|
|
|
|
|
import javax.swing.Icon; |
|
|
|
@ -40,7 +40,7 @@ public final class MultiResultTableDataWrapper implements TableDataWrapper {
|
|
|
|
|
public static AutoProgressBar loadingBar; |
|
|
|
|
|
|
|
|
|
private NameDataModel dataModel; |
|
|
|
|
private final String dsName; |
|
|
|
|
private final String dataModelName; |
|
|
|
|
private final String tableDataName; |
|
|
|
|
private final MultiResultTableData<?> tableData; |
|
|
|
|
private List<String> columnNameList; |
|
|
|
@ -49,29 +49,45 @@ public final class MultiResultTableDataWrapper implements TableDataWrapper {
|
|
|
|
|
private SwingWorker<?, ?> worker; |
|
|
|
|
private int previewModel; |
|
|
|
|
|
|
|
|
|
public MultiResultTableDataWrapper(MultiResultTableData<?> tableData, String tableDataName, String dsName) { |
|
|
|
|
this(null, tableData, tableDataName, dsName, true); |
|
|
|
|
/** |
|
|
|
|
* @param tableData 数据集 |
|
|
|
|
* @param tableDataName 数据集名称 |
|
|
|
|
* @param dataModelName 数据集的一个结果的名称(全限定名称) |
|
|
|
|
*/ |
|
|
|
|
public MultiResultTableDataWrapper(MultiResultTableData<?> tableData, String tableDataName, String dataModelName) { |
|
|
|
|
this(null, tableData, tableDataName, dataModelName, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public MultiResultTableDataWrapper(MultiResultTableData<?> tableData, String tableDataName, String dsName, boolean needLoad) { |
|
|
|
|
this(null, tableData, tableDataName, dsName, needLoad); |
|
|
|
|
/** |
|
|
|
|
* @param tableData 数据集 |
|
|
|
|
* @param tableDataName 数据集名称 |
|
|
|
|
* @param dataModelName 数据集的一个结果的名称(全限定名称) |
|
|
|
|
* @param needLoad 是否需要加载 |
|
|
|
|
*/ |
|
|
|
|
public MultiResultTableDataWrapper(MultiResultTableData<?> tableData, String tableDataName, String dataModelName, boolean needLoad) { |
|
|
|
|
this(null, tableData, tableDataName, dataModelName, needLoad); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public MultiResultTableDataWrapper(Component component, MultiResultTableData<?> tableData, String tableDataName, String dsName) { |
|
|
|
|
this(component, tableData, tableDataName, dsName, true); |
|
|
|
|
/** |
|
|
|
|
* @param component 父容器 |
|
|
|
|
* @param tableData 数据集 |
|
|
|
|
* @param tableDataName 数据集名称 |
|
|
|
|
* @param dataModelName 数据集的一个结果的名称(全限定名称) |
|
|
|
|
*/ |
|
|
|
|
public MultiResultTableDataWrapper(Component component, MultiResultTableData<?> tableData, String tableDataName, String dataModelName) { |
|
|
|
|
this(component, tableData, tableDataName, dataModelName, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param component loadingBar的父弹框(如果不设置父弹框的话,可能出现loadingBar隐藏在一个弹框后的情况) |
|
|
|
|
* @param tableData 存储过程 |
|
|
|
|
* @param tableDataName 存储过程的名字(某些情况下可以为空) |
|
|
|
|
* @param dsName 存储过程一个返回数据集的名字 |
|
|
|
|
* @param tableData 多结果数据集 |
|
|
|
|
* @param tableDataName 多结果数据集的名字(某些情况下可以为空) |
|
|
|
|
* @param dataModelName 多结果数据集一个返回数据集的名字 |
|
|
|
|
* @param needLoad 是否要加载 |
|
|
|
|
**/ |
|
|
|
|
public MultiResultTableDataWrapper(Component component, MultiResultTableData<?> tableData, String tableDataName, String dsName, boolean needLoad) { |
|
|
|
|
this.dsName = dsName; |
|
|
|
|
public MultiResultTableDataWrapper(Component component, MultiResultTableData<?> tableData, String tableDataName, String dataModelName, boolean needLoad) { |
|
|
|
|
this.dataModelName = dataModelName; |
|
|
|
|
this.tableData = tableData; |
|
|
|
|
/*this.tableData.setCalculating(false);*/ |
|
|
|
|
this.tableDataName = tableDataName; |
|
|
|
|
if (component == null) { |
|
|
|
|
component = new JFrame(); |
|
|
|
@ -133,10 +149,11 @@ public final class MultiResultTableDataWrapper implements TableDataWrapper {
|
|
|
|
|
|
|
|
|
|
private void createResults(boolean needLoadingBar) throws Exception { |
|
|
|
|
|
|
|
|
|
this.dataModel = null; |
|
|
|
|
dataModels = DesignTableDataManager.createLazyDataModel(tableData, needLoadingBar); |
|
|
|
|
if (dataModels != null && dataModels.length != 0) { |
|
|
|
|
for (NameDataModel dataModel : dataModels) { |
|
|
|
|
if (ComparatorUtils.equals(this.dsName, tableDataName + "_" + dataModel.getName())) { |
|
|
|
|
if (ComparatorUtils.equals(this.dataModelName, tableDataName + MultiResultTableData.GROUP_MARKER + dataModel.getName())) { |
|
|
|
|
this.dataModel = dataModel; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -148,10 +165,10 @@ public final class MultiResultTableDataWrapper implements TableDataWrapper {
|
|
|
|
|
public Icon getIcon() { |
|
|
|
|
for (TableDataNameObjectCreator creator : TableDataCreatorProducer.getInstance().createReportTableDataCreator()) { |
|
|
|
|
if (creator.createObject().getClass() == this.tableData.getClass()) { |
|
|
|
|
return BaseUtils.readIcon(creator.getIconPath()); |
|
|
|
|
return IOUtils.readIcon(creator.getIconPath()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return BaseUtils.readIcon("/com/fr/design/images/data/multi.png"); |
|
|
|
|
return IOUtils.readIcon("/com/fr/design/images/data/multi.png"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -179,6 +196,8 @@ public final class MultiResultTableDataWrapper implements TableDataWrapper {
|
|
|
|
|
loadingBar.close(); |
|
|
|
|
PreviewTablePane.resetPreviewTable(); |
|
|
|
|
connectionBar.start(); |
|
|
|
|
|
|
|
|
|
// 存储过程需要先测试一下连接
|
|
|
|
|
if (tableData instanceof StoreProcedure) { |
|
|
|
|
boolean status = DataOperator.getInstance().testConnection(((StoreProcedure) getTableData()).getDatabaseConnection()); |
|
|
|
|
if (!status) { |
|
|
|
@ -189,6 +208,8 @@ public final class MultiResultTableDataWrapper implements TableDataWrapper {
|
|
|
|
|
|
|
|
|
|
connectionBar.close(); |
|
|
|
|
tableData.resetDataModelList(); |
|
|
|
|
|
|
|
|
|
// 获取结果
|
|
|
|
|
createResults(true); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
@ -200,7 +221,7 @@ public final class MultiResultTableDataWrapper implements TableDataWrapper {
|
|
|
|
|
loadingBar.close(); |
|
|
|
|
switch (previewModel) { |
|
|
|
|
case MultiResultTableDataWrapper.PREVIEW_ALL: |
|
|
|
|
PreviewTablePane.previewStoreDataWithAllDs(dataModels); |
|
|
|
|
PreviewTablePane.previewMultiDataModels(dataModels); |
|
|
|
|
break; |
|
|
|
|
case MultiResultTableDataWrapper.PREVIEW_ONE: |
|
|
|
|
previewData(); |
|
|
|
@ -246,12 +267,12 @@ public final class MultiResultTableDataWrapper implements TableDataWrapper {
|
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void previewData(final int keyIndex, final int valueIndex) { |
|
|
|
|
PreviewTablePane.previewStoreData(dataModel, keyIndex, valueIndex); |
|
|
|
|
PreviewTablePane.previewDataModel(dataModel, keyIndex, valueIndex); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 预览返回的所有数据集,只有在编辑存储过程时才用到 |
|
|
|
|
* 预览返回的所有数据集,只有在编辑多结果数据集时才用到 |
|
|
|
|
*/ |
|
|
|
|
public void previewAllTable() { |
|
|
|
|
if (dataModel == null) { |
|
|
|
@ -261,12 +282,16 @@ public final class MultiResultTableDataWrapper implements TableDataWrapper {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
PreviewTablePane.previewStoreDataWithAllDs(dataModels); |
|
|
|
|
PreviewTablePane.previewMultiDataModels(dataModels); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String getTableDataName() { |
|
|
|
|
return dsName; |
|
|
|
|
return tableDataName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getDataModelName() { |
|
|
|
|
return dataModelName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -287,7 +312,7 @@ public final class MultiResultTableDataWrapper implements TableDataWrapper {
|
|
|
|
|
@Override |
|
|
|
|
public boolean equals(Object obj) { |
|
|
|
|
return obj instanceof MultiResultTableDataWrapper |
|
|
|
|
&& ComparatorUtils.equals(this.dsName, ((MultiResultTableDataWrapper) obj).getTableDataName()) |
|
|
|
|
&& ComparatorUtils.equals(this.dataModelName, ((MultiResultTableDataWrapper) obj).getTableDataName()) |
|
|
|
|
&& ComparatorUtils.equals(this.tableData, ((MultiResultTableDataWrapper) obj).getTableData()) |
|
|
|
|
&& ComparatorUtils.equals(this.tableDataName, ((MultiResultTableDataWrapper) obj).getTableDataName()); |
|
|
|
|
|
|
|
|
|