hzzz 8 years ago
parent
commit
87c302e4a5
  1. 35
      designer_base/src/com/fr/design/data/DesignTableDataManager.java

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

@ -36,7 +36,6 @@ import java.io.ByteArrayOutputStream;
import java.text.Collator; import java.text.Collator;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* 设计器管理操作数据集的类: * 设计器管理操作数据集的类:
@ -79,7 +78,7 @@ public abstract class DesignTableDataManager {
* 响应数据集改变. * 响应数据集改变.
*/ */
private static void fireDsChanged() { private static void fireDsChanged() {
for(Entry<String, List<ChangeListener>> listenerEntry : dsListenersMap.entrySet()) { for (Entry<String, List<ChangeListener>> listenerEntry : dsListenersMap.entrySet()) {
List<ChangeListener> dsListeners = listenerEntry.getValue(); List<ChangeListener> dsListeners = listenerEntry.getValue();
for (int i = 0; i < dsListeners.size(); i++) { for (int i = 0; i < dsListeners.size(); i++) {
//增强for循环用的iterator实现的, 如果中间哪个listener修改或删除了(如ChartEditPane.dsChangeListener), //增强for循环用的iterator实现的, 如果中间哪个listener修改或删除了(如ChartEditPane.dsChangeListener),
@ -91,8 +90,8 @@ public abstract class DesignTableDataManager {
} }
} }
public static void closeTemplate(JTemplate<?,?> template) { public static void closeTemplate(JTemplate<?, ?> template) {
if(template != null) { if (template != null) {
dsListenersMap.remove(template.getFullPathName()); dsListenersMap.remove(template.getFullPathName());
} }
} }
@ -151,7 +150,7 @@ public abstract class DesignTableDataManager {
public static void addDsChangeListener(ChangeListener l) { public static void addDsChangeListener(ChangeListener l) {
JTemplate<?, ?> template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
String key = StringUtils.EMPTY; String key = StringUtils.EMPTY;
if(template != null) { if (template != null) {
key = template.getFullPathName(); key = template.getFullPathName();
} }
List<ChangeListener> dsListeners = dsListenersMap.get(key); List<ChangeListener> dsListeners = dsListenersMap.get(key);
@ -319,7 +318,6 @@ public abstract class DesignTableDataManager {
} }
private static void addStoreProcedureData(java.util.Map<String, TableDataWrapper> resMap) { private static void addStoreProcedureData(java.util.Map<String, TableDataWrapper> resMap) {
DatasourceManagerProvider mgr = DatasourceManager.getProviderInstance(); DatasourceManagerProvider mgr = DatasourceManager.getProviderInstance();
String[] namearray = new String[0]; 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 { private static EmbeddedTableData previewTableData(TableData tabledata, int rowCount, boolean isMustInputParameters, boolean needLoadingBar) throws Exception {
final AutoProgressBar loadingBar = PreviewTablePane.getInstance().getProgressBar(); final AutoProgressBar loadingBar = PreviewTablePane.getInstance().getProgressBar();
Env currentEnv = FRContext.getCurrentEnv(); Env currentEnv = FRContext.getCurrentEnv();
EmbeddedTableData embeddedTableData = null;
ParameterProvider[] parameters = currentEnv.getTableDataParameters(tabledata); ParameterProvider[] parameters = currentEnv.getTableDataParameters(tabledata);
boolean isNullParameter = parameters == null || parameters.length == 0; if (isNullOrEmpty(parameters)) {
ParameterProvider[] tableDataParameter = tabledata.getParameters(Calculator.createCalculator()); ParameterProvider[] tableDataParameter = tabledata.getParameters(Calculator.createCalculator());
boolean isOriginalNUllParameter = tableDataParameter == null || tableDataParameter.length == 0; checkArgument(!isNullOrEmpty(tableDataParameter), "both parameters and tableDataParameter are empty");
if (isNullParameter && !isOriginalNUllParameter) {
parameters = tableDataParameter; parameters = tableDataParameter;
} }
boolean hasValue = true; boolean hasValue = true;
@ -396,25 +392,24 @@ public abstract class DesignTableDataManager {
break; break;
} }
} }
final Map<String, Object> parameterMap = new HashMap<String, Object>(); final Map<String, Object> parameterMap = new HashMap<>();
if (!hasValue || isMustInputParameters) { if (!hasValue || isMustInputParameters) {
if (parameters != null && parameters.length > 0) {
final ParameterInputPane pPane = new ParameterInputPane(parameters); final ParameterInputPane pPane = new ParameterInputPane(parameters);
pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { pPane.showSmallWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override
public void doOk() { public void doOk() {
parameterMap.putAll(pPane.update()); parameterMap.putAll(pPane.update());
} }
}).setVisible(true); }).setVisible(true);
}
} else { } else {
for (int i = 0; i < parameters.length; i++) { for (ParameterProvider parameter : parameters) {
parameterMap.put(parameters[i].getName(), parameters[i].getValue()); parameterMap.put(parameter.getName(), parameter.getValue());
} }
} }
if (loadingBar != null && needLoadingBar) { if (loadingBar != null && needLoadingBar) {
loadingBar.start(); loadingBar.start();
} }
EmbeddedTableData embeddedTableData = null;
try { try {
for (ParameterProvider parameter : currentEnv.getTableDataParameters(tabledata)) { for (ParameterProvider parameter : currentEnv.getTableDataParameters(tabledata)) {
if (parameterMap.containsKey(parameter.getName())) { if (parameterMap.containsKey(parameter.getName())) {
@ -501,5 +496,13 @@ public abstract class DesignTableDataManager {
threadLocal.set(value); 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);
}
}
} }
Loading…
Cancel
Save