Search in sources :

Example 71 with ExecTaskWithProgress

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

the class SelectTablesPage method pageChanged.

/**
	 * @see org.eclipse.jface.dialogs.IPageChangedListener#pageChanged(org.eclipse.jface.dialogs.PageChangedEvent)
	 * @param event PageChangedEvent
	 */
public void pageChanged(PageChangedEvent event) {
    setPageComplete(false);
    IWizardPage page = (IWizardPage) event.getSelectedPage();
    if (page.getName().equals(PAGENAME)) {
        SlaveDbInfoPage slaveDbInfoPage = (SlaveDbInfoPage) getWizard().getPage(SlaveDbInfoPage.PAGENAME);
        String ip = slaveDbInfoPage.getReplInfo().getMasterList().get(0).getMasterIp();
        String port = slaveDbInfoPage.getMasterHostPort();
        String userName = "admin";
        String password = slaveDbInfoPage.getMasterHostPassword();
        String mdbName = slaveDbInfoPage.getMasterDbName();
        String mdbDbaPassword = slaveDbInfoPage.getMasterDbDbaPassword();
        GetAllClassesTaskExecutor taskExcutor = new GetAllClassesTaskExecutor(getShell(), ip, port, userName, password, mdbName, mdbDbaPassword);
        new ExecTaskWithProgress(taskExcutor).exec();
        if (taskExcutor.isSuccess()) {
            DBClasses dbClasses = taskExcutor.getDBClasses();
            selectTableComp.fillTableViewer(dbClasses);
            setErrorMessage(null);
            setPageComplete(true);
        } else {
            setErrorMessage(Messages.errPreviousPage);
            setPageComplete(false);
        }
    }
}
Also used : ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) IWizardPage(org.eclipse.jface.wizard.IWizardPage) DBClasses(com.cubrid.cubridmanager.core.cubrid.table.model.DBClasses)

Example 72 with ExecTaskWithProgress

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

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

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

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

Aggregations

ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)155 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)124 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)106 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)40 TreeViewer (org.eclipse.jface.viewers.TreeViewer)39 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)37 ITask (com.cubrid.common.core.task.ITask)35 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)30 ArrayList (java.util.ArrayList)29 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)26 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)25 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)23 Shell (org.eclipse.swt.widgets.Shell)15 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)14 HashMap (java.util.HashMap)13 Map (java.util.Map)13 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