Properties Pages
The implementation of a properties page requires that you define an
extension in your plug-in and provide an implementation of the
extension. This solution's plugin.xml
defines one property page
extension. The page is implemented as a subclass of PropertyPage
that implements IWorkbenchPropertyPage
.
Running the Solution
To run the example, launch the run-time instance of Eclipse (Run
> Run As > Run-time Workbench).
- Select any file resource in the Navigator or Package Explorer view
and use the Properties context menu choice to open the
Properties dialog. Select the page titled Soln:
File Properties. You will see the custom preference page
implemented by the
MyPropertyPage
class:
The current values for the selected resource are displayed, and in the
case of the text field, if no value was found a default string is
supplied just before the page is shown.
- Modify the values shown on the properties page and select the Apply
button. The changes will be recorded as part of the resource for this
workspace. That is, these values are not stored in the resource, but
managed by the Eclipse org.eclipse.core.resources plug-in and stored in
the workspace .metadata.
- If you entered a unique string in the text field, you should be
able to find it in the workspace's .metadata. For example, enter the string
qrs-property and select the Apply button.
Then find the .properties file for the project that contains the
resource you selected when opening up the Properties dialog. For
example, given a project named a.custom this would be the file:\runtime-workspace\.metadata\.plugins\org.eclipse.core.resources\.projects\a.custom
Open
the file in Notepad (Wordpad will complain that the file is locked) and
then search for the text qrs-property:
Resource properties are stored in the active workspace, not the
resource itself. This is why resource properties are not sent/returned from a
repository.
Roadmap to the Solution
This example includes a properties page extension that demonstrates
how to build the user interface an access resource properties using the
Workspace API. The extension definition can be found in the plugin.xml.
The class that implements the extension is shown below.
Extension |
Implementation |
Properties page extension |
The properties page is implemented by the MyPropertyPage
class. |
© Copyright International Business Machines Corporation, 2003.
All rights reserved.