我找到的两种方法,希望大家补充
第一种:利用Action
IWorkbenchWindow window = getViewSite().getWorkbenchWindow();
IWorkbenchAction max = ActionFactory.MAXIMIZE.create(window);
max.run();
这段代码要放在何适的位置上才会起到合适的作用。
第二种:利用Zoom
在ApplicationWorkbenchWindowAdvisor#postWindowOpen中做到
public void postWindowOpen() {
IWorkbenchWindow window = Plugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
IViewPart part=null;
try {
part = window.getActivePage().showView(View.ID);
} catch (PartInitException e) {
e.printStackTrace();
}
if(part!=null){
window.getActivePage().activate(part);
window.getActivePage().bringToTop(part);
WorkbenchPage realPage = (WorkbenchPage) window.getActivePage();
IWorkbenchPartReference partRef = window.getActivePage().getActivePartReference();
if (partRef != null) {
((WorkbenchPage) window.getActivePage()).toggleZoom(partRef);
}else{
System.out.println("partRef is null!");
}
}
}