Search in sources :

Example 1 with AddDashboardDialog

use of com.cubrid.cubridmanager.ui.mondashboard.dialog.AddDashboardDialog 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 2 with AddDashboardDialog

use of com.cubrid.cubridmanager.ui.mondashboard.dialog.AddDashboardDialog 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)

Aggregations

AddDashboardDialog (com.cubrid.cubridmanager.ui.mondashboard.dialog.AddDashboardDialog)2 Dashboard (com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard)2 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 MonitorDashboardEditor (com.cubrid.cubridmanager.ui.mondashboard.editor.MonitorDashboardEditor)1 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)1 IEditorPart (org.eclipse.ui.IEditorPart)1