Package org.eclipse.ui.forms
Class ManagedForm
java.lang.Object
org.eclipse.ui.forms.ManagedForm
- All Implemented Interfaces:
IManagedForm
Managed form wraps a form widget and adds life cycle methods for form parts.
A form part is a portion of the form that participates in form life cycle
events.
There is requirement for 1/1 mapping between widgets and form parts. A widget like Section can be a part by itself, but a number of widgets can join around one form part.
Note to developers: this class is left public to allow its use beyond the original intention (inside a multi-page editor's page). You should limit the use of this class to make new instances inside a form container (wizard page, dialog etc.). Clients that need access to the class should not do it directly. Instead, they should do it through IManagedForm interface as much as possible.
- Since:
- 3.0
-
Constructor Summary
ConstructorsConstructorDescriptionManagedForm(Composite parent) Creates a managed form in the provided parent.ManagedForm(FormToolkit toolkit, ScrolledForm form) Creates a managed form that will use the provided toolkit and -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the new part to the form.voidcommit(boolean onSave) Commits the dirty form.voidNotifies the form that the dirty state of one of its parts has changed.voiddispose()Disposes all the parts in this form.voidfireSelectionChanged(IFormPart part, ISelection selection) A part can use this method to notify other parts that implement IPartSelectionListener about selection changes.Returns the container of this form.getForm()Returns the form widget managed by this form.getInput()Returns the current page input.Returns the message manager that will keep track of messages in this form.getParts()Returns all the parts currently managed by this form.Returns the toolkit used by this form.voidInitializes the form by looping through the managed parts and initializing them.booleanisDirty()Tests if form is dirty.booleanisStale()Tests if form is stale.voidreflow(boolean changed) Reflows the form as a result of the layout change.voidrefresh()Refreshes the form by refreshes all the stale parts.voidremovePart(IFormPart part) Removes the part from the form.voidsetContainer(Object container) Sets the container that owns this form.voidsetFocus()Transfers the focus to the first form part.booleanSets the input of this page to the provided object.voidNotifies the form that the stale state of one of its parts has changed.
-
Constructor Details
-
ManagedForm
Creates a managed form in the provided parent. Form toolkit and widget will be created and owned by this object.- Parameters:
parent- the parent widget
-
ManagedForm
Creates a managed form that will use the provided toolkit and- Parameters:
toolkit- existing toolkit to useform- form to manage
-
-
Method Details
-
addPart
Description copied from interface:IManagedFormAdds the new part to the form.- Specified by:
addPartin interfaceIManagedForm- Parameters:
part- the part to add
-
removePart
Description copied from interface:IManagedFormRemoves the part from the form.- Specified by:
removePartin interfaceIManagedForm- Parameters:
part- the part to remove
-
getParts
Description copied from interface:IManagedFormReturns all the parts currently managed by this form.- Specified by:
getPartsin interfaceIManagedForm- Returns:
- the managed parts
-
getToolkit
Description copied from interface:IManagedFormReturns the toolkit used by this form.- Specified by:
getToolkitin interfaceIManagedForm- Returns:
- the toolkit
-
getForm
Description copied from interface:IManagedFormReturns the form widget managed by this form.- Specified by:
getFormin interfaceIManagedForm- Returns:
- the form widget
-
reflow
public void reflow(boolean changed) Description copied from interface:IManagedFormReflows the form as a result of the layout change.- Specified by:
reflowin interfaceIManagedForm- Parameters:
changed- iftrue, discard cached layout information
-
fireSelectionChanged
A part can use this method to notify other parts that implement IPartSelectionListener about selection changes.- Specified by:
fireSelectionChangedin interfaceIManagedForm- Parameters:
part- the part that broadcasts the selectionselection- the selection in the part- See Also:
-
initialize
public void initialize()Initializes the form by looping through the managed parts and initializing them. Has no effect if already called once.- Specified by:
initializein interfaceIManagedForm
-
dispose
public void dispose()Disposes all the parts in this form. -
refresh
public void refresh()Refreshes the form by refreshes all the stale parts. Since 3.1, this method is performed on a UI thread when called from another thread so it is not needed to wrap the call inDisplay.syncExecorasyncExec.- Specified by:
refreshin interfaceIManagedForm
-
commit
public void commit(boolean onSave) Description copied from interface:IManagedFormCommits the dirty form. All pending changes in the widgets are flushed into the model.- Specified by:
commitin interfaceIManagedForm- Parameters:
onSave- indicates if commit is called during 'save' operation or for some other reason (for example, if form is contained in a wizard or a multi-page editor and the user is about to leave the page).
-
setInput
Description copied from interface:IManagedFormSets the input of this page to the provided object.- Specified by:
setInputin interfaceIManagedForm- Parameters:
input- the new page input- Returns:
trueif the form contains this object,falseotherwise.
-
getInput
Description copied from interface:IManagedFormReturns the current page input.- Specified by:
getInputin interfaceIManagedForm- Returns:
- page input object or
nullif not applicable.
-
setFocus
public void setFocus()Transfers the focus to the first form part. -
isDirty
public boolean isDirty()Description copied from interface:IManagedFormTests if form is dirty. A managed form is dirty if at least one managed part is dirty.- Specified by:
isDirtyin interfaceIManagedForm- Returns:
trueif at least one managed part is dirty,falseotherwise.
-
isStale
public boolean isStale()Description copied from interface:IManagedFormTests if form is stale. A managed form is stale if at least one managed part is stale. This can happen when the underlying model changes, resulting in the presentation of the part being out of sync with the model and needing refreshing.- Specified by:
isStalein interfaceIManagedForm- Returns:
trueif the form is stale,falseotherwise.
-
dirtyStateChanged
public void dirtyStateChanged()Description copied from interface:IManagedFormNotifies the form that the dirty state of one of its parts has changed. The global dirty state of the form can be obtained by calling 'isDirty'.- Specified by:
dirtyStateChangedin interfaceIManagedForm- See Also:
-
staleStateChanged
public void staleStateChanged()Description copied from interface:IManagedFormNotifies the form that the stale state of one of its parts has changed. The global stale state of the form can be obtained by calling 'isStale'.- Specified by:
staleStateChangedin interfaceIManagedForm
-
getContainer
Description copied from interface:IManagedFormReturns the container of this form.- Specified by:
getContainerin interfaceIManagedForm- Returns:
- the form container
-
setContainer
Description copied from interface:IManagedFormSets the container that owns this form. Depending on the context, the container may be wizard, editor page, editor etc.- Specified by:
setContainerin interfaceIManagedForm- Parameters:
container- the container of this form
-
getMessageManager
Description copied from interface:IManagedFormReturns the message manager that will keep track of messages in this form.- Specified by:
getMessageManagerin interfaceIManagedForm- Returns:
- the message manager instance
-