The Eclipse Workbench provides a performance view for viewing (and/or editing) the properties of selected items. In this article, you will learn how to create a performance-enhanced user interface view using the tabbed Properties view.
1. Introduction
The Eclipse Workbench provides a property view that describes your performance controls in detail in the article. The default user interface is the property and value pairs table, and the value uses a standard dialog box cell editor.
The workbench uses extensions (extensions) to define a custom user interface for the Properties view. With this extension, the Properties view has been created.
The Properties view allows you to create properties for any user interface. In addition, you can create user interfaces for elements without implementing ipropertysource. In fact, the attribute view can be extended to view any data that is selected in the workbench.
2. Example parsing
Depend onorg.eclipse.ui.views.properties.tabbed 插件
There are three extensibility points to implement:
Org.eclipse.ui.views.properties.tabbed.PropertyContributor
Tabbed View consists of a propertycontributor that contains multiple propertytab.
<extension point= "Org.eclipse.ui.views.properties.tabbed.propertyContributor" > < Propertycontributor contributorid= "Mview.views.SampleView" > <propertycategory category= "Sample"/> </propertyContributor></extension>
Org.eclipse.ui.views.properties.tabbed.PropertyTabs
Each propertytab is composed of multiple propertysection.
<extension point= "Org.eclipse.ui.views.properties.tabbed.propertyTabs" > <propertytabs Contributorid = "Mview.views.SampleView" > <propertytab category= "sample" id= "Mview. Buttontab " label=" button "/> <propertytab aftertab=" Mview. Buttontab " category=" sample " id=" Mview. Advancedtab " label=" advanced "/> </propertyTabs></extension>
Org.eclipse.ui.views.properties.tabbed.PropertySections
Each propertysection is implemented as one or a set of widgets, corresponding to a property.
<extension point= "Org.eclipse.ui.views.properties.tabbed.propertySections" > <propertysections Contributorid= "Mview.views.SampleView" > <propertysection class= "mview.views.LabelSection" Id= "Mview. Labelsection "tab=" Mview. Buttontab "> <input type=" mview.views.ButtonElement "/> </propertySection> <pro Pertysection aftersection= "Mview. Labelsection "class=" mview.views.SizeSection "id=" Mview. Sizesection "tab=" Mview. Buttontab "> <input type=" mview.views.ButtonElement "/> </propertySection> <pro Pertysection aftersection= "Mview. Sizesection "class=" mview.views.FontSection "id=" Mview. Fontsection "tab=" Mview. Buttontab "> <input type=" mview.views.ButtonElement "/> </propertySection> <pro Pertysection class= "org.eclipse.ui.views.properties.tabbed.AdvancedPropertySection" id= "Mview. Advancedsection "tab=" Mview. Advancedtab "> <input type=" mview.views.ButtonElement "/> </propertySection> </pro Pertysections></extension>
The tabbed property is a new view in eclipse3.2 that allows the function of the attribute editor to expand almost indefinitely. Here is a description of how some tabbed property is used. The tabbed property is divided into three parts, Contributer,tabs,sections, a contributor contains several Tabs, and one Tabs can contain several Sections. Let's describe them separately.
1.Contributor This needs to extend the org.eclipse.ui.views.properties.tabbed.PropertyContributor extension point, when defined, the most important is to define the Contributid, this ID must be globally unique, so that when loading the property page, we can find this Define the property page, in general, we will correspond to this property page Workbenchpart ID as the ID of this contributor, so we can not hard code this ID string, With Getsite (). GetId () You can get this ID (of course, the definition ID is not required). A property view can be shared by multiple workbench part, but a workbench part can have only one property view, which Workbench The part needs to implement the Itabbedpropertysheetpagecontributor interface, which has only one method, which requires returning the tabbed property contributor ID of this part, generally as long as return Getsite (). GetId ();
Contributor has several attribute as follows:
1) Typemapper, This class needs to implement Org.eclipse.ui.views.properties.tabbed.ITypeMapper, primarily to implement type mappings, because the element we choose is not necessarily the element that implements Ipropertysource (that is, the property View provides elements of content), such as in GEF, the finger of our choice actually chooses the corresponding Editpart, and actually implements the Ipropertysource general is the model part of the element, So we're going to map the Editpart to the corresponding model element.
2) Labelprovider, need a class to implement Org.eclipse.jface.viewers.ILabelProvider, mainly on the top of each tabs display text and pictures.
3) Propertycategory, used to aggregate multiple tabs, note that at least one category must be defined to aggregate the tabs, otherwise the property failure may be displayed.
2.Tabs, This needs to extend the org.eclipse.ui.views.properties.tabbed.propertyTabs extension point, where Contributorid is the ID of the contributor associated with it, and then we can define multiple tabs, the tab properties As follows:
1) label, used to display the Word on the tab bar of the property view
2) category, which is populated with the category defined in the contributor extension point for aggregation tabs
3) ID, unique identifier for this tab
4) Aftertab, for the Sort between tab, if this is the first tab, then no aftertab,aftertab refers to the tab before this tab, and Aftertab describes the tabs in the same category, The order of the different category is defined according to the order in which the category is defined in contributor.
5) indented, if ture, then each tabs is indented
6) image, picture of this tab
3.section, need to expand Org.eclipse.ui.views.properties.tabbed.PropertySections extension Point, whose contributionid is the ID of the contribution that this section is located in, for each tab, we can define multiple s Ection, the attribut of each section is described as follows:
1) ID, the unique identifier of this secation
2) tab, the label of the tab that this section belongs to
3) class, implements the Org.eclipse.ui.views.properties.tabbed.AbstractPropertySection abstract class, which describes the control and layout of this section.
4) Aftersection is similar to the above Aftertab, which describes the order of sections in the same tab, noting that afterserction describes the ID of the section before this section
5) Filter: A filter that implements the Org.eclipse.jface.viewers.IFilter interface to filter the selected elements.
6) Enablefor: A value that is used to select only the number of values that must be met in order to enable this section. If not, then the section is filtered, and if this value is omitted, then the section's enable will not work. This is a natural number, for example, when enablefor=1, only one element is selected, this section is enabled.
Some notes:
The workbench part that implements the Itabbedpropertysheetpagecontributor interface, in addition to implementing the Getcontributeid method, also needs to overload the Getadapter method, Because the default load of Eclipse's property veiw when the original view, in order to enable tabbed property view to load, we need to overload the Getadapter method, Returns a Tabbedpropertysheetpage object.
When implementing section class, it is important to note that CreateControl should first create a Composite, typically Composite Composite = Getwidgetfactory (). Createflatformcomposite (parent); The individual controls are then created on this composite.