Search in sources :

Example 1 with EditBackupPlanDialog

use of com.cubrid.cubridmanager.ui.cubrid.jobauto.dialog.EditBackupPlanDialog in project cubrid-manager by CUBRID.

the class AddBackupPlanAction method run.

/**
	 * Creates a Dialog which is the instance of EditBackupPlanDialog to add a backup plan
	 *
	 * @param database
	 */
public void run(CubridDatabase database) {
    TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
    ICubridNode jobAutoFolderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridDatabaseLoader.JOB_AUTO_FOLDER_ID);
    DefaultSchemaNode buckupPlanFolderNode = (DefaultSchemaNode) jobAutoFolderNode.getChild(jobAutoFolderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridJobAutoFolderLoader.BACKUP_PLAN_FOLDER_ID);
    EditBackupPlanDialog editBackupPlanDlg = new EditBackupPlanDialog(getShell(), true);
    editBackupPlanDlg.setOperation(AddEditType.ADD);
    editBackupPlanDlg.initPara(buckupPlanFolderNode);
    if (editBackupPlanDlg.open() == Dialog.OK) {
        BackupPlanInfo backupPlanInfo = editBackupPlanDlg.getBackupPlanInfo();
        String newBackupId = backupPlanInfo.getBackupid();
        DefaultSchemaNode newNode = new DefaultSchemaNode(newBackupId, newBackupId, ICON_PATH);
        newNode.setContainer(false);
        newNode.setType(CubridNodeType.BACKUP_PLAN);
        newNode.setModelObj(backupPlanInfo);
        buckupPlanFolderNode.addChild(newNode);
        treeViewer.add(buckupPlanFolderNode, newNode);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
    } else {
        canceledTask = true;
    }
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) EditBackupPlanDialog(com.cubrid.cubridmanager.ui.cubrid.jobauto.dialog.EditBackupPlanDialog) BackupPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.BackupPlanInfo)

Example 2 with EditBackupPlanDialog

use of com.cubrid.cubridmanager.ui.cubrid.jobauto.dialog.EditBackupPlanDialog in project cubrid-manager by CUBRID.

the class EditBackupPlanAction method run.

/**
	 * Creates a Dialog which is the instance of EditBackupPlanDialog to add a
	 * query plan
	 * @param database CubridDatabase
	 * @param selection DefaultSchemaNode
	 */
public int run(CubridDatabase database, DefaultSchemaNode selection) {
    boolean isEditAble = false;
    if (CubridNodeType.BACKUP_PLAN.equals(selection.getType()) && database != null && database.isLogined()) {
        DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
        if (dbUserInfo != null && dbUserInfo.isDbaAuthority()) {
            isEditAble = true;
        }
    }
    EditBackupPlanDialog editBackupPlanDlg = new EditBackupPlanDialog(getShell(), isEditAble);
    editBackupPlanDlg.setOperation(AddEditType.EDIT);
    editBackupPlanDlg.initPara(selection);
    if (editBackupPlanDlg.open() == IDialogConstants.OK_ID) {
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(selection, CubridNodeChangedEventType.NODE_REFRESH));
        ActionManager.getInstance().fireSelectionChanged(getSelection());
        return IDialogConstants.OK_ID;
    }
    return IDialogConstants.CANCEL_ID;
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) EditBackupPlanDialog(com.cubrid.cubridmanager.ui.cubrid.jobauto.dialog.EditBackupPlanDialog)

Aggregations

CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)2 EditBackupPlanDialog (com.cubrid.cubridmanager.ui.cubrid.jobauto.dialog.EditBackupPlanDialog)2 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 BackupPlanInfo (com.cubrid.cubridmanager.core.cubrid.jobauto.model.BackupPlanInfo)1 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1