Class PreferencePage
- All Implemented Interfaces:
- IDialogPage,- IMessageProvider,- IPreferencePage
- Direct Known Subclasses:
- ActivitiesPreferencePage,- ActivityCategoryPreferencePage,- ComparePreferencePage,- FieldEditorPreferencePage,- PropertyPage,- RepositoryManipulationPage,- RootScopePage,- TemplatePreferencePage
 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.
 
- 
Field SummaryFields inherited from interface org.eclipse.jface.dialogs.IMessageProviderERROR, INFORMATION, NONE, WARNING
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedCreates a new preference page with an empty title and no image.protectedPreferencePage(String title) Creates a new preference page with the given title and no image.protectedPreferencePage(String title, ImageDescriptor image) Creates a new abstract preference page with the given title and image.
- 
Method SummaryModifier and TypeMethodDescriptionvoidApplies the given data to this page.protected voidapplyDialogFont(Composite composite) Apply the dialog font to the composite and it's children if it is set.Computes the size for this page's UI control.protected voidcontributeButtons(Composite parent) Contributes additional buttons to the given composite.protected abstract ControlcreateContents(Composite parent) Creates and returns the SWT control for the customized body of this preference page under the given parent composite.voidcreateControl(Composite parent) ThePreferencePageimplementation of thisIDialogPagemethod creates a description label and button bar for the page.protected LabelcreateDescriptionLabel(Composite parent) Creates and returns an SWT label under the given composite.protected CompositecreateNoteComposite(Font font, Composite composite, String title, String message) Creates a composite with a highlighted Note entry and a message text.protected PointComputes the size needed by this page's UI control.protected IPreferenceStoreReturns the preference store of this preference page.protected ButtonReturns the Apply button.Returns the container of this page.protected ButtonReturns the Restore Defaults button.Returns the preference store of this preference page.booleanisValid()The preference page implementation of anIPreferencePagemethod returns whether this preference page is valid.protected voidSuppresses creation of the standard Default and Apply buttons for this page.protected voidSuppress creation of the standard Default button for this page.booleanThePreferencePageimplementation of thisIPreferencePagemethod returnstrueif the page is valid.protected voidPerforms special processing when this page's Apply button has been pressed.booleanThe preference page implementation of anIPreferencePagemethod performs special processing when this page's Cancel button has been pressed.protected voidPerforms special processing when this page's Defaults button has been pressed.voidThis default implementation of anIDialogPagemethod does nothing.booleanNotifies that the OK button of this page's container has been pressed.voidsetContainer(IPreferencePageContainer container) Sets or clears the container of this page.voidsetErrorMessage(String newMessage) Sets or clears the error message for this page.voidsetMessage(String newMessage, int newType) Sets the message for this page with an indication of what type of message it is.voidSets the preference store for this preference page.voidSets the size of this page's UI component.voidThePreferencePageimplementation of thisIDialogPagemethod extends theDialogPageimplementation to update the preference page container title.voidsetValid(boolean b) Sets whether this page is valid.toString()protected voidUpdates the enabled state of the Apply button to reflect whether this page is valid.Methods inherited from class org.eclipse.jface.dialogs.DialogPageconvertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, dispose, getControl, getDescription, getDialogFontName, getErrorMessage, getFont, getImage, getMessage, getMessageType, getShell, getTitle, getToolTipText, initializeDialogUnits, isControlCreated, setButtonLayoutData, setControl, setDescription, setImageDescriptor, setMessage, setVisibleMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jface.dialogs.IDialogPagedispose, getControl, getDescription, getErrorMessage, getImage, getMessage, getTitle, setDescription, setImageDescriptor, setVisible
- 
Constructor Details- 
PreferencePageprotected PreferencePage()Creates a new preference page with an empty title and no image.
- 
PreferencePageCreates a new preference page with the given title and no image.- Parameters:
- title- the title of this preference page
 
- 
PreferencePageCreates 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- nullif none
 
 
- 
- 
Method Details- 
computeSizeComputes the size for this page's UI control.The default implementation of this IPreferencePagemethod returns the size set bysetSize; if no size has been set, but the page has a UI control, the framework methoddoComputeSizeis called to compute the size.- Specified by:
- computeSizein 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
 
- 
contributeButtonsContributes 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++); - Parameters:
- parent- the button bar
 
- 
createContentsCreates 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 Compositeobject whoseLayouthas default margins (for example, aGridLayout) is expected to set the margins of thisLayoutto 0 pixels.- Parameters:
- parent- the parent composite
- Returns:
- the new control
 
- 
createControlThePreferencePageimplementation of thisIDialogPagemethod creates a description label and button bar for the page. It callscreateContentsto create the custom contents of the page.If a subclass that overrides this method creates a Compositethat has a layout with default margins (for example, aGridLayout) it is expected to set the margins of thisLayoutto 0 pixels.- Specified by:
- createControlin interface- IDialogPage
- Parameters:
- parent- the parent composite
- See Also:
 
- 
applyDialogFontApply 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.- Parameters:
- composite- the composite to apply the font to. Font will also be applied to its children. If the control is- nullnothing happens.
 
- 
createDescriptionLabelCreates and returns an SWT label under the given composite.- Parameters:
- parent- the parent composite
- Returns:
- the new label
 
- 
doComputeSizeComputes 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.- Returns:
- the size of the preference page encoded as
   new Point(width,height)
 
- 
doGetPreferenceStoreReturns 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 nullif none
 
- 
getContainerReturns the container of this page.- Returns:
- the preference page container, or nullif this page has yet to be added to a container
 
- 
getPreferenceStoreReturns the preference store of this preference page.- Returns:
- the preference store , or nullif none
 
- 
isValidpublic boolean isValid()The preference page implementation of anIPreferencePagemethod returns whether this preference page is valid. Preference pages are considered valid by default; callsetValid(false)to make a page invalid.- Specified by:
- isValidin interface- IPreferencePage
- Returns:
- trueif the page is in a valid state, and- falseif invalid
- See Also:
 
- 
noDefaultAndApplyButtonprotected void noDefaultAndApplyButton()Suppresses creation of the standard Default and Apply buttons for this page.Subclasses wishing a preference page without these buttons should call this framework method before the page's control has been created. 
- 
noDefaultButtonprotected void noDefaultButton()Suppress creation of the standard Default button for this page.Subclasses wishing a preference page with this button should call this framework method before the page's control has been created. - Since:
- 3.11
 
- 
okToLeavepublic boolean okToLeave()ThePreferencePageimplementation of thisIPreferencePagemethod returnstrueif the page is valid.- Specified by:
- okToLeavein interface- IPreferencePage
- Returns:
- falseto abort page flipping and the have the current page remain visible, and- trueto allow the page flip
- See Also:
 
- 
performApplyprotected void performApply()Performs special processing when this page's Apply button has been pressed.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 performOkto simulate the pressing of the page's OK button.- See Also:
 
- 
performCancelpublic boolean performCancel()The preference page implementation of anIPreferencePagemethod 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.- Specified by:
- performCancelin interface- IPreferencePage
- Returns:
- falseto abort the container's cancel procedure and- trueto allow the cancel to happen
- See Also:
 
- 
performDefaultsprotected 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.
- 
performOkpublic boolean performOk()Description copied from interface:IPreferencePageNotifies that the OK button of this page's container has been pressed.- Specified by:
- performOkin interface- IPreferencePage
- Returns:
- falseto abort the container's OK processing and- trueto allow the OK to happen
 
- 
setContainerDescription copied from interface:IPreferencePageSets or clears the container of this page.- Specified by:
- setContainerin interface- IPreferencePage
- Parameters:
- container- the preference page container, or- null
 
- 
setPreferenceStoreSets 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:
 
- 
setSizeDescription copied from interface:IPreferencePageSets the size of this page's UI component.- Specified by:
- setSizein interface- IPreferencePage
- Parameters:
- uiSize- the size of the preference page encoded as- new Point(width,height)
 
- 
setTitleThePreferencePageimplementation of thisIDialogPagemethod extends theDialogPageimplementation to update the preference page container title. Subclasses may extend.- Specified by:
- setTitlein interface- IDialogPage
- Overrides:
- setTitlein class- DialogPage
- Parameters:
- title- the title of this dialog page, or- nullif none
- See Also:
 
- 
setValidpublic 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
- 
updateApplyButtonprotected void updateApplyButton()Updates the enabled state of the Apply button to reflect whether this page is valid.
- 
createNoteCompositeprotected Composite createNoteComposite(Font font, Composite composite, String title, 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.- Parameters:
- font- the font to use
- composite- the parent composite
- title- the title of the note
- message- the message for the note
- Returns:
- the composite for the note
 
- 
getApplyButtonReturns the Apply button.- Returns:
- the Apply button
 
- 
getDefaultsButtonReturns the Restore Defaults button.- Returns:
- the Restore Defaults button
 
- 
performHelppublic void performHelp()Description copied from class:DialogPageThis default implementation of anIDialogPagemethod does nothing. Subclasses should override to take some action in response to a help request.- Specified by:
- performHelpin interface- IDialogPage
- Overrides:
- performHelpin class- DialogPage
 
- 
applyDataApplies the given data to this page.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. - Parameters:
- data- the data as specified by the subclass
- Since:
- 3.1
 
- 
setErrorMessageDescription copied from class:DialogPageSets or clears the error message for this page.- Overrides:
- setErrorMessagein class- DialogPage
- Parameters:
- newMessage- the message, or- nullto clear the error message
 
- 
setMessageDescription copied from class:DialogPageSets the message for this page with an indication of what type of message it is.The valid message types are one of NONE,INFORMATION,WARNING, orERROR.Note that for backward compatibility, a message of type ERRORis different than an error message (set usingsetErrorMessage). 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.- Overrides:
- setMessagein class- DialogPage
- Parameters:
- newMessage- the message, or- nullto clear the message
- newType- the message type
 
 
-