Search in sources :

Example 61 with TaskExecutor

use of com.cubrid.common.ui.spi.progress.TaskExecutor in project cubrid-manager by CUBRID.

the class SetReplicationParamDialog method createBasicGroup.

/**
	 * Creates basic group
	 * 
	 * @param parent Composite
	 */
private void createBasicGroup(Composite parent) {
    final Group group = new Group(parent, SWT.NONE);
    group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    group.setText(Messages.repparm0grpReplicationInfo);
    final GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 5;
    group.setLayout(gridLayout);
    Label slaveDbNameLabel = new Label(group, SWT.NONE);
    slaveDbNameLabel.setText(Messages.repparm0lblSlaveDbName);
    slaveDbNameLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    slaveDbNameCombo = new Combo(group, SWT.NONE | SWT.READ_ONLY);
    slaveDbNameCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    Button connectButton = new Button(group, SWT.RIGHT);
    connectButton.setText(Messages.repparm0btnConnect);
    connectButton.setLayoutData(new GridData());
    connectButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            GetReplicationParamTask task = new GetReplicationParamTask(database.getServer().getServerInfo());
            task.setMasterDbName(replInfo.getMasterList().get(0).getMasterDbName());
            task.setSlaveDbName(slaveDbNameCombo.getText());
            task.setDistDbName(database.getLabel());
            task.setDistDbDbaPasswd(database.getPassword());
            task.setRunningMode(database.getRunningType() == DbRunningType.CS);
            TaskExecutor taskExecutor = new CommonTaskExec(null);
            taskExecutor.addTask(task);
            new ExecTaskWithProgress(taskExecutor).exec();
            if (taskExecutor.isSuccess()) {
                ReplicationParamInfo paramInfo = task.getReplicationParams();
                Map<String, String> paramMap = paramInfo.getParamMap();
                paramEditor.setReplicationParamMap(paramMap);
            }
        }
    });
}
Also used : Group(org.eclipse.swt.widgets.Group) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) GetReplicationParamTask(com.cubrid.cubridmanager.core.replication.task.GetReplicationParamTask) GridLayout(org.eclipse.swt.layout.GridLayout) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ReplicationParamInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) Map(java.util.Map)

Example 62 with TaskExecutor

use of com.cubrid.common.ui.spi.progress.TaskExecutor in project cubrid-manager by CUBRID.

the class SetReplicationParamDialog method initial.

/**
	 * 
	 * initial the page content
	 * 
	 */
private void initial() {
    setReplInfo((ReplicationInfo) database.getAdapter(ReplicationInfo.class));
    for (int j = 0; j < replInfo.getSlaveList().size(); j++) {
        slaveDbNameCombo.add(replInfo.getSlaveList().get(j).getSlaveDbName());
    }
    slaveDbNameCombo.setText(replInfo.getSlaveList().get(0).getSlaveDbName());
    GetReplicationParamTask task = new GetReplicationParamTask(database.getServer().getServerInfo());
    task.setMasterDbName(replInfo.getMasterList().get(0).getMasterDbName());
    task.setSlaveDbName(slaveDbNameCombo.getText());
    task.setDistDbName(database.getLabel());
    task.setDistDbDbaPasswd(database.getPassword());
    task.setRunningMode(database.getRunningType() == DbRunningType.CS);
    TaskExecutor taskExecutor = new CommonTaskExec(null);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (taskExecutor.isSuccess()) {
        ReplicationParamInfo paramInfo = task.getReplicationParams();
        Map<String, String> paramMap = paramInfo.getParamMap();
        paramEditor.setReplicationParamMap(paramMap);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ReplicationParamInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) GetReplicationParamTask(com.cubrid.cubridmanager.core.replication.task.GetReplicationParamTask)

Example 63 with TaskExecutor

use of com.cubrid.common.ui.spi.progress.TaskExecutor in project cubrid-manager by CUBRID.

the class SetHostInfoDialog method connect.

/**
	 * connect the host
	 * 
	 * @param buttonId int
	 */
private void connect(final int buttonId) {
    final String ip = ipText.getText();
    final String port = portText.getText();
    final String userName = userNameText.getText();
    final String password = passwordText.getText();
    boolean isConnected = ServerManager.getInstance().isConnected(ip, Integer.parseInt(port), userName);
    if (isConnected && hostInfo != null) {
        ServerInfo serverInfo = CMHostNodePersistManager.getInstance().getServerInfo(ip, Integer.parseInt(port), userName);
        if (!serverInfo.getLoginedUserInfo().isAdmin()) {
            CommonUITool.openErrorBox(Messages.bind(Messages.errInvalidUser, ip));
            return;
        }
        hostInfo.setIp(ip);
        hostInfo.setPort(port);
        hostInfo.setUserName(userName);
        hostInfo.setPassword(password);
        hostInfo.setName(ip + ":" + port);
        List<DatabaseInfo> databaseInfoList = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
        hostInfo.setDatabaseInfoList(databaseInfoList);
        hostInfo.setDbPath(serverInfo.getEnvInfo().getDatabaseDir());
        hostInfo.setOsInfoType(serverInfo.getServerOsInfo());
        setReturnCode(buttonId);
        close();
        return;
    }
    if (!isConnected) {
        final ServerInfo serverInfo = new ServerInfo();
        serverInfo.setHostAddress(ip);
        serverInfo.setHostMonPort(Integer.parseInt(port));
        serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
        serverInfo.setUserName(userName);
        serverInfo.setUserPassword(password);
        TaskExecutor taskExcutor = new ConnectHostTaskExecutor(serverInfo, buttonId);
        MonitoringTask monitoringTask = new MonitoringTask(serverInfo);
        taskExcutor.addTask(monitoringTask);
        GetEnvInfoTask getEnvInfoTask = new GetEnvInfoTask(serverInfo);
        taskExcutor.addTask(getEnvInfoTask);
        GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(serverInfo);
        taskExcutor.addTask(getCMConfParameterTask);
        GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
        taskExcutor.addTask(getDatabaseListTask);
        new ExecTaskWithProgress(taskExcutor).exec(true, true);
    }
}
Also used : GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) GetEnvInfoTask(com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)

Example 64 with TaskExecutor

use of com.cubrid.common.ui.spi.progress.TaskExecutor in project cubrid-manager by CUBRID.

the class StartShardAction method run.

/**
	 * Override the run method in order to complete starting broker environment
	 * 
	 */
public void run() {
    final Object[] obj = this.getSelectedObj();
    CubridShard selection = (CubridShard) obj[0];
    if (null == selection) {
        return;
    }
    ServerInfo serverInfo = selection.getServer().getServerInfo();
    StartShardTask task = new StartShardTask(serverInfo, selection.getName());
    IMessageHandler messageHandler = new IMessageHandler() {

        public String translate(String message) {
            if (message == null) {
                return "";
            }
            if (message.indexOf("failed to metadata validate check") != -1) {
                return Messages.errStartShardNotConfigOrFailed + StringUtil.NEWLINE + StringUtil.NEWLINE + Messages.msgShardGuide;
            }
            return "";
        }
    };
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.startShardActionName, messageHandler);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (!taskExecutor.isSuccess()) {
        return;
    }
    if (!task.isSuccess()) {
        String msg = Messages.bind(Messages.errCanNotStartShardBroker, Messages.msgShardGuide);
        CommonUITool.openErrorBox(msg);
        return;
    }
    selection.setRunning(true);
    TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
    CommonUITool.refreshNavigatorTree(treeViewer, selection);
    ActionManager.getInstance().fireSelectionChanged(getSelection());
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IMessageHandler(com.cubrid.common.ui.spi.IMessageHandler) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CubridShard(com.cubrid.cubridmanager.ui.spi.model.CubridShard) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) StartShardTask(com.cubrid.cubridmanager.core.shard.task.StartShardTask)

Example 65 with TaskExecutor

use of com.cubrid.common.ui.spi.progress.TaskExecutor in project cubrid-manager by CUBRID.

the class StartShardEnvAction method run.

/**
	 * Override the run method in order to complete starting broker environment
	 * 
	 */
public void run() {
    final Object[] obj = this.getSelectedObj();
    CubridShardFolder selection = (CubridShardFolder) obj[0];
    if (null == selection) {
        return;
    }
    ServerInfo serverInfo = selection.getServer().getServerInfo();
    StartShardTask task = new StartShardTask(serverInfo, null);
    IMessageHandler messageHandler = new IMessageHandler() {

        public String translate(String message) {
            if (message == null) {
                return "";
            }
            if (message.indexOf("failed to metadata validate check") != -1) {
                return Messages.errStartShardNotConfigOrFailed + StringUtil.NEWLINE + StringUtil.NEWLINE + Messages.msgShardGuide;
            }
            return "";
        }
    };
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.startShardEnvActionName, messageHandler);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (!taskExecutor.isSuccess()) {
        return;
    }
    if (!task.isSuccess()) {
        String msg = Messages.bind(Messages.errCanNotStartShardBroker, Messages.msgShardGuide);
        CommonUITool.openErrorBox(msg);
        return;
    }
    selection.setRunning(true);
    TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
    CommonUITool.refreshNavigatorTree(treeViewer, selection);
    ActionManager.getInstance().fireSelectionChanged(getSelection());
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IMessageHandler(com.cubrid.common.ui.spi.IMessageHandler) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridShardFolder(com.cubrid.cubridmanager.ui.spi.model.CubridShardFolder) StartShardTask(com.cubrid.cubridmanager.core.shard.task.StartShardTask)

Aggregations

ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)124 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)124 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)81 TreeViewer (org.eclipse.jface.viewers.TreeViewer)38 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)37 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)37 ITask (com.cubrid.common.core.task.ITask)35 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)29 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)25 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)24 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)23 ArrayList (java.util.ArrayList)23 Shell (org.eclipse.swt.widgets.Shell)15 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)14 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)13 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)12 IEditorPart (org.eclipse.ui.IEditorPart)12 LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)11 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)10 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9