use of com.cubrid.cubridmanager.ui.host.dialog.NewMultiHostConnectionDialog in project cubrid-manager by CUBRID.
the class ConnectHostAction method doRun.
public void doRun(CubridServer[] servers) {
if (servers.length == 0) {
return;
}
if (servers.length == 1) {
CubridServer server = servers[0];
if (server.isAutoSavePassword() && CubridWorkbenchContrItem.connectHost(server.getServerInfo(), true)) {
server.getLoader().setLoaded(false);
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
if (view == null) {
LOGGER.error("view is null.");
return;
}
TreeViewer treeViewer = view.getViewer();
treeViewer.refresh(server, true);
treeViewer.expandToLevel(server, 1);
ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
CubridNodeChangedEvent event = new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_CONNECTED);
CubridNodeManager.getInstance().fireCubridNodeChanged(event);
} else {
EditHostAction editHostAction = (EditHostAction) ActionManager.getInstance().getAction(EditHostAction.ID);
if (editHostAction != null) {
editHostAction.doRun(servers, true);
}
}
} else {
List<FailedHostServerInfo> failedServerList = new ArrayList<FailedHostServerInfo>();
for (CubridServer object : servers) {
CubridServer server = (CubridServer) object;
String errMsg = null;
if (server.isAutoSavePassword()) {
errMsg = CubridWorkbenchContrItem.connectHostWithErrMsg(server.getServerInfo(), false);
} else {
errMsg = "Incorrect or missing password.";
}
if (errMsg == null) {
server.getLoader().setLoaded(false);
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = view.getViewer();
treeViewer.refresh(server, true);
treeViewer.expandToLevel(server, 1);
ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_CONNECTED));
} else {
failedServerList.add(new FailedHostServerInfo(server, errMsg));
}
}
if (failedServerList.size() > 0) {
NewMultiHostConnectionDialog dialog = new NewMultiHostConnectionDialog(getShell(), failedServerList);
dialog.open();
}
}
}
Aggregations