use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class CubridAdminLogFolderLoader 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();
AdminLogInfoList logInfoList = new AdminLogInfoList();
final CommonQueryTask<AdminLogInfoList> task = new CommonQueryTask<AdminLogInfoList>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), logInfoList);
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();
logInfoList = task.getResultModel();
if (logInfoList != null) {
List<LogInfo> list = logInfoList.getAdminLogInfoList();
if (list != null) {
for (LogInfo logInfo : list) {
DefaultCubridNode logInfoNode = new DefaultCubridNode(parent.getId() + NODE_SEPARATOR + logInfo.getName(), logInfo.getName(), "icons/navigator/log_item.png");
logInfoNode.setType(CubridNodeType.LOGS_BROKER_ADMIN_LOG);
logInfoNode.setContainer(false);
logInfoNode.setEditorId(LogEditorPart.ID);
logInfoNode.setModelObj(logInfo);
parent.addChild(logInfoNode);
}
}
}
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent 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.event.CubridNodeChangedEvent 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.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class CQBDbUsersFolderLoader 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();
GetUserListTask task = new GetUserListTask(database.getDatabaseInfo());
parent.removeAllChild();
try {
dbUserInfoList = task.getResultModel();
} catch (Exception e) {
LOGGER.error("load user failed", e);
}
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(NodeType.USER);
dbUserInfoNode.setModelObj(dbUserInfo);
dbUserInfoNode.setContainer(false);
dbUserInfoNode.setEditorId(CQBUserEditor.ID);
parent.addChild(dbUserInfoNode);
}
databaseInfo.setDbUserInfoList(dbUserInfoList);
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class CubridBrokerFolderLoader method load.
/**
*
* Load children object for parent
*
* @param parent the parent node
* @param monitor the IProgressMonitor object
*/
public void load(final ICubridNode parent, final IProgressMonitor monitor) {
synchronized (this) {
if (isLoaded()) {
return;
}
//when refresh broker,firstly check whether this broker exist
int ret = checkBrokerExist(parent, monitor);
if (ret == 1 || ret == 2) {
setLoaded(true);
return;
}
if (ret != 0) {
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(Messages.errBrokerNoExist);
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer != null) {
CommonUITool.refreshNavigatorTree(treeViewer, parent.getParent());
}
}
});
setLoaded(true);
return;
}
// add sql log folder
String sqlLogFolderId = parent.getId() + NODE_SEPARATOR + SQL_LOG_FOLDER_ID;
ICubridNode sqlLogFolder = parent.getChild(sqlLogFolderId);
if (sqlLogFolder == null) {
sqlLogFolder = new DefaultCubridNode(sqlLogFolderId, SQL_LOG_FOLDER_NAME, "icons/navigator/folder.png");
sqlLogFolder.setType(CubridNodeType.BROKER_SQL_LOG_FOLDER);
sqlLogFolder.setContainer(true);
parent.addChild(sqlLogFolder);
}
//add the children of sql log folder
ServerInfo serverInfo = parent.getServer().getServerInfo();
BrokerLogInfos brokerLogInfos = new BrokerLogInfos();
final CommonQueryTask<BrokerLogInfos> task = new CommonQueryTask<BrokerLogInfos>(serverInfo, CommonSendMsg.getGetBrokerLogFileInfoMSGItems(), brokerLogInfos);
task.setBroker(parent.getLabel());
monitorCancel(monitor, new ITask[] { task });
task.execute();
final String errorMsg = task.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
sqlLogFolder.removeAllChild();
openErrorBox(errorMsg);
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
sqlLogFolder.removeAllChild();
brokerLogInfos = task.getResultModel();
List<LogInfo> logInfoList = brokerLogInfos == null ? null : brokerLogInfos.getBrokerLogInfoList().getLogFileInfoList();
if (logInfoList != null && !logInfoList.isEmpty()) {
for (LogInfo logInfo : logInfoList) {
String id = sqlLogFolder.getId() + NODE_SEPARATOR + logInfo.getName();
ICubridNode logInfoNode = new DefaultCubridNode(id, logInfo.getName(), "icons/navigator/sqllog_item.png");
logInfoNode.setContainer(false);
logInfoNode.setEditorId(LogEditorPart.ID);
logInfoNode.setModelObj(logInfo);
if (LogType.SCRIPT.getText().toLowerCase().equals(logInfo.getType())) {
logInfoNode.setType(CubridNodeType.BROKER_SQL_LOG);
sqlLogFolder.addChild(logInfoNode);
}
}
}
Collections.sort(sqlLogFolder.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
Aggregations