RCP中如何获取页面状态(最大/最小/restore) 博客分类: RCP Java
程序员文章站
2024-02-21 18:13:10
...
如下代码:
在IStackPresentationSite中,共定义了三个状态
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;