Search in sources :

Example 1 with FailedHostServerInfo

use of com.cubrid.cubridmanager.ui.host.dialog.FailedHostServerInfo 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();
        }
    }
}
Also used : FailedHostServerInfo(com.cubrid.cubridmanager.ui.host.dialog.FailedHostServerInfo) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) NewMultiHostConnectionDialog(com.cubrid.cubridmanager.ui.host.dialog.NewMultiHostConnectionDialog) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Aggregations

CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)1 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)1 FailedHostServerInfo (com.cubrid.cubridmanager.ui.host.dialog.FailedHostServerInfo)1 NewMultiHostConnectionDialog (com.cubrid.cubridmanager.ui.host.dialog.NewMultiHostConnectionDialog)1 ArrayList (java.util.ArrayList)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1