Search in sources :

Example 1 with DeleteDatabaseDialog

use of com.cubrid.cubridmanager.ui.cubrid.database.dialog.DeleteDatabaseDialog 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)

Aggregations

CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)1 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)1 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)1 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)1 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)1 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)1 DeleteDatabaseDialog (com.cubrid.cubridmanager.ui.cubrid.database.dialog.DeleteDatabaseDialog)1 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1