Search in sources :

Example 26 with DefaultCubridNode

use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.

the class RemoveAllManagerLogAction method run.

/**
	 * Remove all manager logs
	 */
public void run() {
    if (!CommonUITool.openConfirmBox(Messages.warningRemoveManagerLog)) {
        return;
    }
    Object[] selected = this.getSelectedObj();
    String sendStr;
    if (((DefaultCubridNode) selected[0]).getId().indexOf("Access log") >= 0) {
        sendStr = "deleteaccesslog";
    } else {
        sendStr = "deleteerrorlog";
    }
    DelManagerLogTask delAllLogTask = new DelManagerLogTask(((DefaultCubridNode) selected[0]).getServer().getServerInfo(), sendStr);
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.removeLogTaskName);
    taskExecutor.addTask(delAllLogTask);
    new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
    if (taskExecutor.isSuccess()) {
        refreshLogEditor((ICubridNode) selected[0]);
        CommonUITool.openInformationBox(Messages.msgSuccess, Messages.msgDeleteAllLog);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) DelManagerLogTask(com.cubrid.cubridmanager.core.logs.task.DelManagerLogTask)

Example 27 with DefaultCubridNode

use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.

the class LogPropertyAction method run.

/**
	 * Open dialog
	 */
public void run() {
    Object[] selected = getSelectedObj();
    DefaultCubridNode node = (DefaultCubridNode) selected[0];
    LogInfo logInfo = (LogInfo) ((DefaultCubridNode) selected[0]).getAdapter(LogInfo.class);
    LogPropertyDialog logPropertyDialog = new LogPropertyDialog(getShell());
    logPropertyDialog.setLogInfo(logInfo, node);
    logPropertyDialog.create();
    logPropertyDialog.getShell().setSize(580, 330);
    logPropertyDialog.open();
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) LogPropertyDialog(com.cubrid.cubridmanager.ui.logs.dialog.LogPropertyDialog)

Example 28 with DefaultCubridNode

use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.

the class CubridLogsFolderLoader 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;
        }
        ServerType serverType = parent.getServer().getServerInfo().getServerType();
        // add broker logs folder to logs folder
        if (serverType == ServerType.BOTH || serverType == ServerType.BROKER) {
            String brokerLogsFolderId = parent.getId() + NODE_SEPARATOR + LOGS_BROKER_FOLDER_ID;
            ICubridNode brokerLogsFolder = parent.getChild(brokerLogsFolderId);
            if (brokerLogsFolder == null) {
                brokerLogsFolder = new DefaultCubridNode(brokerLogsFolderId, LOGS_BROKER_FOLDER_NAME, "icons/navigator/log_broker_group.png");
                brokerLogsFolder.setType(CubridNodeType.LOGS_BROKER_FOLDER);
                brokerLogsFolder.setContainer(true);
                ICubridNodeLoader loader = new CubridBrokerLogFolderLoader();
                loader.setLevel(getLevel());
                brokerLogsFolder.setLoader(loader);
                parent.addChild(brokerLogsFolder);
                if (getLevel() == DEFINITE_LEVEL) {
                    brokerLogsFolder.getChildren(monitor);
                }
            } else {
                if (brokerLogsFolder.getLoader() != null && brokerLogsFolder.getLoader().isLoaded()) {
                    brokerLogsFolder.getLoader().setLoaded(false);
                    brokerLogsFolder.getChildren(monitor);
                }
            }
        }
        // add manager logs folder to logs folder
        if (serverType == ServerType.BOTH || serverType == ServerType.DATABASE) {
            String managerLogsFolderId = parent.getId() + NODE_SEPARATOR + LOGS_MANAGER_FOLDER_ID;
            ICubridNode managerLogsFolder = parent.getChild(managerLogsFolderId);
            if (managerLogsFolder == null) {
                managerLogsFolder = new DefaultCubridNode(managerLogsFolderId, LOGS_MANAGER_FOLDER_NAME, "icons/navigator/log_manager_group.png");
                managerLogsFolder.setType(CubridNodeType.LOGS_MANAGER_FOLDER);
                managerLogsFolder.setContainer(true);
                parent.addChild(managerLogsFolder);
            }
            // add access and error log folder to manager logs folder
            String[] managerLogIdArr = { ACCESS_LOG_FOLDER_ID, ERROR_LOG_FOLDER_ID };
            String[] managerLogNameArr = { ACCESS_LOG_FOLDER_NAME, ERROR_LOG_FOLDER_NAME };
            String[] managerLogTypeArr = { CubridNodeType.LOGS_MANAGER_ACCESS_LOG, CubridNodeType.LOGS_MANAGER_ERROR_LOG };
            String[] iconsArr = { "icons/navigator/log_item.png", "icons/navigator/log_item.png" };
            for (int i = 0; i < managerLogNameArr.length; i++) {
                String id = parent.getId() + NODE_SEPARATOR + managerLogIdArr[i];
                ICubridNode logFolder = parent.getChild(id);
                if (logFolder == null) {
                    logFolder = new DefaultCubridNode(id, managerLogNameArr[i], iconsArr[i]);
                    logFolder.setType(managerLogTypeArr[i]);
                    logFolder.setEditorId(LogEditorPart.ID);
                    logFolder.setContainer(false);
                    managerLogsFolder.addChild(logFolder);
                }
            }
            //add database server log folder
            String serverLogsFolderId = parent.getId() + NODE_SEPARATOR + LOGS_SERVER_FOLDER_ID;
            ICubridNode serverLogsFolder = parent.getChild(serverLogsFolderId);
            if (serverLogsFolder == null) {
                serverLogsFolder = new DefaultCubridNode(serverLogsFolderId, LOGS_SERVER_FOLDER_NAME, "icons/navigator/log_db_group.png");
                serverLogsFolder.setType(CubridNodeType.LOGS_SERVER_FOLDER);
                serverLogsFolder.setContainer(true);
                ICubridNodeLoader loader = new CubridDatabaseLogFolderLoader();
                loader.setLevel(getLevel());
                serverLogsFolder.setLoader(loader);
                parent.addChild(serverLogsFolder);
                if (getLevel() == DEFINITE_LEVEL) {
                    serverLogsFolder.getChildren(monitor);
                }
            } else {
                if (serverLogsFolder.getLoader() != null && serverLogsFolder.getLoader().isLoaded()) {
                    serverLogsFolder.getLoader().setLoaded(false);
                    serverLogsFolder.getChildren(monitor);
                }
            }
        }
        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) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

Example 29 with DefaultCubridNode

use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.

the class CubridMonitorFolderLoader method createTempStatusNode.

/**
	 * Create temp status node
	 *
	 * @param parent the parent node
	 */
private void createTempStatusNode(ICubridNode parent) {
    CubridStatusMonitorInstance instance = CubridStatusMonitorInstance.getInstance();
    ServerInfo serverInfo = parent.getServer().getServerInfo();
    String[] keys = QueryOptions.getAllStatusMonitorKey(serverInfo);
    for (String key : keys) {
        StatusMonInstanceData data = instance.loadSetting(key);
        instance.addData(key, data);
    }
    Map<String, StatusMonInstanceData> map = instance.getDataMap();
    for (Map.Entry<String, StatusMonInstanceData> entry : map.entrySet()) {
        String key = entry.getKey();
        String prefix = QueryOptions.getPrefix(serverInfo);
        if (!key.startsWith(prefix)) {
            continue;
        }
        String label = key.substring(key.lastIndexOf(".") + 1);
        StatusMonInstanceData monInstaceData = entry.getValue();
        String statusId = parent.getId() + NODE_SEPARATOR + label;
        ICubridNode stautsNode = new DefaultCubridNode(statusId, label, "icons/navigator/status_item.png");
        stautsNode.setType(CubridNodeType.STATUS_MONITOR_TEMPLATE);
        stautsNode.setModelObj(monInstaceData);
        String viewId = "";
        switch(monInstaceData.getMonitorType()) {
            case BROKER:
                viewId = BrokerStatusMonitorViewPart.ID;
                break;
            case DATABASE:
                viewId = DbStatusDumpMonitorViewPart.ID;
                break;
            default:
        }
        if ("".equals(viewId)) {
            return;
        }
        stautsNode.setViewId(viewId);
        stautsNode.setContainer(false);
        parent.addChild(stautsNode);
    }
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) CubridStatusMonitorInstance(com.cubrid.cubridmanager.ui.monitoring.editor.internal.CubridStatusMonitorInstance) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) StatusMonInstanceData(com.cubrid.cubridmanager.ui.monitoring.editor.internal.StatusMonInstanceData) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) Map(java.util.Map)

Example 30 with DefaultCubridNode

use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.

the class CubridMonitorFolderLoader method loadStatusTempInfoTask.

/**
	 * load sub node by the task of getStatusTemplateInfos
	 *
	 * @param parent the parent node
	 * @param monitor the instance of IProgressMonitor
	 * @param serverInfo the instance of serverInfo
	 * @return boolean false if error occur, true if succeed
	 */
private boolean loadStatusTempInfoTask(ICubridNode parent, final IProgressMonitor monitor, ServerInfo serverInfo) {
    StatusTemplateInfos statusTemplateInfos = new StatusTemplateInfos();
    final CommonQueryTask<StatusTemplateInfos> task = new CommonQueryTask<StatusTemplateInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), statusTemplateInfos);
    monitorCancel(monitor, new ITask[] { task });
    task.execute();
    final String errorMsg = task.getErrorMsg();
    if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
        //parent.removeAllChild();
        removeAllStatusTemp(parent);
        openErrorBox(errorMsg);
        setLoaded(true);
        return false;
    }
    if (monitor.isCanceled()) {
        setLoaded(true);
        return false;
    }
    //parent.removeAllChild();
    removeAllStatusTemp(parent);
    statusTemplateInfos = task.getResultModel();
    if (statusTemplateInfos != null) {
        List<StatusTemplateInfo> list = statusTemplateInfos.getStatusTemplateInfoList().getStatusTemplateInfoList();
        if (list != null) {
            for (StatusTemplateInfo statusTemplateInfo : list) {
                String id = parent.getId() + NODE_SEPARATOR + statusTemplateInfo.getName();
                ICubridNode logInfoNode = new DefaultCubridNode(id, statusTemplateInfo.getName(), "icons/navigator/status_item.png");
                logInfoNode.setType(CubridNodeType.STATUS_MONITOR_TEMPLATE);
                logInfoNode.setModelObj(statusTemplateInfo);
                logInfoNode.setViewId(StatusMonitorViewPart.ID);
                logInfoNode.setContainer(false);
                parent.addChild(logInfoNode);
            }
        }
    }
    return true;
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) StatusTemplateInfo(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) StatusTemplateInfos(com.cubrid.cubridmanager.core.monitoring.model.StatusTemplateInfos) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Aggregations

DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)41 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)25 LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)17 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)15 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)12 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)12 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)12 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)11 TreeViewer (org.eclipse.jface.viewers.TreeViewer)10 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)7 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)6 IEditorPart (org.eclipse.ui.IEditorPart)6 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)6 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)5 DelAllLogTask (com.cubrid.cubridmanager.core.logs.task.DelAllLogTask)5 ArrayList (java.util.ArrayList)5 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)5 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)4 BrokerLogInfos (com.cubrid.cubridmanager.core.logs.model.BrokerLogInfos)4 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)2