Search in sources :

Example 41 with CommonTaskExec

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

the class ERSchemaEditor method syncComments.

/**
	 * sync table comments to db tables.
	* 
	* @return void
	 */
public void syncComments() {
    DatabaseInfo info = database.getDatabaseInfo();
    if (info == null) {
        CommonUITool.openErrorBox(Messages.errNoDatabase);
        return;
    }
    if (!info.isLogined()) {
        CommonUITool.openErrorBox(Messages.msgDBNotLogin);
        return;
    }
    ServerInfo serverInfo = info.getServerInfo();
    if (serverInfo != null && !serverInfo.isConnected()) {
        CommonUITool.openErrorBox(Messages.msgDBNotLogin);
        return;
    }
    boolean isSupportTableComment = false;
    Connection conn = null;
    try {
        conn = JDBCConnectionManager.getConnection(info, false);
        isSupportTableComment = SchemaCommentHandler.isInstalledMetaTable(info, conn);
        if (!isSupportTableComment) {
            CommonUITool.openErrorBox(Messages.cannotSyncComments);
            return;
        }
    } catch (Exception e) {
        LOGGER.error("", e);
    } finally {
        QueryUtil.freeQuery(conn);
    }
    if (!CommonUITool.openConfirmBox(getSite().getShell(), Messages.bind(Messages.msgConfirmSyncComments, database.getLabel()))) {
        return;
    }
    CommonTaskExec taskJobExec = new CommonTaskExec(null);
    List<UpdateDescriptionTask> updateDescTasks = getUpdateDescriptionTaskList(info);
    for (UpdateDescriptionTask task : updateDescTasks) {
        taskJobExec.addTask(task);
    }
    if (updateDescTasks.size() == 0) {
        CommonUITool.openInformationBox(Messages.msgNoComments);
        return;
    }
    new ExecTaskWithProgress(taskJobExec).exec();
    Set<String> failTables = new HashSet<String>();
    for (UpdateDescriptionTask task : updateDescTasks) {
        if (!task.isSuccess()) {
            failTables.add(task.getTableName());
        }
    }
    if (failTables.size() == 0) {
        CommonUITool.openInformationBox(Messages.msgSuccessSyncComments);
    } else {
        CommonUITool.openErrorBox(Messages.bind(Messages.errSyncComments, failTables.toString()));
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ERVirtualDatabaseInfo(com.cubrid.common.ui.er.model.ERVirtualDatabaseInfo) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) WrappedDatabaseInfo(com.cubrid.common.ui.cubrid.database.erwin.WrappedDatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) Connection(java.sql.Connection) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) PartInitException(org.eclipse.ui.PartInitException) SQLException(java.sql.SQLException) UpdateDescriptionTask(com.cubrid.cubridmanager.core.cubrid.table.task.UpdateDescriptionTask) HashSet(java.util.HashSet)

Example 42 with CommonTaskExec

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

the class ServicePropertyPage method perform.

/**
	 *
	 * Perform the task and set cubrid.conf configuration file service section
	 * parameter
	 *
	 * @param confParaMap the conf parameter map
	 */
private void perform(Map<String, Map<String, String>> confParaMap) {
    SetCubridConfParameterTask task = new SetCubridConfParameterTask(node.getServer().getServerInfo());
    task.setConfParameters(confParaMap);
    CommonTaskExec taskExcutor = new CommonTaskExec(Messages.setCubridParameterTaskName);
    taskExcutor.addTask(task);
    new ExecTaskWithProgress(taskExcutor).exec(true, true);
    if (taskExcutor.isSuccess()) {
        CommonUITool.openInformationBox(Messages.titleSuccess, Messages.msgChangeServiceParaSuccess);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) SetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.SetCubridConfParameterTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)

Example 43 with CommonTaskExec

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

the class DeleteDatabaseAction method run.

public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    ISelectionProvider provider = this.getSelectionProvider();
    if (!(provider instanceof TreeViewer)) {
        return;
    }
    ISchemaNode node = (ISchemaNode) obj[0];
    CubridDatabase database = node.getDatabase();
    if (database == null) {
        CommonUITool.openErrorBox(getShell(), Messages.msgSelectDB);
        return;
    }
    CommonQueryTask<DbSpaceInfoList> task = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoList());
    task.setDbName(database.getName());
    TaskExecutor taskExcutor = new CommonTaskExec(Messages.getDbSpaceInfoTaskName);
    taskExcutor.addTask(task);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (!taskExcutor.isSuccess()) {
        return;
    }
    DeleteDatabaseDialog dlg = new DeleteDatabaseDialog(getShell());
    dlg.setDbSpaceInfo(task.getResultModel());
    dlg.setDatabase(database);
    ICubridNode parent = database.getParent();
    if (dlg.open() == DeleteDatabaseDialog.DELETE_ID) {
        boolean isContinue = DatabaseUtils.processDatabaseDeleted(database);
        if (isContinue) {
            TreeViewer viewer = (TreeViewer) provider;
            parent.removeChild(database);
            viewer.remove(parent, obj);
            viewer.setSelection(new StructuredSelection(parent));
        }
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DeleteDatabaseDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.DeleteDatabaseDialog) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 44 with CommonTaskExec

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

the class AddStatusMonitorTemplateAction method run.

/**
	 * Override the run method in order to open an instance of status monitor
	 * dialog
	 *
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    ICubridNode selection = (ICubridNode) obj[0];
    ServerInfo site = selection.getServer().getServerInfo();
    boolean execDiagChecked = false;
    final GetCMConfParameterTask task = new GetCMConfParameterTask(site);
    TaskExecutor taskExec = new CommonTaskExec(null);
    taskExec.addTask(task);
    new ExecTaskWithProgress(taskExec).exec();
    if (!taskExec.isSuccess()) {
        return;
    }
    Map<String, String> confParas = task.getConfParameters();
    if (confParas == null) {
        execDiagChecked = false;
    } else {
        if (confParas.get(ConfConstants.EXECUTE_DIAG) == null) {
            execDiagChecked = false;
        } else {
            execDiagChecked = confParas.get(ConfConstants.EXECUTE_DIAG).equals(OnOffType.ON.getText()) ? true : false;
        }
    }
    DiagStatusMonitorTemplateDialog dialog = new DiagStatusMonitorTemplateDialog(getShell());
    dialog.setOperation(AddEditType.ADD);
    dialog.setSelection(selection);
    dialog.setExecDiagChecked(execDiagChecked);
    if (dialog.open() == Dialog.OK) {
        StatusTemplateInfo statusTemplateInfo = dialog.getStatusTemplateInfo();
        AddStatusTemplateTask addTask = new AddStatusTemplateTask(site);
        addTask.setStatusTemplateInfo(statusTemplateInfo);
        addTask.buildMsg();
        String taskName = Messages.bind(Messages.addTemplateTaskName, statusTemplateInfo.getName());
        TaskExecutor taskExecutor = new CommonTaskExec(taskName);
        taskExecutor.addTask(addTask);
        new ExecTaskWithProgress(taskExecutor).exec();
        if (taskExecutor.isSuccess()) {
            TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
            CommonUITool.refreshNavigatorTree(treeViewer, selection);
        }
    }
}
Also used : DiagStatusMonitorTemplateDialog(com.cubrid.cubridmanager.ui.monitoring.dialog.DiagStatusMonitorTemplateDialog) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) StatusTemplateInfo(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) AddStatusTemplateTask(com.cubrid.cubridmanager.core.monitoring.task.AddStatusTemplateTask)

Example 45 with CommonTaskExec

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

the class EditStatusMonitorTemplateAction method run.

/**
	 * Override the run method in order to open an instance of status monitor
	 * dialog
	 * 
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    ICubridNode selection = (ICubridNode) obj[0];
    ServerInfo serverInfo = selection.getServer().getServerInfo();
    boolean execDiagChecked = false;
    final GetCMConfParameterTask task = new GetCMConfParameterTask(serverInfo);
    TaskExecutor taskExec = new CommonTaskExec(null);
    taskExec.addTask(task);
    new ExecTaskWithProgress(taskExec).exec();
    if (!taskExec.isSuccess()) {
        return;
    }
    Map<String, String> confParas = task.getConfParameters();
    if (confParas == null) {
        execDiagChecked = false;
    } else {
        if (confParas.get(ConfConstants.EXECUTE_DIAG) == null) {
            execDiagChecked = false;
        } else {
            execDiagChecked = confParas.get(ConfConstants.EXECUTE_DIAG).equals(OnOffType.ON.getText()) ? true : false;
        }
    }
    DiagStatusMonitorTemplateDialog dialog = new DiagStatusMonitorTemplateDialog(getShell());
    dialog.setOperation(AddEditType.EDIT);
    dialog.setSelection(selection);
    dialog.setExecDiagChecked(execDiagChecked);
    if (dialog.open() == Dialog.OK) {
        StatusTemplateInfo statusTemplateInfo = dialog.getStatusTemplateInfo();
        UpdateStatusTemplateTask updateTask = new UpdateStatusTemplateTask(serverInfo);
        updateTask.setStatusTemplateInfo(statusTemplateInfo);
        updateTask.buildMsg();
        String taskName = Messages.bind(Messages.editTemplateTaskName, statusTemplateInfo.getName());
        TaskExecutor taskExecutor = new CommonTaskExec(taskName);
        taskExecutor.addTask(updateTask);
        new ExecTaskWithProgress(taskExecutor).exec();
        if (taskExecutor.isSuccess()) {
            TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
            CommonUITool.refreshNavigatorTree(treeViewer, selection.getParent());
        }
    }
}
Also used : DiagStatusMonitorTemplateDialog(com.cubrid.cubridmanager.ui.monitoring.dialog.DiagStatusMonitorTemplateDialog) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) StatusTemplateInfo(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) UpdateStatusTemplateTask(com.cubrid.cubridmanager.core.monitoring.task.UpdateStatusTemplateTask)

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