Search in sources :

Example 6 with HostMonitorPart

use of com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart in project cubrid-manager by CUBRID.

the class MonitorDetailAction method isSupported.

/**
	 * 
	 * 
	 * @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java.lang.Object)
	 * @param obj Object
	 * @return is supported.
	 */
public boolean isSupported(Object obj) {
    HostNode hostNode = null;
    if (obj instanceof HostMonitorPart) {
        hostNode = (HostNode) ((HostMonitorPart) obj).getModel();
    } else if (obj instanceof BrokerMonitorPart) {
        BrokerNode brokerNode = (BrokerNode) ((BrokerMonitorPart) obj).getModel();
        hostNode = brokerNode.getParent();
    }
    if (hostNode != null) {
        return hostNode.isConnected();
    }
    if (obj instanceof DatabaseMonitorPart) {
        DatabaseNode dbNode = (DatabaseNode) ((DatabaseMonitorPart) obj).getModel();
        hostNode = dbNode.getParent();
        return hostNode.isConnected() && dbNode.isConnected();
    }
    return false;
}
Also used : BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) BrokerMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerMonitorPart) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) HostMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart) DatabaseMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)

Example 7 with HostMonitorPart

use of com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart in project cubrid-manager by CUBRID.

the class MonitorDashboardEditor method configureGraphicalViewer.

/**
	 * @see org.eclipse.gef.ui.parts.GraphicalEditor.configureGraphicalViewer
	 */
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    GraphicalViewer viewer = getGraphicalViewer();
    ScalableFreeformRootEditPart rootEditPart = new ScalableFreeformRootEditPart();
    viewer.setRootEditPart(rootEditPart);
    viewer.setEditPartFactory(new MonitorEditPartFacotry());
    ZoomManager manager = rootEditPart.getZoomManager();
    double[] zoomLevels = new double[] { 1.0, 1.2, 1.4, 1.6, 1.8, 2.0 };
    manager.setZoomLevels(zoomLevels);
    getActionRegistry().registerAction(new ZoomInAction(manager));
    getActionRegistry().registerAction(new ZoomOutAction(manager));
    KeyHandler keyHandler = new GefViewerKeyHandler(viewer);
    keyHandler.put(KeyStroke.getReleased('', 97, SWT.CONTROL), getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));
    keyHandler.put(KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0), getActionRegistry().getAction(GEFActionConstants.ZOOM_IN));
    keyHandler.put(KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0), getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT));
    viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.CTRL), MouseWheelZoomHandler.SINGLETON);
    viewer.setKeyHandler(keyHandler);
    //initialize context menu
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(new IMenuListener() {

        /**
			 * get menus to show.
			 * 
			 * @param manager IMenuManager
			 */
        public void menuAboutToShow(IMenuManager manager) {
            IStructuredSelection selection = (IStructuredSelection) getGraphicalViewer().getSelection();
            String[] ids = new String[] {};
            if (null == selection || selection.isEmpty() || selection.getFirstElement() instanceof DashboardPart) {
                manager.add(getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));
                ids = new String[] { AddHostMonitorAction.ID, SEPARATOR, DashboardRefreshAction.ID };
            } else if (selection.getFirstElement() instanceof HostMonitorPart) {
                ids = new String[] { MonitorDetailAction.ID, DeleteHostMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, //HARoleChangeAction.ID, SEPARATOR,
                HostDashboardHistoryAction.ID, AddDatabaseMonitorAction.ID, AddBrokerMonitorAction.ID, SEPARATOR, HideHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
            } else if (selection.getFirstElement() instanceof DatabaseMonitorPart) {
                ids = new String[] { MonitorDetailAction.ID, DeleteDatabaseMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, DbDashboardHistoryAction.ID, OpenApplyLogDBLogAction.ID, OpenCopyLogDBLogAction.ID, OpenDatabaseLogAction.ID, SEPARATOR, ShowHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
            } else if (selection.getFirstElement() instanceof BrokerMonitorPart) {
                ids = new String[] { MonitorDetailAction.ID, DeleteBrokerMonitorAction.ID, EditAliasNameAction.ID, SEPARATOR, ShowBrokerClientAction.ID, ShowBrokerDabaseAction.ID, SEPARATOR, ShowHostAction.ID, MinimizeFigureAction.ID, DashboardRefreshAction.ID };
            } else if (selection.getFirstElement() instanceof ClientMonitorPart) {
                ids = new String[] { EditAliasNameAction.ID };
            } else if (selection.getFirstElement() instanceof BrokerDBListMonitorPart) {
                ids = new String[] { EditAliasNameAction.ID };
            }
            for (String id : ids) {
                if (id.equals(SEPARATOR)) {
                    manager.add(new Separator());
                } else {
                    IAction action = ActionManager.getInstance().getAction(id);
                    ((ISelectionAction) action).setSelectionProvider(getGraphicalViewer());
                    ActionManager.addActionToManager(manager, action);
                }
            }
            manager.update(true);
        }
    });
    viewer.setContextMenu(menuManager);
}
Also used : GraphicalViewer(org.eclipse.gef.GraphicalViewer) BrokerDBListMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerDBListMonitorPart) IAction(org.eclipse.jface.action.IAction) ZoomOutAction(org.eclipse.gef.ui.actions.ZoomOutAction) BrokerMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerMonitorPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) HostMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart) IMenuListener(org.eclipse.jface.action.IMenuListener) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) ClientMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.ClientMonitorPart) ZoomManager(org.eclipse.gef.editparts.ZoomManager) DashboardPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DashboardPart) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) DatabaseMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart) MonitorEditPartFacotry(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.MonitorEditPartFacotry) KeyHandler(org.eclipse.gef.KeyHandler) ZoomInAction(org.eclipse.gef.ui.actions.ZoomInAction) Separator(org.eclipse.jface.action.Separator)

Example 8 with HostMonitorPart

use of com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart in project cubrid-manager by CUBRID.

the class AddBrokerMonitorAction method isSupported.

/**
	 * selection is Host node host is connected
	 * 
	 * @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java.lang.Object)
	 * @param obj Object
	 * @return boolean support:true;not support:false;
	 */
public boolean isSupported(Object obj) {
    if (obj instanceof HostMonitorPart) {
        HostMonitorPart hostMonPart = (HostMonitorPart) obj;
        HostNode hostNode = (HostNode) hostMonPart.getModel();
        if (hostNode == null || hostNode.getServerInfo() == null || hostNode.getServerInfo().getLoginedUserInfo() == null) {
            return false;
        }
        ServerType type = hostNode.getServerInfo().getServerType();
        return type == ServerType.BOTH || type == ServerType.BROKER;
    }
    return false;
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) HostMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart)

Example 9 with HostMonitorPart

use of com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart 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 10 with HostMonitorPart

use of com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart in project cubrid-manager by CUBRID.

the class HARoleChangeAction method run.

/**
	 * HA role change.
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    TaskExecutor taskExcutor = new CommonTaskExec(Messages.changeRoleTaskName);
    HostMonitorPart hostPart = (HostMonitorPart) obj[0];
    //deactive data gather first.
    hostPart.stopMonitorGather();
    //role change task execution.
    HARoleChangeTask task = new HARoleChangeTask(((HostNode) hostPart.getModel()).getServerInfo());
    taskExcutor.addTask(task);
    new ExecTaskWithProgress(taskExcutor).exec();
    hostPart.startMonitorGather();
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) HARoleChangeTask(com.cubrid.cubridmanager.core.mondashboard.task.HARoleChangeTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) HostMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart)

Aggregations

HostMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart)14 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)10 BrokerMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerMonitorPart)4 DatabaseMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)4 Dashboard (com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard)3 CMWizardDialog (com.cubrid.common.ui.spi.dialog.CMWizardDialog)2 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)2 AddHostAndDbWizard (com.cubrid.cubridmanager.ui.mondashboard.dialog.wizard.AddHostAndDbWizard)2 BrokerDBListMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerDBListMonitorPart)2 ClientMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.ClientMonitorPart)2 DashboardPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DashboardPart)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)1 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)1 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)1 HARoleChangeTask (com.cubrid.cubridmanager.core.mondashboard.task.HARoleChangeTask)1 HostDashboardHistoryViewPart (com.cubrid.cubridmanager.ui.mondashboard.editor.HostDashboardHistoryViewPart)1 BrokerNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode)1 DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)1 HANode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode)1