use of com.cubrid.cubridmanager.ui.cubrid.dbspace.dialog.AddVolumeDialog in project cubrid-manager by CUBRID.
the class DatabaseDashboardEditor method createVolumnComposite.
/**
* create volumn information composite
*
* @param bar ExpandBar
* @param bar index
*
*/
public void createVolumnComposite(ExpandBar bar, int index) {
ExpandItem volumnItem = new ExpandItem(bar, SWT.NONE, index);
volumnItem.setText(Messages.exportDashboardVolumnTableTitle);
Composite volumnComposite = new Composite(bar, SWT.NONE);
volumnComposite.setLayout(new FillLayout());
volumnInfoTableViewer = new TableViewer(volumnComposite, SWT.BORDER | SWT.FULL_SELECTION);
volumnInfoTableViewer.getTable().setHeaderVisible(true);
volumnInfoTableViewer.getTable().setLinesVisible(true);
final TableViewerColumn columnVolumn = new TableViewerColumn(volumnInfoTableViewer, SWT.CENTER);
columnVolumn.getColumn().setWidth(140);
columnVolumn.getColumn().setText(Messages.volumnTableVolumnNameColumnLabel);
columnVolumn.getColumn().setToolTipText(Messages.volumnTableVolumnNameColumnLabel);
final TableViewerColumn columnType = new TableViewerColumn(volumnInfoTableViewer, SWT.CENTER);
columnType.getColumn().setWidth(90);
columnType.getColumn().setText(Messages.volumnTableVolumnTypeColumnLabel);
columnType.getColumn().setToolTipText(Messages.volumnTableVolumnTypeColumnLabel);
final TableViewerColumn columnFreeSize = new TableViewerColumn(volumnInfoTableViewer, SWT.RIGHT);
columnFreeSize.getColumn().setWidth(90);
columnFreeSize.getColumn().setText(Messages.volumnTableFreesizeColumnLabel);
columnFreeSize.getColumn().setToolTipText(Messages.volumnTableFreesizeColumnLabel);
final TableViewerColumn columnTotalSize = new TableViewerColumn(volumnInfoTableViewer, SWT.RIGHT);
columnTotalSize.getColumn().setWidth(90);
columnTotalSize.getColumn().setText(Messages.volumnTableTotalsizeColumnLabel);
columnTotalSize.getColumn().setToolTipText(Messages.volumnTableTotalsizeColumnLabel);
final TableViewerColumn lastModifyDate = new TableViewerColumn(volumnInfoTableViewer, SWT.CENTER);
lastModifyDate.getColumn().setWidth(90);
lastModifyDate.getColumn().setText(Messages.volumnTableLastModifyTimeColumnLabel);
lastModifyDate.getColumn().setToolTipText(Messages.volumnTableLastModifyTimeColumnLabel);
final TableViewerColumn columnLocation = new TableViewerColumn(volumnInfoTableViewer, SWT.LEFT);
columnLocation.getColumn().setWidth(300);
columnLocation.getColumn().setText(Messages.tblColumnVolPath);
columnLocation.getColumn().setToolTipText(Messages.tblColumnVolPath);
volumnInfoTableViewer.setContentProvider(new TableContentProvider());
volumnInfoTableViewer.setLabelProvider(new TableLabelProvider());
Table table = volumnInfoTableViewer.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
volumnInfoTableViewer.setInput(volumnInfoListData);
volumnItem.setControl(volumnComposite);
volumnItem.setHeight(130);
volumnItem.setExpanded(true);
Menu menu = new Menu(this.getSite().getShell(), SWT.POP_UP);
final MenuItem itemAddVolumn = new MenuItem(menu, SWT.PUSH);
itemAddVolumn.setText(com.cubrid.cubridmanager.ui.spi.Messages.setAddVolumeActionName);
itemAddVolumn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DefaultSchemaNode node = null;
for (ICubridNode cubridNode : database.getChildren()) {
if (cubridNode.getType().equals(CubridNodeType.DBSPACE_FOLDER)) {
node = (DefaultSchemaNode) cubridNode;
}
}
if (node == null) {
return;
}
// Gets the status of adding volume
GetAddVolumeStatusInfo getAddVolumeStatusInfo = new GetAddVolumeStatusInfo();
final CommonQueryTask<GetAddVolumeStatusInfo> statusTask = new CommonQueryTask<GetAddVolumeStatusInfo>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), getAddVolumeStatusInfo);
statusTask.setDbName(database.getLabel());
TaskExecutor taskExecutor = new CommonTaskExec(com.cubrid.cubridmanager.ui.cubrid.dbspace.Messages.getVolumeInfoTaskName);
taskExecutor.addTask(statusTask);
CommonQueryTask<DbSpaceInfoList> spaceInfoTask = null;
DatabaseInfo databaseInfo = database.getDatabaseInfo();
DbSpaceInfoList dbSpaceInfoList = databaseInfo.getDbSpaceInfoList();
int pageSize = 0;
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 (spaceInfoTask == null) {
pageSize = dbSpaceInfoList.getPagesize();
} else {
final DbSpaceInfoList model = ((CommonQueryTask<DbSpaceInfoList>) spaceInfoTask).getResultModel();
pageSize = model.getPagesize();
}
getAddVolumeStatusInfo = statusTask.getResultModel();
//open add volumn dialog
AddVolumeDialog addVolumeDialog = new AddVolumeDialog(getSite().getShell());
addVolumeDialog.setGetAddVolumeStatusInfo(getAddVolumeStatusInfo);
addVolumeDialog.initPara(node);
addVolumeDialog.setTreeViewer(CubridNavigatorView.getNavigatorView("com.cubrid.cubridmanager.host.navigator").getViewer());
addVolumeDialog.setPageSize(pageSize);
int returnCode = addVolumeDialog.open();
//if add volumn refresh table
if (returnCode == IDialogConstants.OK_ID) {
volumnInfoListData.clear();
loadVolumnsInfo();
volumnInfoTableViewer.refresh();
}
}
});
volumnInfoTableViewer.getTable().setMenu(menu);
tableViewOnBarIndexMap.put(volumnInfoTableViewer, index);
}
use of com.cubrid.cubridmanager.ui.cubrid.dbspace.dialog.AddVolumeDialog in project cubrid-manager by CUBRID.
the class AddVolumeAction method run.
/**
*
* Creates a Dialog which is the instance of AddVolumeDialog to add a query
* plan
*
*/
public void run() {
Object[] obj = this.getSelectedObj();
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;
}
// Gets the status of adding volume
GetAddVolumeStatusInfo getAddVolumeStatusInfo = new GetAddVolumeStatusInfo();
final CommonQueryTask<GetAddVolumeStatusInfo> statusTask = new CommonQueryTask<GetAddVolumeStatusInfo>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), getAddVolumeStatusInfo);
statusTask.setDbName(database.getLabel());
TaskExecutor taskExecutor = new CommonTaskExec(com.cubrid.cubridmanager.ui.cubrid.dbspace.Messages.getVolumeInfoTaskName);
taskExecutor.addTask(statusTask);
CommonQueryTask<DbSpaceInfoList> spaceInfoTask = null;
DatabaseInfo databaseInfo = database.getDatabaseInfo();
DbSpaceInfoList dbSpaceInfoList = databaseInfo.getDbSpaceInfoList();
int pageSize = 0;
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 (spaceInfoTask == null) {
pageSize = dbSpaceInfoList.getPagesize();
} else {
final DbSpaceInfoList model = ((CommonQueryTask<DbSpaceInfoList>) spaceInfoTask).getResultModel();
pageSize = model.getPagesize();
}
getAddVolumeStatusInfo = statusTask.getResultModel();
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
AddVolumeDialog addVolumeDialog = new AddVolumeDialog(getShell());
addVolumeDialog.setGetAddVolumeStatusInfo(getAddVolumeStatusInfo);
addVolumeDialog.initPara(selection);
addVolumeDialog.setTreeViewer(treeViewer);
addVolumeDialog.setPageSize(pageSize);
addVolumeDialog.open();
}
Aggregations