Search in sources :

Example 1 with ConnectHostExecutor

use of com.cubrid.cubridmanager.ui.host.dialog.ConnectHostExecutor in project cubrid-manager by CUBRID.

the class SetHostInfoPage method createControl.

/**
	 * Create the control for this page
	 * 
	 * @param parent Composite
	 */
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 10;
    layout.marginWidth = 10;
    composite.setLayout(layout);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    composite.setLayoutData(gridData);
    Group cmServerInfoGroup = new Group(composite, SWT.NONE);
    cmServerInfoGroup.setText(Messages.grpHostInfo);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    cmServerInfoGroup.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 2;
    cmServerInfoGroup.setLayout(layout);
    Label nickNameLable = new Label(cmServerInfoGroup, SWT.LEFT);
    nickNameLable.setText(Messages.lblNickName);
    nickNameLable.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    nickNameText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
    nickNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    Label ipLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    ipLabel.setText(Messages.lblIPAddress);
    ipLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    ipText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
    ipText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    ipText.addModifyListener(this);
    Label portNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    portNameLabel.setText(Messages.lblPort);
    portNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    portText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
    portText.setTextLimit(5);
    portText.setText("8001");
    portText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    portText.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            portText.selectAll();
            portText.setFocus();
        }
    });
    portText.addModifyListener(this);
    Label userNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    userNameLabel.setText(Messages.lblUserName);
    userNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    userNameText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
    userNameText.setText("admin");
    userNameText.setEnabled(false);
    userNameText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
    userNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    Label passwordLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    passwordLabel.setText(Messages.lblPassword);
    passwordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    passwordText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.PASSWORD | SWT.BORDER);
    passwordText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
    passwordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    passwordText.addModifyListener(this);
    passwordText.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            passwordText.selectAll();
            passwordText.setFocus();
        }
    });
    Composite btnComposite = new Composite(composite, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.spacing = 5;
    btnComposite.setLayout(rowLayout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalAlignment = GridData.END;
    btnComposite.setLayoutData(gridData);
    connectHostButton = new Button(btnComposite, SWT.NONE);
    connectHostButton.setText(Messages.btnConnect);
    connectHostButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            String address = ipText.getText();
            String port = portText.getText();
            String userName = userNameText.getText();
            String password = passwordText.getText();
            String nickName = nickNameText.getText();
            if (nickName.trim().length() == 0) {
                nickNameText.setText(address + ":" + port);
            }
            ServerInfo serverInfo = CMHostNodePersistManager.getInstance().getServerInfo(address, Integer.parseInt(port), userName);
            if (serverInfo == null) {
                serverInfo = new ServerInfo();
                serverInfo.setServerName(address);
                serverInfo.setHostAddress(address);
                serverInfo.setHostMonPort(Integer.parseInt(port));
                serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
                serverInfo.setUserName(userName);
                serverInfo.setUserPassword(password);
                serverInfo.setJdbcDriverVersion(ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION);
            }
            heartbeatNodeInfoTask = new GetHeartbeatNodeInfoTask(serverInfo);
            heartbeatNodeInfoTask.setAllDb(false);
            heartbeatNodeInfoTask.setDbList(new ArrayList<String>());
            TaskExecutor executor = null;
            if (serverInfo.isConnected()) {
                if (CompatibleUtil.isSupportHA(serverInfo)) {
                    executor = new CommonTaskExec(null);
                    executor.addTask(heartbeatNodeInfoTask);
                }
            } else {
                executor = new ConnectHostExecutor(getShell(), serverInfo, true);
                executor.addTask(heartbeatNodeInfoTask);
            }
            if (executor != null) {
                new ExecTaskWithProgress(executor).exec(true, true);
            }
            changeBtnStatus();
        }
    });
    connectHostButton.setEnabled(false);
    init();
    nickNameText.setFocus();
    setTitle(Messages.titileHostInfoPage);
    setMessage(Messages.msgHostInfoPage);
    setControl(composite);
}
Also used : Group(org.eclipse.swt.widgets.Group) FocusAdapter(org.eclipse.swt.events.FocusAdapter) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) Composite(org.eclipse.swt.widgets.Composite) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) Text(org.eclipse.swt.widgets.Text) FocusEvent(org.eclipse.swt.events.FocusEvent) GetHeartbeatNodeInfoTask(com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask) GridLayout(org.eclipse.swt.layout.GridLayout) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ConnectHostExecutor(com.cubrid.cubridmanager.ui.host.dialog.ConnectHostExecutor)

Example 2 with ConnectHostExecutor

use of com.cubrid.cubridmanager.ui.host.dialog.ConnectHostExecutor in project cubrid-manager by CUBRID.

the class EditMultiHostStatisticItemDialog method openAddStatisticHostDialog.

private void openAddStatisticHostDialog(StatisticChartHost hostItem, boolean isFirstHost, boolean isNewHost) {
    EditStatisticHostDialog dialog = new EditStatisticHostDialog(this.getShell(), this, isNewHost);
    if (!isNewHost) {
        //initial data when edit host info
        dialog.init(type, timeType, hostItem);
    }
    dialog.setFirstHost(isFirstHost);
    if (!isFirstHost) {
        StatisticChartHost firstItem = hostList.get(0);
        dialog.setFirstMetric(firstItem.getMetric());
        dialog.setFirstTime(timeType);
    }
    ServerInfo serverInfo = null;
    if (hostItem != null) {
        //edit
        serverInfo = LoadMonitorStatisticDataProgress.buildServerInfo(hostItem);
        boolean isUnavailable = false;
        boolean isSupported = false;
        if (serverInfo == null) {
            isUnavailable = true;
        } else if (serverInfo.isConnected()) {
            isSupported = serverInfo.isSupportMonitorStatistic();
        } else {
            LoadMonitorStatisticDataProgress.addDisconnectedServer(serverInfo);
            TaskExecutor taskExcutor = new ConnectHostExecutor(getShell(), serverInfo, true);
            ((ConnectHostExecutor) taskExcutor).setCheckJdbc(false);
            new ExecTaskWithProgress(taskExcutor).exec(true, true);
            if (taskExcutor.isSuccess()) {
                isSupported = serverInfo.isSupportMonitorStatistic();
            } else {
                isUnavailable = true;
            }
        }
        dialog.setServerInfo(serverInfo);
        if (isUnavailable) {
            dialog.setHostStatusValue(dialog.HOST_STATUS_UNAVAILABLE);
        } else if (isSupported) {
            dialog.setHostStatusValue(dialog.HOST_STATUS_OK);
        } else {
            dialog.setHostStatusValue(dialog.HOST_STATUS_UNSUPPORTED);
        }
    }
    if (dialog.open() == Dialog.OK) {
        if (hostItem != null) {
            int oldIndex = hostList.indexOf(hostItem);
            hostList.set(oldIndex, dialog.getHostItem());
        } else {
            hostList.add(dialog.getHostItem());
        }
        refreshHostTable();
    }
    enableOk();
}
Also used : TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ConnectHostExecutor(com.cubrid.cubridmanager.ui.host.dialog.ConnectHostExecutor) StatisticChartHost(com.cubrid.cubridmanager.core.monstatistic.model.StatisticChartHost)

Example 3 with ConnectHostExecutor

use of com.cubrid.cubridmanager.ui.host.dialog.ConnectHostExecutor in project cubrid-manager by CUBRID.

the class CubridWorkbenchContrItem method connectHostWithErrMsg.

/**
	 * Connect host
	 *
	 * @param serverInfo ServerInfo
	 * @param showErrMsg boolean
	 * @return error messages String
	 */
public static String connectHostWithErrMsg(ServerInfo serverInfo, boolean showErrMsg) {
    String password = serverInfo == null ? null : serverInfo.getUserPassword();
    if (password == null || password.trim().length() == 0) {
        return com.cubrid.cubridmanager.ui.host.Messages.errUserPasswordConnect;
    }
    Map<String, String> jdbcVersionMap = CubridJdbcManager.getInstance().getLoadedJdbc();
    if (jdbcVersionMap == null || jdbcVersionMap.get(serverInfo.getJdbcDriverVersion()) == null) {
        return com.cubrid.cubridmanager.ui.host.Messages.errNoSupportDriver;
    }
    ConnectHostExecutor taskExcutor = new ConnectHostExecutor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), serverInfo, showErrMsg);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (taskExcutor.isSuccess() && GeneralPreference.isUseHostDashboard() && serverInfo != null && serverInfo.isConnected()) {
        HostDashboardAction hostDashboardAction = (HostDashboardAction) ActionManager.getInstance().getAction(HostDashboardAction.ID);
        hostDashboardAction.doRun(serverInfo);
    }
    return taskExcutor.getErrMsg();
}
Also used : ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) HostDashboardAction(com.cubrid.cubridmanager.ui.host.action.HostDashboardAction) ConnectHostExecutor(com.cubrid.cubridmanager.ui.host.dialog.ConnectHostExecutor)

Example 4 with ConnectHostExecutor

use of com.cubrid.cubridmanager.ui.host.dialog.ConnectHostExecutor in project cubrid-manager by CUBRID.

the class CubridWorkbenchContrItem method connectHost.

/**
	 * Connect host
	 *
	 * @param serverInfo ServerInfo
	 * @param showErrMsg boolean
	 * @return boolean
	 */
public static boolean connectHost(ServerInfo serverInfo, boolean showErrMsg) {
    String password = serverInfo == null ? null : serverInfo.getUserPassword();
    if (password == null || password.trim().length() == 0) {
        return false;
    }
    Map<String, String> jdbcVersionMap = CubridJdbcManager.getInstance().getLoadedJdbc();
    if (jdbcVersionMap == null || jdbcVersionMap.get(serverInfo.getJdbcDriverVersion()) == null) {
        return false;
    }
    TaskExecutor taskExcutor = new ConnectHostExecutor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), serverInfo, showErrMsg);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    boolean isConnected = taskExcutor.isSuccess();
    if (isConnected) {
        // if preference use dashboard, when connect successful,open host dashboard
        if (GeneralPreference.isUseHostDashboard() && serverInfo.isConnected()) {
            openHostDashboard(serverInfo);
        }
    //			if (serverInfo.isCheckCertStatus()
    //					&& CertStatus.DEFAULT.equals(serverInfo.getCertStatus())) {
    //				GenCertDialog dialog = new GenCertDialog(
    //						PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), serverInfo);
    //				dialog.open();
    //			}
    }
    return isConnected;
}
Also used : TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) LoginDatabaseTaskExecutor(com.cubrid.cubridmanager.ui.cubrid.database.dialog.LoginDatabaseTaskExecutor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ConnectHostExecutor(com.cubrid.cubridmanager.ui.host.dialog.ConnectHostExecutor)

Example 5 with ConnectHostExecutor

use of com.cubrid.cubridmanager.ui.host.dialog.ConnectHostExecutor in project cubrid-manager by CUBRID.

the class AddHADatabaseDialog method createDialogArea.

/**
	 * Create dialog area content
	 * 
	 * @param parent the parent composite
	 * @return the control
	 */
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    {
        GridLayout compLayout = new GridLayout();
        compLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
        compLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
        compLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
        compLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
        composite.setLayout(compLayout);
        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    }
    Group cmServerInfoGroup = new Group(composite, SWT.NONE);
    cmServerInfoGroup.setText(Messages.grpHostInfo);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    cmServerInfoGroup.setLayoutData(gridData);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    cmServerInfoGroup.setLayout(layout);
    Label ipLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    ipLabel.setText(Messages.lblIPAddress);
    ipLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    ipCombo = new Combo(cmServerInfoGroup, SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
    ipCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    Label portNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    portNameLabel.setText(Messages.lblPort);
    portNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    portText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
    portText.setTextLimit(5);
    portText.setText("8001");
    portText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    portText.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            portText.selectAll();
            portText.setFocus();
        }
    });
    Label userNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    userNameLabel.setText(Messages.lblUserName);
    userNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    userNameText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER);
    userNameText.setText("admin");
    userNameText.setEnabled(false);
    userNameText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
    userNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    Label passwordLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    passwordLabel.setText(Messages.lblPassword);
    passwordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    passwordText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.PASSWORD | SWT.BORDER);
    passwordText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
    passwordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    passwordText.addFocusListener(new FocusAdapter() {

        public void focusGained(FocusEvent event) {
            passwordText.selectAll();
            passwordText.setFocus();
        }
    });
    Label dbNameLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    dbNameLabel.setText(Messages.lblDbName);
    dbNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    dbNameText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
    dbNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 100, -1));
    Label dbaPasswordLabel = new Label(cmServerInfoGroup, SWT.LEFT);
    dbaPasswordLabel.setText(Messages.lblDbaPassword);
    dbaPasswordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    dbaPasswordText = new Text(cmServerInfoGroup, SWT.LEFT | SWT.BORDER | SWT.PASSWORD);
    dbaPasswordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 100, -1));
    Composite btnComposite = new Composite(composite, SWT.NONE);
    RowLayout rowLayout = new RowLayout();
    rowLayout.spacing = 5;
    btnComposite.setLayout(rowLayout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalAlignment = GridData.END;
    btnComposite.setLayoutData(gridData);
    addDatabaseButton = new Button(btnComposite, SWT.NONE);
    addDatabaseButton.setText(Messages.btnAddDb);
    addDatabaseButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            //check this database whether already be added
            String dbName = dbNameText.getText();
            if (isDbExist()) {
                setErrorMessage(Messages.bind(Messages.errDbExist, dbName));
                return;
            }
            //connect server
            String address = ipCombo.getText();
            String port = portText.getText();
            String userName = userNameText.getText();
            String password = passwordText.getText();
            ServerInfo serverInfo = ServerManager.getInstance().getServer(address, Integer.parseInt(port), userName);
            if (serverInfo == null) {
                serverInfo = new ServerInfo();
                serverInfo.setServerName(address);
                serverInfo.setHostAddress(address);
                serverInfo.setHostMonPort(Integer.parseInt(port));
                serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
                serverInfo.setUserName(userName);
                serverInfo.setUserPassword(password);
                serverInfo.setJdbcDriverVersion(ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION);
            }
            String dbaPassword = dbaPasswordText.getText();
            TaskExecutor executor = null;
            VerifyDbUserPasswordTask verifyDbUserPasswordTask = new VerifyDbUserPasswordTask(serverInfo);
            verifyDbUserPasswordTask.setDbName(dbName);
            verifyDbUserPasswordTask.setDbUser("dba");
            verifyDbUserPasswordTask.setDbPassword(dbaPassword);
            if (serverInfo.isConnected()) {
                DatabaseInfo dbInfo = serverInfo.getLoginedUserInfo().getDatabaseInfo(dbName);
                if (dbInfo == null) {
                    setErrorMessage(Messages.errDbNoExist);
                    return;
                }
                executor = new CommonTaskExec(null);
                if (dbInfo.isLogined() && dbInfo.getAuthLoginedDbUserInfo().getName().equalsIgnoreCase("dba")) {
                    String pwd = dbInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
                    if (!dbaPassword.equals(pwd)) {
                        CommonUITool.openErrorBox(Messages.errDbaPassowrd);
                        dbaPasswordText.selectAll();
                        dbaPasswordText.setFocus();
                        return;
                    }
                } else {
                    executor.addTask(verifyDbUserPasswordTask);
                }
            } else {
                executor = new ConnectHostExecutor(getShell(), serverInfo, true);
                executor.addTask(verifyDbUserPasswordTask);
            }
            //get this database status
            HAHostStatusInfo haHostStatusInfo = null;
            HADatabaseStatusInfo haDbStatusInfo = null;
            GetDbModeTask getDbModeTask = new GetDbModeTask(serverInfo);
            List<String> dbList = new ArrayList<String>();
            dbList.add(dbNameText.getText());
            getDbModeTask.setDbList(dbList);
            executor.addTask(getDbModeTask);
            new ExecTaskWithProgress(executor).exec(true, true);
            if (!executor.isSuccess()) {
                if (verifyDbUserPasswordTask != null && verifyDbUserPasswordTask.getErrorMsg() != null && verifyDbUserPasswordTask.getErrorMsg().length() > 0) {
                    dbaPasswordText.selectAll();
                    dbaPasswordText.setFocus();
                }
                return;
            }
            if (getDbModeTask.getDbModes() != null && getDbModeTask.getDbModes().size() > 0) {
                List<HADatabaseStatusInfo> dbModeList = getDbModeTask.getDbModes();
                haDbStatusInfo = dbModeList.get(0);
                haHostStatusInfo = getHAHostStatusInfo(serverInfo.getHostAddress());
                if (haHostStatusInfo != null) {
                    haDbStatusInfo.setHaHostStatusInfo(haHostStatusInfo);
                    haHostStatusInfo.addHADatabaseStatus(haDbStatusInfo);
                }
            }
            if (haDbStatusInfo == null) {
                haDbStatusInfo = HAUtil.getHADatabaseStatusInfo(dbNameText.getText(), haHostStatusInfo, serverInfo);
            }
            if (haHostStatusInfo == null) {
                haHostStatusInfo = HAUtil.getHAHostStatusInfo(serverInfo);
                haHostStatusInfo.addHADatabaseStatus(haDbStatusInfo);
                haDbStatusInfo.setHaHostStatusInfo(haHostStatusInfo);
            }
            DatabaseNode dbNode = new DatabaseNode();
            dbNode.setDbName(dbNameText.getText());
            dbNode.setDbUser("dba");
            dbNode.setDbPassword(dbaPassword);
            dbNode.setName(dbNameText.getText());
            dbNode.setConnected(true);
            dbNode.setHaDatabaseStatus(haDbStatusInfo);
            HostNode hostNode = new HostNode();
            hostNode.setName(ipCombo.getText() + ":" + portText.getText());
            hostNode.setIp(ipCombo.getText());
            hostNode.setPort(portText.getText());
            hostNode.setUserName(userNameText.getText());
            hostNode.setPassword(passwordText.getText());
            hostNode.setHostStatusInfo(haHostStatusInfo);
            hostNode.setConnected(true);
            dbNode.setParent(hostNode);
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("0", dbNode.getDbName());
            map.put("1", DBStatusType.getShowText(dbNode.getDbStatusType()));
            map.put("2", dbNode.getParent().getIp());
            map.put("3", dbNode.getParent().getPort());
            map.put("4", HostStatusType.getShowText(haHostStatusInfo.getStatusType()));
            map.put("5", dbNode);
            if (dbNode.getDbStatusType() == DBStatusType.ACTIVE || dbNode.getDbStatusType() == DBStatusType.TO_BE_ACTIVE) {
                dbNodeList.add(0, map);
            } else {
                dbNodeList.add(map);
            }
            dbTableViewer.refresh();
            for (int i = 0; i < dbTable.getColumnCount(); i++) {
                dbTable.getColumn(i).pack();
            }
            verify();
        }
    });
    addDatabaseButton.setEnabled(false);
    createTable(composite);
    setTitle(Messages.titleAddHADbDialog);
    initial();
    return parentComp;
}
Also used : Group(org.eclipse.swt.widgets.Group) FocusAdapter(org.eclipse.swt.events.FocusAdapter) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) FocusEvent(org.eclipse.swt.events.FocusEvent) GetDbModeTask(com.cubrid.cubridmanager.core.mondashboard.task.GetDbModeTask) HAHostStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo) GridLayout(org.eclipse.swt.layout.GridLayout) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ArrayList(java.util.ArrayList) List(java.util.List) VerifyDbUserPasswordTask(com.cubrid.cubridmanager.core.mondashboard.task.VerifyDbUserPasswordTask) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) GridData(org.eclipse.swt.layout.GridData) ConnectHostExecutor(com.cubrid.cubridmanager.ui.host.dialog.ConnectHostExecutor) HADatabaseStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)5 ConnectHostExecutor (com.cubrid.cubridmanager.ui.host.dialog.ConnectHostExecutor)5 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)4 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)3 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)2 ArrayList (java.util.ArrayList)2 FocusAdapter (org.eclipse.swt.events.FocusAdapter)2 FocusEvent (org.eclipse.swt.events.FocusEvent)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 RowLayout (org.eclipse.swt.layout.RowLayout)2 Button (org.eclipse.swt.widgets.Button)2 Composite (org.eclipse.swt.widgets.Composite)2 Group (org.eclipse.swt.widgets.Group)2 Label (org.eclipse.swt.widgets.Label)2 Text (org.eclipse.swt.widgets.Text)2 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)1 HADatabaseStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)1