当前位置: 代码迷 >> 综合 >> RCP中如何获取页面状态(最大/最小/restore)
  详细解决方案

RCP中如何获取页面状态(最大/最小/restore)

热度:10   发布时间:2023-12-11 23:36:15.0
如下代码:
       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;
  相关解决方案