Search in sources :

Example 1 with MonitorStatistic

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

the class AddDashboardDialog method verify.

/**
	 * 
	 * Verify data
	 * 
	 */
private void verify() {
    String dashboardName = dashboardNameText.getText();
    if (dashboardName.trim().length() == 0) {
        getButton(IDialogConstants.OK_ID).setEnabled(false);
        setErrorMessage(Messages.errDashboardName);
        return;
    }
    List<ICubridNode> dashboardList = MonitorDashboardPersistManager.getInstance().getAllMonitorDashboards();
    for (int i = 0; i < dashboardList.size(); i++) {
        ICubridNode node = dashboardList.get(i);
        if (dashboardName.equals(node.getLabel()) && (dashboard == null || !dashboard.getName().equals(dashboardName))) {
            getButton(IDialogConstants.OK_ID).setEnabled(false);
            setErrorMessage(Messages.errDashboardNameExist);
            return;
        }
    }
    /*TOOLS-3672 Avoid to dashboard node and statistic node have the same name*/
    List<MonitorStatistic> monitorList = MonitorStatisticPersistManager.getInstance().getMonitorStatisticListByHostId(null);
    for (MonitorStatistic monitorStatistic : monitorList) {
        if (dashboardName.equals(monitorStatistic.getId())) {
            if (dashboardName.equals(monitorStatistic.getLabel())) {
                getButton(IDialogConstants.OK_ID).setEnabled(false);
                setErrorMessage(Messages.errDashboardNameExist);
                return;
            }
        }
    }
    if (hostNodeList.isEmpty()) {
        getButton(IDialogConstants.OK_ID).setEnabled(false);
        setErrorMessage(Messages.errHostAndDbList);
        return;
    }
    getButton(IDialogConstants.OK_ID).setEnabled(true);
    setErrorMessage(null);
}
Also used : MonitorStatistic(com.cubrid.common.ui.spi.model.MonitorStatistic) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 2 with MonitorStatistic

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

the class MonitorStatisticPersistManager method removeMonitorStatistic.

/**
	 * Remove MonitorStatistic node according to <i>hostId</i>. If <i>hostId</i>
	 * is null, will check all the MonitorStatistic node belong to Dashboard
	 * tab.
	 *
	 * @param node
	 * @param hostId
	 */
public void removeMonitorStatistic(MonitorStatistic node, String hostId) {
    if (node == null) {
        return;
    }
    synchronized (this) {
        if (hostId == null) {
            hostId = HOST_ID_FOR_MULTI_HOST;
        }
        List<MonitorStatistic> monitorStatisticList = monitorStatisticMap.get(hostId);
        if (monitorStatisticList != null) {
            monitorStatisticList.remove(node);
            saveStatistic();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(node, CubridNodeChangedEventType.NODE_REMOVE));
        }
    }
}
Also used : MonitorStatistic(com.cubrid.common.ui.spi.model.MonitorStatistic) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

Example 3 with MonitorStatistic

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

the class MonitorStatisticPersistManager method addMonitorStatistic.

/**
	 *
	 * Add MonitorStatistic node according to <i>hostId</i>. If <i>hostId</i> is
	 * not null, will add a single host node for the specified host, else add a
	 * multi-host node for Dashboard tab.
	 *
	 * @param node MonitorStatistic
	 * @param hostId Host node id
	 */
public void addMonitorStatistic(MonitorStatistic node, String hostId) {
    if (node == null) {
        return;
    }
    synchronized (this) {
        if (hostId == null) {
            hostId = HOST_ID_FOR_MULTI_HOST;
        }
        List<MonitorStatistic> monitorStatisticList = monitorStatisticMap.get(hostId);
        if (monitorStatisticList == null) {
            monitorStatisticList = new ArrayList<MonitorStatistic>();
        }
        monitorStatisticList.add(node);
        //TODO:
        monitorStatisticMap.put(hostId, monitorStatisticList);
        saveStatistic();
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(node, CubridNodeChangedEventType.NODE_ADD));
    }
}
Also used : MonitorStatistic(com.cubrid.common.ui.spi.model.MonitorStatistic) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

Example 4 with MonitorStatistic

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

the class CubridMonitorFolderLoader 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();
        if (userInfo == null || StatusMonitorAuthType.AUTH_NONE == userInfo.getStatusMonitorAuth()) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        //add status node
        if (CompatibleUtil.isSupportBrokerOrDBStatusMonitor(serverInfo)) {
            String brokerStatusId = parent.getId() + NODE_SEPARATOR + BROKER_STATUS_ID;
            ICubridNode brokerStatusNode = new DefaultCubridNode(brokerStatusId, Messages.msgBrokerStatusMonitorName, "icons/navigator/status_item.png");
            brokerStatusNode.setType(CubridNodeType.STATUS_MONITOR_TEMPLATE);
            brokerStatusNode.setViewId(BrokerStatusMonitorViewPart.ID);
            brokerStatusNode.setContainer(false);
            parent.addChild(brokerStatusNode);
            String dbStatusId = parent.getId() + NODE_SEPARATOR + DB_STATUS_ID;
            ICubridNode dbStautsNode = new DefaultCubridNode(dbStatusId, Messages.msgDbStatusMonitorName, "icons/navigator/status_item.png");
            dbStautsNode.setType(CubridNodeType.STATUS_MONITOR_TEMPLATE);
            dbStautsNode.setViewId(DbStatusDumpMonitorViewPart.ID);
            dbStautsNode.setContainer(false);
            parent.addChild(dbStautsNode);
            createTempStatusNode(parent);
        } else {
            if (!loadStatusTempInfoTask(parent, monitor, serverInfo)) {
                return;
            }
        }
        //add system node
        if (CompatibleUtil.isSupportSystemMonitor(serverInfo)) {
            String hostSystemId = parent.getId() + NODE_SEPARATOR + HOST_SYSTEM_ID;
            ICubridNode hostSystemNode = new DefaultCubridNode(hostSystemId, Messages.msgHostSystemMonitorName, "icons/navigator/status_item.png");
            hostSystemNode.setType(CubridNodeType.SYSTEM_MONITOR_TEMPLATE);
            hostSystemNode.setViewId(HostSystemMonitorViewPart.ID);
            hostSystemNode.setContainer(false);
            parent.addChild(hostSystemNode);
            if (CompatibleUtil.isSupportDBSystemMonitor(serverInfo)) {
                String dbSystemId = parent.getId() + NODE_SEPARATOR + DB_SYSTEM_ID;
                ICubridNode dbSystemNode = new DefaultCubridNode(dbSystemId, Messages.msgDbSystemMonitorName, "icons/navigator/status_item.png");
                dbSystemNode.setType(CubridNodeType.SYSTEM_MONITOR_TEMPLATE);
                dbSystemNode.setViewId(DbSystemMonitorViewPart.ID);
                dbSystemNode.setContainer(false);
                parent.addChild(dbSystemNode);
            }
        }
        //add monitor statistic node
        if (CompatibleUtil.isSupportMonitorStatistic(serverInfo)) {
            List<MonitorStatistic> childList = MonitorStatisticPersistManager.getInstance().getMonitorStatisticListByHostId(serverInfo.getServerName());
            for (MonitorStatistic node : childList) {
                if (node == null) {
                    continue;
                }
                parent.addChild(node);
            }
        }
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) MonitorStatistic(com.cubrid.common.ui.spi.model.MonitorStatistic) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 5 with MonitorStatistic

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

the class AddMonitorStatisticPageAction method run.

/**
	 * Override the run method in order to open an instance of status monitor
	 * dialog
	 * 
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    ICubridNode node = null;
    if (obj.length > 0) {
        node = (ICubridNode) obj[0];
    }
    String hostId = null;
    boolean isSingleHost = node != null && CubridNodeType.MONITOR_FOLDER.equals(node.getType());
    if (isSingleHost) {
        ServerInfo serverInfo = node.getServer().getServerInfo();
        hostId = serverInfo.getServerName();
        if (!serverInfo.isSupportMonitorStatistic()) {
            CommonUITool.openWarningBox(Messages.needEnableMonitorStatisticMsg);
            return;
        }
    }
    AddStatisticPageDialog dialog = new AddStatisticPageDialog(getShell());
    dialog.setCubridServerId(hostId);
    if (dialog.open() == Dialog.OK) {
        final String iconPath = "icons/navigator/status_item.png";
        String labelName = dialog.getName();
        String pageName = labelName;
        if (hostId != null) {
            pageName += "@" + hostId;
        }
        MonitorStatistic monitorStatisticNode = new MonitorStatistic(pageName, labelName, iconPath);
        monitorStatisticNode.setType(CubridNodeType.MONITOR_STATISTIC_PAGE);
        monitorStatisticNode.setEditorId(MonitorStatisticEditor.ID);
        if (isSingleHost) {
            monitorStatisticNode.setMultiHost(false);
            ServerInfo serverInfo = node.getServer().getServerInfo();
            monitorStatisticNode.setIp(serverInfo.getHostAddress());
            monitorStatisticNode.setPort(serverInfo.getHostMonPort());
        } else {
            monitorStatisticNode.setMultiHost(true);
        }
        MonitorStatisticPersistManager persistManager = MonitorStatisticPersistManager.getInstance();
        persistManager.addMonitorStatistic(monitorStatisticNode, hostId);
        persistManager.saveStatistic();
        //refresh TreeViewer
        TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
        if (isSingleHost) {
            node.addChild(monitorStatisticNode);
            treeViewer.add(node, monitorStatisticNode);
        } else {
            /*TOOLS-3665 Refresh the input of TreeViewer*/
            treeViewer.setInput(CubridMonitorNavigatorView.getTreeViewerInput());
        }
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(monitorStatisticNode, CubridNodeChangedEventType.NODE_ADD));
        try {
            IWorkbench workbench = PlatformUI.getWorkbench();
            IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
            workbenchWindow.getActivePage().openEditor(monitorStatisticNode, MonitorStatisticEditor.ID);
        } catch (Exception ignore) {
        }
    } else {
    //TODO
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) MonitorStatisticPersistManager(com.cubrid.cubridmanager.ui.spi.persist.MonitorStatisticPersistManager) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) IWorkbench(org.eclipse.ui.IWorkbench) AddStatisticPageDialog(com.cubrid.cubridmanager.ui.monstatistic.dialog.AddStatisticPageDialog) MonitorStatistic(com.cubrid.common.ui.spi.model.MonitorStatistic)

Aggregations

MonitorStatistic (com.cubrid.common.ui.spi.model.MonitorStatistic)8 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)4 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)4 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)3 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)2 XMLMemento (com.cubrid.cubridmanager.core.common.xml.XMLMemento)2 MultiHostChartItem (com.cubrid.cubridmanager.core.monstatistic.model.MultiHostChartItem)2 SingleHostChartItem (com.cubrid.cubridmanager.core.monstatistic.model.SingleHostChartItem)2 StatisticChartHost (com.cubrid.cubridmanager.core.monstatistic.model.StatisticChartHost)2 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)1 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)1 StatisticChartItem (com.cubrid.cubridmanager.core.monstatistic.model.StatisticChartItem)1 StatisticType (com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType)1 BrokerDBListNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerDBListNode)1 BrokerNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode)1 ClientNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.ClientNode)1 Dashboard (com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard)1 DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)1 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)1 AddStatisticPageDialog (com.cubrid.cubridmanager.ui.monstatistic.dialog.AddStatisticPageDialog)1