Search in sources :

Example 91 with ExecTaskWithProgress

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

the class CreateViewAction method run.

public void run(CubridDatabase database) {
    TaskExecutor taskExcutor = new CommonTaskExec(null);
    DatabaseInfo databaseInfo = database.getDatabaseInfo();
    JDBCGetAllDbUserTask task = new JDBCGetAllDbUserTask(databaseInfo);
    taskExcutor.addTask(task);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (!taskExcutor.isSuccess()) {
        return;
    }
    List<String> dbUserList = task.getDbUserList();
    CreateViewDialog dialog = new CreateViewDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), database, true);
    dialog.setDbUserList(dbUserList);
    ISelectionProvider provider = getSelectionProvider();
    if (dialog.open() == IDialogConstants.OK_ID && (provider instanceof TreeViewer)) {
        TreeViewer treeViewer = (TreeViewer) provider;
        ICubridNode folderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridViewsFolderLoader.VIEWS_FOLDER_ID);
        if (folderNode == null || !folderNode.getLoader().isLoaded()) {
            return;
        }
        String viewName = dialog.getNewViewName();
        String owner = dialog.getOwner();
        String id = folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + viewName;
        ClassInfo newClassInfo = new ClassInfo(viewName, owner, ClassType.VIEW, false, false);
        ICubridNode newNode = CubridViewsFolderLoader.createUserViewNode(id, newClassInfo);
        CommonUITool.addNodeToTree(treeViewer, folderNode, newNode);
        CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, folderNode);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
    } else {
        canceledTask = true;
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) JDBCGetAllDbUserTask(com.cubrid.cubridmanager.core.cubrid.user.task.JDBCGetAllDbUserTask) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) CreateViewDialog(com.cubrid.common.ui.cubrid.table.dialog.CreateViewDialog) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ClassInfo(com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)

Example 92 with ExecTaskWithProgress

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

the class EditFunctionDialog method execute.

/**
	 * Execute tasks
	 *
	 * @param buttonId the button id
	 * @param tasks the task array
	 */
public void execute(final int buttonId, final ITask[] tasks) {
    TaskExecutor taskExcutor = new CommonTaskExec(null);
    taskExcutor.setTask(tasks);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (taskExcutor.isSuccess() && buttonId >= 0) {
        setReturnCode(buttonId);
        close();
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)

Example 93 with ExecTaskWithProgress

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

the class RowDetailDialog method exportData.

/**
	 * Export data
	 *
	 * @param filePath String
	 */
private void exportData(final String filePath) {
    final String oidStr = dataItem.getText(1);
    final String value = columnValueText.getText();
    final String fileCharset = fileCharsetCombo.getText();
    AbstractUITask task = new AbstractUITask() {

        boolean isSuccess = false;

        public void execute(final IProgressMonitor monitor) {
            try {
                export(filePath, oidStr, value, fileCharset);
                isSuccess = true;
            } catch (IOException e) {
                errorMsg = e.getMessage();
            } catch (SQLException e) {
                errorMsg = e.getMessage();
            }
        }

        public void cancel() {
        //empty
        }

        public void finish() {
        //empty
        }

        public boolean isCancel() {
            return false;
        }

        public boolean isSuccess() {
            return isSuccess;
        }
    };
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.exportDataTaskName);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (taskExecutor.isSuccess()) {
        CommonUITool.openInformationBox(getShell(), com.cubrid.common.ui.common.Messages.titleSuccess, Messages.msgExportData);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) AbstractUITask(com.cubrid.common.core.task.AbstractUITask) SQLException(java.sql.SQLException) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) IOException(java.io.IOException)

Example 94 with ExecTaskWithProgress

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

the class RowDetailDialog method updateData.

/**
	 * Update data
	 */
private void updateData() {
    if (!validate()) {
        return;
    }
    final String columnValue = columnValueText.getText();
    final String fileCharset = fileCharsetCombo.getText();
    final String oid = dataItem.getText(1);
    final boolean updateDB = !QueryExecuter.isNewInsertedRecordItem(dataItem);
    AbstractUITask task = new AbstractUITask() {

        boolean isSuccess = false;

        public void execute(IProgressMonitor monitor) {
            errorMsg = update(columnValue, fileCharset, oid, updateDB);
            isSuccess = errorMsg == null;
        }

        public void cancel() {
        //empty
        }

        public void finish() {
        //empty
        }

        public boolean isCancel() {
            return false;
        }

        public boolean isSuccess() {
            return isSuccess;
        }
    };
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.updateDataTaskName);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).exec();
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) AbstractUITask(com.cubrid.common.core.task.AbstractUITask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)

Example 95 with ExecTaskWithProgress

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

the class ColumnViewerSorter method refresh.

/**
	 * Refresh the data
	 *
	 * @param name
	 */
private void refresh(String name) {
    final LoadTableDetailInfoTask loadTableDetailInfoTask = new LoadTableDetailInfoTask(Messages.tablesDetailInfoLoadingDataTitle, database, name);
    CommonTaskExec taskExec = new CommonTaskExec(Messages.bind(Messages.tablesDetailInfoLoadingData, name));
    taskExec.addTask(loadTableDetailInfoTask);
    new ExecTaskWithProgress(taskExec).busyCursorWhile();
    if (taskExec.isSuccess()) {
        TableDetailInfo tableInfo = loadTableDetailInfoTask.getTableInfo();
        if (tableInfo != null) {
            TableDetailInfo oldTableInfo = findTableInfo(name);
            if (oldTableInfo != null) {
                TableDetailInfo.copyAllAttribute(tableInfo, oldTableInfo);
                tableListView.refresh();
            } else {
                tableList.add(tableInfo);
                tableListView.refresh();
            }
        }
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) LoadTableDetailInfoTask(com.cubrid.common.ui.spi.progress.LoadTableDetailInfoTask)

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