欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

RCP中如何获取页面状态(最大/最小/restore) 博客分类: RCP Java 

程序员文章站 2024-02-21 18:13:10
...
如下代码:
       IWorkbenchPage ipage= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
       IWorkbenchPartReference partRef=ipage.getActivePartReference();
       WorkbenchPage page=(WorkbenchPage)ipage;
       //获得页面状态 IStackPresentationSite.STATE_MINIMIZED
       //IStackPresentationSite.STATE_MAXIMIZED
       //IStackPresentationSite.STATE_RESTORED三种
       int state = getState(partRef, page.getActivePerspective());


    int getState(IWorkbenchPartReference ref,Perspective persp) {
        if (persp == null) {
            return IStackPresentationSite.STATE_RESTORED;
        }

        PartPane pane = ((WorkbenchPartReference) ref).getPane();
        
        if (ref instanceof IViewReference
                && persp.isFastView((IViewReference) ref)) {
            return persp.getFastViewState();
        }       
        
        PartStack parent = ((PartStack)pane.getContainer());
        
        if (parent != null) {
            return parent.getState();
        }
        
        return IStackPresentationSite.STATE_RESTORED;
    }


在IStackPresentationSite中,共定义了三个状态

    public static int STATE_MINIMIZED = 0;

    public static int STATE_MAXIMIZED = 1;

    public static int STATE_RESTORED = 2;
相关标签: Java