Search in sources :

Example 16 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class AddBackupPlanAction method run.

public void run() {
    Object[] obj = this.getSelectedObj();
    CubridDatabase database = null;
    DefaultSchemaNode selection = null;
    if (obj.length > 0 && obj[0] instanceof DefaultSchemaNode) {
        selection = (DefaultSchemaNode) obj[0];
        database = selection.getDatabase();
    }
    if (database == null) {
        CommonUITool.openErrorBox(Messages.msgSelectDB);
        return;
    }
    run(database);
}
Also used : CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 17 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode 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 18 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class DeleteBackupPlanAction method isSupported.

/**
	 * Sets this action support this object
	 * 
	 * @see org.eclipse.jface.action.IAction.ISelectionAction
	 * @param obj Object
	 * @return boolean
	 */
public boolean isSupported(Object obj) {
    if (obj instanceof ISchemaNode) {
        ISchemaNode node = (ISchemaNode) obj;
        CubridDatabase database = node.getDatabase();
        if (CubridNodeType.BACKUP_PLAN.equals(node.getType()) && database != null && database.isLogined()) {
            DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
            if (dbUserInfo != null && dbUserInfo.isDbaAuthority()) {
                return true;
            }
        }
    } else if (obj instanceof Object[]) {
        Object[] objArr = (Object[]) obj;
        CubridDatabase database = null;
        for (Object object : objArr) {
            DefaultSchemaNode node = (DefaultSchemaNode) object;
            CubridDatabase db = node.getDatabase();
            if (database == null) {
                database = db;
            } else if (!database.getId().equals(db.getId())) {
                return false;
            }
        }
        return true;
    }
    return false;
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 19 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode 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)

Example 20 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class DeleteQueryPlanAction method isSupported.

/**
	 * Sets this action support this object
	 * 
	 * @see org.eclipse.jface.action.IAction.ISelectionAction
	 * @param obj Object
	 * @return boolean
	 */
public boolean isSupported(Object obj) {
    if (obj instanceof ISchemaNode) {
        ISchemaNode node = (ISchemaNode) obj;
        CubridDatabase database = node.getDatabase();
        if (CubridNodeType.QUERY_PLAN.equals(node.getType()) && database != null && database.isLogined()) {
            DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
            if (dbUserInfo != null && dbUserInfo.isDbaAuthority()) {
                return true;
            }
        }
    } else if (obj instanceof Object[]) {
        Object[] objArr = (Object[]) obj;
        CubridDatabase database = null;
        for (Object object : objArr) {
            DefaultSchemaNode node = (DefaultSchemaNode) object;
            CubridDatabase db = node.getDatabase();
            if (database == null) {
                database = db;
            } else if (!database.getId().equals(db.getId())) {
                return false;
            }
        }
        return true;
    }
    return false;
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Aggregations

DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)88 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)62 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)33 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)22 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)21 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)18 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)17 ArrayList (java.util.ArrayList)15 TreeViewer (org.eclipse.jface.viewers.TreeViewer)10 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)9 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)9 Display (org.eclipse.swt.widgets.Display)9 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)8 ClassInfo (com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)7 File (java.io.File)5 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)4 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)4 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)4 GetAllClassListTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask)4 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)4