在我开发插件DBDA(Database Development Assistant-”数据库开发助手“,我自已开发的一个数据库插件)时,有一个问题困扰了我很久,如何实现对同一个数据库对象,在不同的平台下显示不同的属性页,最好属性页能以标签的行式出现,我自已到是实现了一个这样的功能,但时经常会出现一些问题,而且性能也不是很好,直到我在Eclipse的网站上看到上面所提的那篇文章,我才发现问题有这么好的解决方法。
在Eclipse3.2中加入了一个插件“标签属性视图”(
org.eclipse.ui.views.properties.tabbed)
,这个插件有三个扩展点:
org.eclipse.ui.views.properties.tabbed.PropertyContributor
org.eclipse.ui.views.properties.tabbed.PropertyTabs
org.eclipse.ui.views.properties.tabbed.PropertySections
Property Contributor
扩展点org.eclipse.ui.views.properties.tabbed.PropertyContributor
是标签属性视图的关键. It most importantly identifies the unique contributor identifier for your tabs and sections. Most frequently, this identifier matches the unique workbench part id that is contributing the tabbed properties view.
Note that a property contributor can be shared among several workbench parts. For example, an application may have an explorer view, editor and outline whose selections share a common set of properties. In this case, all three workbench parts can share the same tabbed properties view as identified by the unique contributor identifier.
A workbench part cannot make use of two or more property contributors. It can identify a single property contributor by implementing the ITabbedPropertySheetPageContributor
interface.
PropertyContributor扩展点定义了以下属性
:
typeMapper | 实现类型映射器的类. |
labelProvider | The class that implements the label provider for the title bar. |
propertyCategory | 一个或多个用于组织标签的种类属性. |
Property Tabs
org.eclipse.ui.views.properties.tabbed.PropertyTabs
扩展点描述给于一个贡献者( contributor)的标签 (tabs) . Each tab belongs to one contributor as identified by its unique contributor identifier. The PropertyTabs
extension point can define one or more tabs through the PropertyTab
attribute.
A ProperyTab
defines the following attributes:
id | The unique id for the tab. |
label | The label to be displayed on the tab. |
category | The category from the PropertyContributor extension point used to group tabs. |
afterTab | When there is more than one tab in a category, tabs are sorted by the afterTab attribute. |
image | The optional image to display on the tab. |
indented | true if the tab is indented. |
Property Sections
The org.eclipse.ui.views.properties.tabbed.PropertySections
extension point describes the sections for a contributor. Each section belongs to one configuration as identified by its unique contributor identifier.
The PropertySections
extension point can define one or more sections through the PropertySection
attribute. Each section belongs to one tab as identified by its unique tab identifier.
The PropertySection
defines the following attributes:
id | The unique id for the section. |
tab | The unique tab id in which this section appears. |
class | The class that implements the section |
afterSection | When there is more than one section in a tab, sections are sorted by the afterSection attribute. |
filter | The class that implements a section filter. |
enablesFor | a value indicating the selection count which must be met to enable the section. If specified and the condition is not met, the section is filtered. If omitted, the section enablement is not affected. The following attribute formats are currently supported: n - a precise number of items selected. For example: enablesFor=" 1" enables the section only when 1 item is selected |
The PropertySection
also defines one or more input type
attributes. Each type
is a class or interface that the selection must match for the section to be displayed on the tab.