Search in sources :

Example 76 with DefaultSchemaNode

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

the class CubridDbUsersFolderLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        CubridDatabase database = ((ISchemaNode) parent).getDatabase();
        if (database.getRunningType() == DbRunningType.STANDALONE) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        DbUserInfoList dbUserInfoList = new DbUserInfoList();
        final CommonQueryTask<DbUserInfoList> task = new CommonQueryTask<DbUserInfoList>(parent.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), dbUserInfoList, database.getDatabaseInfo().getCharSet());
        task.setDbName(database.getLabel());
        monitorCancel(monitor, new ITask[] { task });
        task.execute();
        final String errorMsg = task.getErrorMsg();
        if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
            parent.removeAllChild();
            openErrorBox(errorMsg);
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        parent.removeAllChild();
        dbUserInfoList = task.getResultModel();
        DbUserInfo latestDLoginedbUserInfo = databaseInfo.getAuthLoginedDbUserInfo();
        List<DbUserInfo> dbUserList = dbUserInfoList == null ? null : dbUserInfoList.getUserList();
        formatUserList(dbUserList);
        for (int i = 0; dbUserList != null && dbUserList.size() > i; i++) {
            DbUserInfo dbUserInfo = dbUserList.get(i);
            if (dbUserInfo.getName().equals(latestDLoginedbUserInfo.getName())) {
                dbUserInfo.setDbaAuthority(latestDLoginedbUserInfo.isDbaAuthority());
            // databaseInfo.setAuthLoginedDbUserInfo(dbUserInfo);
            }
            String id = parent.getId() + NODE_SEPARATOR + dbUserInfo.getName();
            ICubridNode dbUserInfoNode = new DefaultSchemaNode(id, dbUserInfo.getName(), "icons/navigator/user_item.png");
            dbUserInfoNode.setType(CubridNodeType.USER);
            dbUserInfoNode.setModelObj(dbUserInfo);
            dbUserInfoNode.setContainer(false);
            dbUserInfoNode.setEditorId(UserEditor.ID);
            parent.addChild(dbUserInfoNode);
        }
        databaseInfo.setDbUserInfoList(dbUserInfoList);
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) DbUserInfoList(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 77 with DefaultSchemaNode

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

the class CQBDbConnectionLoader method addTriggerFolder.

/**
	 * Add trigger folder
	 * 
	 * @param monitor the IProgressMonitor
	 * @param database the CubridDatabase
	 */
private void addTriggerFolder(final IProgressMonitor monitor, CubridDatabase database) {
    if (!database.getDatabaseInfo().getAuthLoginedDbUserInfo().isDbaAuthority()) {
        return;
    }
    String tiggerFolderId = database.getId() + NODE_SEPARATOR + TRIGGER_FOLDER_ID;
    ICubridNode tiggerFolder = database.getChild(tiggerFolderId);
    if (tiggerFolder == null) {
        tiggerFolder = new DefaultSchemaNode(tiggerFolderId, TRIGGER_FOLDER_NAME, "icons/navigator/trigger_group.png");
        tiggerFolder.setType(NodeType.TRIGGER_FOLDER);
        tiggerFolder.setContainer(true);
        ICubridNodeLoader loader = new CubridTriggerFolderLoader();
        loader.setLevel(getLevel());
        tiggerFolder.setLoader(loader);
        database.addChild(tiggerFolder);
        if (getLevel() == DEFINITE_LEVEL) {
            tiggerFolder.getChildren(monitor);
        }
    } else {
        if (tiggerFolder.getLoader() != null && tiggerFolder.getLoader().isLoaded()) {
            tiggerFolder.getLoader().setLoaded(false);
            tiggerFolder.getChildren(monitor);
        }
    }
}
Also used : ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) CubridTriggerFolderLoader(com.cubrid.common.ui.spi.model.loader.CubridTriggerFolderLoader) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 78 with DefaultSchemaNode

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

the class CQBDbConnectionLoader method addUserFolder.

/**
	 * Add user folder
	 * 
	 * @param monitor the IProgressMonitor
	 * @param database the CubridDatabase
	 */
private void addUserFolder(final IProgressMonitor monitor, CubridDatabase database) {
    String userFolderId = database.getId() + NODE_SEPARATOR + USERS_FOLDER_ID;
    ICubridNode userFolder = database.getChild(userFolderId);
    if (userFolder == null) {
        userFolder = new DefaultSchemaNode(userFolderId, USERS_FOLDER_NAME, "icons/navigator/user_group.png");
        userFolder.setType(NodeType.USER_FOLDER);
        userFolder.setContainer(true);
        ICubridNodeLoader loader = new CQBDbUsersFolderLoader();
        loader.setLevel(getLevel());
        userFolder.setLoader(loader);
        database.addChild(userFolder);
        if (getLevel() == DEFINITE_LEVEL) {
            userFolder.getChildren(monitor);
        }
    } else {
        if (userFolder.getLoader() != null && userFolder.getLoader().isLoaded()) {
            userFolder.getLoader().setLoaded(false);
            userFolder.getChildren(monitor);
        }
    }
}
Also used : ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 79 with DefaultSchemaNode

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

the class CQBDbConnectionLoader method addSerialFolder.

/**
	 * Add serial folder
	 * 
	 * @param monitor the IProgressMonitor
	 * @param database the CubridDatabase
	 */
private void addSerialFolder(final IProgressMonitor monitor, CubridDatabase database) {
    String serialFolderId = database.getId() + NODE_SEPARATOR + SERIAL_FOLDER_ID;
    ICubridNode serialFolder = database.getChild(serialFolderId);
    if (serialFolder == null) {
        serialFolder = new DefaultSchemaNode(serialFolderId, SERIAL_FOLDER_NAME, "icons/navigator/serial_group.png");
        serialFolder.setType(NodeType.SERIAL_FOLDER);
        serialFolder.setContainer(true);
        ICubridNodeLoader loader = new CubridSerialFolderLoader();
        loader.setLevel(getLevel());
        serialFolder.setLoader(loader);
        database.addChild(serialFolder);
        if (getLevel() == DEFINITE_LEVEL) {
            serialFolder.getChildren(monitor);
        }
    } else {
        if (serialFolder.getLoader() != null && serialFolder.getLoader().isLoaded()) {
            serialFolder.getLoader().setLoaded(false);
            serialFolder.getChildren(monitor);
        }
    }
}
Also used : ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) CubridSerialFolderLoader(com.cubrid.common.ui.spi.model.loader.CubridSerialFolderLoader) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 80 with DefaultSchemaNode

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

the class CQBDbConnectionLoader method addProcedureFolder.

/**
	 * Add procedure folder
	 * 
	 * @param monitor the IProgressMonitor
	 * @param database the CubridDatabase
	 */
private void addProcedureFolder(final IProgressMonitor monitor, CubridDatabase database) {
    String spFolderId = database.getId() + NODE_SEPARATOR + SP_FOLDER_ID;
    ICubridNode spFolder = database.getChild(spFolderId);
    if (spFolder == null) {
        spFolder = new DefaultSchemaNode(spFolderId, SP_FOLDER_NAME, "icons/navigator/procedure_group.png");
        spFolder.setType(NodeType.STORED_PROCEDURE_FOLDER);
        spFolder.setContainer(true);
        ICubridNodeLoader loader = new CubridSPFolderLoader();
        loader.setLevel(getLevel());
        spFolder.setLoader(loader);
        database.addChild(spFolder);
        if (getLevel() == DEFINITE_LEVEL) {
            spFolder.getChildren(monitor);
        }
    } else {
        if (spFolder.getLoader() != null && spFolder.getLoader().isLoaded()) {
            spFolder.getLoader().setLoaded(false);
            spFolder.getChildren(monitor);
        }
    }
}
Also used : ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) CubridSPFolderLoader(com.cubrid.common.ui.spi.model.loader.sp.CubridSPFolderLoader)

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