Search in sources :

Example 36 with ServerInfo

use of com.cubrid.cubridmanager.core.common.model.ServerInfo 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)

Example 37 with ServerInfo

use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.

the class AddVolumeDialog method createDialogArea.

/**
	 * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 * @param parent The parent composite to contain the dialog area
	 * @return the dialog area control
	 */
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    setTitle(Messages.dialogTitle);
    setMessage(Messages.dialogMsg);
    final Composite composite = new Composite(parentComp, SWT.RESIZE);
    final GridData gdComposite = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gdComposite.widthHint = 500;
    composite.setLayoutData(gdComposite);
    final GridLayout gridLayout = new GridLayout();
    gridLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    gridLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    gridLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    gridLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(gridLayout);
    final Group group = new Group(composite, SWT.NONE);
    group.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
    final GridLayout gdGroup = new GridLayout();
    gdGroup.verticalSpacing = 0;
    group.setLayout(gdGroup);
    final Composite pathComp = new Composite(group, SWT.RESIZE);
    final GridLayout pathLayout = new GridLayout(3, false);
    pathLayout.marginBottom = 0;
    final GridData gdPathComp = new GridData(SWT.FILL, SWT.CENTER, true, false);
    pathComp.setLayout(pathLayout);
    pathComp.setLayoutData(gdPathComp);
    final GridData gdLabel = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
    gdLabel.widthHint = 100;
    final Label pathLbl = new Label(pathComp, SWT.NONE);
    pathLbl.setText(Messages.pathLblName);
    pathLbl.setLayoutData(gdLabel);
    pathText = new Text(pathComp, SWT.BORDER);
    final GridData gdPathText = new GridData(SWT.FILL, SWT.CENTER, true, false);
    pathText.setLayoutData(gdPathText);
    pathText.setToolTipText(Messages.pathToolTip);
    Button selectTargetDirBtn = new Button(pathComp, SWT.NONE);
    selectTargetDirBtn.setText(Messages.btnBrowse);
    selectTargetDirBtn.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
    selectTargetDirBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            DirectoryDialog dlg = new DirectoryDialog(getShell());
            String backupDir = pathText.getText();
            if (backupDir != null && backupDir.trim().length() > 0) {
                dlg.setFilterPath(backupDir);
            }
            dlg.setText(Messages.msgSelectDir);
            dlg.setMessage(Messages.msgSelectDir);
            String dir = dlg.open();
            if (dir != null) {
                pathText.setText(dir);
            }
        }
    });
    ServerInfo serverInfo = selection.getServer().getServerInfo();
    if (serverInfo != null && !serverInfo.isLocalServer()) {
        selectTargetDirBtn.setEnabled(false);
    }
    final Composite purpComp = new Composite(group, SWT.RESIZE);
    final GridLayout purpLayout = new GridLayout(2, false);
    purpLayout.marginTop = 0;
    purpLayout.verticalSpacing = 10;
    final GridData gdPurtComp = new GridData(SWT.FILL, SWT.CENTER, true, false);
    purpComp.setLayout(purpLayout);
    purpComp.setLayoutData(gdPurtComp);
    final Label purposeLbl = new Label(purpComp, SWT.NONE);
    purposeLbl.setText(Messages.purposeLbllName);
    purposeLbl.setLayoutData(gdLabel);
    purposeCombo = new Combo(purpComp, SWT.BORDER | SWT.RIGHT | SWT.READ_ONLY);
    if (purposeEnable) {
        purposeCombo.setEnabled(true);
    } else {
        purposeCombo.setEnabled(false);
    }
    final GridData gdPurposeText = new GridData(SWT.FILL, SWT.CENTER, true, false);
    purposeCombo.setLayoutData(gdPurposeText);
    purposeCombo.setItems(itemsOfPurpose);
    final Label volumeSizeLbl = new Label(purpComp, SWT.NONE);
    volumeSizeLbl.setText(Messages.volumeSizeLblName);
    volumeSizeLbl.setLayoutData(gdLabel);
    volumeSizetext = new Text(purpComp, SWT.BORDER | SWT.RIGHT);
    final GridData gdVolumeSizetext = new GridData(SWT.FILL, SWT.CENTER, true, false);
    volumeSizetext.setLayoutData(gdVolumeSizetext);
    volumeSizetext.setToolTipText(Messages.volumeSizeToolTip);
    /*Initial the volume size*/
    String volumeSize = ConfConstants.DEFAULT_DATA_VOLUME_SIZE;
    String configVolumeSize = CompatibleUtil.getConfigGenericVolumeSize(selection.getServer().getServerInfo(), null);
    if (!StringUtil.isEmpty(configVolumeSize)) {
        Long bytes = StringUtil.getByteNumber(configVolumeSize);
        if (bytes > -1) {
            double value = StringUtil.convertToM(bytes);
            NumberFormat nf = NumberFormat.getInstance();
            nf.setGroupingUsed(false);
            nf.setMaximumFractionDigits(3);
            nf.setMinimumFractionDigits(3);
            volumeSize = nf.format(value);
        }
    }
    volumeSizetext.setText(volumeSize);
    volumeSizetext.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            verify();
        }
    });
    // Sets the initial value
    pathText.setText(getAddVolumeStatusInfo.getVolpath());
    purposeCombo.setText(purpose);
    // Sets listener
    pathText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            verify();
        }
    });
    return parentComp;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog) NumberFormat(java.text.NumberFormat)

Example 38 with ServerInfo

use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.

the class AddVolumeDialog method performTask.

/**
	 * perform the task
	 * 
	 * @param addVolumeDbInfo AddVolumeDbInfo
	 */
private void performTask(AddVolumeDbInfo addVolumeDbInfo) {
    // Checks the path
    String sPathText = pathText.getText().trim();
    ServerInfo serverInfo = selection.getServer().getServerInfo();
    CheckDirTask checkDirTask = new CheckDirTask(serverInfo);
    checkDirTask.setDirectory(new String[] { sPathText });
    CubridDatabase database = selection.getDatabase();
    AddVolumeDbTask addVolumeTask = new AddVolumeDbTask(database.getServer().getServerInfo());
    addVolumeTask.setDbname(database.getName());
    addVolumeTask.setVolname(addVolumeDbInfo.getVolname());
    addVolumeTask.setPurpose(addVolumeDbInfo.getPurpose());
    addVolumeTask.setPath(addVolumeDbInfo.getPath());
    addVolumeTask.setNumberofpages(addVolumeDbInfo.getNumberofpage());
    addVolumeTask.setSizeNeedMb(addVolumeDbInfo.getSize_need_mb());
    // Gets the database space info
    DbSpaceInfoList dbSpaceInfo = new DbSpaceInfoList();
    final CommonQueryTask<DbSpaceInfoList> dbSpaceInfoTask = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), dbSpaceInfo);
    dbSpaceInfoTask.setDbName(database.getLabel());
    JobFamily jobFamily = new JobFamily();
    String serverName = selection.getServer().getName();
    String dbName = selection.getDatabase().getName();
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(dbName);
    jobName = Messages.msgAddVolRearJobName + " - " + dbName + "@" + serverName;
    TaskJobExecutor taskExec = new CommonTaskJobExec(this);
    taskExec.addTask(checkDirTask);
    taskExec.addTask(addVolumeTask);
    taskExec.addTask(dbSpaceInfoTask);
    taskExec.schedule(dbName, jobFamily, true, Job.SHORT);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) AddVolumeDbTask(com.cubrid.cubridmanager.core.cubrid.dbspace.task.AddVolumeDbTask) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) CheckDirTask(com.cubrid.cubridmanager.core.cubrid.database.task.CheckDirTask)

Example 39 with ServerInfo

use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.

the class UnloadDatabaseDialog method initial.

/**
	 * 
	 * Initial data
	 * 
	 */
private void initial() {
    databaseNameText.setText(database.getLabel());
    dbDir = database.getDatabaseInfo().getDbDir();
    ServerInfo serverInfo = database.getServer().getServerInfo();
    if (serverInfo != null) {
        dbDir = FileUtil.changeSeparatorByOS(dbDir, serverInfo.getServerOsInfo());
    }
    if (dbDir != null) {
        targetDirText.setText(dbDir);
        hashFileText.setText(dbDir + database.getServer().getServerInfo().getPathSeparator() + "hashfile");
    }
    allSchemaButton.setSelection(true);
    for (int i = 0, n = schemaTable.getItemCount(); i < n; i++) {
        schemaTable.getItem(i).setChecked(true);
    }
    targetDirText.addModifyListener(this);
    prefixText.addModifyListener(this);
    hashFileText.addModifyListener(this);
    cachedPageText.addModifyListener(this);
    estimatedSizeText.addModifyListener(this);
    loFileCountText.addModifyListener(this);
    valid();
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Example 40 with ServerInfo

use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.

the class DeleteBackupPlanAction method run.

/**
	 * Deletes the selected backup plan
	 * 
	 */
public void run(ISchemaNode[] nodeArray) {
    List<String> nodeNames = new ArrayList<String>();
    for (Object obj : nodeArray) {
        ICubridNode selection = (ICubridNode) obj;
        nodeNames.add(selection.getLabel());
    }
    if (!CommonUITool.openConfirmBox(Messages.bind(Messages.delBackupPlanConfirmContent, nodeNames))) {
        return;
    }
    String taskName = Messages.bind(Messages.delBackupPlanTaskName, nodeNames);
    CommonTaskExec taskExecutor = new CommonTaskExec(taskName);
    for (Object obj : nodeArray) {
        CubridDatabase database = null;
        if (obj instanceof DefaultSchemaNode) {
            database = ((DefaultSchemaNode) obj).getDatabase();
        }
        if (database == null) {
            CommonUITool.openErrorBox(Messages.msgSelectDB);
            return;
        }
        ServerInfo serverInfo = database.getServer().getServerInfo();
        DelBackupPlanTask delBackupPlanTask = new DelBackupPlanTask(serverInfo);
        delBackupPlanTask.setDbname(database.getName());
        String backupid = ((DefaultSchemaNode) obj).getLabel();
        delBackupPlanTask.setBackupid(backupid);
        taskExecutor.addTask(delBackupPlanTask);
    }
    new ExecTaskWithProgress(taskExecutor).exec();
    if (!taskExecutor.isSuccess()) {
        return;
    }
    for (Object obj : nodeArray) {
        TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
        DefaultSchemaNode delNode = ((DefaultSchemaNode) obj);
        ICubridNode parentNode = delNode.getParent();
        parentNode.removeChild(delNode);
        treeViewer.remove(delNode);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) DelBackupPlanTask(com.cubrid.cubridmanager.core.cubrid.jobauto.task.DelBackupPlanTask)

Aggregations

ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)255 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)40 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)40 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)39 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)37 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)35 ArrayList (java.util.ArrayList)30 EnvInfo (com.cubrid.cubridmanager.core.common.model.EnvInfo)29 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)28 TreeViewer (org.eclipse.jface.viewers.TreeViewer)27 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)24 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)24 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)24 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)21 SelectionEvent (org.eclipse.swt.events.SelectionEvent)20 GridData (org.eclipse.swt.layout.GridData)17 GridLayout (org.eclipse.swt.layout.GridLayout)17 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)16 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)16 ITask (com.cubrid.common.core.task.ITask)15