use of com.cubrid.common.ui.spi.model.ICubridNodeLoader 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));
}
}
use of com.cubrid.common.ui.spi.model.ICubridNodeLoader in project cubrid-manager by CUBRID.
the class CubridJobAutoFolderLoader 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;
}
// add backup plan folder
String backupPlanFolderId = parent.getId() + NODE_SEPARATOR + BACKUP_PLAN_FOLDER_ID;
ICubridNode backupPlanFolder = parent.getChild(backupPlanFolderId);
if (backupPlanFolder == null) {
backupPlanFolder = new DefaultSchemaNode(backupPlanFolderId, BACKUP_PLAN_FOLDER_NAME, "icons/navigator/folder.png");
backupPlanFolder.setType(CubridNodeType.BACKUP_PLAN_FOLDER);
backupPlanFolder.setContainer(true);
ICubridNodeLoader loader = new CubridBackupPlanFolderLoader();
loader.setLevel(getLevel());
backupPlanFolder.setLoader(loader);
parent.addChild(backupPlanFolder);
if (getLevel() == DEFINITE_LEVEL) {
backupPlanFolder.getChildren(monitor);
}
} else {
if (backupPlanFolder.getLoader() != null && backupPlanFolder.getLoader().isLoaded()) {
backupPlanFolder.getLoader().setLoaded(false);
backupPlanFolder.getChildren(monitor);
}
}
// add query plan folder
String queryPlanFolderId = parent.getId() + NODE_SEPARATOR + QUERY_PLAN_FOLDER_ID;
ICubridNode queryPlanFolder = parent.getChild(queryPlanFolderId);
if (queryPlanFolder == null) {
queryPlanFolder = new DefaultSchemaNode(queryPlanFolderId, QUERY_PLAN_FOLDER_NAME, "icons/navigator/folder.png");
queryPlanFolder.setType(CubridNodeType.QUERY_PLAN_FOLDER);
queryPlanFolder.setContainer(true);
ICubridNodeLoader loader = new CubridQueryPlanFolderLoader();
loader.setLevel(getLevel());
queryPlanFolder.setLoader(loader);
parent.addChild(queryPlanFolder);
if (getLevel() == DEFINITE_LEVEL) {
queryPlanFolder.getChildren(monitor);
}
} else {
if (queryPlanFolder.getLoader() != null && queryPlanFolder.getLoader().isLoaded()) {
queryPlanFolder.getLoader().setLoaded(false);
queryPlanFolder.getChildren(monitor);
}
}
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.model.ICubridNodeLoader in project cubrid-manager by CUBRID.
the class CubridBrokerLogFolderLoader 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;
}
// add access and error and admin log folder to broker logs folder
String[] brokerLogIdArr = { ACCESS_LOG_FOLDER_ID, ERROR_LOG_FOLDER_ID, ADMIN_LOG_FOLDER_ID };
String[] brokerLogNameArr = { ACCESS_LOG_FOLDER_NAME, ERROR_LOG_FOLDER_NAME, ADMIN_LOG_FOLDER_NAME };
String[] brokerLogTypeArr = { CubridNodeType.LOGS_BROKER_ACCESS_LOG_FOLDER, CubridNodeType.LOGS_BROKER_ERROR_LOG_FOLDER, CubridNodeType.LOGS_BROKER_ADMIN_LOG_FOLDER };
String[] iconArr = { "icons/navigator/folder.png", "icons/navigator/folder.png", "icons/navigator/folder.png" };
ICubridNode[] logFoldrNodeArr = new ICubridNode[3];
for (int i = 0; i < brokerLogNameArr.length; i++) {
String id = parent.getId() + NODE_SEPARATOR + brokerLogIdArr[i];
logFoldrNodeArr[i] = parent.getChild(id);
if (logFoldrNodeArr[i] == null) {
logFoldrNodeArr[i] = new DefaultCubridNode(id, brokerLogNameArr[i], iconArr[i]);
logFoldrNodeArr[i].setType(brokerLogTypeArr[i]);
logFoldrNodeArr[i].setContainer(true);
parent.addChild(logFoldrNodeArr[i]);
if (i == 2) {
ICubridNodeLoader loader = new CubridAdminLogFolderLoader();
loader.setLevel(getLevel());
logFoldrNodeArr[i].setLoader(loader);
if (getLevel() == DEFINITE_LEVEL) {
logFoldrNodeArr[i].getChildren(monitor);
}
}
} else {
if (logFoldrNodeArr[i].getLoader() != null) {
logFoldrNodeArr[i].getLoader().setLoaded(false);
logFoldrNodeArr[i].getChildren(monitor);
}
}
}
ServerInfo serverInfo = parent.getServer().getServerInfo();
BrokerInfos brokerInfos = serverInfo.getBrokerInfos();
Shards shards = serverInfo.getShards();
monitorCancel(monitor, new ITask[] { loadBrokersTask, loadBrokrLogInfoTask });
if (brokerInfos == null && !monitor.isCanceled()) {
// load all borkers
brokerInfos = new BrokerInfos();
loadBrokersTask = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
loadBrokersTask.execute();
final String errorMsg = loadBrokersTask.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
logFoldrNodeArr[0].removeAllChild();
logFoldrNodeArr[1].removeAllChild();
openErrorBox(errorMsg);
setLoaded(true);
return;
}
brokerInfos = loadBrokersTask.getResultModel();
serverInfo.setBrokerInfos(brokerInfos);
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
// load broker log file information
List<BrokerLogInfos> brokerLogInfosList = new ArrayList<BrokerLogInfos>();
if (brokerInfos != null) {
BrokerInfoList list = brokerInfos.getBorkerInfoList();
if (list != null && list.getBrokerInfoList() != null) {
List<BrokerInfo> brokerInfoList = list.getBrokerInfoList();
for (int i = 0; !monitor.isCanceled() && brokerInfoList != null && i < brokerInfoList.size(); i++) {
BrokerInfo brokerInfo = brokerInfoList.get(i);
BrokerLogInfos brokerLogInfos = new BrokerLogInfos();
loadBrokrLogInfoTask = new CommonQueryTask<BrokerLogInfos>(serverInfo, CommonSendMsg.getGetBrokerLogFileInfoMSGItems(), brokerLogInfos);
loadBrokrLogInfoTask.setBroker(brokerInfo.getName());
loadBrokrLogInfoTask.execute();
final String errorMsg = loadBrokrLogInfoTask.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
logFoldrNodeArr[0].removeAllChild();
logFoldrNodeArr[1].removeAllChild();
openErrorBox(errorMsg);
setLoaded(true);
return;
}
brokerLogInfos = loadBrokrLogInfoTask.getResultModel();
brokerLogInfosList.add(brokerLogInfos);
}
}
}
// load shard broker log file information
if (shards != null) {
List<Shard> shardList = shards.getShardList();
if (shardList != null) {
for (int i = 0; i < shardList.size(); i++) {
Shard shard = shardList.get(i);
BrokerLogInfos brokerLogInfos = new BrokerLogInfos();
loadBrokrLogInfoTask = new CommonQueryTask<BrokerLogInfos>(serverInfo, CommonSendMsg.getGetBrokerLogFileInfoMSGItems(), brokerLogInfos);
loadBrokrLogInfoTask.setBroker(shard.getName());
loadBrokrLogInfoTask.execute();
final String errorMsg = loadBrokrLogInfoTask.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
logFoldrNodeArr[0].removeAllChild();
logFoldrNodeArr[1].removeAllChild();
openErrorBox(errorMsg);
setLoaded(true);
return;
}
brokerLogInfos = loadBrokrLogInfoTask.getResultModel();
brokerLogInfosList.add(brokerLogInfos);
}
}
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
logFoldrNodeArr[0].removeAllChild();
logFoldrNodeArr[1].removeAllChild();
for (BrokerLogInfos brokerLogInfos : brokerLogInfosList) {
List<LogInfo> logInfoList = brokerLogInfos.getBrokerLogInfoList().getLogFileInfoList();
if (logInfoList != null && !logInfoList.isEmpty()) {
for (LogInfo logInfo : logInfoList) {
ICubridNode logInfoNode = new DefaultCubridNode("", logInfo.getName(), "");
logInfoNode.setContainer(false);
logInfoNode.setModelObj(logInfo);
logInfoNode.setEditorId(LogEditorPart.ID);
if (LogType.ACCESS.getText().toLowerCase().equals(logInfo.getType())) {
String id = logFoldrNodeArr[0].getId() + NODE_SEPARATOR + logInfo.getName();
logInfoNode.setId(id);
logInfoNode.setType(CubridNodeType.LOGS_BROKER_ACCESS_LOG);
logInfoNode.setIconPath("icons/navigator/log_item.png");
logFoldrNodeArr[0].addChild(logInfoNode);
} else if (LogType.ERROR.getText().toLowerCase().equals(logInfo.getType())) {
String id = logFoldrNodeArr[1].getId() + NODE_SEPARATOR + logInfo.getName();
logInfoNode.setId(id);
logInfoNode.setType(CubridNodeType.LOGS_BROKER_ERROR_LOG);
logInfoNode.setIconPath("icons/navigator/log_item.png");
logFoldrNodeArr[1].addChild(logInfoNode);
}
}
}
}
Collections.sort(logFoldrNodeArr[0].getChildren());
Collections.sort(logFoldrNodeArr[1].getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(logFoldrNodeArr[0], CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(logFoldrNodeArr[1], CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.model.ICubridNodeLoader in project cubrid-manager by CUBRID.
the class CubridDatabaseLogFolderLoader 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;
}
ServerInfo serverInfo = parent.getServer().getServerInfo();
ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
List<DatabaseInfo> databaseInfoList = userInfo.getDatabaseInfoList();
if (databaseInfoList == null || databaseInfoList.size() <= 0) {
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
List<ICubridNode> oldNodeList = new ArrayList<ICubridNode>();
oldNodeList.addAll(parent.getChildren());
parent.removeAllChild();
for (int i = 0; i < databaseInfoList.size() && !monitor.isCanceled(); i++) {
DatabaseInfo databaseInfo = databaseInfoList.get(i);
String id = parent.getId() + NODE_SEPARATOR + databaseInfo.getDbName();
ICubridNode logDatabaseNode = isContained(oldNodeList, id);
if (logDatabaseNode == null) {
logDatabaseNode = new DefaultCubridNode(id, databaseInfo.getDbName(), "icons/navigator/folder.png");
logDatabaseNode.setType(CubridNodeType.LOGS_SERVER_DATABASE_FOLDER);
logDatabaseNode.setModelObj(databaseInfo);
logDatabaseNode.setContainer(true);
ICubridNodeLoader loader = new CubridDatabaseLogLoader();
loader.setLevel(getLevel());
logDatabaseNode.setLoader(loader);
parent.addChild(logDatabaseNode);
if (getLevel() == DEFINITE_LEVEL) {
logDatabaseNode.getChildren(monitor);
}
} else {
parent.addChild(logDatabaseNode);
if (logDatabaseNode.getLoader() != null && logDatabaseNode.getLoader().isLoaded()) {
logDatabaseNode.getLoader().setLoaded(false);
logDatabaseNode.getChildren(monitor);
}
}
}
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.model.ICubridNodeLoader in project cubrid-manager by CUBRID.
the class CQBDbConnectionLoader method addViewFolder.
/**
* Add view folder
*
* @param monitor the IProgressMonitor
* @param database the CubridDatabase
*/
private void addViewFolder(final IProgressMonitor monitor, CubridDatabase database) {
String viewsFolderId = database.getId() + NODE_SEPARATOR + VIEWS_FOLDER_ID;
ICubridNode viewsFolder = database.getChild(viewsFolderId);
if (viewsFolder == null) {
viewsFolder = new DefaultSchemaNode(viewsFolderId, VIEWS_FOLDER_NAME, "icons/navigator/schema_view.png");
viewsFolder.setType(NodeType.VIEW_FOLDER);
viewsFolder.setContainer(true);
ICubridNodeLoader loader = new CubridViewsFolderLoader();
loader.setLevel(getLevel());
viewsFolder.setLoader(loader);
database.addChild(viewsFolder);
if (getLevel() == DEFINITE_LEVEL) {
viewsFolder.getChildren(monitor);
}
} else {
if (viewsFolder.getLoader() != null && viewsFolder.getLoader().isLoaded()) {
viewsFolder.getLoader().setLoaded(false);
viewsFolder.getChildren(monitor);
}
}
}
Aggregations