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));
}
}
Aggregations