1. Only one Workbench
IWorkbench wb = PlatformUI.getWorkbench();
2. A workbench has one or more main windows(always one)
IWorkbenchWindow[] wbWindows = PlatformUI.getWorkbench()getWorkbenchWindows();
IWorkbenchWindow wbWindow =
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
//others
Display display =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay();
display.syncExec(Runnable); //串行
display.asyncExec(Runnable); //并行
…
3. Each workbench window has a collection of pages(always one)
IWorkbenchPage[] pages =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPages();
IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
Composite composite = page.getClientComposite();
4.Each workbench page has a collection of workbench parts, of which there are
two kinds: views and editors.
IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorReference[] editorRefs = page.getEditorReferences();
IEditorPart[] editors = page.getEditors();
IViewReference[] viewRefs = page.getViewReferences();
IViewPart[] views = page.getViews();
//you can also get perspective from WorkbenchPage
Perspective perspective = page.getActivePerspective();
5. LayoutPart and its child class PartPane PartPlaceholder PartSashContainer
PartStack, jsut layout. for example: zoom in/out, specified size, drag/drop.
6. Editors shared one Action Bars, Views has his own Action Bars.
Editor: getSite().getActionBars();
editors[0].getEditorSite().getActionBars();
View: views[0].getViewSite().getActionBars();
7. Get contorl from editor/view:
Composite composite = views[0].getPane().getControl();
Composite composite = editors[0].getPane().getControl();
8. What’s Site
PartSite is the general implementation for an IWorkbenchPartSite. A site
maintains the context for a part, including the part, its pane, active
contributions, selection provider, etc. Together, these components make up the
complete behavior for a part as if it was implemented by one person. The
PartSite lifecycle is as follows ..
1. a site is constructed
2. a part is constructed and stored in the part
3. the site calls part.init()
4. a pane is constructed and stored in the site
5. the action bars for a part are constructed and stored in the site
6. the pane is added to a presentation
7. the SWT widgets for the pane and part are created
8. the site is activated, causing the actions to become visible
http://www.eclipse.org/articles/Article-UI-Workbench/workbench.html