From e9e97d907a6bdb0d9dac8af085dae6cb04fc5e8d Mon Sep 17 00:00:00 2001 From: rinoux Date: Tue, 29 Mar 2022 16:24:01 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-68607=20=E6=95=B0=E6=8D=AE=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E9=85=8D=E7=BD=AE=E6=93=8D=E4=BD=9C=E6=94=BE=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datapane/connect/ConnectionListPane.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java index c0d23ed466..1913ee8803 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java @@ -20,6 +20,8 @@ import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; import com.fr.stable.StringUtils; import com.fr.stable.core.PropertyChangeAdapter; +import com.fr.transaction.Configurations; +import com.fr.transaction.WorkerFacade; import javax.swing.SwingUtilities; import java.util.ArrayList; @@ -163,18 +165,29 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh Map updatedMap = new LinkedHashMap<>(); Arrays.stream(res).map(n -> (NameObject) n).forEach(no -> updatedMap.put(no.getName(), (Connection) no.getObject())); + List removedConnNames = new ArrayList<>(); + Map addedOrUpdatedConnections = new LinkedHashMap<>(); MapCompareUtils.contrastMapEntries(populatedConnectionsSnapshot, updatedMap, (entryEventKind, s, connection) -> { switch (entryEventKind) { case REMOVED: - connectionConfig.removeConnection(s); + removedConnNames.add(s); break; case ADDED: case UPDATED: - connectionConfig.addConnection(s, connection); + addedOrUpdatedConnections.put(s, connection); default: break; } }); + + // 之前丢有可能是因为没有放事务里吧 + Configurations.modify(new WorkerFacade(ConnectionConfig.class) { + @Override + public void run() { + removedConnNames.forEach(n -> ConnectionConfig.getInstance().removeConnection(n)); + addedOrUpdatedConnections.forEach((name, conn) -> ConnectionConfig.getInstance().addConnection(name, conn)); + } + }); } @Override