Search in sources :

Example 1 with CubridDbLogNode

use of com.cubrid.cubridmanager.ui.spi.model.CubridDbLogNode in project cubrid-manager by CUBRID.

the class CubridDatabaseLogLoader 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() || parent == null) {
            return;
        }
        String dbName = parent.getLabel();
        ServerInfo serverInfo = parent.getServer().getServerInfo();
        DbLogInfos dbLogInfos = new DbLogInfos();
        final CommonQueryTask<DbLogInfos> task = new CommonQueryTask<DbLogInfos>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), dbLogInfos);
        task.setDbName(dbName);
        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();
        dbLogInfos = task.getResultModel();
        DbLogInfoList dbLogInfoList = dbLogInfos == null ? null : dbLogInfos.getDbLogInfoList();
        List<LogInfo> logInfoList = dbLogInfoList == null ? null : dbLogInfoList.getDbLogInfoList();
        if (logInfoList != null) {
            for (LogInfo dbLogInfo : logInfoList) {
                String id = parent.getId() + NODE_SEPARATOR + dbLogInfo.getName();
                CubridDbLogNode dbLogInfoNode = new CubridDbLogNode(id, dbLogInfo.getName(), "icons/navigator/log_item.png");
                dbLogInfoNode.setType(CubridNodeType.LOGS_SERVER_DATABASE_LOG);
                dbLogInfoNode.setModelObj(dbLogInfo);
                dbLogInfoNode.setEditorId(LogEditorPart.ID);
                dbLogInfoNode.setContainer(false);
                parent.addChild(dbLogInfoNode);
            }
        }
        if (dbLogInfos != null && serverInfo.getLogInfoManager() != null) {
            serverInfo.getLogInfoManager().addDbLogInfos(dbLogInfos);
        }
        if (parent.getChildren() != null && !parent.getChildren().isEmpty()) {
            Collections.sort(parent.getChildren());
        }
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : DbLogInfos(com.cubrid.cubridmanager.core.logs.model.DbLogInfos) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) DbLogInfoList(com.cubrid.cubridmanager.core.logs.model.DbLogInfoList) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) CubridDbLogNode(com.cubrid.cubridmanager.ui.spi.model.CubridDbLogNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Aggregations

CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)1 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)1 DbLogInfoList (com.cubrid.cubridmanager.core.logs.model.DbLogInfoList)1 DbLogInfos (com.cubrid.cubridmanager.core.logs.model.DbLogInfos)1 LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)1 CubridDbLogNode (com.cubrid.cubridmanager.ui.spi.model.CubridDbLogNode)1