Browse Source

REPORT-53772 【智能联动】组件名/数据集名替换时,拖入失败时重新再拖入成功 有几率造成多次替换

feature/10.0
hades 3 years ago
parent
commit
814b4636f5
  1. 11
      designer-base/src/main/java/com/fr/design/mod/ContentReplacerCenter.java

11
designer-base/src/main/java/com/fr/design/mod/ContentReplacerCenter.java

@ -30,6 +30,7 @@ import com.fr.event.Listener;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -51,7 +52,7 @@ public class ContentReplacerCenter {
} }
private List<ContentChange> contentChangeList = new ArrayList<>(); private List<ContentChange> contentChangeList = new ArrayList<>();
private List<ContentChangeItem> items = new ArrayList<>(); private Map<ChangeItem, ContentChangeItem> itemsMap = new HashMap<>();
private ContentReplacerCenter() { private ContentReplacerCenter() {
@ -61,21 +62,21 @@ public class ContentReplacerCenter {
if (param.getChangeMap().isEmpty()) { if (param.getChangeMap().isEmpty()) {
return; return;
} }
items.add(param); itemsMap.put(param.getChangeItem(), param);
} }
}); });
EventDispatcher.listen(TableDataModifyEvent.INSTANCE, new Listener<ContentChangeItem>() { EventDispatcher.listen(TableDataModifyEvent.INSTANCE, new Listener<ContentChangeItem>() {
@Override @Override
public void on(Event event, ContentChangeItem param) { public void on(Event event, ContentChangeItem param) {
items.add(param); itemsMap.put(param.getChangeItem(), param);
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
ContentObjectManager.getInstance().searchObject(param.getObject()); ContentObjectManager.getInstance().searchObject(param.getObject());
FineLoggerFactory.getLogger().debug("search object spend {} ms", (System.currentTimeMillis() - start)); FineLoggerFactory.getLogger().debug("search object spend {} ms", (System.currentTimeMillis() - start));
FineLoggerFactory.getLogger().debug("search result: {}", ContentObjectManager.getInstance().getObjectMap() == null FineLoggerFactory.getLogger().debug("search result: {}", ContentObjectManager.getInstance().getObjectMap() == null
? null : ContentObjectManager.getInstance().getObjectMap().keySet()); ? null : ContentObjectManager.getInstance().getObjectMap().keySet());
List<ContentChangeItem> itemsCopy = new ArrayList<>(items); List<ContentChangeItem> itemsCopy = new ArrayList<>(itemsMap.values());
items.clear(); itemsMap.clear();
onRename(itemsCopy, contentChangeList); onRename(itemsCopy, contentChangeList);
} }
}); });

Loading…
Cancel
Save