public abstract class PreferencePage extends DialogPage implements IPreferencePage
Subclasses must implement the createContents
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.
ERROR, INFORMATION, NONE, WARNING
Modifier | Constructor and Description |
---|---|
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.
|
Modifier and Type | Method and Description |
---|---|
void |
applyData(Object data)
Applies the given data to this page.
|
protected void |
applyDialogFont(Composite composite)
Apply the dialog font to the composite and it's children
if it is set.
|
Point |
computeSize()
Computes the size for this page's UI control.
|
protected void |
contributeButtons(Composite parent)
Contributes additional buttons to the given composite.
|
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. |
protected Label |
createDescriptionLabel(Composite parent)
Creates and returns an SWT label under the given composite.
|
protected Composite |
createNoteComposite(Font font,
Composite composite,
String title,
String message)
Creates a composite with a highlighted Note entry and a message text.
|
protected Point |
doComputeSize()
Computes the size needed by this page's UI control.
|
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.
|
protected 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.
|
protected void |
noDefaultButton()
Suppress creation of the standard Default button 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()
This default implementation of an
IDialogPage method does
nothing. |
boolean |
performOk()
Notifies that the OK button of this page's container has been pressed.
|
void |
setContainer(IPreferencePageContainer container)
Sets or clears the container of this page.
|
void |
setErrorMessage(String newMessage)
Sets or clears the error message for this page.
|
void |
setMessage(String newMessage,
int newType)
Sets the message for this page with an indication of what type of message
it is.
|
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() |
protected void |
updateApplyButton()
Updates the enabled state of the Apply button to reflect whether
this page is valid.
|
convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, dispose, getControl, getDescription, getDialogFontName, getErrorMessage, getFont, getImage, getMessage, getMessageType, getShell, getTitle, getToolTipText, initializeDialogUnits, isControlCreated, setButtonLayoutData, setControl, setDescription, setImageDescriptor, setMessage, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
dispose, getControl, getDescription, getErrorMessage, getImage, getMessage, getTitle, setDescription, setImageDescriptor, setVisible
protected PreferencePage()
protected PreferencePage(String title)
title
- the title of this preference pageprotected PreferencePage(String title, ImageDescriptor image)
title
- the title of this preference pageimage
- the image for this preference page,
or null
if nonepublic Point computeSize()
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.
computeSize
in interface IPreferencePage
new Point(width,height)
, or
(0,0)
if the page doesn't currently have any UI componentprotected void contributeButtons(Composite parent)
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++);
parent
- the button barprotected abstract Control createContents(Composite parent)
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.
parent
- the parent compositepublic void createControl(Composite parent)
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.
createControl
in interface IDialogPage
parent
- the parent compositeIDialogPage.createControl(Composite)
protected void applyDialogFont(Composite composite)
composite
- protected Label createDescriptionLabel(Composite parent)
parent
- the parent compositeprotected Point doComputeSize()
All pages should override this method and set the appropriate sizes
of their widgets, and then call super.doComputeSize
.
new Point(width,height)
protected IPreferenceStore doGetPreferenceStore()
This is a framework hook method for subclasses to return a
page-specific preference store. The default implementation
returns null
.
null
if nonepublic IPreferencePageContainer getContainer()
null
if this
page has yet to be added to a containerpublic IPreferenceStore getPreferenceStore()
null
if nonepublic boolean isValid()
IPreferencePage
method returns whether this preference page is valid. Preference
pages are considered valid by default; call setValid(false)
to make a page invalid.isValid
in interface IPreferencePage
true
if the page is in a valid state,
and false
if invalidIPreferencePage.isValid()
protected void noDefaultAndApplyButton()
Subclasses wishing a preference page without these buttons should call this framework method before the page's control has been created.
protected void noDefaultButton()
Subclasses wishing a preference page with this button should call this framework method before the page's control has been created.
public boolean okToLeave()
PreferencePage
implementation of this
IPreferencePage
method returns true
if the page
is valid.okToLeave
in interface IPreferencePage
false
to abort page flipping and the
have the current page remain visible, and true
to allow the page flipIPreferencePage.okToLeave()
protected void performApply()
This is a framework hook method for subclasses 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.
performOk()
,
performCancel()
public boolean performCancel()
IPreferencePage
method performs special processing when this page's Cancel button has
been pressed.
This is a framework hook method for subclasses to do special things when
the Cancel button has been pressed. The default implementation of this
framework method does nothing and returns true
.
Note that UI guidelines on different platforms disagree on whether Cancel
should revert changes that have been applied with the Apply button.
Windows
wants applied changes to persist on Cancel, whereas
Mac and
GTK
consider Apply a preview that should not be saved on Cancel. Eclipse applications
typically adhere to the Windows guidelines and just override performOk()
and save preferences there.
performCancel
in interface IPreferencePage
false
to abort the container's cancel
procedure and true
to allow the cancel to happenIPreferencePage.performCancel()
protected void performDefaults()
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
.
public boolean performOk()
IPreferencePage
performOk
in interface IPreferencePage
false
to abort the container's OK
processing and true
to allow the OK to happenpublic void setContainer(IPreferencePageContainer container)
IPreferencePage
setContainer
in interface IPreferencePage
container
- the preference page container, or null
public void setPreferenceStore(IPreferenceStore store)
If preferenceStore is set to null, getPreferenceStore will invoke doGetPreferenceStore the next time it is called.
store
- the preference store, or null
getPreferenceStore()
public void setSize(Point uiSize)
IPreferencePage
setSize
in interface IPreferencePage
uiSize
- the size of the preference page encoded as
new Point(width,height)
public void setTitle(String title)
PreferencePage
implementation of this IDialogPage
method extends the DialogPage
implementation to update
the preference page container title. Subclasses may extend.setTitle
in interface IDialogPage
setTitle
in class DialogPage
title
- the title of this dialog page,
or null
if noneIDialogPage.setTitle(String)
public void setValid(boolean b)
b
- the new valid stateprotected void updateApplyButton()
protected Composite createNoteComposite(Font font, Composite composite, String title, String message)
font
- the font to usecomposite
- the parent compositetitle
- the title of the notemessage
- the message for the noteprotected Button getApplyButton()
protected Button getDefaultsButton()
public void performHelp()
DialogPage
IDialogPage
method does
nothing. Subclasses should override to take some action in response to a
help request.performHelp
in interface IDialogPage
performHelp
in class DialogPage
public void applyData(Object data)
It is up to the subclasses to specify the contract and the data format. The contract is not guaranteed if the subclass is in an internal package.
Note: The implementation must silently ignore all unknown data.
The default implementation does nothing.
data
- the data as specified by the subclasspublic void setErrorMessage(String newMessage)
DialogPage
setErrorMessage
in class DialogPage
newMessage
- the message, or null
to clear the error messagepublic void setMessage(String newMessage, int newType)
DialogPage
The valid message types are one of NONE
,
INFORMATION
,WARNING
, or
ERROR
.
Note that for backward compatibility, a message of type
ERROR
is different than an error message (set using
setErrorMessage
). An error message overrides the current
message until the error message is cleared. This method replaces the
current message and does not affect the error message.
setMessage
in class DialogPage
newMessage
- the message, or null
to clear the messagenewType
- the message type
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.