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