Search in sources :

Example 1 with CubridLogsFolderLoader

use of com.cubrid.cubridmanager.ui.spi.model.loader.logs.CubridLogsFolderLoader in project cubrid-manager by CUBRID.

the class CubridServerLoader method load.

/**
	 *
	 * Load children object for parent
	 *
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        parent.setEditorId(HostDashboardEditor.ID);
        CubridServer server = parent.getServer();
        if (!server.isConnected()) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        ServerType serverType = server.getServerInfo().getServerType();
        // add database folder
        if (serverType == ServerType.BOTH || serverType == ServerType.DATABASE) {
            String databaseFolderId = parent.getId() + NODE_SEPARATOR + DATABASE_FOLDER_ID;
            ICubridNode databaseFolder = parent.getChild(databaseFolderId);
            if (databaseFolder == null) {
                databaseFolder = new DefaultCubridNode(databaseFolderId, DATABASE_FOLDER_NAME, "icons/navigator/database_group.png");
                databaseFolder.setType(NodeType.DATABASE_FOLDER);
                databaseFolder.setContainer(true);
                ICubridNodeLoader loader = new CubridDatabasesFolderLoader();
                loader.setLevel(getLevel());
                databaseFolder.setLoader(loader);
                parent.addChild(databaseFolder);
                if (getLevel() == DEFINITE_LEVEL) {
                    databaseFolder.getChildren(monitor);
                }
            } else {
                if (databaseFolder.getLoader() != null && databaseFolder.getLoader().isLoaded()) {
                    databaseFolder.getLoader().setLoaded(false);
                    databaseFolder.getChildren(monitor);
                }
            }
        }
        ServerUserInfo userInfo = parent.getServer().getServerInfo().getLoginedUserInfo();
        // add broker folder
        if ((serverType == ServerType.BOTH || serverType == ServerType.BROKER) && userInfo != null && (CasAuthType.AUTH_ADMIN == userInfo.getCasAuth() || CasAuthType.AUTH_MONITOR == userInfo.getCasAuth())) {
            String brokerFolderId = parent.getId() + NODE_SEPARATOR + BROKER_FOLDER_ID;
            ICubridNode brokerFolder = parent.getChild(brokerFolderId);
            if (brokerFolder == null) {
                brokerFolder = new CubridBrokerFolder(brokerFolderId, BROKER_FOLDER_NAME, "icons/navigator/broker_group.png");
                ((CubridBrokerFolder) brokerFolder).setStartedIconPath("icons/navigator/broker_service_started.png");
                brokerFolder.setContainer(true);
                brokerFolder.setViewId(BrokerEnvStatusView.ID);
                ICubridNodeLoader loader = new CubridBrokersFolderLoader();
                loader.setLevel(getLevel());
                brokerFolder.setLoader(loader);
                parent.addChild(brokerFolder);
                if (getLevel() == DEFINITE_LEVEL) {
                    brokerFolder.getChildren(monitor);
                }
            } else {
                if (brokerFolder.getLoader() != null && brokerFolder.getLoader().isLoaded()) {
                    brokerFolder.getLoader().setLoaded(false);
                    brokerFolder.getChildren(monitor);
                }
            }
        }
        //			#2 Remove the legacy monitoring menu
        //			// add monitor folder
        //			if (userInfo != null
        //					&& (StatusMonitorAuthType.AUTH_ADMIN == userInfo.getStatusMonitorAuth() || StatusMonitorAuthType.AUTH_MONITOR == userInfo.getStatusMonitorAuth())) {
        //				String monitroingId = parent.getId() + NODE_SEPARATOR
        //						+ MONITORING_FOLDER_ID;
        //				ICubridNode monitoringFolder = parent.getChild(monitroingId);
        //				if (monitoringFolder == null) {
        //					monitoringFolder = new DefaultCubridNode(monitroingId,
        //							MONITORING_FOLDER_NAME,
        //							"icons/navigator/status_group.png");
        //					monitoringFolder.setType(CubridNodeType.MONITOR_FOLDER);
        //					monitoringFolder.setContainer(true);
        //					ICubridNodeLoader loader = new CubridMonitorFolderLoader();
        //					loader.setLevel(getLevel());
        //					monitoringFolder.setLoader(loader);
        //					parent.addChild(monitoringFolder);
        //					if (getLevel() == DEFINITE_LEVEL) {
        //						monitoringFolder.getChildren(monitor);
        //					}
        //				} else {
        //					if (monitoringFolder.getLoader() != null
        //							&& monitoringFolder.getLoader().isLoaded()) {
        //						monitoringFolder.getLoader().setLoaded(false);
        //						monitoringFolder.getChildren(monitor);
        //					}
        //				}
        //			}
        // add logs folder
        String logsFolderId = parent.getId() + NODE_SEPARATOR + LOGS_FOLDER_ID;
        ICubridNode logsFolder = parent.getChild(logsFolderId);
        if (logsFolder == null) {
            logsFolder = new DefaultCubridNode(logsFolderId, LOGS_FOLDER_NAME, "icons/navigator/log_group_big.png");
            logsFolder.setType(CubridNodeType.LOGS_FOLDER);
            logsFolder.setContainer(true);
            ICubridNodeLoader loader = new CubridLogsFolderLoader();
            loader.setLevel(getLevel());
            logsFolder.setLoader(loader);
            parent.addChild(logsFolder);
            if (getLevel() == DEFINITE_LEVEL) {
                logsFolder.getChildren(monitor);
            }
        } else {
            if (logsFolder.getLoader() != null && logsFolder.getLoader().isLoaded()) {
                logsFolder.getLoader().setLoaded(false);
                logsFolder.getChildren(monitor);
            }
        }
        if (server.isConnected() && CompatibleUtil.isSupportHA(server.getServerInfo())) {
            getHostStatus(server);
        }
        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) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) CubridBrokerFolder(com.cubrid.cubridmanager.ui.spi.model.CubridBrokerFolder) CubridLogsFolderLoader(com.cubrid.cubridmanager.ui.spi.model.loader.logs.CubridLogsFolderLoader)

Aggregations

CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)1 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)1 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)1 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)1 CubridBrokerFolder (com.cubrid.cubridmanager.ui.spi.model.CubridBrokerFolder)1 CubridLogsFolderLoader (com.cubrid.cubridmanager.ui.spi.model.loader.logs.CubridLogsFolderLoader)1