Search in sources :

Example 1 with RestoreDatabaseDialog

use of com.cubrid.cubridmanager.ui.cubrid.database.dialog.RestoreDatabaseDialog in project cubrid-manager by CUBRID.

the class RestoreDatabaseAction 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 RestoreDatabaseDialog dialog = new RestoreDatabaseDialog(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.loadDbBackupInfoTaskName, 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 GetBackupListTask) {
                    GetBackupListTask getDbBackupListTask = (GetBackupListTask) task;
                    dialog.setBackupList(getDbBackupListTask.getDbBackupList());
                }
            }
            return true;
        }
    };
    GetBackupListTask getDbBackupListTask = new GetBackupListTask(database.getServer().getServerInfo());
    getDbBackupListTask.setDbName(database.getLabel());
    taskExcutor.addTask(getDbBackupListTask);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (taskExcutor.isSuccess()) {
        dialog.open();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITask(com.cubrid.common.core.task.ITask) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) RestoreDatabaseDialog(com.cubrid.cubridmanager.ui.cubrid.database.dialog.RestoreDatabaseDialog) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) GetBackupListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetBackupListTask) 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 GetBackupListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetBackupListTask)1 RestoreDatabaseDialog (com.cubrid.cubridmanager.ui.cubrid.database.dialog.RestoreDatabaseDialog)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Shell (org.eclipse.swt.widgets.Shell)1