Search in sources :

Example 41 with CubridDatabase

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

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

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

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

Example 45 with CubridDatabase

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

the class MultiDatabaseLoginFailedDialog method editHost.

public void editHost(MultiDatabaseloginFailedInfo multiDatabaseloginFailedInfo) {
    if (multiDatabaseloginFailedInfo == null) {
        return;
    }
    CubridDatabase database = multiDatabaseloginFailedInfo.getCubridDatabase();
    //if login ,can't edit
    if (database.isLogined()) {
        return;
    }
    //		CubridDatabase oldDatabase = null;
    //		try {
    //			oldDatabase = database.clone();
    //		} catch (CloneNotSupportedException e) {
    //			//Ignore
    //		}
    LoginDatabaseDialog dialog = new LoginDatabaseDialog(getShell(), database);
    int returnVal = dialog.open();
    if (returnVal == IDialogConstants.OK_ID) {
        CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
        TreeViewer treeViewer = view.getViewer();
        database.removeAllChild();
        if (database.getLoader() != null) {
            database.getLoader().setLoaded(false);
        }
        treeViewer.refresh(database, true);
        treeViewer.expandToLevel(database, 1);
        /*Save the data*/
        DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, true);
        if (editorConfig == null) {
            editorConfig = new DatabaseEditorConfig();
        }
        editorConfig.setBackGround(dialog.getSelectedColor());
        CMDBNodePersistManager.getInstance().addDatabase(database, editorConfig);
        ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
        LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
        multiDatabaseloginFailedInfo.setErrMsg("");
    }
    databaseTable.refresh();
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DatabaseEditorConfig(com.cubrid.common.ui.spi.model.DatabaseEditorConfig)

Aggregations

CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)278 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)104 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)79 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)67 ArrayList (java.util.ArrayList)45 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)43 TreeViewer (org.eclipse.jface.viewers.TreeViewer)42 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)36 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)33 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)30 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)29 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)28 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)25 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)22 Shell (org.eclipse.swt.widgets.Shell)22 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)19 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)18 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)18 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)18 ITask (com.cubrid.common.core.task.ITask)17