Browse Source

Merge branch 'feature/x' of ssh://code.fineres.com:7999/~roger.chen/design into feature/x

 Conflicts:
	designer-base/src/main/java/com/fr/design/data/datapane/management/search/control/common/TableDataSearchTask.java
feature/x
roger 2 years ago
parent
commit
f2d2052fd9
  1. 22
      designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java
  2. 53
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  3. 55
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataSourceOP.java
  4. 4
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java
  5. 9
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/control/common/TableDataSearchTask.java
  6. 9
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java
  7. 25
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java
  8. 8
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java
  9. 150
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/MultiResultTableDataNameWrapper.java
  10. 296
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/MultiResultTableDataWrapper.java
  11. 4
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureDataWrapper.java
  12. 4
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java

22
designer-base/src/main/java/com/fr/design/data/BasicTableDataTreePane.java

@ -2,9 +2,9 @@ package com.fr.design.data;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.data.MultiResultTableData;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.data.api.StoreProcedureAssist; import com.fr.data.api.StoreProcedureAssist;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.data.datapane.TableDataCreatorProducer; import com.fr.design.data.datapane.TableDataCreatorProducer;
@ -13,7 +13,7 @@ import com.fr.design.data.datapane.TableDataSourceOP;
import com.fr.design.data.datapane.TableDataTree; import com.fr.design.data.datapane.TableDataTree;
import com.fr.design.data.tabledata.ResponseDataSourceChange; import com.fr.design.data.tabledata.ResponseDataSourceChange;
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane;
import com.fr.design.data.tabledata.wrapper.StoreProcedureDataWrapper; import com.fr.design.data.tabledata.wrapper.MultiResultTableDataWrapper;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
@ -441,16 +441,16 @@ public abstract class BasicTableDataTreePane extends DockingView implements Resp
data = selectedNO.getObject(); data = selectedNO.getObject();
} }
try { try {
if (((TableDataWrapper) Objects.requireNonNull(data)).getTableData() instanceof StoreProcedure) { if (((TableDataWrapper) Objects.requireNonNull(data)).getTableData() instanceof MultiResultTableData) {
((StoreProcedure) (((TableDataWrapper) data).getTableData())).resetDataModelList(); ((MultiResultTableData<?>) (((TableDataWrapper) data).getTableData())).resetDataModelList();
if (data instanceof StoreProcedureDataWrapper) { if (data instanceof MultiResultTableDataWrapper) {
StoreProcedureDataWrapper oldSdw = ((StoreProcedureDataWrapper) data); MultiResultTableDataWrapper oldSdw = ((MultiResultTableDataWrapper) data);
StoreProcedureDataWrapper newSdw = new StoreProcedureDataWrapper((StoreProcedure) oldSdw.getTableData(), oldSdw.getStoreprocedureName(), oldSdw.getTableDataName()); MultiResultTableDataWrapper newSdw = new MultiResultTableDataWrapper((MultiResultTableData<?>) oldSdw.getTableData(), oldSdw.getTableDataName(), oldSdw.getTableDataName());
newSdw.previewData(StoreProcedureDataWrapper.PREVIEW_ONE); newSdw.previewData(MultiResultTableDataWrapper.PREVIEW_ONE);
} else { } else {
StoreProcedure storeProcedure = (StoreProcedure) ((TableDataWrapper) data).getTableData(); MultiResultTableData<?> tableData = (MultiResultTableData<?>) ((TableDataWrapper) data).getTableData();
StoreProcedureDataWrapper storeProcedureDataWrapper = new StoreProcedureDataWrapper(storeProcedure, StringUtils.EMPTY, StringUtils.EMPTY); MultiResultTableDataWrapper storeProcedureDataWrapper = new MultiResultTableDataWrapper(tableData, StringUtils.EMPTY, StringUtils.EMPTY);
storeProcedureDataWrapper.previewData(StoreProcedureDataWrapper.PREVIEW_ALL); storeProcedureDataWrapper.previewData(MultiResultTableDataWrapper.PREVIEW_ALL);
} }
} else { } else {
((TableDataWrapper) data).previewData(); ((TableDataWrapper) data).previewData();

53
designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java

@ -3,19 +3,20 @@ package com.fr.design.data;
import com.fr.base.StoreProcedureParameter; import com.fr.base.StoreProcedureParameter;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.concurrent.NamedThreadFactory; import com.fr.concurrent.NamedThreadFactory;
import com.fr.data.MultiResultTableData;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.data.TableDataSourceTailor; import com.fr.data.TableDataSourceTailor;
import com.fr.data.core.DataCoreXmlUtils; import com.fr.data.core.DataCoreXmlUtils;
import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.EmbeddedTableData;
import com.fr.data.impl.storeproc.ProcedureDataModel; import com.fr.data.impl.NameDataModel;
import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.data.impl.storeproc.StoreProcedureConstants; import com.fr.data.impl.storeproc.StoreProcedureConstants;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.data.tabledata.wrapper.MultiResultTableDataNameWrapper;
import com.fr.design.data.tabledata.wrapper.MultiResultTableDataWrapper;
import com.fr.design.data.tabledata.wrapper.ServerTableDataWrapper; import com.fr.design.data.tabledata.wrapper.ServerTableDataWrapper;
import com.fr.design.data.tabledata.wrapper.StoreProcedureDataWrapper;
import com.fr.design.data.tabledata.wrapper.StoreProcedureNameWrapper;
import com.fr.design.data.tabledata.wrapper.TableDataFactory; import com.fr.design.data.tabledata.wrapper.TableDataFactory;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper;
@ -325,28 +326,38 @@ public abstract class DesignTableDataManager {
while (entryIt.hasNext()) { while (entryIt.hasNext()) {
String key = entryIt.next().getKey(); String key = entryIt.next().getKey();
TableDataWrapper tableDataWrapper = resMap.get(key); TableDataWrapper tableDataWrapper = resMap.get(key);
if (tableDataWrapper.getTableData() instanceof StoreProcedure) { if (tableDataWrapper.getTableData() instanceof MultiResultTableData) {
StoreProcedure storeProcedure = (StoreProcedure) tableDataWrapper.getTableData(); MultiResultTableData<?> tableData = (MultiResultTableData<?>) tableDataWrapper.getTableData();
String name = tableDataWrapper.getTableDataName();
List<String> resultNames = tableData.getResultNames();
TableDataWrapper tdw = new MultiResultTableDataNameWrapper(name + "_Table", tableData);
boolean hasSchemaOrResult = false; boolean hasSchemaOrResult = false;
if (tableData instanceof StoreProcedure) {
StoreProcedure storeProcedure = (StoreProcedure) tableData;
StoreProcedureParameter[] parameters = StoreProcedure.getSortPara(storeProcedure.getParameters()); StoreProcedureParameter[] parameters = StoreProcedure.getSortPara(storeProcedure.getParameters());
String name = tableDataWrapper.getTableDataName();
List<String> resultNames = storeProcedure.getResultNames();
TableDataWrapper tdw = new StoreProcedureNameWrapper(name + "_Table", storeProcedure);
for (StoreProcedureParameter parameter : parameters) { for (StoreProcedureParameter parameter : parameters) {
if (parameter.getSchema() != StoreProcedureConstants.IN) { if (parameter.getSchema() != StoreProcedureConstants.IN) {
String parameterName = name + "_" + parameter.getName(); String parameterName = name + "_" + parameter.getName();
TableDataWrapper newTwd = new StoreProcedureDataWrapper(storeProcedure, name, parameterName, false); TableDataWrapper newTwd = new MultiResultTableDataWrapper(storeProcedure, name, parameterName, false);
dsMap.put(parameterName, newTwd); dsMap.put(parameterName, newTwd);
hasSchemaOrResult = true; hasSchemaOrResult = true;
} }
} }
} else {
for (NameDataModel nameDataModel : tableData.getDataModelList()) {
String dmName = name + "_" + nameDataModel.getName();
dsMap.put(nameDataModel.getName(), new MultiResultTableDataWrapper(tableData, name, dmName, false));
}
}
if (!resultNames.isEmpty()) { if (!resultNames.isEmpty()) {
hasSchemaOrResult = true; hasSchemaOrResult = true;
for (int i = 0; i < resultNames.size(); i++) { for (int i = 0; i < resultNames.size(); i++) {
String parameterName = name + "_" + resultNames.get(i); String parameterName = name + "_" + resultNames.get(i);
TableDataWrapper newTwd = new StoreProcedureDataWrapper(storeProcedure, name, parameterName, false); TableDataWrapper newTwd = new MultiResultTableDataWrapper(tableData, name, parameterName, false);
dsMap.put(parameterName, newTwd); dsMap.put(parameterName, newTwd);
} }
} }
@ -429,7 +440,7 @@ public abstract class DesignTableDataManager {
if (globalDsCache.containsKey(name)) { if (globalDsCache.containsKey(name)) {
resMap.put(name, globalDsCache.get(name)); resMap.put(name, globalDsCache.get(name));
} else { } else {
TableDataWrapper tdw = new StoreProcedureNameWrapper(name, storeProcedure); TableDataWrapper tdw = new MultiResultTableDataNameWrapper(name, storeProcedure);
resMap.put(name, tdw); resMap.put(name, tdw);
globalDsCache.put(name, tdw); globalDsCache.put(name, tdw);
} }
@ -599,10 +610,13 @@ public abstract class DesignTableDataManager {
* 所以用该方法不会对一个已经计算了的存储过程重复计算.和分页预览时处理机制一样这样对有多个返回数据集的存储过程来说很有必要 * 所以用该方法不会对一个已经计算了的存储过程重复计算.和分页预览时处理机制一样这样对有多个返回数据集的存储过程来说很有必要
* *
* @param needLoadingBar 是否需要进度条 * @param needLoadingBar 是否需要进度条
* @param storeProcedure 存储过程 * @param tableData 存储过程
* @return 数据 * @return 数据
*/ */
public static ProcedureDataModel[] createLazyDataModel(StoreProcedure storeProcedure, boolean needLoadingBar) throws Exception { public static NameDataModel[] createLazyDataModel(MultiResultTableData<?> tableData, boolean needLoadingBar) throws Exception {
Map<String, Object> parameterMap = new HashMap<>();
if (tableData instanceof StoreProcedure) {
StoreProcedure storeProcedure = (StoreProcedure) tableData;
ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream out = new ByteArrayOutputStream();
XMLPrintWriter writer = XMLPrintWriter.create(out); XMLPrintWriter writer = XMLPrintWriter.create(out);
// 把storeProcedure写成xml文件到out // 把storeProcedure写成xml文件到out
@ -611,17 +625,20 @@ public abstract class DesignTableDataManager {
return storeProcedure.creatLazyDataModel(); return storeProcedure.creatLazyDataModel();
} }
ParameterProvider[] inParameters = DataOperator.getInstance().getStoreProcedureParameters(storeProcedure); ParameterProvider[] inParameters = DataOperator.getInstance().getStoreProcedureParameters(storeProcedure);
Map<String, Object> parameterMap = new HashMap<>();
if (inParameters.length > 0 && !ComparatorUtils.equals(threadLocal.get(), NO_PARAMETER)) {// 检查Parameter.
if (inParameters.length > 0 && !ComparatorUtils.equals(threadLocal.get(), NO_PARAMETER)) {// 检查Parameter.
showParaWindow(parameterMap, inParameters); showParaWindow(parameterMap, inParameters);
} }
storeProcedure.setFirstExpand(false); storeProcedure.setFirstExpand(false);
}
// 存储过程有些特殊处理
// 这个就简单直接获取暂存列表吧
// TODO 参数处理?
if (needLoadingBar) { if (needLoadingBar) {
StoreProcedureDataWrapper.loadingBar.start(); MultiResultTableDataWrapper.loadingBar.start();
} }
return DataOperator.getInstance().previewProcedureDataModel(storeProcedure, parameterMap, 0); return DataOperator.getInstance().previewMultiResultTableData(tableData, parameterMap, 0);
} }
private static void showParaWindow(final Map<String, Object> parameterMap, ParameterProvider[] inParameters) { private static void showParaWindow(final Map<String, Object> parameterMap, ParameterProvider[] inParameters) {

55
designer-base/src/main/java/com/fr/design/data/datapane/TableDataSourceOP.java

@ -2,20 +2,25 @@ package com.fr.design.data.datapane;
import com.fr.base.StoreProcedureParameter; import com.fr.base.StoreProcedureParameter;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.data.MultiResultTableData;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.data.impl.NameDataModel;
import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.data.impl.storeproc.StoreProcedureConstants; import com.fr.data.impl.storeproc.StoreProcedureConstants;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.tabledata.wrapper.StoreProcedureDataWrapper; import com.fr.design.data.tabledata.wrapper.MultiResultTableDataNameWrapper;
import com.fr.design.data.tabledata.wrapper.StoreProcedureNameWrapper; import com.fr.design.data.tabledata.wrapper.MultiResultTableDataWrapper;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.design.gui.itree.refreshabletree.UserObjectOP; import com.fr.design.gui.itree.refreshabletree.UserObjectOP;
import com.fr.general.NameObject; import com.fr.general.NameObject;
import java.util.*; import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
/** /**
@ -155,9 +160,9 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
list.add(initStoreProcedureNode(storeProcedureMap)); list.add(initStoreProcedureNode(storeProcedureMap));
for (int i = 0; i < getNodeArrayFromMap(storeProcedureMap).length; i++) { for (int i = 0; i < getNodeArrayFromMap(storeProcedureMap).length; i++) {
ExpandMutableTreeNode tmpNode = getNodeArrayFromMap(storeProcedureMap)[i]; ExpandMutableTreeNode tmpNode = getNodeArrayFromMap(storeProcedureMap)[i];
if (((NameObject) tmpNode.getUserObject()).getObject() instanceof StoreProcedureNameWrapper) { if (((NameObject) tmpNode.getUserObject()).getObject() instanceof MultiResultTableDataNameWrapper) {
TableData tableData = ((StoreProcedureNameWrapper) (((NameObject) tmpNode.getUserObject()).getObject())).getStoreProcedure(); TableData tableData = ((MultiResultTableDataNameWrapper) (((NameObject) tmpNode.getUserObject()).getObject())).getTableData();
setStoreProcedureTree(tableData, tmpNode); setStoreProcedureTree((MultiResultTableData<?>) tableData, tmpNode);
serverlist.add(tmpNode); serverlist.add(tmpNode);
} }
} }
@ -176,8 +181,8 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
for (int i = 0; i < getNodeArrayFromMap(dataMap).length; i++) { for (int i = 0; i < getNodeArrayFromMap(dataMap).length; i++) {
ExpandMutableTreeNode tmpNode = getNodeArrayFromMap(dataMap)[i]; ExpandMutableTreeNode tmpNode = getNodeArrayFromMap(dataMap)[i];
TableData tableData = ((TableDataWrapper) (((NameObject) tmpNode.getUserObject()).getObject())).getTableData(); TableData tableData = ((TableDataWrapper) (((NameObject) tmpNode.getUserObject()).getObject())).getTableData();
if (tableData instanceof StoreProcedure) { if (tableData instanceof MultiResultTableData<?>) {
setStoreProcedureTree(tableData, tmpNode); setStoreProcedureTree((MultiResultTableData<?>) tableData, tmpNode);
dataList.add(tmpNode); dataList.add(tmpNode);
} else { } else {
dataList.add(tmpNode); dataList.add(tmpNode);
@ -185,31 +190,49 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
} }
} }
protected void setStoreProcedureTree(TableData tableData, ExpandMutableTreeNode tmpNode) { protected void setStoreProcedureTree(MultiResultTableData<?> tableData, ExpandMutableTreeNode tmpNode) {
ArrayList<String> nodeName = new ArrayList<>(); ArrayList<String> nodeName = new ArrayList<>();
StoreProcedure storeProcedure = (StoreProcedure) tableData;
String name = ((NameObject) tmpNode.getUserObject()).getName(); String name = ((NameObject) tmpNode.getUserObject()).getName();
StoreProcedureParameter[] parameters = StoreProcedure.getSortPara(storeProcedure.getParameters()); List<String> resultNames = tableData.getResultNames();
List<String> resultNames = storeProcedure.getResultNames();
boolean hasChild = false; boolean hasChild = false;
tmpNode.remove(0); tmpNode.remove(0);
TableDataWrapper tdw = new StoreProcedureNameWrapper(name + "_Table1", storeProcedure); TableDataWrapper tdw = new MultiResultTableDataNameWrapper(name + "_Table1", tableData);
ExpandMutableTreeNode childNode = new ExpandMutableTreeNode(new NameObject("Table", tdw)); ExpandMutableTreeNode childNode = new ExpandMutableTreeNode(new NameObject("Table", tdw));
childNode.add(new ExpandMutableTreeNode()); childNode.add(new ExpandMutableTreeNode());
tmpNode.add(childNode); tmpNode.add(childNode);
if (tableData instanceof StoreProcedure) {
StoreProcedure storeProcedure = (StoreProcedure) tableData;
StoreProcedureParameter[] parameters = StoreProcedure.getSortPara(storeProcedure.getParameters());
for (StoreProcedureParameter parameter : parameters) { for (StoreProcedureParameter parameter : parameters) {
if (parameter.getSchema() != StoreProcedureConstants.IN) { if (parameter.getSchema() != StoreProcedureConstants.IN) {
if (!nodeName.contains(parameter.getName())) { if (!nodeName.contains(parameter.getName())) {
nodeName.add(parameter.getName()); nodeName.add(parameter.getName());
hasChild = true; hasChild = true;
String parameterName = name + "_" + parameter.getName(); String parameterName = name + "_" + parameter.getName();
TableDataWrapper newTwd = new StoreProcedureDataWrapper(storeProcedure, name, parameterName, false); TableDataWrapper newTwd = new MultiResultTableDataWrapper(tableData, name, parameterName, false);
ExpandMutableTreeNode newChildNode = new ExpandMutableTreeNode(new NameObject(parameter.getName(), newTwd)); ExpandMutableTreeNode newChildNode = new ExpandMutableTreeNode(new NameObject(parameter.getName(), newTwd));
newChildNode.add(new ExpandMutableTreeNode()); newChildNode.add(new ExpandMutableTreeNode());
tmpNode.add(newChildNode); tmpNode.add(newChildNode);
} }
} }
} }
} else {
if (tableData.getDataModelList().size() > 1) {
for (NameDataModel nameDataModel : tableData.getDataModelList()) {
if (!nodeName.contains(nameDataModel.getName())) {
nodeName.add(nameDataModel.getName());
hasChild = true;
String parameterName = name + "_" + nameDataModel.getName();
TableDataWrapper newTwd = new MultiResultTableDataWrapper(tableData, name, parameterName, false);
ExpandMutableTreeNode newChildNode = new ExpandMutableTreeNode(new NameObject(nameDataModel.getName(), newTwd));
newChildNode.add(new ExpandMutableTreeNode());
tmpNode.add(newChildNode);
}
}
}
}
if (!resultNames.isEmpty()) { if (!resultNames.isEmpty()) {
for (String resultName : resultNames) { for (String resultName : resultNames) {
@ -217,7 +240,7 @@ public class TableDataSourceOP implements UserObjectOP<TableDataWrapper> {
nodeName.add(resultName); nodeName.add(resultName);
hasChild = true; hasChild = true;
String parameterName = name + "_" + resultName; String parameterName = name + "_" + resultName;
TableDataWrapper newTwd = new StoreProcedureDataWrapper(storeProcedure, name, parameterName, false); TableDataWrapper newTwd = new MultiResultTableDataWrapper(tableData, name, parameterName, false);
ExpandMutableTreeNode newChildNode = new ExpandMutableTreeNode(new NameObject(resultName, newTwd)); ExpandMutableTreeNode newChildNode = new ExpandMutableTreeNode(new NameObject(resultName, newTwd));
newChildNode.add(new ExpandMutableTreeNode()); newChildNode.add(new ExpandMutableTreeNode());
tmpNode.add(newChildNode); tmpNode.add(newChildNode);

4
designer-base/src/main/java/com/fr/design/data/datapane/TableDataTree.java

@ -1,7 +1,7 @@
package com.fr.design.data.datapane; package com.fr.design.data.datapane;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.MultiResultTableData;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager; import com.fr.design.data.datapane.management.search.TableDataTreeSearchManager;
import com.fr.design.data.tabledata.wrapper.AbstractTableDataWrapper; import com.fr.design.data.tabledata.wrapper.AbstractTableDataWrapper;
@ -462,7 +462,7 @@ public class TableDataTree extends UserObjectRefreshJTree<TableDataSourceOP> {
if (userObject instanceof NameObject) { if (userObject instanceof NameObject) {
NameObject nameObject = (NameObject) userObject; NameObject nameObject = (NameObject) userObject;
TableDataWrapper tableDataWrapper = (TableDataWrapper) nameObject.getObject(); TableDataWrapper tableDataWrapper = (TableDataWrapper) nameObject.getObject();
return tableDataWrapper.getTableData() instanceof StoreProcedure; return tableDataWrapper.getTableData() instanceof MultiResultTableData<?>;
} }
return false; return false;
} }

9
designer-base/src/main/java/com/fr/design/data/datapane/management/search/control/common/TableDataSearchTask.java

@ -1,5 +1,6 @@
package com.fr.design.data.datapane.management.search.control.common; package com.fr.design.data.datapane.management.search.control.common;
import com.fr.design.data.tabledata.wrapper.MultiResultTableDataWrapper;
import com.fr.design.search.control.TreeSearchCallback; import com.fr.design.search.control.TreeSearchCallback;
import com.fr.design.search.control.TreeSearchResult; import com.fr.design.search.control.TreeSearchResult;
import com.fr.design.search.control.TreeSearchTask; import com.fr.design.search.control.TreeSearchTask;
@ -39,7 +40,7 @@ public class TableDataSearchTask implements TreeSearchTask {
TreeSearchResult result; TreeSearchResult result;
try { try {
if (isTableDataStoreProcedure(tableDataWrapper)) { if (isTableDataStoreProcedure(tableDataWrapper)) {
result = dealWithStoreProcedureTableDataWrapper((StoreProcedureDataWrapper) tableDataWrapper); result = dealWithStoreProcedureTableDataWrapper((MultiResultTableDataWrapper) tableDataWrapper);
} else { } else {
result = dealWithCommonTableDataWrapper(tableDataWrapper); result = dealWithCommonTableDataWrapper(tableDataWrapper);
} }
@ -87,11 +88,11 @@ public class TableDataSearchTask implements TreeSearchTask {
* *
* @param procedureDataWrapper * @param procedureDataWrapper
*/ */
private TreeSearchResult dealWithStoreProcedureTableDataWrapper(StoreProcedureDataWrapper procedureDataWrapper) { private TreeSearchResult dealWithStoreProcedureTableDataWrapper(MultiResultTableDataWrapper procedureDataWrapper) {
// 存储过程数据集名称,例如 Proc1_Table1 // 存储过程数据集名称,例如 Proc1_Table1
String tableDataName = procedureDataWrapper.getTableDataName(); String tableDataName = procedureDataWrapper.getTableDataName();
// 存储过程名称,例如 Proc1 // 存储过程名称,例如 Proc1
String storeProcedureName = procedureDataWrapper.getStoreprocedureName(); String storeProcedureName = procedureDataWrapper.getTableDataName();
// 存储过程子表名称,例如 Table1 // 存储过程子表名称,例如 Table1
String tableName = tableDataName.replaceFirst(storeProcedureName, StringUtils.EMPTY).replaceFirst("_", StringUtils.EMPTY); String tableName = tableDataName.replaceFirst(storeProcedureName, StringUtils.EMPTY).replaceFirst("_", StringUtils.EMPTY);
boolean isStoreProcedureNameMatch = isMatchSearch(storeProcedureName, searchText); boolean isStoreProcedureNameMatch = isMatchSearch(storeProcedureName, searchText);
@ -132,7 +133,7 @@ public class TableDataSearchTask implements TreeSearchTask {
* @return * @return
*/ */
private boolean isTableDataStoreProcedure(TableDataWrapper tableDataWrapper) { private boolean isTableDataStoreProcedure(TableDataWrapper tableDataWrapper) {
return tableDataWrapper instanceof StoreProcedureDataWrapper; return tableDataWrapper instanceof MultiResultTableDataWrapper;
} }
/** /**

9
designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java

@ -3,7 +3,7 @@ package com.fr.design.data.datapane.preview;
import com.fr.cache.list.IntList; import com.fr.cache.list.IntList;
import com.fr.data.AbstractDataModel; import com.fr.data.AbstractDataModel;
import com.fr.data.impl.EmbeddedTableData.EmbeddedTDDataModel; import com.fr.data.impl.EmbeddedTableData.EmbeddedTDDataModel;
import com.fr.data.impl.storeproc.ProcedureDataModel; import com.fr.data.impl.NameDataModel;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.general.data.DataModel; import com.fr.general.data.DataModel;
import com.fr.general.data.TableDataException; import com.fr.general.data.TableDataException;
@ -32,8 +32,9 @@ public class PreviewTableModel extends AbstractTableModel {
} }
public PreviewTableModel(DataModel sourceResultSet, int maxRowCount) { public PreviewTableModel(DataModel sourceResultSet, int maxRowCount) {
if (sourceResultSet instanceof ProcedureDataModel) { // 如果是这种NameDataModel,根据maxRowCount截断一下
ProcedureDataModel rs = (ProcedureDataModel) sourceResultSet; if (sourceResultSet instanceof NameDataModel) {
NameDataModel rs = (NameDataModel) sourceResultSet;
try { try {
this.dataModel = createRowDataModel(rs, maxRowCount); this.dataModel = createRowDataModel(rs, maxRowCount);
} catch (TableDataException e) { } catch (TableDataException e) {
@ -45,7 +46,7 @@ public class PreviewTableModel extends AbstractTableModel {
} }
} }
public static DataModel createRowDataModel(final ProcedureDataModel rs, int maxRowCount) throws TableDataException { public static DataModel createRowDataModel(final NameDataModel rs, int maxRowCount) throws TableDataException {
int rowCount = rs.getRowCount(); int rowCount = rs.getRowCount();
if (maxRowCount == 0) { if (maxRowCount == 0) {
maxRowCount = rowCount; maxRowCount = rowCount;

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

@ -8,7 +8,8 @@ import com.fr.base.TableData;
import com.fr.data.TableDataSource; import com.fr.data.TableDataSource;
import com.fr.data.impl.DBTableData; import com.fr.data.impl.DBTableData;
import com.fr.data.impl.EmbeddedTableData; import com.fr.data.impl.EmbeddedTableData;
import com.fr.data.impl.storeproc.ProcedureDataModel;
import com.fr.data.impl.NameDataModel;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
@ -28,6 +29,7 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.ui.util.UIUtil; 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.general.data.DataModel;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -55,6 +57,7 @@ import java.awt.event.MouseEvent;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.concurrent.CancellationException; import java.util.concurrent.CancellationException;
/** /**
@ -62,13 +65,13 @@ import java.util.concurrent.CancellationException;
*/ */
public class PreviewTablePane extends BasicPane { public class PreviewTablePane extends BasicPane {
private TableData tableData; private TableData tableData;
private ProcedureDataModel storeProcedureDataModel; private NameDataModel dataModel;
private static UINumberField maxPreviewNumberField; private UINumberField maxPreviewNumberField;
private UINumberField currentRowsField; private UINumberField currentRowsField;
private JTable preveiwTable; private JTable preveiwTable;
private static AutoProgressBar progressBar; private static AutoProgressBar progressBar;
private AutoProgressBar connectionBar; private AutoProgressBar connectionBar;
private java.util.List<LoadedEventListener> listeners = new ArrayList<LoadedEventListener>(); private List<LoadedEventListener> listeners = new ArrayList<LoadedEventListener>();
private BasicDialog dialog; private BasicDialog dialog;
private SwingWorker worker; private SwingWorker worker;
@ -152,7 +155,7 @@ public class PreviewTablePane extends BasicPane {
refreshLabel.setBackground(java.awt.Color.WHITE); refreshLabel.setBackground(java.awt.Color.WHITE);
try { try {
populate(tableData); populate(tableData);
if (storeProcedureDataModel != null) { if (dataModel != null) {
populateStoreDataSQL(); populateStoreDataSQL();
} }
} catch (Exception e1) { } catch (Exception e1) {
@ -423,7 +426,7 @@ public class PreviewTablePane extends BasicPane {
* *
* @param storeProcedureDataModel storeProcedureDataModel * @param storeProcedureDataModel storeProcedureDataModel
*/ */
public static void previewStoreData(ProcedureDataModel storeProcedureDataModel) { public static void previewStoreData(NameDataModel storeProcedureDataModel) {
previewStoreData(storeProcedureDataModel, -1, -1); previewStoreData(storeProcedureDataModel, -1, -1);
} }
@ -434,9 +437,9 @@ public class PreviewTablePane extends BasicPane {
* @param keyIndex 实际值 * @param keyIndex 实际值
* @param valueIndex 显示值 * @param valueIndex 显示值
*/ */
public static void previewStoreData(final ProcedureDataModel storeProcedureDataModel, final int keyIndex, final int valueIndex) { public static void previewStoreData(final NameDataModel storeProcedureDataModel, final int keyIndex, final int valueIndex) {
final PreviewTablePane previewTablePane = new PreviewTablePane(); final PreviewTablePane previewTablePane = new PreviewTablePane();
previewTablePane.storeProcedureDataModel = storeProcedureDataModel; previewTablePane.dataModel = storeProcedureDataModel;
previewTablePane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Data"))); previewTablePane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Data")));
try { try {
@ -462,12 +465,12 @@ public class PreviewTablePane extends BasicPane {
* *
* @param storeProcedureDataModels storeProcedureDataModels * @param storeProcedureDataModels storeProcedureDataModels
*/ */
public static void previewStoreDataWithAllDs(ProcedureDataModel[] storeProcedureDataModels) { public static void previewStoreDataWithAllDs(NameDataModel[] storeProcedureDataModels) {
UITabbedPane tabPreviewpane = new UITabbedPane(); UITabbedPane tabPreviewpane = new UITabbedPane();
int tableSize = storeProcedureDataModels.length; int tableSize = storeProcedureDataModels.length;
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.dataModel = storeProcedureDataModels[i];
previewTablePane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Data"))); previewTablePane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Data")));
try { try {
previewTablePane.populateStoreDataSQL(); previewTablePane.populateStoreDataSQL();
@ -493,7 +496,7 @@ public class PreviewTablePane extends BasicPane {
private void populateStoreDataSQL() throws Exception { private void populateStoreDataSQL() throws Exception {
PreviewTableModel previewModel; PreviewTableModel previewModel;
try { try {
previewModel = new PreviewTableModel(storeProcedureDataModel, (int) maxPreviewNumberField.getValue()); previewModel = new PreviewTableModel(dataModel, (int) maxPreviewNumberField.getValue());
} catch (Exception e) { } catch (Exception e) {
previewModel = new PreviewTableModel((int) maxPreviewNumberField.getValue()); previewModel = new PreviewTableModel((int) maxPreviewNumberField.getValue());
} }

8
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/ProcedureDataPane.java

@ -19,7 +19,7 @@ import com.fr.design.data.datapane.connect.ConnectionTableProcedurePane.DoubleCl
import com.fr.design.data.datapane.sqlpane.SQLEditPane; import com.fr.design.data.datapane.sqlpane.SQLEditPane;
import com.fr.design.data.tabledata.ResponseDataSourceChange; import com.fr.design.data.tabledata.ResponseDataSourceChange;
import com.fr.design.data.tabledata.StoreProcedureWorkerListener; import com.fr.design.data.tabledata.StoreProcedureWorkerListener;
import com.fr.design.data.tabledata.wrapper.StoreProcedureDataWrapper; import com.fr.design.data.tabledata.wrapper.MultiResultTableDataWrapper;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
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;
@ -290,7 +290,7 @@ public class ProcedureDataPane extends AbstractTableDataPane<StoreProcedure> imp
protected Void doInBackground() throws Exception { protected Void doInBackground() throws Exception {
DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER); DesignTableDataManager.setThreadLocal(DesignTableDataManager.NO_PARAMETER);
sp.setCalculating(true); sp.setCalculating(true);
ProcedureDataModel[] dataModels = DesignTableDataManager.createLazyDataModel(sp, false); ProcedureDataModel[] dataModels = (ProcedureDataModel[]) DesignTableDataManager.createLazyDataModel(sp, false);
sp.refreshDataModelListAndResultNames(dataModels); sp.refreshDataModelListAndResultNames(dataModels);
return null; return null;
} }
@ -382,8 +382,8 @@ public class ProcedureDataPane extends AbstractTableDataPane<StoreProcedure> imp
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
StoreProcedure sp = updateBeanWithOutExecute(); StoreProcedure sp = updateBeanWithOutExecute();
StoreProcedureDataWrapper storeProcedureDataWrapper = new StoreProcedureDataWrapper(this.procedureDataPane, sp, StringUtils.EMPTY, queryText.getText()); MultiResultTableDataWrapper wrapper = new MultiResultTableDataWrapper(this.procedureDataPane, sp, StringUtils.EMPTY, queryText.getText());
storeProcedureDataWrapper.previewData(StoreProcedureDataWrapper.PREVIEW_ALL); wrapper.previewData(MultiResultTableDataWrapper.PREVIEW_ALL);
} }
} }

150
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/MultiResultTableDataNameWrapper.java

@ -0,0 +1,150 @@
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;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataCreatorProducer;
import com.fr.design.data.datapane.TableDataNameObjectCreator;
import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode;
import com.fr.log.FineLoggerFactory;
import com.fr.workspace.WorkContext;
import javax.swing.Icon;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* 多结果数据集-结果包装
*
* @author rinoux
* @version 11.0
* Created by rinoux on 2022/8/12
*/
public final class MultiResultTableDataNameWrapper implements TableDataWrapper {
private NameDataModel dataModel;
private final String name;
private final MultiResultTableData<?> tableData;
private List<String> columnNameList;
/**
* @param name 存储过程本身名字
* @param storeProcedure 存储过程
*/
public MultiResultTableDataNameWrapper(String name, MultiResultTableData<?> storeProcedure) {
this.name = name;
this.tableData = storeProcedure;
}
/**
* 生成子节点
*
* @return 子节点
*/
public ExpandMutableTreeNode[] load() {
List<String> namelist = calculateColumnNameList();
ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[namelist.size()];
for (int i = 0; i < res.length; i++) {
res[i] = new ExpandMutableTreeNode(namelist.get(i));
}
return res;
}
@Override
public String getTableDataName() {
return name;
}
@Override
public TableData getTableData() {
return tableData;
}
@Override
public Icon getIcon() {
// TODO
for (TableDataNameObjectCreator creator : TableDataCreatorProducer.getInstance().createReportTableDataCreator()) {
if (creator.createObject().getClass() == this.tableData.getClass()) {
return BaseUtils.readIcon(creator.getIconPath());
}
}
return BaseUtils.readIcon("/com/fr/design/images/data/multi.png");
}
private void createResult(boolean needLoadingBar) {
try {
dataModel = DesignTableDataManager.createLazyDataModel(tableData, needLoadingBar)[0];
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
/**
* 数据集执行结果返回的所有字段
* <p/>
* TODO:要不要加上Exception呢个人感觉很有必要
*
* @return 字段
*/
public List<String> calculateColumnNameList() {
if (columnNameList != null) {
return columnNameList;
}
columnNameList = new ArrayList<String>();
if (!WorkContext.getCurrent().isLocal()) {
try {
createResult(false);
columnNameList = Arrays.asList(dataModel.getColumnNames());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
} else {
if (dataModel == null) {
createResult(false);
}
if (dataModel != null) {
columnNameList = Arrays.asList(dataModel.getColumnNames());
}
}
return columnNameList;
}
/**
* 预览数据集
*/
public void previewData() {
if (dataModel == null) {
createResult(true);
}
PreviewTablePane.previewStoreData(dataModel);
}
/**
* 预览数据集带有显示值和实际值的标记结果
*
* @param keyIndex 显示值Index
* @param valueIndex 实际值index
*/
public void previewData(int keyIndex, int valueIndex) {
if (dataModel == null) {
createResult(true);
}
PreviewTablePane.previewStoreData(dataModel, keyIndex, valueIndex);
}
/**
* 是否异常
*
* @return 异常返回true
*/
public boolean isUnusual() {
return false;
}
}

296
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/MultiResultTableDataWrapper.java

@ -0,0 +1,296 @@
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;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.data.operator.DataOperator;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataCreatorProducer;
import com.fr.design.data.datapane.TableDataNameObjectCreator;
import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.iprogressbar.AutoProgressBar;
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.log.FineLoggerFactory;
import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.SwingWorker;
import java.awt.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CancellationException;
/**
* 多结果数据集包装
*
* @author rinoux
* @version 11.0
* Created by rinoux on 2022/8/12
*/
public final class MultiResultTableDataWrapper implements TableDataWrapper {
public static final int PREVIEW_ALL = 0;
public static final int PREVIEW_ONE = 1;
public static AutoProgressBar loadingBar;
private NameDataModel dataModel;
private final String dsName;
private final String tableDataName;
private final MultiResultTableData<?> tableData;
private List<String> columnNameList;
private AutoProgressBar connectionBar;
private NameDataModel[] dataModels;
private SwingWorker<?, ?> worker;
private int previewModel;
public MultiResultTableDataWrapper(MultiResultTableData<?> tableData, String tableDataName, String dsName) {
this(null, tableData, tableDataName, dsName, true);
}
public MultiResultTableDataWrapper(MultiResultTableData<?> tableData, String tableDataName, String dsName, boolean needLoad) {
this(null, tableData, tableDataName, dsName, needLoad);
}
public MultiResultTableDataWrapper(Component component, MultiResultTableData<?> tableData, String tableDataName, String dsName) {
this(component, tableData, tableDataName, dsName, true);
}
/**
* @param component loadingBar的父弹框如果不设置父弹框的话可能出现loadingBar隐藏在一个弹框后的情况
* @param tableData 存储过程
* @param tableDataName 存储过程的名字(某些情况下可以为空)
* @param dsName 存储过程一个返回数据集的名字
* @param needLoad 是否要加载
**/
public MultiResultTableDataWrapper(Component component, MultiResultTableData<?> tableData, String tableDataName, String dsName, boolean needLoad) {
this.dsName = dsName;
this.tableData = tableData;
this.tableData.setCalculating(false);
this.tableDataName = tableDataName;
if (component == null) {
component = new JFrame();
}
if (needLoad) {
setWorker(component);
}
loadingBar = new AutoProgressBar(component, Toolkit.i18nText("Fine-Design_Basic_Loading_Data"), "", 0, 100) {
@Override
public void doMonitorCanceled() {
getWorker().cancel(true);
}
};
}
/**
* 数据集执行结果返回的所有字段
*
* @return 数据集执行结果返回的所有字段
* @date 2014-12-3-下午7:43:17
*/
@Override
public List<String> calculateColumnNameList() {
if (columnNameList != null) {
return columnNameList;
}
try {
createResults(false);
} catch (Exception e) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Engine_No_TableData"));
return new ArrayList<String>();
}
columnNameList = Arrays.asList(dataModel.getColumnNames());
return columnNameList;
}
/**
* 生成子节点
*
* @return 节点数组
* @date 2014-12-3-下午7:06:47
*/
@Override
public ExpandMutableTreeNode[] load() {
List<String> namelist;
if (tableData.isCalculating()) {
namelist = Arrays.asList(new String[0]);
} else {
namelist = calculateColumnNameList();
}
ExpandMutableTreeNode[] res = new ExpandMutableTreeNode[namelist.size()];
for (int i = 0; i < res.length; i++) {
res[i] = new ExpandMutableTreeNode(namelist.get(i));
}
return res;
}
private void createResults(boolean needLoadingBar) throws Exception {
dataModels = DesignTableDataManager.createLazyDataModel(tableData, needLoadingBar);
if (dataModels != null && dataModels.length != 0) {
for (NameDataModel dataModel : dataModels) {
if (ComparatorUtils.equals(this.dsName, tableDataName + "_" + dataModel.getName())) {
this.dataModel = dataModel;
break;
}
}
}
}
@Override
public Icon getIcon() {
for (TableDataNameObjectCreator creator : TableDataCreatorProducer.getInstance().createReportTableDataCreator()) {
if (creator.createObject().getClass() == this.tableData.getClass()) {
return BaseUtils.readIcon(creator.getIconPath());
}
}
return BaseUtils.readIcon("/com/fr/design/images/data/multi.png");
}
/**
* 预览数据
*
* @param previewModel 预览模式, 全部还是一个
* @date 2014-12-3-下午7:05:50
*/
public void previewData(final int previewModel) {
this.previewModel = previewModel;
connectionBar = new AutoProgressBar(new JFrame(), Toolkit.i18nText("Fine-Design_Basic_Utils_Now_Create_Connection"), "", 0, 100) {
@Override
public void doMonitorCanceled() {
connectionBar.close();
worker.cancel(true);
}
};
worker.execute();
}
private void setWorker(final Component parent) {
worker = new SwingWorker<Void, Void>() {
@Override
protected Void doInBackground() throws Exception {
loadingBar.close();
PreviewTablePane.resetPreviewTable();
connectionBar.start();
if (tableData instanceof StoreProcedure) {
boolean status = DataOperator.getInstance().testConnection(((StoreProcedure) getTableData()).getDatabaseConnection());
if (!status) {
connectionBar.close();
throw new Exception(Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed"));
}
}
connectionBar.close();
tableData.resetDataModelList();
createResults(true);
return null;
}
@Override
public void done() {
try {
get();
loadingBar.close();
switch (previewModel) {
case MultiResultTableDataWrapper.PREVIEW_ALL:
PreviewTablePane.previewStoreDataWithAllDs(dataModels);
break;
case MultiResultTableDataWrapper.PREVIEW_ONE:
previewData();
break;
default:
break;
}
} catch (Exception e) {
loadingBar.close();
if (!(e instanceof CancellationException)) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog(parent, e.getMessage());
}
}
}
};
}
private SwingWorker getWorker() {
return this.worker;
}
// august:这个只是预览返回的一个数据集
/**
* 预览返回的一个数据集
*
* @date 2014-12-3-下午7:42:53
*/
@Override
public void previewData() {
previewData(-1, -1);
}
// august:这个只是预览返回的一个数据集
/**
* 预览返回的一个数据集带有显示值和实际值的标记结果
*
* @param keyIndex 实际值
* @param valueIndex 显示值
* @date 2014-12-3-下午7:42:27
*/
@Override
public void previewData(final int keyIndex, final int valueIndex) {
PreviewTablePane.previewStoreData(dataModel, keyIndex, valueIndex);
}
/**
* 预览返回的所有数据集只有在编辑存储过程时才用到
*/
public void previewAllTable() {
if (dataModel == null) {
try {
createResults(true);
} catch (Exception e) {
return;
}
}
PreviewTablePane.previewStoreDataWithAllDs(dataModels);
}
@Override
public String getTableDataName() {
return dsName;
}
@Override
public TableData getTableData() {
return tableData;
}
/**
* 是否异常
*
* @return 是否异常
*/
@Override
public boolean isUnusual() {
return false;
}
@Override
public boolean equals(Object obj) {
return obj instanceof MultiResultTableDataWrapper
&& ComparatorUtils.equals(this.dsName, ((MultiResultTableDataWrapper) obj).getTableDataName())
&& ComparatorUtils.equals(this.tableData, ((MultiResultTableDataWrapper) obj).getTableData())
&& ComparatorUtils.equals(this.tableDataName, ((MultiResultTableDataWrapper) obj).getTableDataName());
}
}

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

@ -36,7 +36,9 @@ import java.util.concurrent.CancellationException;
* *
* @author zhou * @author zhou
* @since 2012-4-12上午10:29:15 * @since 2012-4-12上午10:29:15
* @deprecated 请勿使用{@link MultiResultTableDataWrapper}
*/ */
@Deprecated
public final class StoreProcedureDataWrapper implements TableDataWrapper { public final class StoreProcedureDataWrapper implements TableDataWrapper {
public static final int PREVIEW_ALL = 0; public static final int PREVIEW_ALL = 0;
public static final int PREVIEW_ONE = 1; public static final int PREVIEW_ONE = 1;
@ -135,7 +137,7 @@ public final class StoreProcedureDataWrapper implements TableDataWrapper {
} }
private void createStore(boolean needLoadingBar) throws Exception { private void createStore(boolean needLoadingBar) throws Exception {
dataModels = DesignTableDataManager.createLazyDataModel(storeProcedure, needLoadingBar); dataModels = (ProcedureDataModel[]) DesignTableDataManager.createLazyDataModel(storeProcedure, needLoadingBar);
if (dataModels != null && dataModels.length != 0) { if (dataModels != null && dataModels.length != 0) {
for (ProcedureDataModel dataModel : dataModels) { for (ProcedureDataModel dataModel : dataModels) {
if (ComparatorUtils.equals(this.dsName, storeprocedureName + "_" + dataModel.getName())) { if (ComparatorUtils.equals(this.dsName, storeprocedureName + "_" + dataModel.getName())) {

4
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/StoreProcedureNameWrapper.java

@ -27,7 +27,9 @@ import java.util.List;
* *
* @author zhou * @author zhou
* @since 2012-4-12上午10:29:15 * @since 2012-4-12上午10:29:15
* @deprecated 请勿使用{@link MultiResultTableDataNameWrapper}
*/ */
@Deprecated
public final class StoreProcedureNameWrapper implements TableDataWrapper { public final class StoreProcedureNameWrapper implements TableDataWrapper {
private ProcedureDataModel procedureDataModel; private ProcedureDataModel procedureDataModel;
private String name; private String name;
@ -74,7 +76,7 @@ public final class StoreProcedureNameWrapper implements TableDataWrapper {
private void createStore(boolean needLoadingBar) { private void createStore(boolean needLoadingBar) {
try { try {
procedureDataModel = DesignTableDataManager.createLazyDataModel(storeProcedure, needLoadingBar)[0]; procedureDataModel = (ProcedureDataModel) DesignTableDataManager.createLazyDataModel(storeProcedure, needLoadingBar)[0];
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }

Loading…
Cancel
Save