Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Eclipse Plug-in Developer Guide
Previous Page Home Next Page

Implementing a property page

When the workbench creates and launches a properties page, it sets the selected resource into the page. The page can use the getElement() method to obtain its element, an IAdaptable .

The pattern for creating property pages is similar to that of preference pages, so we will only focus on what is different. Property pages show information about their element. This information can be obtained by accessing the element in order to query or compute the relevant information.  The information can also be stored and retrieved from the resource's properties.

The ReadmeFilePropertyPage computes most of its information using its element. The following snippet shows how the number of sections is computed and displayed in a label.

   IResource resource = (IResource) getElement();
   IAdaptable sections = getSections(resource);
   if (sections instanceof AdaptableList) {
      AdaptableList list = (AdaptableList)sections;
      label = createLabel(panel, String.valueOf(list.size()));

When a property is computed, there is no need for corresponding logic to save the value, since the user cannot update this value.

Properties pages are commonly used for viewing and for setting the application-specific  properties of a resource. (See Resource properties for a discussion of session and persistent properties.)  Since the property page knows its resource, the resources API can be used in the page to initialize control values or to set new property values based on user selections in the properties page.

The following snippet shows a checkbox value being initialized from a property on a property page's element.

   private void initializeValues() {
      IResource resource = (IResource) getElement();

The corresponding code for saving the checkbox value back into the property looks like this:

   private void storeValues() {
      IResource resource = (IResource) getElement();
      resource.setPersistentProperty("MyProperty", label.getText());

  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire