Search in sources :

Example 1 with DbDashboardHistoryViewPart

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

the class DbDashboardHistoryAction method run.

/**
	 * Open monitor host detail windows.
	 */
public void run() {
    if (getSelectedObj() == null || getSelectedObj().length == 0) {
        return;
    }
    Object obj = getSelectedObj()[0];
    if (!(obj instanceof DatabaseMonitorPart)) {
        return;
    }
    DatabaseMonitorPart part = (DatabaseMonitorPart) obj;
    DatabaseNode dn = (DatabaseNode) part.getModel();
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    IWorkbenchPage page = window.getActivePage();
    if (page == null) {
        return;
    }
    HostNode hn = dn.getParent();
    String secondaryId = new StringBuffer(dn.getDbName()).append("&").append(hn.getUserName()).append("&").append(hn.getIp()).append("&").append(hn.getPort()).toString();
    IViewReference viewReference = page.findViewReference(DbDashboardHistoryViewPart.ID, secondaryId);
    if (viewReference == null) {
        try {
            IViewPart viewPart = page.showView(DbDashboardHistoryViewPart.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
            ((DbDashboardHistoryViewPart) viewPart).init((DatabaseNode) part.getModel());
        } catch (PartInitException ex) {
            viewReference = null;
        }
    } else {
        IViewPart viewPart = viewReference.getView(false);
        window.getActivePage().bringToTop(viewPart);
        ((DbDashboardHistoryViewPart) viewPart).init((DatabaseNode) part.getModel());
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) DbDashboardHistoryViewPart(com.cubrid.cubridmanager.ui.mondashboard.editor.DbDashboardHistoryViewPart) PartInitException(org.eclipse.ui.PartInitException) DatabaseMonitorPart(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)

Aggregations

DbDashboardHistoryViewPart (com.cubrid.cubridmanager.ui.mondashboard.editor.DbDashboardHistoryViewPart)1 DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)1 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)1 DatabaseMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)1 IViewPart (org.eclipse.ui.IViewPart)1 IViewReference (org.eclipse.ui.IViewReference)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 PartInitException (org.eclipse.ui.PartInitException)1