Search in sources :

Example 6 with DatabaseMonitorPart

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

the class OpenCopyLogDBLogAction 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) {
    if (obj instanceof DatabaseMonitorPart) {
        DatabaseMonitorPart dbMonPart = (DatabaseMonitorPart) obj;
        DatabaseNode dbNode = (DatabaseNode) dbMonPart.getModel();
        HostNode hostNode = dbNode.getParent();
        if (hostNode != null && hostNode.getServerInfo() != null && hostNode.getServerInfo().isConnected() && (dbNode.getDbStatusType() == DBStatusType.STANDBY || dbNode.getDbStatusType() == DBStatusType.MAINTENANCE) && hostNode.getHostStatusInfo() != null && hostNode.getHostStatusInfo().getMasterHostStatusInfo() != null) {
            return true;
        }
    }
    return false;
}
Also used : DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) DatabaseMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)

Example 7 with DatabaseMonitorPart

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

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

the class ShowHostAction method isSupported.

/**
	 * Always support
	 * 
	 * @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) {
    IStructuredSelection selection = (IStructuredSelection) getSelection();
    Iterator<?> iterator = selection.iterator();
    boolean isVisible = true;
    while (iterator.hasNext()) {
        Object objSelected = iterator.next();
        if (objSelected instanceof DatabaseMonitorPart) {
            DatabaseMonitorPart cmp = (DatabaseMonitorPart) objSelected;
            DatabaseNode dn = ((DatabaseNode) cmp.getModel());
            if (!dn.getParent().isVisible()) {
                isVisible = false;
                break;
            }
        } else if (objSelected instanceof BrokerMonitorPart) {
            BrokerMonitorPart cmp = (BrokerMonitorPart) objSelected;
            BrokerNode bn = ((BrokerNode) cmp.getModel());
            if (!bn.getParent().isVisible()) {
                isVisible = false;
                break;
            }
        }
    }
    setChecked(isVisible);
    return true;
}
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) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DatabaseMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)

Example 9 with DatabaseMonitorPart

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

the class OpenApplyLogDBLogAction 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) {
    if (obj instanceof DatabaseMonitorPart) {
        DatabaseMonitorPart dbMonPart = (DatabaseMonitorPart) obj;
        DatabaseNode dbNode = (DatabaseNode) dbMonPart.getModel();
        HostNode hostNode = dbNode.getParent();
        if (hostNode != null && hostNode.isConnected() && (dbNode.getDbStatusType() == DBStatusType.STANDBY || dbNode.getDbStatusType() == DBStatusType.MAINTENANCE) && hostNode.getHostStatusInfo() != null && hostNode.getHostStatusInfo().getMasterHostStatusInfo() != null) {
            return true;
        }
    }
    return false;
}
Also used : DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) DatabaseMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)

Example 10 with DatabaseMonitorPart

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

the class OpenCopyLogDBLogAction method run.

/**
	 * open apply database log
	 * 
	 * @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;
    }
    DatabaseMonitorPart dbMonPart = (DatabaseMonitorPart) objArr[0];
    DatabaseNode dbNode = (DatabaseNode) dbMonPart.getModel();
    HostNode hostNode = dbNode.getParent();
    ServerInfo serverInfo = hostNode.getServerInfo();
    CubridServer server = new CubridServer(serverInfo.getHostAddress(), serverInfo.getHostAddress(), null, null);
    server.setServerInfo(serverInfo);
    LogInfo logInfo = new LogInfo();
    String logPath = serverInfo.getEnvInfo().getRootDir() + serverInfo.getPathSeparator() + "log" + serverInfo.getPathSeparator();
    String fileName = dbNode.getDbName() + "@" + hostNode.getHostStatusInfo().getMasterHostStatusInfo().getHostName() + "_copylogdb.err";
    logInfo.setPath(logPath + fileName);
    DefaultCubridNode dbLogInfoNode = new DefaultCubridNode(dbNode.getDbName() + ICubridNodeLoader.NODE_SEPARATOR + "copy_database_log", logInfo.getName(), "icons/navigator/log_item.png");
    dbLogInfoNode.setType(CubridNodeType.LOGS_COPY_DATABASE_LOG);
    dbLogInfoNode.setModelObj(logInfo);
    dbLogInfoNode.setEditorId(LogEditorPart.ID);
    dbLogInfoNode.setContainer(false);
    dbLogInfoNode.setServer(server);
    LogViewAction action = (LogViewAction) ActionManager.getInstance().getAction(LogViewAction.ID);
    action.setCubridNode(dbLogInfoNode);
    action.run();
}
Also used : LogViewAction(com.cubrid.cubridmanager.ui.logs.action.LogViewAction) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) DatabaseMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Aggregations

DatabaseMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)14 DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)11 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)9 BrokerMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerMonitorPart)6 HostMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)3 BrokerNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode)3 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)2 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)2 LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)2 LogViewAction (com.cubrid.cubridmanager.ui.logs.action.LogViewAction)2 BrokerDBListMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.BrokerDBListMonitorPart)2 ClientMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.ClientMonitorPart)2 DatabaseLogListDialog (com.cubrid.cubridmanager.ui.mondashboard.dialog.DatabaseLogListDialog)1 DbDashboardHistoryViewPart (com.cubrid.cubridmanager.ui.mondashboard.editor.DbDashboardHistoryViewPart)1 HANode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode)1 DashboardPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DashboardPart)1 HANodePart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HANodePart)1 MonitorEditPartFacotry (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.MonitorEditPartFacotry)1