Search in sources :

Example 46 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec 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 47 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec 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 48 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec 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 49 with CommonTaskExec

use of com.cubrid.common.ui.spi.progress.CommonTaskExec 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)

Example 50 with CommonTaskExec

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

the class ShardParameterPropertyPage method performOk.

/**
	 * Save the page content
	 * 
	 * @return <code>true</code> if it saved successfully;<code>false</code>
	 *         otherwise
	 */
public boolean performOk() {
    shardParameterPanel.save();
    ShardsTaskFactory taskFactory = new ShardsTaskFactory(this.serverInfo, this.shards);
    taskFactory.addUpdateFile(this.shard, oldShardName);
    CommonTaskExec taskExec = new CommonTaskExec(Messages.msgOperating);
    taskExec.setTask(taskFactory.generateTasks());
    new ExecTaskWithProgress(taskExec).exec();
    if (taskExec.isSuccess()) {
        CommonUITool.openInformationBox(Messages.titleSuccess, Messages.restartShardBrokerMsg);
        return true;
    } else {
        CommonUITool.openErrorBox(Messages.msgOperationFailed);
        return false;
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ShardsTaskFactory(com.cubrid.cubridmanager.core.shard.task.ShardsTaskFactory) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)

Aggregations

CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)106 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)106 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)81 TreeViewer (org.eclipse.jface.viewers.TreeViewer)31 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)24 ArrayList (java.util.ArrayList)24 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)23 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)18 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)14 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)13 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)13 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)12 LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)11 IEditorPart (org.eclipse.ui.IEditorPart)11 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)9 HashMap (java.util.HashMap)9 AbstractUITask (com.cubrid.common.core.task.AbstractUITask)8 Map (java.util.Map)8 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)8