Browse Source

RES-2 关联数据集预览问题

master
finereport 7 years ago
parent
commit
cb9cfc27ef
  1. 62
      designer_base/src/com/fr/design/data/DesignTableDataManager.java
  2. 5
      designer_base/src/com/fr/design/data/datapane/preview/PreviewTablePane.java
  3. 2
      designer_base/src/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java
  4. 13
      designer_base/src/com/fr/env/RemoteEnv.java

62
designer_base/src/com/fr/design/data/DesignTableDataManager.java

@ -6,19 +6,24 @@ import com.fr.base.StoreProcedureParameter;
import com.fr.base.TableData;
import com.fr.data.TableDataSource;
import com.fr.data.core.DataCoreXmlUtils;
import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.data.impl.EmbeddedTableData;
import com.fr.data.impl.storeproc.ProcedureDataModel;
import com.fr.data.impl.storeproc.StoreProcedure;
import com.fr.data.impl.storeproc.StoreProcedureConstants;
import com.fr.design.data.tabledata.wrapper.*;
import com.fr.design.DesignModelAdapter;
import com.fr.design.data.datapane.preview.PreviewTablePane;
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.TableDataWrapper;
import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.iprogressbar.AutoProgressBar;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.parameter.ParameterInputPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.file.DatasourceManager;
import com.fr.file.DatasourceManagerProvider;
import com.fr.general.ComparatorUtils;
@ -34,9 +39,16 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.io.ByteArrayOutputStream;
import java.text.Collator;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.Timer;
import java.util.TimerTask;
/**
* 设计器管理操作数据集的类:
@ -55,11 +67,11 @@ public abstract class DesignTableDataManager {
* 其实globalDsCache没有绝对的必要只是为了操作方便如果没有它那么每次清空服务器数据集或者存储过程的时候还要去遍历找一下
* 这个操作可能比较复杂 从减少代码复杂度的角度看还是很有必要的
*/
private static java.util.Map<String, TableDataWrapper> globalDsCache = new ConcurrentHashMap<String, TableDataWrapper>();
private static java.util.Map<String, String> dsNameChangedMap = new ConcurrentHashMap<String, String>();
private static java.util.Map<String, TableDataWrapper> globalDsCache = new java.util.HashMap<String, TableDataWrapper>();
private static java.util.Map<String, String> dsNameChangedMap = new HashMap<String, String>();
// private static List<ChangeListener> dsListeners = new ArrayList<ChangeListener>();
private static Map<String, List<ChangeListener>> dsListenersMap = new ConcurrentHashMap<String, List<ChangeListener>>();;
private static Map<String, List<ChangeListener>> dsListenersMap = new HashMap<String, List<ChangeListener>>();
public static String NO_PARAMETER = "no_paramater_pane";
@ -352,7 +364,20 @@ public abstract class DesignTableDataManager {
* @throws Exception 异常
*/
public static EmbeddedTableData previewTableDataNeedInputParameters(TableData tabledata, int rowCount, boolean needLoadingBar) throws Exception {
return previewTableData(tabledata, rowCount, true, needLoadingBar);
return previewTableData(null, tabledata, rowCount, true, needLoadingBar);
}
/**
* 预览需要参数的数据集
*
* @param tabledata 数据集
* @param rowCount 需要预览的行数
* @param needLoadingBar 是否需要加载进度条
* @return 数据集
* @throws Exception 异常
*/
public static EmbeddedTableData previewTableDataNeedInputParameters(TableDataSource tableDataSource, TableData tabledata, int rowCount, boolean needLoadingBar) throws Exception {
return previewTableData(tableDataSource, tabledata, rowCount, true, needLoadingBar);
}
/**
@ -365,7 +390,20 @@ public abstract class DesignTableDataManager {
* @throws Exception 异常
*/
public static EmbeddedTableData previewTableDataNotNeedInputParameters(TableData tabledata, int rowCount, boolean needLoadingBar) throws Exception {
return previewTableData(tabledata, rowCount, false, needLoadingBar);
return previewTableData(null, tabledata, rowCount, false, needLoadingBar);
}
/**
* 预览不需要参数的数据集
*
* @param tabledata 数据集
* @param rowCount 需要预览的行数
* @param needLoadingBar 是否需要加载进度条
* @return 数据集
* @throws Exception 异常
*/
public static EmbeddedTableData previewTableDataNotNeedInputParameters(TableDataSource tableDataSource, TableData tabledata, int rowCount, boolean needLoadingBar) throws Exception {
return previewTableData(tableDataSource, tabledata, rowCount, false, needLoadingBar);
}
/**
@ -377,7 +415,7 @@ public abstract class DesignTableDataManager {
* 而获取数据集的字段名字时则没必要
* @return
*/
private static EmbeddedTableData previewTableData(TableData tabledata, int rowCount, boolean isMustInputParameters, boolean needLoadingBar) throws Exception {
private static EmbeddedTableData previewTableData(TableDataSource tableDataSource, TableData tabledata, int rowCount, boolean isMustInputParameters, boolean needLoadingBar) throws Exception {
final AutoProgressBar loadingBar = PreviewTablePane.getInstance().getProgressBar();
Env currentEnv = FRContext.getCurrentEnv();
ParameterProvider[] parameters = currentEnv.getTableDataParameters(tabledata);
@ -407,7 +445,7 @@ public abstract class DesignTableDataManager {
parameter.setValue(parameterMap.get(parameter.getName()));
}
}
return currentEnv.previewTableData(tabledata, parameterMap, rowCount);
return currentEnv.previewTableData(tableDataSource, tabledata, parameterMap, rowCount);
} catch (TableDataException e) {
throw new TableDataException(e.getMessage(), e);
} finally {

5
designer_base/src/com/fr/design/data/datapane/preview/PreviewTablePane.java

@ -6,6 +6,7 @@ package com.fr.design.data.datapane.preview;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.TableData;
import com.fr.data.TableDataSource;
import com.fr.data.impl.DBTableData;
import com.fr.data.impl.EmbeddedTableData;
import com.fr.data.impl.storeproc.ProcedureDataModel;
@ -13,6 +14,7 @@ import com.fr.design.DesignerEnvManager;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.BasicPane;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.frpane.UITabbedPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iprogressbar.AutoProgressBar;
@ -362,7 +364,8 @@ public class PreviewTablePane extends BasicPane {
}
}
connectionBar.close();
previewTableData = DesignTableDataManager.previewTableDataNeedInputParameters(tableData, (int) maxPreviewNumberField.getValue(), true);
TableDataSource dataSource = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getTarget();
previewTableData = DesignTableDataManager.previewTableDataNeedInputParameters(dataSource, tableData, (int) maxPreviewNumberField.getValue(), true);
// parameterInputDialog
// update之后的parameters,转成一个parameterMap,用于预览TableData
PreviewTableModel previewModel = new PreviewTableModel(previewTableData.createDataModel(null), (int) maxPreviewNumberField.getValue());

2
designer_base/src/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java

@ -58,7 +58,7 @@ public abstract class AbstractTableDataWrapper implements TableDataWrapper {
EmbeddedTableData embeddedTableData = null;
try {
embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tabledata, TableData.RESULT_NOT_NEED, false);
embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tds, tabledata, TableData.RESULT_NOT_NEED, false);
} catch (Exception e) {
if (e.getMessage()!=null) {
DesignUtils.errorMessage(e.getMessage());

13
designer_base/src/com/fr/env/RemoteEnv.java vendored

@ -10,6 +10,7 @@ import com.fr.base.StoreProcedureParameter;
import com.fr.base.TableData;
import com.fr.base.Utils;
import com.fr.base.remote.RemoteDeziConstants;
import com.fr.data.TableDataSource;
import com.fr.data.core.DataCoreUtils;
import com.fr.data.core.db.TableProcedure;
import com.fr.data.impl.Connection;
@ -1253,6 +1254,11 @@ public class RemoteEnv extends AbstractEnv {
return DavXMLUtils.readXMLParameters(input);
}
@Override
public EmbeddedTableData previewTableData(Object tableData, Map parameterMap, int rowCount) throws Exception {
return previewTableData(null, tableData, parameterMap, rowCount);
}
/**
* 根据指定的参数生成一个实际可预览的数据集
*
@ -1262,7 +1268,7 @@ public class RemoteEnv extends AbstractEnv {
* @return 实际的二维数据集
* @throws Exception 如果生成数据失败则抛出此异常
*/
public EmbeddedTableData previewTableData(Object tableData, java.util.Map parameterMap, int rowCount) throws Exception {
public EmbeddedTableData previewTableData(TableDataSource dataSource, Object tableData, java.util.Map parameterMap, int rowCount) throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
// 把tableData写成xml文件到out
@ -1301,6 +1307,11 @@ public class RemoteEnv extends AbstractEnv {
return previewTableData(tableData, parameterMap, -1);
}
@Override
public Object previewTableData(TableDataSource dataSource, Object tableData, Map parameterMap, int start, int end, String[] cols, int[] colIdx) throws Exception {
return previewTableData(dataSource, tableData, parameterMap, -1);
}
/**
* nameValuePairs,这个参数要接着this.path,拼成一个URL,否则服务器端req.getParameter是无法得到的
*

Loading…
Cancel
Save