Search in sources :

Example 1 with SetAutoAddVolumeDialog

use of com.cubrid.cubridmanager.ui.cubrid.dbspace.dialog.SetAutoAddVolumeDialog in project cubrid-manager by CUBRID.

the class SetAutoAddVolumeAction method run.

/**
	 * Creates a Dialog which is the instance of SetAutoAddVolumeDialog to set a
	 * auto adding volume
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    DefaultSchemaNode selection = null;
    CubridDatabase database = null;
    if (obj.length > 0 && obj[0] instanceof DefaultSchemaNode) {
        selection = (DefaultSchemaNode) obj[0];
        database = selection.getDatabase();
    }
    if (database == null) {
        CommonUITool.openErrorBox(Messages.msgSelectDB);
        return;
    }
    //Get the info of AutoAddVolumeInfo
    GetAutoAddVolumeInfo getAutoAddVolumeInfo = new GetAutoAddVolumeInfo();
    final CommonQueryTask<GetAutoAddVolumeInfo> autoAddVolumetask = new CommonQueryTask<GetAutoAddVolumeInfo>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), getAutoAddVolumeInfo);
    autoAddVolumetask.setDbName(database.getLabel());
    TaskExecutor taskExecutor = new CommonTaskExec(com.cubrid.cubridmanager.ui.cubrid.dbspace.Messages.getVolumeInfoTaskName);
    taskExecutor.addTask(autoAddVolumetask);
    //Gets the page size in the database
    int pageSize = 0;
    CommonQueryTask<DbSpaceInfoList> spaceInfoTask = null;
    DatabaseInfo databaseInfo = database.getDatabaseInfo();
    DbSpaceInfoList dbSpaceInfoList = databaseInfo.getDbSpaceInfoList();
    if (null == dbSpaceInfoList) {
        dbSpaceInfoList = new DbSpaceInfoList();
        spaceInfoTask = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), dbSpaceInfoList);
        spaceInfoTask.setDbName(database.getLabel());
        taskExecutor.addTask(spaceInfoTask);
    }
    new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
    if (!taskExecutor.isSuccess()) {
        return;
    }
    if (spaceInfoTask == null) {
        pageSize = dbSpaceInfoList.getPagesize();
    } else {
        final DbSpaceInfoList model = ((CommonQueryTask<DbSpaceInfoList>) spaceInfoTask).getResultModel();
        pageSize = model.getPagesize();
    }
    getAutoAddVolumeInfo = autoAddVolumetask.getResultModel();
    SetAutoAddVolumeDialog dialog = new SetAutoAddVolumeDialog(getShell());
    dialog.setGetAutoAddVolumeInfo(getAutoAddVolumeInfo);
    dialog.setPageSize(pageSize);
    GetAutoAddVolumeInfo returnInfo = dialog.getGetAutoAddVolumeInfo();
    if (dialog.open() == Dialog.OK) {
        ServerInfo serverInfo = database.getServer().getServerInfo();
        SetAutoAddVolumeTask setTask = new SetAutoAddVolumeTask(serverInfo);
        setTask.setDbname(database.getName());
        setTask.setData(returnInfo.getData());
        setTask.setDataWarnOutofspace(returnInfo.getData_warn_outofspace());
        setTask.setDataExtPage(returnInfo.getData_ext_page());
        setTask.setIndex(returnInfo.getIndex());
        setTask.setIndexWarnOutofspace(returnInfo.getIndex_warn_outofspace());
        setTask.setIndexExtPage(returnInfo.getIndex_ext_page());
        taskExecutor = new CommonTaskExec(com.cubrid.cubridmanager.ui.cubrid.dbspace.Messages.setAutoAddedVolInfoTaskName);
        taskExecutor.addTask(setTask);
        new ExecTaskWithProgress(taskExecutor).exec();
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) SetAutoAddVolumeDialog(com.cubrid.cubridmanager.ui.cubrid.dbspace.dialog.SetAutoAddVolumeDialog) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) SetAutoAddVolumeTask(com.cubrid.cubridmanager.core.cubrid.dbspace.task.SetAutoAddVolumeTask) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) GetAutoAddVolumeInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.GetAutoAddVolumeInfo)

Aggregations

CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)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 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)1 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)1 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)1 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)1 GetAutoAddVolumeInfo (com.cubrid.cubridmanager.core.cubrid.dbspace.model.GetAutoAddVolumeInfo)1 SetAutoAddVolumeTask (com.cubrid.cubridmanager.core.cubrid.dbspace.task.SetAutoAddVolumeTask)1 SetAutoAddVolumeDialog (com.cubrid.cubridmanager.ui.cubrid.dbspace.dialog.SetAutoAddVolumeDialog)1