Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.jface.preference
Class PreferencePage  view PreferencePage download PreferencePage.java

java.lang.Object
  extended byorg.eclipse.jface.dialogs.DialogPage
      extended byorg.eclipse.jface.preference.PreferencePage
All Implemented Interfaces:
org.eclipse.jface.dialogs.IDialogPage, org.eclipse.jface.dialogs.IMessageProvider, IPreferencePage
Direct Known Subclasses:
FieldEditorPreferencePage

public abstract class PreferencePage
extends org.eclipse.jface.dialogs.DialogPage
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.


Field Summary
private  org.eclipse.swt.widgets.Button applyButton
          Standard Apply button, or null if none.
private  org.eclipse.swt.widgets.Control body
          Body of page.
private  IPreferencePageContainer container
          The container this preference page belongs to; null if none.
private  boolean createDefaultAndApplyButton
          Whether this page has the standard Apply and Defaults buttons; true by default.
private  org.eclipse.swt.widgets.Button defaultsButton
          Standard Defaults button, or null if none.
private  org.eclipse.swt.widgets.Label descriptionLabel
          Description label.
private  boolean isValid
          Valid state for this page; true by default.
private  IPreferenceStore preferenceStore
          Preference store, or null.
private  org.eclipse.swt.graphics.Point size
          Caches size of page.
 
Fields inherited from class org.eclipse.jface.dialogs.DialogPage
 
Fields inherited from interface org.eclipse.jface.dialogs.IMessageProvider
ERROR, INFORMATION, NONE, WARNING
 
Constructor Summary
protected PreferencePage()
          Creates a new preference page with an empty title and no image.
protected PreferencePage(java.lang.String title)
          Creates a new preference page with the given title and no image.
protected PreferencePage(java.lang.String title, org.eclipse.jface.resource.ImageDescriptor image)
          Creates a new abstract preference page with the given title and image.
 
Method Summary
protected  void applyDialogFont(org.eclipse.swt.widgets.Composite composite)
          Apply the dialog font to the composite and it's children if it is set.
 org.eclipse.swt.graphics.Point computeSize()
          Computes the size for this page's UI control.
protected  void contributeButtons(org.eclipse.swt.widgets.Composite parent)
          Contributes additional buttons to the given composite.
protected abstract  org.eclipse.swt.widgets.Control createContents(org.eclipse.swt.widgets.Composite parent)
          Creates and returns the SWT control for the customized body of this preference page under the given parent composite.
 void createControl(org.eclipse.swt.widgets.Composite parent)
          The PreferencePage implementation of this IDialogPage method creates a description label and button bar for the page.
protected  org.eclipse.swt.widgets.Label createDescriptionLabel(org.eclipse.swt.widgets.Composite parent)
          Creates and returns an SWT label under the given composite.
protected  org.eclipse.swt.widgets.Composite createNoteComposite(org.eclipse.swt.graphics.Font font, org.eclipse.swt.widgets.Composite composite, java.lang.String title, java.lang.String message)
          Creates a composite with a highlighted Note entry and a message text.
protected  org.eclipse.swt.graphics.Point doComputeSize()
          Computes the size needed by this page's UI control.
protected  IPreferenceStore doGetPreferenceStore()
          Returns the preference store of this preference page.
protected  org.eclipse.swt.widgets.Button getApplyButton()
          Returns the Apply button.
 IPreferencePageContainer getContainer()
          Returns the container of this page.
protected  org.eclipse.swt.widgets.Button getDefaultsButton()
          Returns the Restore Defaults button.
 IPreferenceStore getPreferenceStore()
          Returns the preference store of this preference page.
 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.
 void performHelp()
          Notifies that help has been requested for this dialog page.
 boolean performOk()
          Method declared on IPreferencePage.
 void setContainer(IPreferencePageContainer container)
          (non-Javadoc) Method declared on IPreferencePage.
 void setErrorMessage(java.lang.String newMessage)
          The PreferencePage implementation of this method declared on DialogPage updates the container.
 void setMessage(java.lang.String newMessage, int newType)
          The PreferencePage implementation of this method declared on DialogPage updates the container.
 void setPreferenceStore(IPreferenceStore store)
          Sets the preference store for this preference page.
 void setSize(org.eclipse.swt.graphics.Point uiSize)
          Sets the size of this page's UI component.
 void setTitle(java.lang.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.
 java.lang.String toString()
          Returns a string suitable for debugging purpose only.
protected  void updateApplyButton()
          Updates the enabled state of the Apply button to reflect whether this page is valid.
 
Methods inherited from class org.eclipse.jface.dialogs.DialogPage
convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, dispose, getControl, getDescription, getDialogFontName, getErrorMessage, getFont, getImage, getMessage, getMessageType, getShell, getTitle, getToolTipText, initializeDialogUnits, isControlCreated, setButtonLayoutData, setControl, setDescription, setImageDescriptor, setMessage, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.eclipse.jface.dialogs.IDialogPage
dispose, getControl, getDescription, getErrorMessage, getImage, getMessage, getTitle, setDescription, setImageDescriptor, setVisible
 

Field Detail

preferenceStore

private IPreferenceStore preferenceStore
Preference store, or null.


isValid

private boolean isValid
Valid state for this page; true by default.

See Also:
isValid 55

body

private org.eclipse.swt.widgets.Control body
Body of page.


createDefaultAndApplyButton

private boolean createDefaultAndApplyButton
Whether this page has the standard Apply and Defaults buttons; true by default.

See Also:
noDefaultAndApplyButton() 55

defaultsButton

private org.eclipse.swt.widgets.Button defaultsButton
Standard Defaults button, or null if none. This button has id DEFAULTS_ID.


container

private IPreferencePageContainer container
The container this preference page belongs to; null if none.


applyButton

private org.eclipse.swt.widgets.Button applyButton
Standard Apply button, or null if none. This button has id APPLY_ID.


descriptionLabel

private org.eclipse.swt.widgets.Label descriptionLabel
Description label.

See Also:
#createDescriptionLabel.

size

private org.eclipse.swt.graphics.Point size
Caches size of page.

Constructor Detail

PreferencePage

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


PreferencePage

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


PreferencePage

protected PreferencePage(java.lang.String title,
                         org.eclipse.jface.resource.ImageDescriptor image)
Creates a new abstract preference page with the given title and image.

Method Detail

computeSize

public org.eclipse.swt.graphics.Point computeSize()
Computes the size for this page's UI control.

The default implementation of this IPreferencePage method returns the size set by setSize; if no size has been set, but the page has a UI control, the framework method doComputeSize is called to compute the size.

Specified by:
computeSize in interface IPreferencePage

contributeButtons

protected void contributeButtons(org.eclipse.swt.widgets.Composite parent)
Contributes additional buttons to the given composite.

The default implementation of this framework hook method does nothing. Subclasses should override this method to contribute buttons to this page's button bar. For each button a subclass contributes, it must also increase the parent's grid layout number of columns by one; that is,

 ((GridLayout) parent.getLayout()).numColumns++);
 


createContents

protected abstract org.eclipse.swt.widgets.Control createContents(org.eclipse.swt.widgets.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.


createControl

public void createControl(org.eclipse.swt.widgets.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.

Specified by:
createControl in interface org.eclipse.jface.dialogs.IDialogPage

applyDialogFont

protected void applyDialogFont(org.eclipse.swt.widgets.Composite composite)
Apply the dialog font to the composite and it's children if it is set. Subclasses may override if they wish to set the font themselves.


createDescriptionLabel

protected org.eclipse.swt.widgets.Label createDescriptionLabel(org.eclipse.swt.widgets.Composite parent)
Creates and returns an SWT label under the given composite.


doComputeSize

protected org.eclipse.swt.graphics.Point doComputeSize()
Computes the size needed by this page's UI control.

All pages should override this method and set the appropriate sizes of their widgets, and then call super.doComputeSize.


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.


getContainer

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


getPreferenceStore

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


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

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

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.


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

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

setContainer

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

Specified by:
setContainer in interface IPreferencePage

setErrorMessage

public void setErrorMessage(java.lang.String newMessage)
The PreferencePage implementation of this method declared on DialogPage updates the container.


setMessage

public void setMessage(java.lang.String newMessage,
                       int newType)
The PreferencePage implementation of this method declared on DialogPage updates the container.


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.


setSize

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

Specified by:
setSize in interface IPreferencePage

setTitle

public void setTitle(java.lang.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 org.eclipse.jface.dialogs.IDialogPage

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.


toString

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


updateApplyButton

protected void updateApplyButton()
Updates the enabled state of the Apply button to reflect whether this page is valid.


createNoteComposite

protected org.eclipse.swt.widgets.Composite createNoteComposite(org.eclipse.swt.graphics.Font font,
                                                                org.eclipse.swt.widgets.Composite composite,
                                                                java.lang.String title,
                                                                java.lang.String message)
Creates a composite with a highlighted Note entry and a message text. This is designed to take up the full width of the page.


getApplyButton

protected org.eclipse.swt.widgets.Button getApplyButton()
Returns the Apply button.


getDefaultsButton

protected org.eclipse.swt.widgets.Button getDefaultsButton()
Returns the Restore Defaults button.


performHelp

public void performHelp()
Description copied from interface: org.eclipse.jface.dialogs.IDialogPage
Notifies that help has been requested for this dialog page.

Specified by:
performHelp in interface org.eclipse.jface.dialogs.IDialogPage