1..IWorkbench:
workbench是eclipse用户界面中最底层的对象,它建立在Display之上,包含一个或多个IWorkbenchWindow,用于向终端用户呈现信息

当你的workbench插件被激活的时候,eclipse平台将为之创建一个实例,在平台的整个生命周期中,只允许出现该workbench的唯一实例

2..IWorkbenchWindow
上面提到IWorkbench利用其包含的IWorkbenchWindow向终端用户展现信息
"A workbench window is a top level window in a workbench. "
IWorkbenchWindow通常包含菜单栏,工具栏,状态栏和一个用来显示IWorkbenchPage的主要区域
每个IWorkbenchWindow可以包含一个或多个IWorkbenchPage,但是同一时刻只允许一个IWorkbenchPage被激活并向终端用户显示

3..IWorkbenchPage
IWorkbenchPage的功能就是组织一个或多个IEditorPart或IViewPart显示在一个IWorkbenchWindow中,最终呈现给终端用户
IWorkbenchPage包含一个或多个IEditorPart或IViewPart,这些IEditorPart和IViewPart完全被包含在这个IWorkbenchPage并且不能与其它的IWorkbenchPage共享
IWorkbenchPage上定义的Layout和ActionSet就是我们常说的透视图——perspective了
4..IWorkbenchPart
IWorkbenchPart就是上面提到的IEditorPart和IViewPart,它也只包含这两个子类型,看到这里大家应该明白,我们绝大部分的工作就是基于这个IWorkbenchPart
关于IEditorPart和IViewPart,相信大家应该已经十分了解了
IViewPart常常被用于导航信息的层次结构,例如我们的workspace,或者用来打开一个编辑器,或者用来显示这个编辑器的某些属性
IEditorPart多被用来编辑或浏览一个文档或一个输入的对象,而这个输入的对象必须是一个IEditorInput,IEditorPart遵循的就是打开-保存-关闭的生命周期模型
最后给出IWorkbenchPart的生命周期模型,希望对大家的开发能够有所帮助:
IWorkbenchPart拓展点被创建: 
实例化IWorkbenchPart 
创建一个IWorkbenchPartSite 
调用part.init(site) 
IWorkbenchPart成为可见: 
调用part.createControl(parent)绘制 IWorkbenchPart 
激活partOpened event
IWorkbenchPart被激活或者取得焦点: 
调用part.setFocus() 
激活partActivated event 
IWorkbenchPart被关闭: 
如需要保存,完成保存 
解除IWorkbenchPart的激活状态 
激活partClosed event 
从界面上移除IWorkbenchPart 
调用part.dispose()

关于IWorkbench 对象

public interface IWorkbench
extends IAdaptable, IServiceLocator
A workbench is the root object for the Eclipse Platform user interface.

A workbench has one or more main windows which present to the end user information based on some underlying model, typically on resources in an underlying workspace. A workbench usually starts with a single open window, and automatically closes when its last window closes.

Each workbench window has a collection of pages; the active page is the one that is being presented to the end user; at most one page is active in a window at a time.

Each workbench page has a collection of workbench parts, of which there are two kinds: views and editors. A page's parts are arranged (tiled or stacked) for presentation on the screen. The arrangement is not fixed; the user can arrange the parts as they see fit. A perspective is a template for a page, capturing a collection of parts and their arrangement.

The platform creates a workbench when the workbench plug-in is activated; since this happens at most once during the life of the running platform, there is only one workbench instance. Due to its singular nature, it is commonly referred to as the workbench.

The workbench supports a few services by default. If these services are used to allocate resources, it is important to remember to clean up those resources after you are done with them. Otherwise, the resources will exist until the workbench shuts down. The supported services are:

IBindingService
ICommandService
IContextService
IHandlerService
This interface is not intended to be implemented by clients.

See Also:
PlatformUI.getWorkbench()
Restriction:
This interface is not intended to be implemented by clients.

关于PlatformUI对象

public final class PlatformUI
extends Object
The central class for access to the Eclipse Platform User Interface. This class cannot be instantiated; all functionality is provided by static methods. Features provided:

creation of the workbench.
access to the workbench.
See Also:
IWorkbench

关于IEclipseContext对象

org.eclipse.e4.core.contexts
Interface IEclipseContext

public interface IEclipseContext
A context is used to isolate application code from its dependencies on an application framework or container. This helps avoid building in dependencies on a specific framework that inhibit reuse of the application code. Fundamentally a context supplies values (either data objects or services), and allows values to be set. Typically a client will be provided values from a context through injection, removing the need for clients to even depend on this interface.
While a context appears superficially to be a Map, it may in fact compute values for requested keys dynamically rather than simply retrieving a stored value.

Contexts may have a parent context, and may delegate lookup of a value to their parent. Whether a value is computed or stored in this context or a parent context is an implementation detail that clients need not be concerned with. The content of parent contexts cannot be modified by a child context.

Contexts may have child contexts. Children inherit context values from their parent as described earlier. At any time, one of the children may be considered the active child. The interpretation of what active means depends on the domain in which the context is used.

Like maps, values are stored in the context based on keys. Two types of keys can be used: strings and classes. When classes are used to access objects in the context, keys are calculated based on the class name, so the value stored for the class String can be retrieved using the key value of "java.lang.String".

Since:
1.3
Restriction:
This interface is not intended to be implemented by clients.
Restriction:
This interface is not intended to be extended by clients.

rcp(插件开发)如何打开编辑器、视图、透视图

如下:

IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

1.打开编辑器
window.getActivePage().openEditor(input, Editor Id);

2.打开视图
window.getActivePage().showView(View Id);

3.打开透视图
PlatformUI.getWorkbench().showPerspective(Perspective Id,w.getActiveWorkbenchWindow());

最新文章

  1. &#65279导致页面顶部空白一行解决方法 【】
  2. html页面输入框input的美化
  3. 给HashMap排序,使之成为有序Map
  4. nodejs中Stream的理解
  5. 参数化命令相关知识点之==================防止SQl的注入
  6. IBM RSA 的语言设置
  7. BZOJ2243 (树链剖分+线段树)
  8. 设计模式(九)外观模式Facade(结构型)
  9. Web采矿技术
  10. P1045 麦森数
  11. [精简版]snowing snow
  12. 洛谷P1605 迷宫 (DFS)
  13. Beaglebone板子修改usb连接时的默认IP192.168.0.2
  14. Golang 调用 Python 代码
  15. 在Spring(4.3.22)中集成Hibernate(5.4.0)
  16. TFS应用层服务器获取F5用户的真实IP地址(高可用性)
  17. TP5使用Composer安装phpoffice/phpspreadsheet,导出Excel文件
  18. 《You dont know JS》原生函数
  19. JavaScript总结(四)
  20. 【敏捷】7.showcase,开发中必须引起重视的小环节

热门文章

  1. WebBrowser实现编辑网页
  2. DB2 VALUES用法详解
  3. codeforces 622A Infinite Sequence
  4. BestCoder Round #69 (div.2)(hdu5611)
  5. [iOS基础控件 - 6.12.1] QQ菜单管理 UITabBarController 控制器管理
  6. scp命令获取远程文件
  7. UVa 112 Tree Summing
  8. Codeforces Round #185 (Div. 2) B. Archer 水题
  9. Codeforces Round #250 (Div. 1) A. The Child and Toy 水题
  10. TListView列表拒绝添加重复信息