eclipse workbench usage(EditReference ViewReference etc)

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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值