Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Custom Annotation Property Views"
(New page: __TOC__ {{backlink|Tigerstripe_APIs}} === Introduction === Annotation Framework support 4 ways to extend Annotation Property View: override properties section, add properties tabs, add ann...) |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
Annotation Framework support 4 ways to extend Annotation Property View: override properties section, add properties tabs, add annotation actions and register custom properties editors. | Annotation Framework support 4 ways to extend Annotation Property View: override properties section, add properties tabs, add annotation actions and register custom properties editors. | ||
=== Custom Annotation Property Section === | === Custom Annotation Property Section === | ||
− | To replace annotation property section in the Annotation Property View we need to provide new section and annotation filter. Annotation Property View based on the tabbed properties, so customizing can be done using org.eclipse.ui.views.properties.tabbed.propertySections extension point: | + | |
+ | [[Image:Tigerstripe_Annotation_Custom_Section.jpg]] | ||
+ | |||
+ | To replace annotation property section in the Annotation Property View we need to provide new section and annotation filter. Annotation Property View based on the tabbed properties, so customizing can be done using <i>org.eclipse.ui.views.properties.tabbed.propertySections</i> extension point: | ||
<extension point="org.eclipse.ui.views.properties.tabbed.propertySections"> | <extension point="org.eclipse.ui.views.properties.tabbed.propertySections"> | ||
Line 17: | Line 20: | ||
* contributorId="org.eclipse.tigerstripe.annotation.ui.properties" - identifier of the annotation property page contributor. | * contributorId="org.eclipse.tigerstripe.annotation.ui.properties" - identifier of the annotation property page contributor. | ||
− | * tab="property.tab.PropertiesPropertySection" - properties tab | + | * tab="property.tab.PropertiesPropertySection" - identifier of the properties tab which we want to override. |
− | * class - annotation section class. This class should extend org.eclipse.tigerstripe.annotation.ui.core.properties.AnnotationPropertiesSection class: | + | * class - annotation section class. This class should extend <i>org.eclipse.tigerstripe.annotation.ui.core.properties.AnnotationPropertiesSection</i> class: |
public class CustomSection extends AnnotationPropertiesSection { | public class CustomSection extends AnnotationPropertiesSection { | ||
public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) { | public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) { | ||
Line 29: | Line 32: | ||
} | } | ||
} | } | ||
− | * filter - annotation filter | + | * filter - annotation filter determines if annotation section should be overridden. Annotation filter should extend <i>org.eclipse.tigerstripe.annotation.ui.core.properties.AnnotationFilter</i> class: |
− | CustomAnnotationFilter extends AnnotationFilter { | + | public CustomAnnotationFilter extends AnnotationFilter { |
public boolean select(Annotation annotation) { | public boolean select(Annotation annotation) { | ||
//return true if section should be overridden for the specified annotation | //return true if section should be overridden for the specified annotation | ||
+ | ... | ||
} | } | ||
} | } | ||
Line 38: | Line 42: | ||
=== Add Annotation Property Tab === | === Add Annotation Property Tab === | ||
− | + | ||
+ | [[Image:Tigerstripe_Annotation_Custom_Tab.jpg]] | ||
+ | |||
+ | Another way to extend Annotation Properties View is add own property tab. To define new tab we need to use <i>org.eclipse.ui.views.properties.tabbed.propertyTabs</i> extension point: | ||
+ | <extension | ||
+ | point="org.eclipse.ui.views.properties.tabbed.propertyTabs"> | ||
+ | <propertyTabs | ||
+ | contributorId="org.eclipse.tigerstripe.annotation.ui.properties"> | ||
+ | <propertyTab | ||
+ | category="Properties" | ||
+ | id="property.tab.ExampleSection" | ||
+ | label="Example Section"/> | ||
+ | </propertyTabs> | ||
+ | </extension> | ||
+ | |||
+ | * contributorId="org.eclipse.tigerstripe.annotation.ui.properties" - identifier of the annotation property page contributor. | ||
+ | * category="Properties" - identifier of the properties tab category. | ||
+ | * label - the label to be displayed on the tab. | ||
+ | * id - the unique id for the tab. | ||
+ | |||
+ | Next step - provide custom annotation property section (as described above) with custom tab identifier (in this case tab="property.tab.ExampleSection"). | ||
+ | |||
=== Contribute Annotation Actions === | === Contribute Annotation Actions === | ||
− | Custom actions can be contributed to the Annotation Property View using standard org.eclipse.ui.popupMenus extension point with | + | Custom actions can be contributed to the Annotation Property View using standard org.eclipse.ui.popupMenus extension point with the <i>annotationProperties<i> as menubar path and <i>org.eclipse.tigerstripe.annotation.core.Annotation</i> as selection: |
<extension | <extension | ||
Line 55: | Line 80: | ||
=== Register Properties Editors === | === Register Properties Editors === | ||
− | + | ||
+ | To provide custom properties we need to register property provider using <i>org.eclipse.tigerstripe.annotation.ui.propertyProvider</i> extension point: | ||
+ | |||
+ | <extension | ||
+ | point="org.eclipse.tigerstripe.annotation.ui.propertyProvider"> | ||
+ | <provider | ||
+ | class="org.eclipse.tigerstripe.annotation.ui.example.customview.CustomPropertyProvider" | ||
+ | priority="1"/> | ||
+ | </extension> | ||
+ | |||
+ | * class - property provider class implemented <i>org.eclipse.tigerstripe.annotation.ui.core.properties.EPropertyProvider</i> interface: | ||
+ | public class GeneralPropertyProvider implements EPropertyProvider { | ||
+ | public EProperty getProperty(EObject object, EStructuralFeature feature) { | ||
+ | //return EProperty for the object feature or null if this provider do not provide properties for this feature | ||
+ | ... | ||
+ | } | ||
+ | } | ||
+ | * priority - the priority of the provider. It should be positive integer. A provider at a higher priority will take a chance first at deciding provision. | ||
+ | |||
+ | EProperty customize property display name, value, cell editor and so on. Clients should not implement this interface directly, but should extend <i>org.eclipse.tigerstripe.annotation.ui.core.properties.EPropertyImpl</i> implementation. | ||
[[Category:Tigerstripe_APIs]] | [[Category:Tigerstripe_APIs]] |
Latest revision as of 05:14, 18 July 2008
Contents
< To: Tigerstripe_APIs
Introduction
Annotation Framework support 4 ways to extend Annotation Property View: override properties section, add properties tabs, add annotation actions and register custom properties editors.
Custom Annotation Property Section
To replace annotation property section in the Annotation Property View we need to provide new section and annotation filter. Annotation Property View based on the tabbed properties, so customizing can be done using org.eclipse.ui.views.properties.tabbed.propertySections extension point:
<extension point="org.eclipse.ui.views.properties.tabbed.propertySections"> <propertySections contributorId="org.eclipse.tigerstripe.annotation.ui.properties"> <propertySection class="org.eclipse.tigerstripe.annotation.ui.example.customview.CustomSection" filter="org.eclipse.tigerstripe.annotation.ui.example.customview.CustomAnnotationFilter" id="property.section.CustomSection" tab="property.tab.PropertiesPropertySection"/> </propertySections> </extension>
- contributorId="org.eclipse.tigerstripe.annotation.ui.properties" - identifier of the annotation property page contributor.
- tab="property.tab.PropertiesPropertySection" - identifier of the properties tab which we want to override.
- class - annotation section class. This class should extend org.eclipse.tigerstripe.annotation.ui.core.properties.AnnotationPropertiesSection class:
public class CustomSection extends AnnotationPropertiesSection { public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) { //create section controls ... } protected void updateSection(Annotation annotation) { //update section when selected annotation changed ... } }
- filter - annotation filter determines if annotation section should be overridden. Annotation filter should extend org.eclipse.tigerstripe.annotation.ui.core.properties.AnnotationFilter class:
public CustomAnnotationFilter extends AnnotationFilter { public boolean select(Annotation annotation) { //return true if section should be overridden for the specified annotation ... } }
- id - the unique identifier for the section
Add Annotation Property Tab
Another way to extend Annotation Properties View is add own property tab. To define new tab we need to use org.eclipse.ui.views.properties.tabbed.propertyTabs extension point:
<extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs"> <propertyTabs contributorId="org.eclipse.tigerstripe.annotation.ui.properties"> <propertyTab category="Properties" id="property.tab.ExampleSection" label="Example Section"/> </propertyTabs> </extension>
- contributorId="org.eclipse.tigerstripe.annotation.ui.properties" - identifier of the annotation property page contributor.
- category="Properties" - identifier of the properties tab category.
- label - the label to be displayed on the tab.
- id - the unique id for the tab.
Next step - provide custom annotation property section (as described above) with custom tab identifier (in this case tab="property.tab.ExampleSection").
Contribute Annotation Actions
Custom actions can be contributed to the Annotation Property View using standard org.eclipse.ui.popupMenus extension point with the annotationProperties<i> as menubar path and <i>org.eclipse.tigerstripe.annotation.core.Annotation as selection:
<extension point="org.eclipse.ui.popupMenus"> <objectContribution ... objectClass="org.eclipse.tigerstripe.annotation.core.Annotation"> <action ... menubarPath="annotationProperties"/> </objectContribution> <extension/>
Register Properties Editors
To provide custom properties we need to register property provider using org.eclipse.tigerstripe.annotation.ui.propertyProvider extension point:
<extension point="org.eclipse.tigerstripe.annotation.ui.propertyProvider"> <provider class="org.eclipse.tigerstripe.annotation.ui.example.customview.CustomPropertyProvider" priority="1"/> </extension>
- class - property provider class implemented org.eclipse.tigerstripe.annotation.ui.core.properties.EPropertyProvider interface:
public class GeneralPropertyProvider implements EPropertyProvider { public EProperty getProperty(EObject object, EStructuralFeature feature) { //return EProperty for the object feature or null if this provider do not provide properties for this feature ... } }
- priority - the priority of the provider. It should be positive integer. A provider at a higher priority will take a chance first at deciding provision.
EProperty customize property display name, value, cell editor and so on. Clients should not implement this interface directly, but should extend org.eclipse.tigerstripe.annotation.ui.core.properties.EPropertyImpl implementation.