|
|
|
@ -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<String, Connection> updatedMap = new LinkedHashMap<>(); |
|
|
|
|
Arrays.stream(res).map(n -> (NameObject) n).forEach(no -> updatedMap.put(no.getName(), (Connection) no.getObject())); |
|
|
|
|
|
|
|
|
|
List<String> removedConnNames = new ArrayList<>(); |
|
|
|
|
Map<String, Connection> 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 |
|
|
|
|