Browse Source

Merge pull request #1260 in BA/design from master to release/8.0

* commit 'cb9cfc27efff79baf05303ac539ae12665bd7331':
  RES-2 关联数据集预览问题
  fix
  BI启动用了UIbutton,导致FRCoreContext提前加载了
  REPORT-2975 9.0更新升级 同步一份到master
  修改数据查询数据集可以随意选取其他类型的数据连接的BUG
master
superman 7 years ago
parent
commit
1b4b0e24b7
  1. 62
      designer_base/src/com/fr/design/data/DesignTableDataManager.java
  2. 13
      designer_base/src/com/fr/design/data/datapane/connect/ConnectionTableProcedurePane.java
  3. 5
      designer_base/src/com/fr/design/data/datapane/preview/PreviewTablePane.java
  4. 13
      designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java
  5. 2
      designer_base/src/com/fr/design/data/tabledata/wrapper/AbstractTableDataWrapper.java
  6. 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 {

13
designer_base/src/com/fr/design/data/datapane/connect/ConnectionTableProcedurePane.java

@ -1,6 +1,8 @@
package com.fr.design.data.datapane.connect;
import com.fr.base.BaseUtils;
import com.fr.data.impl.AbstractDatabaseConnection;
import com.fr.data.impl.Connection;
import com.fr.design.constants.UIConstants;
import com.fr.data.core.db.TableProcedure;
import com.fr.design.border.UIRoundedBorder;
@ -20,6 +22,7 @@ import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
import java.awt.event.*;
import java.util.List;
/**
* 数据集编辑面板左边的部分
@ -39,6 +42,12 @@ public class ConnectionTableProcedurePane extends BasicPane {
public ConnectionTableProcedurePane() {
this.setLayout(new BorderLayout(4, 4));
connectionComboBox = new ConnectionComboBoxPanel(com.fr.data.impl.Connection.class) {
@Override
protected void filterConnection(Connection connection, String conName, List<String> nameList) {
filter(connection, conName, nameList);
}
protected void refreshItems() {
super.refreshItems();
if (tableViewList != null) {
@ -83,6 +92,10 @@ public class ConnectionTableProcedurePane extends BasicPane {
this.setPreferredSize(new Dimension(WIDTH, getPreferredSize().height));
}
protected void filter(Connection connection, String conName, List<String> nameList) {
connection.addConnection(nameList, conName, new Class[]{AbstractDatabaseConnection.class});
}
protected JPanel createCheckBoxgroupPane() {
JPanel checkBoxgroupPane = FRGUIPaneFactory.createNColumnGridInnerContainer_S_Pane(2);
JPanel first = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();

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());

13
designer_base/src/com/fr/design/data/tabledata/tabledatapane/DBTableDataPane.java

@ -5,7 +5,11 @@ import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.base.ParameterHelper;
import com.fr.data.core.db.TableProcedure;
import com.fr.data.impl.AbstractDatabaseConnection;
import com.fr.data.impl.Connection;
import com.fr.data.impl.DBTableData;
import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.data.impl.JNDIDatabaseConnection;
import com.fr.data.impl.NameDatabaseConnection;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.UpdateAction;
@ -37,6 +41,7 @@ import com.fr.script.Calculator;
import com.fr.stable.ArrayUtils;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import org.sqlite.JDBC;
import javax.swing.*;
import javax.swing.text.BadLocationException;
@ -102,7 +107,12 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
sqlSplitPane.add(box, BorderLayout.CENTER);
// 左边的Panel,上面是选择DatabaseConnection的ComboBox,下面DatabaseConnection对应的Table
connectionTableProcedurePane = new ConnectionTableProcedurePane();
connectionTableProcedurePane = new ConnectionTableProcedurePane() {
@Override
protected void filter(Connection connection, String conName, List<String> nameList) {
connection.addConnection(nameList, conName, new Class[]{JDBCDatabaseConnection.class, JNDIDatabaseConnection.class});
}
};
connectionTableProcedurePane.addDoubleClickListener(new DoubleClickSelectedNodeOnTreeListener() {
@Override
@ -138,6 +148,7 @@ public class DBTableDataPane extends AbstractTableDataPane<DBTableData> {
this.add(mainSplitPane, BorderLayout.CENTER);
}
private boolean isPreviewOrRefreshButton (FocusEvent e) {
if (e.getOppositeComponent() != null) {
String name = e.getOppositeComponent().getName();

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;
@ -1263,6 +1264,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);
}
/**
* 根据指定的参数生成一个实际可预览的数据集
*
@ -1272,7 +1278,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
@ -1311,6 +1317,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