Search in sources :

Example 11 with Dashboard

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard in project cubrid-manager by CUBRID.

the class AddBrokerMonitorAction method run.

/**
	 * open add broker monitor dialog.
	 * 
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    Object[] objArr = this.getSelectedObj();
    if (objArr == null || objArr.length <= 0 || !isSupported(objArr[0])) {
        setEnabled(false);
        return;
    }
    HostMonitorPart hostMonPart = (HostMonitorPart) objArr[0];
    HostNode hostNode = (HostNode) hostMonPart.getModel();
    Dashboard dashboard = (Dashboard) hostMonPart.getParent().getModel();
    if (hostNode != null && dashboard != null) {
        AddHostAndDbWizard wizard = new AddHostAndDbWizard(hostNode, dashboard.getHostNodeList(), 2);
        CMWizardDialog dialog = new CMWizardDialog(getShell(), wizard);
        dialog.setPageSize(660, 380);
        int returnCode = dialog.open();
        if (returnCode == IDialogConstants.OK_ID) {
            List<HostNode> addedHostNodeList = wizard.getAddedHostNodeList();
            HAUtil.mergeHostNode(dashboard, addedHostNodeList);
            HAUtil.calcLocation(dashboard.getHostNodeList());
        }
    }
}
Also used : HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) AddHostAndDbWizard(com.cubrid.cubridmanager.ui.mondashboard.dialog.wizard.AddHostAndDbWizard) Dashboard(com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard) HostMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog)

Example 12 with Dashboard

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard in project cubrid-manager by CUBRID.

the class AddHostMonitorAction method run.

/**
	 * Open add host monitor dialog.
	 * 
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    Object[] objArr = this.getSelectedObj();
    if (objArr == null || objArr.length <= 0 || !isSupported(objArr[0])) {
        setEnabled(false);
        return;
    }
    DashboardPart dp = (DashboardPart) objArr[0];
    Dashboard dashboard = (Dashboard) dp.getModel();
    if (dashboard != null) {
        AddHostAndDbWizard wizard = new AddHostAndDbWizard(null, dashboard.getHostNodeList(), 0);
        CMWizardDialog dialog = new CMWizardDialog(getShell(), wizard);
        dialog.setPageSize(660, 380);
        int returnCode = dialog.open();
        if (returnCode == IDialogConstants.OK_ID) {
            List<HostNode> addedHostNodeList = wizard.getAddedHostNodeList();
            HAUtil.mergeHostNode(dashboard, addedHostNodeList);
            HAUtil.calcLocation(dashboard.getHostNodeList());
        }
    }
}
Also used : DashboardPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DashboardPart) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) AddHostAndDbWizard(com.cubrid.cubridmanager.ui.mondashboard.dialog.wizard.AddHostAndDbWizard) Dashboard(com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog)

Example 13 with Dashboard

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard in project cubrid-manager by CUBRID.

the class EditMonitorDashboardAction method run.

/**
	 * Open the selected monitoring dash board
	 */
public void run() {
    Object[] objArr = this.getSelectedObj();
    if (objArr == null || objArr.length <= 0) {
        setEnabled(false);
        return;
    }
    ICubridNode node = (ICubridNode) objArr[0];
    Dashboard dashboard = (Dashboard) node.getAdapter(Dashboard.class);
    if (dashboard == null) {
        return;
    }
    AddDashboardDialog dialog = new AddDashboardDialog(getShell());
    dialog.setDashboard(dashboard);
    int returnCode = dialog.open();
    if (returnCode == IDialogConstants.OK_ID) {
        node.setId(dashboard.getName());
        node.setLabel(dashboard.getName());
        MonitorDashboardPersistManager.getInstance().saveDashboard();
        ISelectionProvider provider = getSelectionProvider();
        if (provider instanceof TreeViewer) {
            TreeViewer treeViewer = (TreeViewer) provider;
            treeViewer.refresh(node, true);
        }
        IEditorPart part = LayoutUtil.getEditorPart(node, node.getEditorId());
        if (part instanceof MonitorDashboardEditor) {
            ((MonitorDashboardEditor) part).changePartName(dashboard.getName());
        }
    } else {
        for (int i = 0; i < dashboard.getHostNodeList().size(); i++) {
            HostNode hostNode = dashboard.getHostNodeList().get(i);
            hostNode.getCopyedHaNodeList().clear();
            hostNode.getCopyedHaNodeList().addAll(hostNode.getDbNodeList());
            hostNode.getCopyedHaNodeList().addAll(hostNode.getBrokerNodeList());
        }
    }
}
Also used : AddDashboardDialog(com.cubrid.cubridmanager.ui.mondashboard.dialog.AddDashboardDialog) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) MonitorDashboardEditor(com.cubrid.cubridmanager.ui.mondashboard.editor.MonitorDashboardEditor) Dashboard(com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) IEditorPart(org.eclipse.ui.IEditorPart)

Example 14 with Dashboard

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard in project cubrid-manager by CUBRID.

the class AddMonitorDashboardAction method run.

/**
	 * Open the dialog
	 */
public void run() {
    AddDashboardDialog dialog = new AddDashboardDialog(getShell());
    int returnCode = dialog.open();
    if (returnCode == IDialogConstants.OK_ID) {
        Dashboard dashboard = dialog.getDashboard();
        DefaultCubridNode dashboardNode = new DefaultCubridNode(dashboard.getName(), dashboard.getName(), "icons/navigator/status_item.png");
        dashboardNode.setType(CubridNodeType.MONITOR_DASHBOARD);
        dashboardNode.setEditorId(MonitorDashboardEditor.ID);
        dashboardNode.setModelObj(dashboard);
        MonitorDashboardPersistManager.getInstance().addMonitorDashboard(dashboardNode);
        ISelectionProvider provider = getSelectionProvider();
        if (provider instanceof TreeViewer) {
            TreeViewer treeViewer = (TreeViewer) provider;
            /*TOOLS-3665 Refresh the input of TreeViewer*/
            treeViewer.setInput(CubridMonitorNavigatorView.getTreeViewerInput());
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(dashboardNode, CubridNodeChangedEventType.NODE_ADD));
            LayoutManager.getInstance().getWorkbenchContrItem().openEditorOrView(dashboardNode);
        }
    }
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) AddDashboardDialog(com.cubrid.cubridmanager.ui.mondashboard.dialog.AddDashboardDialog) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Dashboard(com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)

Example 15 with Dashboard

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard in project cubrid-manager by CUBRID.

the class MonitorDashboardPersistManager method saveDashboard.

/**
	 * 
	 * Save dash boards
	 * 
	 */
public void saveDashboard() {
    synchronized (this) {
        XMLMemento memento = XMLMemento.createWriteRoot("dashboards");
        Iterator<ICubridNode> iterator = monitorDashboardList.iterator();
        while (iterator.hasNext()) {
            ICubridNode node = (ICubridNode) iterator.next();
            if (node instanceof MonitorStatistic) {
                continue;
            }
            Dashboard dashboard = (Dashboard) node.getAdapter(Dashboard.class);
            IXMLMemento dashboardChild = memento.createChild("dashboard");
            dashboardChild.putString("name", node.getName());
            Iterator<HostNode> nodeIte = dashboard.getHostNodeList().iterator();
            while (nodeIte.hasNext()) {
                //save host node
                HostNode hostNode = nodeIte.next();
                IXMLMemento hostNodeChild = dashboardChild.createChild("host");
                hostNodeChild.putString("aliasname", hostNode.getName());
                hostNodeChild.putString("ip", hostNode.getIp());
                hostNodeChild.putString("port", hostNode.getPort());
                hostNodeChild.putString("username", hostNode.getUserName());
                hostNodeChild.putString("password", CipherUtils.encrypt(hostNode.getPassword()));
                hostNodeChild.putString("location", hostNode.getLocation().x + "," + hostNode.getLocation().y);
                hostNodeChild.putString("visible", hostNode.isVisible() ? "true" : "false");
                //save the database node list
                List<DatabaseNode> dbNodeList = hostNode.getDbNodeList();
                Iterator<DatabaseNode> dbNodeIte = dbNodeList.iterator();
                while (dbNodeIte.hasNext()) {
                    DatabaseNode dbNode = (DatabaseNode) dbNodeIte.next();
                    IXMLMemento databaseNodeChild = hostNodeChild.createChild("database");
                    databaseNodeChild.putString("aliasname", dbNode.getName());
                    databaseNodeChild.putString("dbname", dbNode.getDbName());
                    databaseNodeChild.putString("username", dbNode.getDbUser());
                    databaseNodeChild.putString("password", CipherUtils.encrypt(dbNode.getDbPassword()));
                    databaseNodeChild.putString("location", dbNode.getLocation().x + "," + dbNode.getLocation().y);
                }
                //save broker node list
                List<BrokerNode> brokerNodeList = hostNode.getBrokerNodeList();
                Iterator<BrokerNode> brokerNodeIte = brokerNodeList.iterator();
                while (brokerNodeIte.hasNext()) {
                    BrokerNode brokerNode = (BrokerNode) brokerNodeIte.next();
                    IXMLMemento brokerNodeChild = hostNodeChild.createChild("broker");
                    brokerNodeChild.putString("aliasname", brokerNode.getName());
                    brokerNodeChild.putString("brokername", brokerNode.getBrokerName());
                    brokerNodeChild.putString("location", brokerNode.getLocation().x + "," + brokerNode.getLocation().y);
                    //save the client IP list
                    ClientNode ipListNode = dashboard.getClientNodeByBroker(brokerNode);
                    Point point = null;
                    String clientIpName = null;
                    if (ipListNode == null) {
                        brokerNodeChild.putString("show_ip_list", "false");
                        point = brokerNode.getClientsLocation();
                    } else {
                        brokerNodeChild.putString("show_ip_list", ipListNode.isVisible() ? "true" : "false");
                        point = ipListNode.getLocation();
                        clientIpName = ipListNode.getName();
                    }
                    if (point != null) {
                        brokerNodeChild.putString("client_ip_location", point.x + "," + point.y);
                    }
                    if (clientIpName != null) {
                        brokerNodeChild.putString("client_ip_name", clientIpName);
                    }
                    //save the database list
                    BrokerDBListNode dbListNode = dashboard.getBrokerDBListNodeByBroker(brokerNode);
                    String clientDbName = null;
                    if (dbListNode == null) {
                        brokerNodeChild.putString("show_db_list", "false");
                        point = brokerNode.getDatabasesLocation();
                    } else {
                        brokerNodeChild.putString("show_db_list", dbListNode.isVisible() ? "true" : "false");
                        point = dbListNode.getLocation();
                        clientDbName = dbListNode.getName();
                    }
                    if (point != null) {
                        brokerNodeChild.putString("client_db_location", point.x + "," + point.y);
                    }
                    if (clientDbName != null) {
                        brokerNodeChild.putString("client_db_name", clientDbName);
                    }
                }
            }
        }
        PersistUtils.saveXMLMemento(CubridManagerUIPlugin.PLUGIN_ID, MONITOR_DASHBOARD_XML_CONTENT, memento);
    }
}
Also used : IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) ClientNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.ClientNode) BrokerDBListNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerDBListNode) Dashboard(com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) Point(org.eclipse.draw2d.geometry.Point) BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) MonitorStatistic(com.cubrid.common.ui.spi.model.MonitorStatistic)

Aggregations

Dashboard (com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard)16 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)8 BrokerNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode)7 DashboardPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DashboardPart)6 BrokerDBListNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerDBListNode)5 ClientNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.ClientNode)4 BrokerMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerMonitorPart)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 CMWizardDialog (com.cubrid.common.ui.spi.dialog.CMWizardDialog)3 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)3 AddHostAndDbWizard (com.cubrid.cubridmanager.ui.mondashboard.dialog.wizard.AddHostAndDbWizard)3 DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)3 HostMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart)3 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)2 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)2 AddDashboardDialog (com.cubrid.cubridmanager.ui.mondashboard.dialog.AddDashboardDialog)2 Point (org.eclipse.draw2d.geometry.Point)2 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1