Search in sources :

Example 36 with ExecTaskWithProgress

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

the class ExecuteSqlLogAction method run.

/**
	 * Open dialog
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    DefaultCubridNode node = null;
    LogInfo logInfo = null;
    node = (DefaultCubridNode) obj[0];
    String targetBroker = node.getParent().getParent().getLabel();
    logInfo = (LogInfo) node.getAdapter(LogInfo.class);
    List<String> allDatabaseList = node.getServer().getServerInfo().getAllDatabaseList();
    BrokerInfos brokerInfos = node.getServer().getServerInfo().getBrokerInfos();
    CasRunnerConfigDialog casRunnerConfigDialog = new CasRunnerConfigDialog(getShell());
    casRunnerConfigDialog.setBrokerInfos(brokerInfos);
    casRunnerConfigDialog.setAllDatabaseList(allDatabaseList);
    casRunnerConfigDialog.setLogInfo(logInfo);
    casRunnerConfigDialog.setTargetBroker(targetBroker);
    casRunnerConfigDialog.setExecwithFile(true);
    casRunnerConfigDialog.create();
    if (casRunnerConfigDialog.open() == Dialog.OK) {
        final GetExecuteCasRunnerResultTask task = new GetExecuteCasRunnerResultTask(((DefaultCubridNode) obj[0]).getServer().getServerInfo());
        task.setBrokerName(CasRunnerConfigDialog.getBrokerName());
        task.setUserName(CasRunnerConfigDialog.getUserName());
        task.setPasswd(CasRunnerConfigDialog.getPassword());
        task.setNumThread(CasRunnerConfigDialog.getNumThread());
        task.setRepeatCount(casRunnerConfigDialog.getNumRepeatCount());
        String isShowqueryresult = "";
        if (casRunnerConfigDialog.isShowqueryresult()) {
            isShowqueryresult = "yes";
        } else {
            isShowqueryresult = "no";
        }
        task.setShowQueryResult(isShowqueryresult);
        String isShowqueryplan = "";
        if (casRunnerConfigDialog.isShowqueryplan()) {
            isShowqueryplan = "yes";
        } else {
            isShowqueryplan = "no";
        }
        task.setShowQueryResult(isShowqueryplan);
        task.setDbName(CasRunnerConfigDialog.getDbname());
        task.setExecuteLogFile("yes");
        task.setLogFile(logInfo.getPath());
        TaskExecutor taskExcutor = new CommonTaskExec(Messages.loadSqlLogExecResultTaskName);
        taskExcutor.addTask(task);
        new ExecTaskWithProgress(taskExcutor).exec();
        if (!taskExcutor.isSuccess()) {
            return;
        }
        GetExecuteCasRunnerResultInfo getExecuteCasRunnerResultInfo = (GetExecuteCasRunnerResultInfo) task.getContent();
        StringBuffer result = new StringBuffer("");
        if (getExecuteCasRunnerResultInfo.getResult() != null) {
            for (int i = 0, n = getExecuteCasRunnerResultInfo.getResult().size(); i < n; i++) {
                result.append(getExecuteCasRunnerResultInfo.getResult().get(i) + "\n");
            }
        }
        CasRunnerResultDialog casRunnerResultDialog = new CasRunnerResultDialog(getShell());
        casRunnerResultDialog.setResult(result);
        casRunnerResultDialog.open();
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) GetExecuteCasRunnerResultInfo(com.cubrid.cubridmanager.core.logs.model.GetExecuteCasRunnerResultInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) CasRunnerConfigDialog(com.cubrid.cubridmanager.ui.logs.dialog.CasRunnerConfigDialog) CasRunnerResultDialog(com.cubrid.cubridmanager.ui.logs.dialog.CasRunnerResultDialog) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) GetExecuteCasRunnerResultTask(com.cubrid.cubridmanager.core.logs.task.GetExecuteCasRunnerResultTask)

Example 37 with ExecTaskWithProgress

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

the class CasRunnerResultViewDialog method connectInit.

/**
	 * initialize log view table.
	 *
	 * @param logPath String
	 * @param dbName String
	 * @param node DefaultCubridNode
	 */
public void connectInit(String logPath, String dbName, DefaultCubridNode node) {
    this.selection = node;
    final GetLogListTask taskGetLog = new GetLogListTask(node.getServer().getServerInfo());
    path = logPath;
    this.dbName = dbName;
    taskGetLog.setPath(path + "." + String.valueOf(currentResultFileIndex - 1));
    taskGetLog.setDbName(dbName);
    taskGetLog.setStart("1");
    taskGetLog.setEnd(Long.toString(LINE_NUM_TO_DISPLAY));
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.loadLogTaskName);
    taskExecutor.addTask(taskGetLog);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (taskExecutor.isSuccess()) {
        LogContentInfo logContentInfo = (LogContentInfo) taskGetLog.getLogContent();
        this.setinfo(logContentInfo, selection);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) LogContentInfo(com.cubrid.cubridmanager.core.logs.model.LogContentInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) GetLogListTask(com.cubrid.cubridmanager.core.logs.task.GetLogListTask)

Example 38 with ExecTaskWithProgress

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

the class CasRunnerResultViewDialog method connect.

/**
	 * each page of log connect
	 *
	 */
public void connect() {
    final GetLogListTask task = new GetLogListTask(selection.getServer().getServerInfo());
    task.setPath(path + "." + String.valueOf(currentResultFileIndex - 1));
    task.setDbName(dbName);
    task.setStart(Long.toString(lineStart));
    task.setEnd(Long.toString(lineEnd));
    task.execute();
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.loadLogTaskName);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (taskExecutor.isSuccess()) {
        LogContentInfo logContentInfo = (LogContentInfo) task.getLogContent();
        this.setinfo(logContentInfo, selection);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) LogContentInfo(com.cubrid.cubridmanager.core.logs.model.LogContentInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) GetLogListTask(com.cubrid.cubridmanager.core.logs.task.GetLogListTask)

Example 39 with ExecTaskWithProgress

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

the class ResetAdminLogAction method run.

/**
	 * Reset Admin log
	 */
public void run() {
    if (!CommonUITool.openConfirmBox(Messages.warningResetAdminLog)) {
        return;
    }
    Object[] selected = this.getSelectedObj();
    LogInfo logInfo = (LogInfo) ((DefaultCubridNode) selected[0]).getAdapter(LogInfo.class);
    ResetLogTask resetLogTask = new ResetLogTask(((DefaultCubridNode) selected[0]).getServer().getServerInfo());
    resetLogTask.setPath(logInfo.getPath());
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.resetAdminLogTaskName);
    taskExecutor.addTask(resetLogTask);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (taskExecutor.isSuccess()) {
        refreshLogEditor((ICubridNode) selected[0]);
        CommonUITool.openInformationBox(Messages.msgSuccess, Messages.msgDeleteAllLog);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) ResetLogTask(com.cubrid.cubridmanager.core.logs.task.ResetLogTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)

Example 40 with ExecTaskWithProgress

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

the class ResetAdminLogAction 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) {
        LogInfo logInfo = (LogInfo) node.getAdapter(LogInfo.class);
        TaskExecutor taskExecutor = new CommonTaskExec(Messages.viewLogJobName);
        GetLogListTask task = new GetLogListTask(node.getServer().getServerInfo());
        task.setPath(logInfo.getPath());
        task.setStart("1");
        task.setEnd("100");
        taskExecutor.addTask(task);
        new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
        LogContentInfo logContentInfo = (LogContentInfo) task.getLogContent();
        try {
            editor = window.getActivePage().openEditor(node, LogEditorPart.ID);
            ((LogEditorPart) editor).setTableInfo(logContentInfo, true);
        } 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) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) LogContentInfo(com.cubrid.cubridmanager.core.logs.model.LogContentInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) GetLogListTask(com.cubrid.cubridmanager.core.logs.task.GetLogListTask) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) LogEditorPart(com.cubrid.cubridmanager.ui.logs.editor.LogEditorPart)

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