Search in sources :

Example 1 with DashboardPart

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

the class GefViewerKeyHandler method keyPressed.

/**
	 * @see org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler.keyPressed
	 * @param event KeyEvent
	 * @return true or false.
	 */
public boolean keyPressed(KeyEvent event) {
    GraphicalEditPart editPart = getFocusEditPart();
    if (editPart instanceof HANodePart) {
        if (moveHANodesByKey(event)) {
            return true;
        }
        if (deleteHANodeByKey(event)) {
            return true;
        }
    }
    if (editPart instanceof DashboardPart && event.keyCode == SWT.F5) {
        DashboardPart dp = (DashboardPart) editPart;
        dp.refresh();
        List<?> childEditPart = dp.getChildren();
        for (Object child : childEditPart) {
            ((EditPart) child).refresh();
        }
    }
    return super.keyPressed(event);
}
Also used : DashboardPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DashboardPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) HANodePart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HANodePart)

Example 2 with DashboardPart

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

the class DashboardRefreshAction method run.

/**
	 * refresh dashboard run.
	 * 
	 * @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 = null;
    if (objArr[0] instanceof DashboardPart) {
        dp = (DashboardPart) objArr[0];
    } else {
        dp = (DashboardPart) ((EditPart) objArr[0]).getParent();
    }
    //Clear error messages
    IStructuredSelection selection = (IStructuredSelection) getSelection();
    Iterator<?> iterator = selection.iterator();
    while (iterator.hasNext()) {
        Object objSelected = iterator.next();
        if (objSelected instanceof HANodePart) {
            HANodePart ep = (HANodePart) objSelected;
            ((HANode) ep.getModel()).clearErrorMessages();
        }
    }
    dp.refresh();
    List<?> childEditPart = dp.getChildren();
    for (Object child : childEditPart) {
        ((EditPart) child).refresh();
    }
}
Also used : DashboardPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DashboardPart) EditPart(org.eclipse.gef.EditPart) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) HANode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode) HANodePart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HANodePart)

Example 3 with DashboardPart

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

the class DeleteHostMonitorAction method run.

/**
	 * Delete host and it's databases from dashboard.
	 */
public void run() {
    if (getSelectedObj() == null || getSelectedObj().length == 0) {
        return;
    }
    HostMonitorPart part = (HostMonitorPart) getSelectedObj()[0];
    DashboardPart dashboardPart = (DashboardPart) part.getParent();
    Dashboard dashboard = (Dashboard) dashboardPart.getModel();
    HostNode hn = (HostNode) part.getModel();
    boolean isDelete = CommonUITool.openConfirmBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.bind(Messages.msgConfirmDeleteHost, hn.getName()));
    if (!isDelete) {
        return;
    }
    dashboard.removeNode(hn);
}
Also used : DashboardPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DashboardPart) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) Dashboard(com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard) HostMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart)

Example 4 with DashboardPart

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

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

the class ShowBrokerClientAction method run.

/**
	 * Create a new figure in dashboard.
	 * 
	 * @see org.eclipse.jface.action.Action#run()
	 */
public void run() {
    IStructuredSelection selection = (IStructuredSelection) getSelection();
    BrokerMonitorPart cmp = (BrokerMonitorPart) selection.getFirstElement();
    DashboardPart dp = (DashboardPart) cmp.getParent();
    Dashboard db = (Dashboard) dp.getModel();
    BrokerNode model = (BrokerNode) cmp.getModel();
    ClientNode clientNode = db.getClientNodeByBroker(model);
    if (this.isChecked()) {
        if (null == clientNode) {
            clientNode = new ClientNode();
            clientNode.setBrokerNode(model);
            db.addClientNode(clientNode);
        }
        clientNode.setVisible(true);
    } else {
        clientNode.setVisible(false);
    }
    db.refresh();
}
Also used : BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) BrokerMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerMonitorPart) DashboardPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DashboardPart) ClientNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.ClientNode) Dashboard(com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

DashboardPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DashboardPart)9 Dashboard (com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6 BrokerMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerMonitorPart)5 BrokerNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode)4 BrokerDBListNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerDBListNode)2 ClientNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.ClientNode)2 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)2 HANodePart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HANodePart)2 HostMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart)2 EditPart (org.eclipse.gef.EditPart)2 CMWizardDialog (com.cubrid.common.ui.spi.dialog.CMWizardDialog)1 AddHostAndDbWizard (com.cubrid.cubridmanager.ui.mondashboard.dialog.wizard.AddHostAndDbWizard)1 HANode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode)1 BrokerDBListMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerDBListMonitorPart)1 ClientMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.ClientMonitorPart)1 DatabaseMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)1 MonitorEditPartFacotry (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.MonitorEditPartFacotry)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 GraphicalViewer (org.eclipse.gef.GraphicalViewer)1