Search in sources :

Example 1 with GetDbUnloadInfoTask

use of com.cubrid.cubridmanager.core.cubrid.database.task.GetDbUnloadInfoTask in project cubrid-manager by CUBRID.

the class LoadDatabaseAction method run.

public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    ISchemaNode node = (ISchemaNode) obj[0];
    final CubridDatabase database = node.getDatabase();
    final LoadDatabaseDialog dialog = new LoadDatabaseDialog(getShell());
    dialog.setDatabase(database);
    final Shell shell = getShell();
    TaskExecutor taskExcutor = new TaskExecutor() {

        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            monitor.beginTask(Messages.loadDbUnloadInfoTaskName, IProgressMonitor.UNKNOWN);
            for (ITask task : taskList) {
                task.execute();
                final String msg = task.getErrorMsg();
                if (openErrorBox(shell, msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
                if (task instanceof GetDbUnloadInfoTask) {
                    GetDbUnloadInfoTask getDbUnloadInfoTask = (GetDbUnloadInfoTask) task;
                    List<DbUnloadInfo> dbUnloadInfoList = getDbUnloadInfoTask.getDbUnloadInfoList();
                    dialog.setDbUnloadInfoList(dbUnloadInfoList);
                }
            }
            return true;
        }
    };
    ServerInfo serverInfo = database.getServer().getServerInfo();
    GetDbUnloadInfoTask task = new GetDbUnloadInfoTask(serverInfo);
    taskExcutor.addTask(task);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (taskExcutor.isSuccess()) {
        dialog.open();
    }
}
Also used : ITask(com.cubrid.common.core.task.ITask) LoadDatabaseDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.LoadDatabaseDialog) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) DbUnloadInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DbUnloadInfo) GetDbUnloadInfoTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDbUnloadInfoTask) Shell(org.eclipse.swt.widgets.Shell) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

ITask (com.cubrid.common.core.task.ITask)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)1 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)1 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)1 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)1 DbUnloadInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DbUnloadInfo)1 GetDbUnloadInfoTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDbUnloadInfoTask)1 LoadDatabaseDialog (com.cubrid.cubridmanager.ui.cubrid.database.dialog.LoadDatabaseDialog)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Shell (org.eclipse.swt.widgets.Shell)1