Search in sources :

Example 21 with ICubridNodeLoader

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

the class CubridDatabasesFolderLoader method buildDatabasesFolder.

/**
	 * Construct the database folder children
	 *
	 * @param parent the database folder node
	 * @param monitor the IProgressMonitor
	 * @param serverInfo the ServerInfo
	 * @param oldDatabaseInfoList the old database information list
	 * @param newDatabaseInfoList the new database information list
	 * @param oldNodeList the old node list
	 */
private void buildDatabasesFolder(ICubridNode parent, final IProgressMonitor monitor, ServerInfo serverInfo, List<DatabaseInfo> oldDatabaseInfoList, List<DatabaseInfo> newDatabaseInfoList, List<ICubridNode> oldNodeList) {
    ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
    List<DatabaseInfo> authorDatabaseList = userInfo.getDatabaseInfoList();
    if (authorDatabaseList == null) {
        authorDatabaseList = new ArrayList<DatabaseInfo>();
        userInfo.setDatabaseInfoList(authorDatabaseList);
    }
    filterDatabaseList(serverInfo, newDatabaseInfoList, authorDatabaseList);
    for (int i = 0; i < authorDatabaseList.size() && !monitor.isCanceled(); i++) {
        DatabaseInfo databaseInfo = authorDatabaseList.get(i);
        DatabaseInfo newDatabaseInfo = getDatabaseInfo(newDatabaseInfoList, databaseInfo.getDbName());
        if (newDatabaseInfo == null) {
            continue;
        } else {
            databaseInfo.setDbDir(newDatabaseInfo.getDbDir());
            databaseInfo.setRunningType(newDatabaseInfo.getRunningType());
            newDatabaseInfo = getDatabaseInfo(oldDatabaseInfoList, databaseInfo.getDbName());
            if (newDatabaseInfo != null) {
                DbUserInfo dbUserInfo = newDatabaseInfo.getAuthLoginedDbUserInfo();
                if (dbUserInfo != null && databaseInfo.getAuthLoginedDbUserInfo() != null) {
                    databaseInfo.getAuthLoginedDbUserInfo().setNoEncryptPassword(dbUserInfo.getNoEncryptPassword());
                }
            }
        }
        String name = databaseInfo.getDbName();
        String id = parent.getId() + NODE_SEPARATOR + name;
        ICubridNode databaseNode = isContained(oldNodeList, id);
        if (databaseNode == null) {
            databaseNode = new CubridDatabase(id, databaseInfo.getDbName());
            CubridDatabase database = (CubridDatabase) databaseNode;
            database.setStartAndLoginIconPath("icons/navigator/database_start_connected.png");
            database.setStartAndLogoutIconPath("icons/navigator/database_start_disconnected.png");
            database.setStopAndLogoutIconPath("icons/navigator/database_stop_disconnected.png");
            database.setStopAndLoginIconPath("icons/navigator/database_stop_connected.png");
            ICubridNodeLoader loader = new CubridDatabaseLoader();
            loader.setLevel(getLevel());
            databaseNode.setLoader(loader);
            parent.addChild(databaseNode);
            if (getLevel() == DEFINITE_LEVEL) {
                databaseNode.getChildren(monitor);
            }
            databaseNode.setEditorId(DatabaseDashboardEditor.ID);
            ((CubridDatabase) databaseNode).setDatabaseInfo(databaseInfo);
            databaseNode.setContainer(true);
            ((CubridDatabase) databaseNode).setAutoSavePassword(CMDBNodePersistManager.getInstance().getDbSavePassword(serverInfo.getHostAddress(), String.valueOf(serverInfo.getHostMonPort()), databaseInfo.getDbName(), databaseInfo.getAuthLoginedDbUserInfo().getName()));
            String jdbcAttrs = CMDBNodePersistManager.getInstance().getJdbcAttrs((CubridDatabase) databaseNode);
            databaseInfo.setJdbcAttrs(jdbcAttrs);
        } else {
            parent.addChild(databaseNode);
            databaseInfo.setLogined(((CubridDatabase) databaseNode).isLogined());
            ((CubridDatabase) databaseNode).setDatabaseInfo(databaseInfo);
            if (databaseNode.getLoader() != null && databaseNode.getLoader().isLoaded()) {
                databaseNode.getLoader().setLoaded(false);
                databaseNode.getChildren(monitor);
            }
        }
    }
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 22 with ICubridNodeLoader

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

the class CubridLogsFolderLoader 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;
        }
        ServerType serverType = parent.getServer().getServerInfo().getServerType();
        // add broker logs folder to logs folder
        if (serverType == ServerType.BOTH || serverType == ServerType.BROKER) {
            String brokerLogsFolderId = parent.getId() + NODE_SEPARATOR + LOGS_BROKER_FOLDER_ID;
            ICubridNode brokerLogsFolder = parent.getChild(brokerLogsFolderId);
            if (brokerLogsFolder == null) {
                brokerLogsFolder = new DefaultCubridNode(brokerLogsFolderId, LOGS_BROKER_FOLDER_NAME, "icons/navigator/log_broker_group.png");
                brokerLogsFolder.setType(CubridNodeType.LOGS_BROKER_FOLDER);
                brokerLogsFolder.setContainer(true);
                ICubridNodeLoader loader = new CubridBrokerLogFolderLoader();
                loader.setLevel(getLevel());
                brokerLogsFolder.setLoader(loader);
                parent.addChild(brokerLogsFolder);
                if (getLevel() == DEFINITE_LEVEL) {
                    brokerLogsFolder.getChildren(monitor);
                }
            } else {
                if (brokerLogsFolder.getLoader() != null && brokerLogsFolder.getLoader().isLoaded()) {
                    brokerLogsFolder.getLoader().setLoaded(false);
                    brokerLogsFolder.getChildren(monitor);
                }
            }
        }
        // add manager logs folder to logs folder
        if (serverType == ServerType.BOTH || serverType == ServerType.DATABASE) {
            String managerLogsFolderId = parent.getId() + NODE_SEPARATOR + LOGS_MANAGER_FOLDER_ID;
            ICubridNode managerLogsFolder = parent.getChild(managerLogsFolderId);
            if (managerLogsFolder == null) {
                managerLogsFolder = new DefaultCubridNode(managerLogsFolderId, LOGS_MANAGER_FOLDER_NAME, "icons/navigator/log_manager_group.png");
                managerLogsFolder.setType(CubridNodeType.LOGS_MANAGER_FOLDER);
                managerLogsFolder.setContainer(true);
                parent.addChild(managerLogsFolder);
            }
            // add access and error log folder to manager logs folder
            String[] managerLogIdArr = { ACCESS_LOG_FOLDER_ID, ERROR_LOG_FOLDER_ID };
            String[] managerLogNameArr = { ACCESS_LOG_FOLDER_NAME, ERROR_LOG_FOLDER_NAME };
            String[] managerLogTypeArr = { CubridNodeType.LOGS_MANAGER_ACCESS_LOG, CubridNodeType.LOGS_MANAGER_ERROR_LOG };
            String[] iconsArr = { "icons/navigator/log_item.png", "icons/navigator/log_item.png" };
            for (int i = 0; i < managerLogNameArr.length; i++) {
                String id = parent.getId() + NODE_SEPARATOR + managerLogIdArr[i];
                ICubridNode logFolder = parent.getChild(id);
                if (logFolder == null) {
                    logFolder = new DefaultCubridNode(id, managerLogNameArr[i], iconsArr[i]);
                    logFolder.setType(managerLogTypeArr[i]);
                    logFolder.setEditorId(LogEditorPart.ID);
                    logFolder.setContainer(false);
                    managerLogsFolder.addChild(logFolder);
                }
            }
            //add database server log folder
            String serverLogsFolderId = parent.getId() + NODE_SEPARATOR + LOGS_SERVER_FOLDER_ID;
            ICubridNode serverLogsFolder = parent.getChild(serverLogsFolderId);
            if (serverLogsFolder == null) {
                serverLogsFolder = new DefaultCubridNode(serverLogsFolderId, LOGS_SERVER_FOLDER_NAME, "icons/navigator/log_db_group.png");
                serverLogsFolder.setType(CubridNodeType.LOGS_SERVER_FOLDER);
                serverLogsFolder.setContainer(true);
                ICubridNodeLoader loader = new CubridDatabaseLogFolderLoader();
                loader.setLevel(getLevel());
                serverLogsFolder.setLoader(loader);
                parent.addChild(serverLogsFolder);
                if (getLevel() == DEFINITE_LEVEL) {
                    serverLogsFolder.getChildren(monitor);
                }
            } else {
                if (serverLogsFolder.getLoader() != null && serverLogsFolder.getLoader().isLoaded()) {
                    serverLogsFolder.getLoader().setLoaded(false);
                    serverLogsFolder.getChildren(monitor);
                }
            }
        }
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

Example 23 with ICubridNodeLoader

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

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

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

Aggregations

ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)27 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)27 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)21 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)9 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)5 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)5 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)4 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)4 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)4 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)3 ClassInfo (com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)3 ArrayList (java.util.ArrayList)3 CubridSerialFolderLoader (com.cubrid.common.ui.spi.model.loader.CubridSerialFolderLoader)2 CubridTriggerFolderLoader (com.cubrid.common.ui.spi.model.loader.CubridTriggerFolderLoader)2 CubridTablesFolderLoader (com.cubrid.common.ui.spi.model.loader.schema.CubridTablesFolderLoader)2 CubridViewsFolderLoader (com.cubrid.common.ui.spi.model.loader.schema.CubridViewsFolderLoader)2 CubridSPFolderLoader (com.cubrid.common.ui.spi.model.loader.sp.CubridSPFolderLoader)2 BrokerInfo (com.cubrid.cubridmanager.core.broker.model.BrokerInfo)2 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)2 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)2