Search in sources :

Example 1 with GetAddVolumeStatusInfo

use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.GetAddVolumeStatusInfo 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);
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) MenuItem(org.eclipse.swt.widgets.MenuItem) FillLayout(org.eclipse.swt.layout.FillLayout) TableLabelProvider(com.cubrid.common.ui.spi.TableLabelProvider) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) GetAddVolumeStatusInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.GetAddVolumeStatusInfo) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ExpandItem(org.eclipse.swt.widgets.ExpandItem) AddVolumeDialog(com.cubrid.cubridmanager.ui.cubrid.dbspace.dialog.AddVolumeDialog) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 2 with GetAddVolumeStatusInfo

use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.GetAddVolumeStatusInfo 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();
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) GetAddVolumeStatusInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.GetAddVolumeStatusInfo) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) AddVolumeDialog(com.cubrid.cubridmanager.ui.cubrid.dbspace.dialog.AddVolumeDialog) 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)

Example 3 with GetAddVolumeStatusInfo

use of com.cubrid.cubridmanager.core.cubrid.dbspace.model.GetAddVolumeStatusInfo in project cubrid-manager by CUBRID.

the class AddVolumeDbTaskTest method testExecute.

public void testExecute() {
    String dbName = testDbName;
    GetAddVolumeStatusInfo getAddVolumeStatusInfo = new GetAddVolumeStatusInfo();
    final CommonQueryTask<GetAddVolumeStatusInfo> statusTask = new CommonQueryTask<GetAddVolumeStatusInfo>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), getAddVolumeStatusInfo);
    statusTask.setDbName(dbName);
    statusTask.execute();
    getAddVolumeStatusInfo = statusTask.getResultModel();
    assertNotNull(getAddVolumeStatusInfo);
    String volpath = getAddVolumeStatusInfo.getVolpath();
    assertNotNull(volpath);
    AddVolumeDbInfo addVolumeDbInfo = new AddVolumeDbInfo();
    addVolumeDbInfo.setDbname(dbName);
    addVolumeDbInfo.setPurpose("generic");
    addVolumeDbInfo.setPath(volpath);
    addVolumeDbInfo.setSize_need_mb("40");
    addVolumeDbInfo.setNumberofpage("10000");
    AddVolumeDbTask addTask = new AddVolumeDbTask(serverInfo);
    addTask.setDbname(dbName);
    addTask.setVolname(addVolumeDbInfo.getVolname());
    addTask.setPurpose(addVolumeDbInfo.getPurpose());
    addTask.setPath(addVolumeDbInfo.getPath());
    addTask.setNumberofpages(addVolumeDbInfo.getNumberofpage());
    addTask.setSizeNeedMb(addVolumeDbInfo.getSize_need_mb());
    //addTask.execute();
    assertNull(addTask.getErrorMsg());
}
Also used : AddVolumeDbInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.AddVolumeDbInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) GetAddVolumeStatusInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.GetAddVolumeStatusInfo)

Aggregations

CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)3 GetAddVolumeStatusInfo (com.cubrid.cubridmanager.core.cubrid.dbspace.model.GetAddVolumeStatusInfo)3 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)2 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)2 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)2 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)2 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)2 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)2 AddVolumeDialog (com.cubrid.cubridmanager.ui.cubrid.dbspace.dialog.AddVolumeDialog)2 TableContentProvider (com.cubrid.common.ui.spi.TableContentProvider)1 TableLabelProvider (com.cubrid.common.ui.spi.TableLabelProvider)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 AddVolumeDbInfo (com.cubrid.cubridmanager.core.cubrid.dbspace.model.AddVolumeDbInfo)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 FillLayout (org.eclipse.swt.layout.FillLayout)1