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();
}
}
Aggregations