Eclipse eRCP
Release 1.1

org.eclipse.jface.preference
Class PreferencePage

java.lang.Object
  extended byorg.eclipse.jface.preference.PreferencePage
All Implemented Interfaces:
IPreferencePage

public abstract class PreferencePage
extends Object
implements IPreferencePage

Abstract base implementation for all preference page implementations.

Subclasses must implement the createControl framework method to supply the page's main control.

Subclasses should extend the doComputeSize framework method to compute the size of the page's control.

Subclasses may override the performOk, performApply, performDefaults, performCancel, and performHelp framework methods to react to the standard button events.

Subclasses may call the noDefaultAndApplyButton framework method before the page's control has been created to suppress the standard Apply and Defaults buttons.


Constructor Summary
protected PreferencePage()
          Creates a new preference page with an empty title and no image.
protected PreferencePage(String title)
          Creates a new preference page with the given title and no image.
protected PreferencePage(String title, ImageDescriptor image)
          Creates a new abstract preference page with the given title and image.
 
Method Summary
 void applyData(Object data)
          Apply the data to the receiver.
 Point computeSize()
          Computes a size for this page's UI component.
protected abstract  Control createContents(Composite parent)
          Creates and returns the SWT control for the customized body of this preference page under the given parent composite.
 void createControl(Composite parent)
          The PreferencePage implementation of this IDialogPage method creates a description label and button bar for the page.
 void dispose()
          The DialogPage implementation of an IDialogPage method does nothing.
protected  IPreferenceStore doGetPreferenceStore()
          Returns the preference store of this preference page.
protected  Button getApplyButton()
          Returns the Apply button.
 IPreferencePageContainer getContainer()
          Returns the container of this page.
 Control getControl()
          Returns the top level control for this dialog page.
protected  Button getDefaultsButton()
          Returns the Restore Defaults button.
 String getDescription()
           
 Image getImage()
           
 IPreferenceStore getPreferenceStore()
          Returns the preference store of this preference page.
 String getTitle()
          Returns this page's title.
 boolean isValid()
          The preference page implementation of an IPreferencePage method returns whether this preference page is valid.
protected  void noDefaultAndApplyButton()
          Suppresses creation of the standard Default and Apply buttons for this page.
 boolean okToLeave()
          The PreferencePage implementation of this IPreferencePage method returns true if the page is valid.
protected  void performApply()
          Performs special processing when this page's Apply button has been pressed.
 boolean performCancel()
          The preference page implementation of an IPreferencePage method performs special processing when this page's Cancel button has been pressed.
protected  void performDefaults()
          Performs special processing when this page's Defaults button has been pressed.
 boolean performOk()
          Method declared on IPreferencePage.
 void setContainer(IPreferencePageContainer container)
          (non-Javadoc) Method declared on IPreferencePage.
 void setDescription(String description)
           
 void setImageDescriptor(ImageDescriptor desc)
          Sets this page's image.
 void setPreferenceStore(IPreferenceStore store)
          Sets the preference store for this preference page.
 void setSize(Point uiSize)
          Sets the size of this page's UI component.
 void setTitle(String title)
          The PreferencePage implementation of this IDialogPage method extends the DialogPage implementation to update the preference page container title.
 void setValid(boolean b)
          Sets whether this page is valid.
 String toString()
          Returns a string suitable for debugging purpose only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PreferencePage

protected PreferencePage()
Creates a new preference page with an empty title and no image.


PreferencePage

protected PreferencePage(String title)
Creates a new preference page with the given title and no image.

Parameters:
title - the title of this preference page

PreferencePage

protected PreferencePage(String title,
                         ImageDescriptor image)
Creates a new abstract preference page with the given title and image.

Parameters:
title - the title of this preference page
image - the image for this preference page, or null if none
Method Detail

createContents

protected abstract Control createContents(Composite parent)
Creates and returns the SWT control for the customized body of this preference page under the given parent composite.

This framework method must be implemented by concrete subclasses. Any subclass returning a Composite object whose Layout has default margins (for example, a GridLayout) are expected to set the margins of this Layout to 0 pixels.

Parameters:
parent - the parent composite
Returns:
the new control

createControl

public void createControl(Composite parent)
The PreferencePage implementation of this IDialogPage method creates a description label and button bar for the page. It calls createContents to create the custom contents of the page.

If a subclass that overrides this method creates a Composite that has a layout with default margins (for example, a GridLayout) it is expected to set the margins of this Layout to 0 pixels.

Parameters:
parent - parent of the new control

getControl

public Control getControl()
Returns the top level control for this dialog page.

Returns:
the top level control

doGetPreferenceStore

protected IPreferenceStore doGetPreferenceStore()
Returns the preference store of this preference page.

This is a framework hook method for subclasses to return a page-specific preference store. The default implementation returns null.

Returns:
the preference store, or null if none

getContainer

public IPreferencePageContainer getContainer()
Returns the container of this page.

Returns:
the preference page container, or null if this page has yet to be added to a container

getPreferenceStore

public IPreferenceStore getPreferenceStore()
Returns the preference store of this preference page.

Returns:
the preference store , or null if none

isValid

public boolean isValid()
The preference page implementation of an IPreferencePage method returns whether this preference page is valid. Preference pages are considered valid by default; call setValid(false) to make a page invalid.

Specified by:
isValid in interface IPreferencePage
Returns:
true if the page is in a valid state, and false if invalid

noDefaultAndApplyButton

protected void noDefaultAndApplyButton()
Suppresses creation of the standard Default and Apply buttons for this page.

Subclasses wishing a preference page wihthout these buttons should call this framework method before the page's control has been created.


okToLeave

public boolean okToLeave()
The PreferencePage implementation of this IPreferencePage method returns true if the page is valid.

Specified by:
okToLeave in interface IPreferencePage
Returns:
false to abort page flipping and the have the current page remain visible, and true to allow the page flip

performApply

protected void performApply()
Performs special processing when this page's Apply button has been pressed.

This is a framework hook method for sublcasses to do special things when the Apply button has been pressed. The default implementation of this framework method simply calls performOk to simulate the pressing of the page's OK button.

See Also:
performOk()

performCancel

public boolean performCancel()
The preference page implementation of an IPreferencePage method performs special processing when this page's Cancel button has been pressed.

This is a framework hook method for sublcasses to do special things when the Cancel button has been pressed. The default implementation of this framework method does nothing and returns true.

Specified by:
performCancel in interface IPreferencePage
Returns:
false to abort the container's cancel procedure and true to allow the cancel to happen

performDefaults

protected void performDefaults()
Performs special processing when this page's Defaults button has been pressed.

This is a framework hook method for subclasses to do special things when the Defaults button has been pressed. Subclasses may override, but should call super.performDefaults.


performOk

public boolean performOk()
Method declared on IPreferencePage. Subclasses should override

Specified by:
performOk in interface IPreferencePage
Returns:
false to abort the container's OK processing and true to allow the OK to happen

setContainer

public void setContainer(IPreferencePageContainer container)
(non-Javadoc) Method declared on IPreferencePage.

Specified by:
setContainer in interface IPreferencePage
Parameters:
container - the preference page container, or null

setPreferenceStore

public void setPreferenceStore(IPreferenceStore store)
Sets the preference store for this preference page.

If preferenceStore is set to null, getPreferenceStore will invoke doGetPreferenceStore the next time it is called.

Parameters:
store - the preference store, or null
See Also:
getPreferenceStore()

setSize

public void setSize(Point uiSize)
Description copied from interface: IPreferencePage
Sets the size of this page's UI component.

Specified by:
setSize in interface IPreferencePage
Parameters:
uiSize - the size of the preference page encoded as new Point(width,height)

setTitle

public void setTitle(String title)
The PreferencePage implementation of this IDialogPage method extends the DialogPage implementation to update the preference page container title. Subclasses may extend.

Specified by:
setTitle in interface IPreferencePage
Parameters:
title - the title of this dialog page, or null if none

setValid

public void setValid(boolean b)
Sets whether this page is valid. The enable state of the container buttons and the apply button is updated when a page's valid state changes.

Parameters:
b - the new valid state

toString

public String toString()
Returns a string suitable for debugging purpose only.


getApplyButton

protected Button getApplyButton()
Returns the Apply button.

Returns:
the Apply button

getDefaultsButton

protected Button getDefaultsButton()
Returns the Restore Defaults button.

Returns:
the Restore Defaults button

applyData

public void applyData(Object data)
Apply the data to the receiver. By default do nothing.

Parameters:
data -
Since:
3.1

getTitle

public String getTitle()
Description copied from interface: IPreferencePage
Returns this page's title. Cloned from IDialogPage.

Specified by:
getTitle in interface IPreferencePage
Returns:
the title of this dialog page, or null if none

getImage

public Image getImage()

setImageDescriptor

public void setImageDescriptor(ImageDescriptor desc)
Description copied from interface: IPreferencePage
Sets this page's image. Cloned from IDialogPage.

Specified by:
setImageDescriptor in interface IPreferencePage
Parameters:
desc - the image for this dialog page, or null if none

dispose

public void dispose()
The DialogPage implementation of an IDialogPage method does nothing. Subclasses may extend.

Specified by:
dispose in interface IPreferencePage

computeSize

public Point computeSize()
Description copied from interface: IPreferencePage
Computes a size for this page's UI component.

Specified by:
computeSize in interface IPreferencePage
Returns:
the size of the preference page encoded as new Point(width,height), or (0,0) if the page doesn't currently have any UI component

setDescription

public void setDescription(String description)

getDescription

public String getDescription()

Eclipse eRCP
Release 1.1