Browse Source

REPORT-58012

bugfix/11.0
方磊 3 years ago
parent
commit
4da64a9955
  1. 40
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  2. 27
      designer-base/src/main/java/com/fr/design/data/NameChangeBean.java

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

@ -47,9 +47,11 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -71,8 +73,8 @@ public abstract class DesignTableDataManager {
* 其实globalDsCache没有绝对的必要只是为了操作方便如果没有它那么每次清空服务器数据集或者存储过程的时候还要去遍历找一下 * 其实globalDsCache没有绝对的必要只是为了操作方便如果没有它那么每次清空服务器数据集或者存储过程的时候还要去遍历找一下
* 这个操作可能比较复杂 从减少代码复杂度的角度看还是很有必要的 * 这个操作可能比较复杂 从减少代码复杂度的角度看还是很有必要的
*/ */
private static java.util.Map<String, TableDataWrapper> globalDsCache = new java.util.HashMap<String, TableDataWrapper>(); private static Map<String, TableDataWrapper> globalDsCache = new java.util.HashMap<String, TableDataWrapper>();
private static java.util.Map<String, String> dsNameChangedMap = new HashMap<String, String>(); private static Set<NameChangeBean> dsNameChangedSet = new LinkedHashSet<>();
private static List<ChangeListener> globalDsListeners = new ArrayList<>(); private static List<ChangeListener> globalDsListeners = new ArrayList<>();
private static Map<String, List<ChangeListener>> dsListenersMap = new ConcurrentHashMap<>(); private static Map<String, List<ChangeListener>> dsListenersMap = new ConcurrentHashMap<>();
@ -123,7 +125,7 @@ public abstract class DesignTableDataManager {
public static void envChange() { public static void envChange() {
columnCache.clear(); columnCache.clear();
dsListenersMap.clear(); dsListenersMap.clear();
dsNameChangedMap.clear(); dsNameChangedSet.clear();
clearGlobalDs(); clearGlobalDs();
} }
@ -136,17 +138,17 @@ public abstract class DesignTableDataManager {
public static void fireDSChanged(Map<String, String> dsNameChangedMap) { public static void fireDSChanged(Map<String, String> dsNameChangedMap) {
clearGlobalDs(); clearGlobalDs();
if (!dsNameChangedMap.isEmpty()) { if (!dsNameChangedMap.isEmpty()) {
setDsNameChangedMap(dsNameChangedMap); setDsNameChangedSet(dsNameChangedMap);
} }
fireDsChanged(); fireDsChanged();
dsNameChangedMap.clear(); dsNameChangedMap.clear();
} }
private static void setDsNameChangedMap(Map<String, String> map) { private static void setDsNameChangedSet(Map<String, String> map) {
Iterator iterator = map.keySet().iterator(); Iterator iterator = map.keySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
String key = (String) iterator.next(); String key = (String) iterator.next();
dsNameChangedMap.put(key, map.get(key)); dsNameChangedSet.add(new NameChangeBean(key, map.get(key)));
} }
} }
@ -157,23 +159,21 @@ public abstract class DesignTableDataManager {
* @return 是则返回true * @return 是则返回true
*/ */
public static boolean isDsNameChanged(String oldDsName) { public static boolean isDsNameChanged(String oldDsName) {
return dsNameChangedMap.containsKey(oldDsName); for (NameChangeBean bean : dsNameChangedSet) {
} if (ComparatorUtils.equals(oldDsName, bean.getOldName())) {
return true;
public static String getChangedDsNameByOldDsName(String oldDsName) { }
String changeName;
if (isDsNameChanged(oldDsName)) {
changeName = dsNameChangedMap.get(oldDsName);
} else {
changeName = StringUtils.EMPTY;
} }
return false;
}
if (StringUtils.isNotEmpty(changeName)) { public static String getChangedDsNameByOldDsName(String dsName) {
return getChangedDsNameByOldDsName(changeName); for (NameChangeBean bean : dsNameChangedSet) {
} else { if (ComparatorUtils.equals(dsName, bean.getOldName())) {
return oldDsName; dsName = bean.getChangedName();
}
} }
return dsName;
} }
public static void addGlobalDsChangeListener(ChangeListener l) { public static void addGlobalDsChangeListener(ChangeListener l) {

27
designer-base/src/main/java/com/fr/design/data/NameChangeBean.java

@ -0,0 +1,27 @@
package com.fr.design.data;
public class NameChangeBean {
private String oldName;
private String changedName;
public NameChangeBean(String oldName, String changedName) {
this.oldName = oldName;
this.changedName = changedName;
}
public String getOldName() {
return oldName;
}
public void setOldName(String oldName) {
this.oldName = oldName;
}
public String getChangedName() {
return changedName;
}
public void setChangedName(String changedName) {
this.changedName = changedName;
}
}
Loading…
Cancel
Save