载入中
自定义HTML载入中... loading
Eclipse Basic workbench extension points using commands [转贴 2008-03-18 21:30:25]  删除... 
字体变小 字体变大

Basic workbench extension points using commands

Commands and handlers have been provided by the workbench in one form or another since 3.0. In 3.2 the commands, handlers, and keybindings portion of the Command Framework became mature. In 3.3 the menu contributions portion of the Command Framework is now available.

We are going to take a look at how commands, handlers, menu contributions, and keybindings can be used to contribute behaviour to the workbench, to views, and to editors. We'll use the Info example from the contributions plugin. It provides a view that lists people and an editor for updating their names. Much of the contribution of editors and views has already been covered in the readme example in Basic workbench extension points using actions.

You can show any view in the workbench by choosing Window > Show View > Other... and selecting the view from the Show View list. Use this to select the Info View from the View Contributions category.

The Info example is located in the org.eclipse.ui.examples.contributions package. To follow along, you will need to make sure that you have installed the platform examples. (See the Examples Guide for more information.)

The plug-in class

So far, we've been looking at the different extensions that are provided by the readme tool. Let's look at the general definition of the readme tool plug-in.

Plug-in definition

The readme tool plug-in is defined in the MANIFEST.MF file.

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.ui.examples.readmetool; singleton:=true
Bundle-Version: 3.3.0.qualifier
Bundle-ClassPath: readmetool.jar
Bundle-Activator: org.eclipse.ui.examples.readmetool.ReadmePlugin
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.resources,
 org.eclipse.core.runtime,
 org.eclipse.ui.views,
 org.eclipse.ui.ide,
 org.eclipse.jface.text,
 org.eclipse.text,
 org.eclipse.ui.workbench.texteditor,
 org.eclipse.ui.editors
Eclipse-AutoStart: true
Eclipse-AutoStart-comment: Use Eclipse-AutoStart instead of Eclipse-LazyStart because the readme example should run against 3.1 as well as 3.2.

The plug-in definition includes the Bundle-Name, Bundle-SymbolicName (plug-in id), Bundle-Version, and Bundle-Vendor of the plug-in. We saw most of these parameters before in our hello world plug-in. The readme tool also defines a specialized plug-in class, ReadmePlugin.

The name of the jar file is also provided. File names specified in Bundle-ClassPath are relative to the plug-in's directory, so the readme tool's jar file should be located directly in the plug-in's directory.

The Require-Bundle element informs the platform of the readme tool's dependencies. The workbench UI plug-ins are listed as required plug-ins, along with the various core, jface, and text plug-ins.

AbstractUIPlugin

The ReadmePlugin class represents the readme tool plug-in and manages the life cycle of the plug-in.  As we saw in the Hello World example, you don't have to specify a plug-in class.  The platform will provide one for you.  In this case, our plug-in needs to initialize UI related data when it starts up.  The platform class AbstractUIPlugin provides a structure for managing UI resources and is extended by ReadmePlugin.

AbstractUIPlugin uses the generic startup and shutdown methods to manage images, dialog settings, and a preference store during the lifetime of the plug-in.  We'll look at the specifics of the ReadmePlugin class when we work with dialogs and preferences.

分类: Eclipse
票数:
什么是“我顶”?
点击数:    评论数:
本文章引用通告地址(TrackBack Ping URL)为:
本文章尚未被引用。
发表评论
大 名:
(不填写则显示为匿名者)
网 址:
(您的网址,可以不填)
标 题:
内 容:
请根据下图中的字符输入验证码:
(您的评论将有可能审核后才能发表)
和讯个人门户 v1.0 | 和讯部落 | 客服中心