Search in sources :

Example 96 with TaskExecutor

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

the class RemoveAllManagerLogAction method refreshLogEditor.

/**
	 *
	 * Refresh the log editor
	 *
	 * @param node ICubridNode
	 */
private void refreshLogEditor(ICubridNode node) {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage activePage = window.getActivePage();
    IEditorPart editor = activePage.findEditor(node);
    if (null != editor) {
        GetManagerLogListTask task = new GetManagerLogListTask(node.getServer().getServerInfo());
        TaskExecutor taskExecutor = new CommonTaskExec(Messages.viewLogJobName);
        taskExecutor.addTask(task);
        new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
        ManagerLogInfos managerLogInfos = (ManagerLogInfos) task.getLogContent();
        try {
            editor = window.getActivePage().openEditor(node, LogEditorPart.ID);
            ((LogEditorPart) editor).setManagerLogInfo(managerLogInfos, false);
        } catch (PartInitException e) {
            LOGGER.error(e.getMessage(), e);
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) GetManagerLogListTask(com.cubrid.cubridmanager.core.logs.task.GetManagerLogListTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ManagerLogInfos(com.cubrid.cubridmanager.core.logs.model.ManagerLogInfos) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) LogEditorPart(com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart)

Example 97 with TaskExecutor

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

the class CubridWorkbenchContrItem method connectDatabase.

/**
	 * Connect the database
	 *
	 * @param dbInfo DatabaseInfo
	 * @param showErrMsg boolean
	 * @return boolean
	 */
public static boolean connectDatabase(DatabaseInfo dbInfo, boolean showErrMsg) {
    if (dbInfo == null || dbInfo.getServerInfo() == null || dbInfo.getAuthLoginedDbUserInfo() == null) {
        return false;
    }
    final String USER_DBA = "dba";
    DbUserInfo dbUserInfo = dbInfo.getAuthLoginedDbUserInfo();
    String dbUser = dbUserInfo.getName();
    String dbPassword = dbUserInfo.getNoEncryptPassword();
    if (dbUser == null || dbUser.trim().length() == 0 || dbPassword == null) {
        return false;
    }
    TaskExecutor taskExcutor = new LoginDatabaseTaskExecutor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), dbInfo.getServerInfo(), dbInfo.getDbName(), dbUser, dbPassword, showErrMsg);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    boolean isSuccess = taskExcutor.isSuccess();
    if (!isSuccess) {
        LOGGER.error("login database failed");
    }
    /*For [TOOLS-3516]*/
    if (dbInfo.getAuthLoginedDbUserInfo() != null && CompatibleUtil.isNeedCheckDbaAuthorityByJDBC(dbInfo)) {
        IsDBAUserTask checkTask = new IsDBAUserTask(dbInfo);
        checkTask.execute();
        if (checkTask.isSuccess()) {
            dbInfo.getAuthLoginedDbUserInfo().setDbaAuthority(checkTask.isDBAUser());
        } else {
            dbInfo.getAuthLoginedDbUserInfo().setDbaAuthority(USER_DBA.equals(dbUser.toLowerCase()));
        }
    }
    /*Modify*/
    CMDBNodePersistManager.getInstance().fireModifyDatabase(dbInfo, dbInfo);
    return taskExcutor.isSuccess();
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) 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) IsDBAUserTask(com.cubrid.cubridmanager.core.cubrid.user.task.IsDBAUserTask) LoginDatabaseTaskExecutor(com.cubrid.cubridmanager.ui.cubrid.database.dialog.LoginDatabaseTaskExecutor)

Example 98 with TaskExecutor

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

the class DeleteUserAction method doRun.

public void doRun(ISchemaNode node) {
    // FIXME move this logic to core module
    CubridDatabase database = node.getDatabase();
    if (database == null || node == null) {
        CommonUITool.openErrorBox(getShell(), Messages.msgSelectDB);
        return;
    }
    String childId = database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridNodeLoader.USERS_FOLDER_ID;
    ICubridNode folderNode = database.getChild(childId);
    if (folderNode == null || !folderNode.getLoader().isLoaded()) {
        return;
    }
    //		if (database.getDatabaseInfo().isHAMode()) {
    //			CommonUITool.openErrorBox(com.cubrid.cubridmanager.ui.common.Messages.errNoSupportInHA);
    //			return;
    //		}
    TaskExecutor taskExecutor = new CommonTaskExec(CommonTaskName.DELETE_USER_TASK_NAME);
    DropUserTask task = new DropUserTask(database.getDatabaseInfo(), node.getName());
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
    if (taskExecutor.isSuccess()) {
        CubridNavigatorView navigatorView = CubridNavigatorView.findNavigationView();
        if (navigatorView != null) {
            TreeViewer treeViewer = navigatorView.getViewer();
            if (treeViewer != null) {
                //refresh user folder count label
                CubridNodeChangedEvent event = new CubridNodeChangedEvent(folderNode, CubridNodeChangedEventType.NODE_REFRESH);
                CubridNodeManager.getInstance().fireCubridNodeChanged(event);
                CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, node.getParent());
                CommonUITool.openInformationBox(com.cubrid.common.ui.common.Messages.titleSuccess, Messages.msgDeleteUserSuccess);
            }
        }
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DropUserTask(com.cubrid.cubridmanager.core.cubrid.user.task.DropUserTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 99 with TaskExecutor

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

the class EditUserDialog method execTask.

public boolean execTask(final int buttonId, final ITask[] tasks, Shell shell) {
    final Display display = Display.getCurrent();
    TaskExecutor taskExecutor = new TaskExecutor() {

        public boolean exec(IProgressMonitor monitor) {
            for (ITask task : tasks) {
                if (task instanceof GetAllClassListTask) {
                    setAllClassInfoList(((GetAllClassListTask) task).getAllClassInfoList());
                } else {
                    task.execute();
                }
                if (openErrorBox(null, task.getErrorMsg(), monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
            }
            if (!monitor.isCanceled()) {
                display.syncExec(new Runnable() {

                    public void run() {
                        if (buttonId > 0) {
                            setReturnCode(buttonId);
                            close();
                        }
                    }
                });
            }
            return true;
        }
    };
    for (ITask task : tasks) {
        taskExecutor.addTask(task);
    }
    new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
    return taskExecutor.isSuccess();
}
Also used : TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITask(com.cubrid.common.core.task.ITask) GetAllClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) Display(org.eclipse.swt.widgets.Display)

Example 100 with TaskExecutor

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

the class CreateTriggerDialog method executeBySocket.

/**
	 *
	 * Execute to add or alter trigger by socket
	 *
	 * @param buttonId int
	 */
private void executeBySocket(int buttonId) {
    // FIXME remove
    String taskName = null;
    String message = null;
    ITask executedTask = null;
    if (buttonId == IDialogConstants.OK_ID) {
        String eventType = getEventType();
        String triggerEventTargetTable = triggerTargetTableCombo.getText().trim();
        String triggerEventTargetColumn = triggerTargetColumnCombo.getText().trim();
        AddTriggerTask task = new AddTriggerTask(database.getServer().getServerInfo());
        task.setDbName(database.getName());
        task.setTriggerName("\"" + triggerName + "\"");
        String eventTime = getEventTime();
        task.setConditionTime(TriggerConditionTime.eval(eventTime));
        task.setEventType(TriggerEvent.eval(eventType));
        String triggerActionType = getActionType();
        String triggerAction = triggerActionText.getText().trim();
        String crChar = "\r";
        String nlChar = "\n";
        triggerAction = triggerAction.replaceAll(crChar, "");
        triggerAction = triggerAction.replaceAll(nlChar, " ");
        task.setAction(Trigger.TriggerAction.eval(triggerActionType), triggerAction);
        if (triggerEventTargetTable.length() > 0) {
            if (triggerEventTargetColumn.length() > 0) {
                task.setEventTarget("\"" + triggerEventTargetTable + "\"(\"" + triggerEventTargetColumn + "\")");
            } else {
                task.setEventTarget("\"" + triggerEventTargetTable + "\"");
            }
        }
        String actionTime = getActionTime();
        if (!actionTime.equals(Messages.actionTimeDefault)) {
            // action time selected
            task.setActionTime(TriggerActionTime.eval(actionTime));
        }
        String triggerCondition = triggerConditionText.getText().trim();
        triggerCondition = triggerCondition.replaceAll(crChar, "");
        triggerCondition = triggerCondition.replaceAll(nlChar, " ");
        task.setCondition(triggerCondition);
        String triggerStatus = this.getStatus();
        task.setStatus(TriggerStatus.eval(triggerStatus));
        String strPriority = triggerPriorityText.getText();
        task.setPriority(strPriority);
        taskName = Messages.bind(Messages.addTriggerTaskName, triggerName);
        message = Messages.newTriggerSuccess;
        executedTask = task;
    } else if (buttonId == ALTER_TRIGGER_OK_ID) {
        AlterTriggerTask task = new AlterTriggerTask(database.getServer().getServerInfo());
        task.setDbName(database.getName());
        task.setTriggerName(trigger.getName());
        String triggerStatus = this.getStatus();
        task.setStatus(TriggerStatus.eval(triggerStatus));
        String strPriority = triggerPriorityText.getText();
        task.setPriority(strPriority);
        taskName = Messages.bind(Messages.alterTriggerTaskName, trigger.getName());
        message = Messages.alterTriggerSuccess;
        executedTask = task;
    }
    TaskExecutor taskExecutor = new CommonTaskExec(taskName);
    taskExecutor.addTask(executedTask);
    new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
    if (taskExecutor.isSuccess()) {
        setReturnCode(buttonId);
        close();
        CommonUITool.openInformationBox(Messages.msgInformation, message);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ITask(com.cubrid.common.core.task.ITask) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) AddTriggerTask(com.cubrid.cubridmanager.core.cubrid.trigger.task.AddTriggerTask) AlterTriggerTask(com.cubrid.cubridmanager.core.cubrid.trigger.task.AlterTriggerTask)

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