|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.fr.design.data.datapane.connect; |
|
|
|
|
|
|
|
|
|
import com.fanruan.config.impl.data.ConnectionConfigProviderFactory; |
|
|
|
|
import com.fr.config.remote.RemoteConfigEvent; |
|
|
|
|
import com.fr.data.driver.DriverClassNotFoundException; |
|
|
|
|
import com.fr.data.impl.Connection; |
|
|
|
@ -18,7 +19,6 @@ import com.fr.design.gui.controlpane.NameableCreator;
|
|
|
|
|
import com.fr.design.gui.ilist.ListModelElement; |
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
import com.fr.event.EventDispatcher; |
|
|
|
|
import com.fr.file.ConnectionConfig; |
|
|
|
|
import com.fr.file.ConnectionOperator; |
|
|
|
|
import com.fr.general.NameObject; |
|
|
|
|
import com.fr.license.database.DBTypes; |
|
|
|
@ -29,8 +29,6 @@ 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 com.fr.workspace.WorkContext; |
|
|
|
|
import com.fr.workspace.server.database.DataBaseTypeOperator; |
|
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
@ -191,15 +189,12 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
|
|
|
|
|
return TITLE_NAME; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Populate. |
|
|
|
|
* |
|
|
|
|
* @param connectionConfig the new datasourceManager. |
|
|
|
|
*/ |
|
|
|
|
public void populate(ConnectionConfig connectionConfig) { |
|
|
|
|
|
|
|
|
|
//todo config invalidate
|
|
|
|
|
public void populate(Map<String, Connection> connectionMap) { |
|
|
|
|
List<NameObject> nameObjectList = new ArrayList<NameObject>(); |
|
|
|
|
populatedConnectionsSnapshot.clear(); |
|
|
|
|
for (Map.Entry<String, Connection> entry : connectionConfig.getConnections().entrySet()) { |
|
|
|
|
for (Map.Entry<String, Connection> entry : ConnectionConfigProviderFactory.getConfigProvider().getConnections().entrySet()) { |
|
|
|
|
nameObjectList.add(new NameObject(entry.getKey(), entry.getValue())); |
|
|
|
|
try { |
|
|
|
|
populatedConnectionsSnapshot.put(entry.getKey(), (Connection) entry.getValue().clone()); |
|
|
|
@ -213,7 +208,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
|
|
|
|
|
/** |
|
|
|
|
* Update. |
|
|
|
|
*/ |
|
|
|
|
public void update(ConnectionConfig connectionConfig) throws Exception { |
|
|
|
|
public void update(Map<String, Connection> connectionMap) throws Exception { |
|
|
|
|
// Nameable[]居然不能强转成NameObject[],一定要这么写...
|
|
|
|
|
Nameable[] res = this.update(); |
|
|
|
|
Map<String, Connection> updatedMap = new LinkedHashMap<>(); |
|
|
|
@ -337,7 +332,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
|
|
|
|
|
|
|
|
|
|
// hades:远程环境时,由于时直接RPC调用远程修改,因此设计器本地配置需要失效
|
|
|
|
|
if (!WorkContext.getCurrent().isLocal()) { |
|
|
|
|
EventDispatcher.fire(RemoteConfigEvent.EDIT, ConnectionConfig.getInstance().getNameSpace()); |
|
|
|
|
EventDispatcher.fire(RemoteConfigEvent.EDIT, "ConnectionConfig"); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
@ -345,41 +340,35 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean saveByOldWay(List<String> removedConnNames, List<ConnectionBean> addedOrUpdatedConnections) { |
|
|
|
|
final int remaining = ConnectionConfig.getInstance().getRemainingCon(removedConnNames.size(), addedOrUpdatedConnections.size()); |
|
|
|
|
final int remaining = ConnectionConfigProviderFactory.getConfigProvider().getRemainingCon(removedConnNames.size(), addedOrUpdatedConnections.size()); |
|
|
|
|
try { |
|
|
|
|
return Configurations.modify(new WorkerFacade(ConnectionConfig.class) { |
|
|
|
|
@Override |
|
|
|
|
public void run() { |
|
|
|
|
removedConnNames.forEach(n -> ConnectionConfig.getInstance().removeConnection(n)); |
|
|
|
|
int innerRemaining = remaining; |
|
|
|
|
for (ConnectionBean cb : addedOrUpdatedConnections) { |
|
|
|
|
if (innerRemaining > 0) { |
|
|
|
|
ConnectionConfig.getInstance().addConnectionWithoutCheck(cb.getName(), cb.getConnection()); |
|
|
|
|
innerRemaining--; |
|
|
|
|
} else { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
removedConnNames.forEach(n -> ConnectionConfigProviderFactory.getConfigProvider().removeConnection(n)); |
|
|
|
|
int innerRemaining = remaining; |
|
|
|
|
for (ConnectionBean cb : addedOrUpdatedConnections) { |
|
|
|
|
if (innerRemaining > 0) { |
|
|
|
|
ConnectionConfigProviderFactory.getConfigProvider().addConnectionWithoutCheck(cb.getName(), cb.getConnection()); |
|
|
|
|
innerRemaining--; |
|
|
|
|
} else { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void showDialog(Window parent) { |
|
|
|
|
final ConnectionConfig connectionConfig = ConnectionConfig.getInstance(); |
|
|
|
|
Map<String, Connection> connectionMap = ConnectionConfigProviderFactory.getConfigProvider().getConnections(); |
|
|
|
|
final ConnectionManagerPane connectionManagerPane = new ConnectionManagerPane() { |
|
|
|
|
@Override |
|
|
|
|
public void complete() { |
|
|
|
|
ConnectionConfig cloned = connectionConfig.mirror(); |
|
|
|
|
populate(cloned); |
|
|
|
|
populate(connectionMap); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
final BasicDialog connectionListDialog = connectionManagerPane.showLargeWindow(parent, null); |
|
|
|
|
connectionListDialog.addDialogActionListener(new ConnectionListDialogActionAdapter(connectionManagerPane, connectionListDialog, connectionConfig)); |
|
|
|
|
connectionListDialog.addDialogActionListener(new ConnectionListDialogActionAdapter(connectionManagerPane, connectionListDialog, connectionMap)); |
|
|
|
|
connectionListDialog.setVisible(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|