From 45adf67ff30da5eea6e4c652bfc8c3fce3901769 Mon Sep 17 00:00:00 2001 From: hzzz Date: Mon, 8 May 2017 17:14:34 +0800 Subject: [PATCH 1/9] fix REPORT-2600 --- .../src/com/fr/design/data/DesignTableDataManager.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/designer_base/src/com/fr/design/data/DesignTableDataManager.java b/designer_base/src/com/fr/design/data/DesignTableDataManager.java index e0569424d..acd344dbe 100644 --- a/designer_base/src/com/fr/design/data/DesignTableDataManager.java +++ b/designer_base/src/com/fr/design/data/DesignTableDataManager.java @@ -416,6 +416,11 @@ public abstract class DesignTableDataManager { loadingBar.start(); } try { + for (ParameterProvider parameter : currentEnv.getTableDataParameters(tabledata)) { + if (parameterMap.containsKey(parameter.getName())) { + parameter.setValue(parameterMap.get(parameter.getName())); + } + } embeddedTableData = currentEnv.previewTableData(tabledata, parameterMap, rowCount); } catch (TableDataException e) { throw new TableDataException(e.getMessage(), e); From 810686c8a39314eb22d8fe92a457a6c9d2cdc8c7 Mon Sep 17 00:00:00 2001 From: hzzz Date: Mon, 8 May 2017 17:18:56 +0800 Subject: [PATCH 2/9] fix PMD --- .../src/com/fr/design/data/DesignTableDataManager.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/data/DesignTableDataManager.java b/designer_base/src/com/fr/design/data/DesignTableDataManager.java index acd344dbe..e593f5944 100644 --- a/designer_base/src/com/fr/design/data/DesignTableDataManager.java +++ b/designer_base/src/com/fr/design/data/DesignTableDataManager.java @@ -378,7 +378,8 @@ public abstract class DesignTableDataManager { * 而获取数据集的字段名字时,则没必要 * @return */ - private static EmbeddedTableData previewTableData(TableData tabledata, int rowCount, boolean isMustInputParameters, boolean needLoadingBar) throws Exception { + private static EmbeddedTableData previewTableData(TableData tabledata, int rowCount, boolean isMustInputParameters, + boolean needLoadingBar) throws Exception { final AutoProgressBar loadingBar = PreviewTablePane.getInstance().getProgressBar(); Env currentEnv = FRContext.getCurrentEnv(); EmbeddedTableData embeddedTableData = null; From ad1e62a59cf6de0f7932902f0253d2a5a8e7ef87 Mon Sep 17 00:00:00 2001 From: hzzz Date: Mon, 8 May 2017 17:19:52 +0800 Subject: [PATCH 3/9] .. --- .../src/com/fr/design/data/DesignTableDataManager.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/designer_base/src/com/fr/design/data/DesignTableDataManager.java b/designer_base/src/com/fr/design/data/DesignTableDataManager.java index e593f5944..acd344dbe 100644 --- a/designer_base/src/com/fr/design/data/DesignTableDataManager.java +++ b/designer_base/src/com/fr/design/data/DesignTableDataManager.java @@ -378,8 +378,7 @@ public abstract class DesignTableDataManager { * 而获取数据集的字段名字时,则没必要 * @return */ - private static EmbeddedTableData previewTableData(TableData tabledata, int rowCount, boolean isMustInputParameters, - boolean needLoadingBar) throws Exception { + private static EmbeddedTableData previewTableData(TableData tabledata, int rowCount, boolean isMustInputParameters, boolean needLoadingBar) throws Exception { final AutoProgressBar loadingBar = PreviewTablePane.getInstance().getProgressBar(); Env currentEnv = FRContext.getCurrentEnv(); EmbeddedTableData embeddedTableData = null; From 87c302e4a5e4ffb8e238ce6eed1d9fb343520f54 Mon Sep 17 00:00:00 2001 From: hzzz Date: Mon, 8 May 2017 17:37:08 +0800 Subject: [PATCH 4/9] fix --- .../design/data/DesignTableDataManager.java | 53 ++++++++++--------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/designer_base/src/com/fr/design/data/DesignTableDataManager.java b/designer_base/src/com/fr/design/data/DesignTableDataManager.java index acd344dbe..c15faec63 100644 --- a/designer_base/src/com/fr/design/data/DesignTableDataManager.java +++ b/designer_base/src/com/fr/design/data/DesignTableDataManager.java @@ -36,7 +36,6 @@ import java.io.ByteArrayOutputStream; import java.text.Collator; import java.util.*; import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; /** * 设计器管理操作数据集的类: @@ -59,7 +58,7 @@ public abstract class DesignTableDataManager { private static java.util.Map dsNameChangedMap = new HashMap(); // private static List dsListeners = new ArrayList(); - private static Map> dsListenersMap = new HashMap>(); + private static Map> dsListenersMap = new HashMap>(); public static String NO_PARAMETER = "no_paramater_pane"; @@ -79,7 +78,7 @@ public abstract class DesignTableDataManager { * 响应数据集改变. */ private static void fireDsChanged() { - for(Entry> listenerEntry : dsListenersMap.entrySet()) { + for (Entry> listenerEntry : dsListenersMap.entrySet()) { List dsListeners = listenerEntry.getValue(); for (int i = 0; i < dsListeners.size(); i++) { //增强for循环用的iterator实现的, 如果中间哪个listener修改或删除了(如ChartEditPane.dsChangeListener), @@ -91,8 +90,8 @@ public abstract class DesignTableDataManager { } } - public static void closeTemplate(JTemplate template) { - if(template != null) { + public static void closeTemplate(JTemplate template) { + if (template != null) { dsListenersMap.remove(template.getFullPathName()); } } @@ -151,7 +150,7 @@ public abstract class DesignTableDataManager { public static void addDsChangeListener(ChangeListener l) { JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); String key = StringUtils.EMPTY; - if(template != null) { + if (template != null) { key = template.getFullPathName(); } List dsListeners = dsListenersMap.get(key); @@ -180,7 +179,7 @@ public abstract class DesignTableDataManager { * august:返回当前正在编辑的具有报表数据源的模板(基本报表、聚合报表) 包括 : 图表模板 * * @return TableDataSource - * attention:与这个方法有关系的静态组件(不随着切换模板tab而变化的),应该重新执行该方法,再刷新组件 + * attention:与这个方法有关系的静态组件(不随着切换模板tab而变化的),应该重新执行该方法,再刷新组件 */ public static TableDataSource getEditingTableDataSource() { return DesignModelAdapter.getCurrentModelAdapter() == null ? null : DesignModelAdapter.getCurrentModelAdapter().getBook(); @@ -319,7 +318,6 @@ public abstract class DesignTableDataManager { } - private static void addStoreProcedureData(java.util.Map resMap) { DatasourceManagerProvider mgr = DatasourceManager.getProviderInstance(); String[] namearray = new String[0]; @@ -381,12 +379,10 @@ public abstract class DesignTableDataManager { private static EmbeddedTableData previewTableData(TableData tabledata, int rowCount, boolean isMustInputParameters, boolean needLoadingBar) throws Exception { final AutoProgressBar loadingBar = PreviewTablePane.getInstance().getProgressBar(); Env currentEnv = FRContext.getCurrentEnv(); - EmbeddedTableData embeddedTableData = null; ParameterProvider[] parameters = currentEnv.getTableDataParameters(tabledata); - boolean isNullParameter = parameters == null || parameters.length == 0; - ParameterProvider[] tableDataParameter = tabledata.getParameters(Calculator.createCalculator()); - boolean isOriginalNUllParameter = tableDataParameter == null || tableDataParameter.length == 0; - if (isNullParameter && !isOriginalNUllParameter) { + if (isNullOrEmpty(parameters)) { + ParameterProvider[] tableDataParameter = tabledata.getParameters(Calculator.createCalculator()); + checkArgument(!isNullOrEmpty(tableDataParameter), "both parameters and tableDataParameter are empty"); parameters = tableDataParameter; } boolean hasValue = true; @@ -396,25 +392,24 @@ public abstract class DesignTableDataManager { break; } } - final Map parameterMap = new HashMap(); + final Map parameterMap = new HashMap<>(); if (!hasValue || isMustInputParameters) { - if (parameters != null && parameters.length > 0) { - final ParameterInputPane pPane = new ParameterInputPane(parameters); - pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { - - public void doOk() { - parameterMap.putAll(pPane.update()); - } - }).setVisible(true); - } + final ParameterInputPane pPane = new ParameterInputPane(parameters); + pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + parameterMap.putAll(pPane.update()); + } + }).setVisible(true); } else { - for (int i = 0; i < parameters.length; i++) { - parameterMap.put(parameters[i].getName(), parameters[i].getValue()); + for (ParameterProvider parameter : parameters) { + parameterMap.put(parameter.getName(), parameter.getValue()); } } if (loadingBar != null && needLoadingBar) { loadingBar.start(); } + EmbeddedTableData embeddedTableData = null; try { for (ParameterProvider parameter : currentEnv.getTableDataParameters(tabledata)) { if (parameterMap.containsKey(parameter.getName())) { @@ -501,5 +496,13 @@ public abstract class DesignTableDataManager { threadLocal.set(value); } + private static boolean isNullOrEmpty(Object[] objs) { + return objs == null || objs.length == 0; + } + private static void checkArgument(boolean expression, String errorMessage) { + if (!expression) { + throw new IllegalArgumentException(errorMessage); + } + } } \ No newline at end of file From 999d5e2b52be7cd07b0597aa607cd0c431183b99 Mon Sep 17 00:00:00 2001 From: hzzz Date: Tue, 9 May 2017 09:15:06 +0800 Subject: [PATCH 5/9] fix --- .../com/fr/design/data/DesignTableDataManager.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/designer_base/src/com/fr/design/data/DesignTableDataManager.java b/designer_base/src/com/fr/design/data/DesignTableDataManager.java index c15faec63..3f67d6d4c 100644 --- a/designer_base/src/com/fr/design/data/DesignTableDataManager.java +++ b/designer_base/src/com/fr/design/data/DesignTableDataManager.java @@ -380,9 +380,9 @@ public abstract class DesignTableDataManager { final AutoProgressBar loadingBar = PreviewTablePane.getInstance().getProgressBar(); Env currentEnv = FRContext.getCurrentEnv(); ParameterProvider[] parameters = currentEnv.getTableDataParameters(tabledata); - if (isNullOrEmpty(parameters)) { + if (ArrayUtils.isEmpty(parameters)) { ParameterProvider[] tableDataParameter = tabledata.getParameters(Calculator.createCalculator()); - checkArgument(!isNullOrEmpty(tableDataParameter), "both parameters and tableDataParameter are empty"); + checkArgument(!ArrayUtils.isEmpty(tableDataParameter), "both parameters and tableDataParameter are empty"); parameters = tableDataParameter; } boolean hasValue = true; @@ -409,14 +409,13 @@ public abstract class DesignTableDataManager { if (loadingBar != null && needLoadingBar) { loadingBar.start(); } - EmbeddedTableData embeddedTableData = null; try { for (ParameterProvider parameter : currentEnv.getTableDataParameters(tabledata)) { if (parameterMap.containsKey(parameter.getName())) { parameter.setValue(parameterMap.get(parameter.getName())); } } - embeddedTableData = currentEnv.previewTableData(tabledata, parameterMap, rowCount); + return currentEnv.previewTableData(tabledata, parameterMap, rowCount); } catch (TableDataException e) { throw new TableDataException(e.getMessage(), e); } finally { @@ -426,7 +425,6 @@ public abstract class DesignTableDataManager { } }, 100); } - return embeddedTableData; } /** @@ -496,10 +494,6 @@ public abstract class DesignTableDataManager { threadLocal.set(value); } - private static boolean isNullOrEmpty(Object[] objs) { - return objs == null || objs.length == 0; - } - private static void checkArgument(boolean expression, String errorMessage) { if (!expression) { throw new IllegalArgumentException(errorMessage); From 542d6f9980514027bfac00cee2405d624f89cc10 Mon Sep 17 00:00:00 2001 From: hzzz Date: Tue, 9 May 2017 11:40:54 +0800 Subject: [PATCH 6/9] fix --- .../src/com/fr/design/data/DesignTableDataManager.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/designer_base/src/com/fr/design/data/DesignTableDataManager.java b/designer_base/src/com/fr/design/data/DesignTableDataManager.java index 3f67d6d4c..3b4877154 100644 --- a/designer_base/src/com/fr/design/data/DesignTableDataManager.java +++ b/designer_base/src/com/fr/design/data/DesignTableDataManager.java @@ -381,9 +381,7 @@ public abstract class DesignTableDataManager { Env currentEnv = FRContext.getCurrentEnv(); ParameterProvider[] parameters = currentEnv.getTableDataParameters(tabledata); if (ArrayUtils.isEmpty(parameters)) { - ParameterProvider[] tableDataParameter = tabledata.getParameters(Calculator.createCalculator()); - checkArgument(!ArrayUtils.isEmpty(tableDataParameter), "both parameters and tableDataParameter are empty"); - parameters = tableDataParameter; + parameters = tabledata.getParameters(Calculator.createCalculator()); } boolean hasValue = true; for (ParameterProvider parameter : parameters) { From 8b8e30196ba1b8e8a7381db9b1b1d694fdef27c0 Mon Sep 17 00:00:00 2001 From: hzzz Date: Tue, 9 May 2017 11:44:37 +0800 Subject: [PATCH 7/9] remove unused code --- .../src/com/fr/design/data/DesignTableDataManager.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/designer_base/src/com/fr/design/data/DesignTableDataManager.java b/designer_base/src/com/fr/design/data/DesignTableDataManager.java index 3b4877154..c2e039a44 100644 --- a/designer_base/src/com/fr/design/data/DesignTableDataManager.java +++ b/designer_base/src/com/fr/design/data/DesignTableDataManager.java @@ -491,10 +491,4 @@ public abstract class DesignTableDataManager { public static void setThreadLocal(String value) { threadLocal.set(value); } - - private static void checkArgument(boolean expression, String errorMessage) { - if (!expression) { - throw new IllegalArgumentException(errorMessage); - } - } } \ No newline at end of file From 9baa73b95f392ec118d49969aca659e2fb7cff1c Mon Sep 17 00:00:00 2001 From: hzzz Date: Thu, 11 May 2017 15:46:13 +0800 Subject: [PATCH 8/9] fix --- .../design/data/DesignTableDataManager.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/designer_base/src/com/fr/design/data/DesignTableDataManager.java b/designer_base/src/com/fr/design/data/DesignTableDataManager.java index c2e039a44..73d222938 100644 --- a/designer_base/src/com/fr/design/data/DesignTableDataManager.java +++ b/designer_base/src/com/fr/design/data/DesignTableDataManager.java @@ -383,15 +383,8 @@ public abstract class DesignTableDataManager { if (ArrayUtils.isEmpty(parameters)) { parameters = tabledata.getParameters(Calculator.createCalculator()); } - boolean hasValue = true; - for (ParameterProvider parameter : parameters) { - if (parameter.getValue() == null || ComparatorUtils.equals(StringUtils.EMPTY, parameter.getValue())) { - hasValue = false; - break; - } - } final Map parameterMap = new HashMap<>(); - if (!hasValue || isMustInputParameters) { + if (needInputParams(isMustInputParameters, parameters)) { final ParameterInputPane pPane = new ParameterInputPane(parameters); pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override @@ -425,6 +418,18 @@ public abstract class DesignTableDataManager { } } + /** + * 是否需要展示输入框让用户输入参数 == 当前不是所有参数都有值 && 必须有值 + */ + private static boolean needInputParams(boolean mustInputParameters, ParameterProvider[] parameters) { + for (ParameterProvider parameter : parameters) { + if (parameter.getValue() == null || StringUtils.EMPTY.equals(parameter.getValue())) { + return mustInputParameters; + } + } + return false; + } + /** * 返回TableData的数据列,注意TableData * 是没有考虑参数的。用于简单的查询语句生成的TableData, 或者 From f0bb46a9cdc0e7addc5206965c0ee70fa458e9dd Mon Sep 17 00:00:00 2001 From: hzzz Date: Fri, 12 May 2017 09:17:11 +0800 Subject: [PATCH 9/9] fix --- .../src/com/fr/design/data/DesignTableDataManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/designer_base/src/com/fr/design/data/DesignTableDataManager.java b/designer_base/src/com/fr/design/data/DesignTableDataManager.java index 73d222938..621e303b1 100644 --- a/designer_base/src/com/fr/design/data/DesignTableDataManager.java +++ b/designer_base/src/com/fr/design/data/DesignTableDataManager.java @@ -418,13 +418,13 @@ public abstract class DesignTableDataManager { } } - /** - * 是否需要展示输入框让用户输入参数 == 当前不是所有参数都有值 && 必须有值 - */ private static boolean needInputParams(boolean mustInputParameters, ParameterProvider[] parameters) { + if (mustInputParameters && ArrayUtils.isNotEmpty(parameters)) { + return true; + } for (ParameterProvider parameter : parameters) { if (parameter.getValue() == null || StringUtils.EMPTY.equals(parameter.getValue())) { - return mustInputParameters; + return true; } } return false;