Search in sources :

Example 46 with IViewReference

use of org.eclipse.ui.IViewReference in project cubrid-manager by CUBRID.

the class HostMonitorPart method performRequest.

/**
	 * @see org.eclipse.gef.editparts.AbstractEditPart#performRequest(org.eclipse.gef.Request)
	 * @param req Request
	 */
public void performRequest(Request req) {
    if (req.getType() == RequestConstants.REQ_OPEN) {
        HostNode hn = (HostNode) getModel();
        if (!hn.isConnected()) {
            return;
        }
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (window == null) {
            return;
        }
        IWorkbenchPage page = window.getActivePage();
        if (page == null) {
            return;
        }
        String secondaryId = new StringBuffer(hn.getUserName()).append("&").append(hn.getIp()).append("&").append(hn.getPort()).toString();
        IViewReference viewReference = page.findViewReference(HostDashboardViewPart.ID, secondaryId);
        if (viewReference == null) {
            try {
                IViewPart viewPart = page.showView(HostDashboardViewPart.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
                ((HostDashboardViewPart) viewPart).init((HostNode) getModel());
            } catch (PartInitException ex) {
                viewReference = null;
            }
        } else {
            IViewPart viewPart = viewReference.getView(false);
            window.getActivePage().bringToTop(viewPart);
            ((HostDashboardViewPart) viewPart).init((HostNode) getModel());
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) HostDashboardViewPart(com.cubrid.cubridmanager.ui.mondashboard.editor.HostDashboardViewPart)

Example 47 with IViewReference

use of org.eclipse.ui.IViewReference in project cubrid-manager by CUBRID.

the class DeleteStatusMonitorTemplateAction method delStatusTemp.

/**
	 * delete status template task.
	 * 
	 * @param activePage IWorkbenchPage
	 * @param selection ICubridNode
	 * @return DelStatusTemplateTask
	 */
private DelStatusTemplateTask delStatusTemp(IWorkbenchPage activePage, ICubridNode selection) {
    DelStatusTemplateTask delTsk = new DelStatusTemplateTask(selection.getServer().getServerInfo());
    IViewReference viewRef = activePage.findViewReference(StatusMonitorViewPart.ID, selection.getLabel());
    if (viewRef != null) {
        IViewPart viewPart = viewRef.getView(false);
        //closes the view part
        if (null != viewPart && viewPart.getTitle().endsWith(selection.getLabel())) {
            activePage.hideView(viewPart);
        }
    }
    delTsk.setTemplateName(selection.getName());
    return delTsk;
}
Also used : IViewPart(org.eclipse.ui.IViewPart) DelStatusTemplateTask(com.cubrid.cubridmanager.core.monitoring.task.DelStatusTemplateTask) IViewReference(org.eclipse.ui.IViewReference)

Example 48 with IViewReference

use of org.eclipse.ui.IViewReference in project cubrid-manager by CUBRID.

the class HostDashboardHistoryAction method run.

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

Example 49 with IViewReference

use of org.eclipse.ui.IViewReference in project cubrid-manager by CUBRID.

the class OpenMonitorDashboardViewAction method run.

/**
	 * Open HA monitor view part
	 */
public void run() {
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    boolean isExist = false;
    IViewReference[] viewRefArr = page.getViewReferences();
    if (viewRefArr != null && viewRefArr.length > 0) {
        for (IViewReference viewRef : viewRefArr) {
            String id = viewRef.getId();
            if (CubridMonitorNavigatorView.ID.equals(id)) {
                IViewPart viewPart = viewRef.getView(true);
                if (viewPart == null) {
                    isExist = false;
                } else {
                    page.bringToTop(viewRef.getView(true));
                    isExist = true;
                }
                break;
            }
        }
    }
    if (!isExist) {
        try {
            page.showView(CubridMonitorNavigatorView.ID);
        } catch (PartInitException e) {
            LOGGER.error(e.getMessage());
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException)

Example 50 with IViewReference

use of org.eclipse.ui.IViewReference in project tdi-studio-se by Talend.

the class StartMonitorJobAction method getProperriesView.

/**
     * Gets the currently opened properties view.
     * 
     * @return The properties views
     */
private static List<PropertySheet> getProperriesView() {
    List<PropertySheet> list = new ArrayList<PropertySheet>();
    IViewReference[] views = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
    for (IViewReference viewReference : views) {
        if (IPageLayout.ID_PROP_SHEET.equals(viewReference.getId())) {
            list.add((PropertySheet) viewReference.getView(true));
        }
    }
    return list;
}
Also used : PropertySheet(org.eclipse.ui.views.properties.PropertySheet) IViewReference(org.eclipse.ui.IViewReference) ArrayList(java.util.ArrayList)

Aggregations

IViewReference (org.eclipse.ui.IViewReference)66 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)48 IViewPart (org.eclipse.ui.IViewPart)37 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)23 PartInitException (org.eclipse.ui.PartInitException)23 IFile (org.eclipse.core.resources.IFile)10 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)8 ArrayList (java.util.ArrayList)8 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)8 CubridViewPart (com.cubrid.common.ui.spi.part.CubridViewPart)7 UserException (org.eclipse.titan.log.viewer.exceptions.UserException)7 IOException (java.io.IOException)6 IEditorInput (org.eclipse.ui.IEditorInput)6 IEditorReference (org.eclipse.ui.IEditorReference)6 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)4 ParseException (java.text.ParseException)4 IProject (org.eclipse.core.resources.IProject)4 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)4