Package org.eclipse.ui.forms
Class ManagedForm
- java.lang.Object
-
- org.eclipse.ui.forms.ManagedForm
-
- All Implemented Interfaces:
IManagedForm
public class ManagedForm extends Object implements 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
Constructors Constructor Description ManagedForm(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPart(IFormPart part)
Adds the new part to the form.void
commit(boolean onSave)
Commits the dirty form.void
dirtyStateChanged()
Notifies the form that the dirty state of one of its parts has changed.void
dispose()
Disposes all the parts in this form.void
fireSelectionChanged(IFormPart part, ISelection selection)
A part can use this method to notify other parts that implement IPartSelectionListener about selection changes.Object
getContainer()
Returns the container of this form.ScrolledForm
getForm()
Returns the form widget managed by this form.Object
getInput()
Returns the current page input.IMessageManager
getMessageManager()
Returns the message manager that will keep track of messages in this form.IFormPart[]
getParts()
Returns all the parts currently managed by this form.FormToolkit
getToolkit()
Returns the toolkit used by this form.void
initialize()
Initializes the form by looping through the managed parts and initializing them.boolean
isDirty()
Tests if form is dirty.boolean
isStale()
Tests if form is stale.void
reflow(boolean changed)
Reflows the form as a result of the layout change.void
refresh()
Refreshes the form by refreshes all the stale parts.void
removePart(IFormPart part)
Removes the part from the form.void
setContainer(Object container)
Sets the container that owns this form.void
setFocus()
Transfers the focus to the first form part.boolean
setInput(Object input)
Sets the input of this page to the provided object.void
staleStateChanged()
Notifies the form that the stale state of one of its parts has changed.
-
-
-
Constructor Detail
-
ManagedForm
public ManagedForm(Composite parent)
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
public ManagedForm(FormToolkit toolkit, ScrolledForm form)
Creates a managed form that will use the provided toolkit and- Parameters:
toolkit
- existing toolkit to useform
- form to manage
-
-
Method Detail
-
addPart
public void addPart(IFormPart part)
Description copied from interface:IManagedForm
Adds the new part to the form.- Specified by:
addPart
in interfaceIManagedForm
- Parameters:
part
- the part to add
-
removePart
public void removePart(IFormPart part)
Description copied from interface:IManagedForm
Removes the part from the form.- Specified by:
removePart
in interfaceIManagedForm
- Parameters:
part
- the part to remove
-
getParts
public IFormPart[] getParts()
Description copied from interface:IManagedForm
Returns all the parts currently managed by this form.- Specified by:
getParts
in interfaceIManagedForm
- Returns:
- the managed parts
-
getToolkit
public FormToolkit getToolkit()
Description copied from interface:IManagedForm
Returns the toolkit used by this form.- Specified by:
getToolkit
in interfaceIManagedForm
- Returns:
- the toolkit
-
getForm
public ScrolledForm getForm()
Description copied from interface:IManagedForm
Returns the form widget managed by this form.- Specified by:
getForm
in interfaceIManagedForm
- Returns:
- the form widget
-
reflow
public void reflow(boolean changed)
Description copied from interface:IManagedForm
Reflows the form as a result of the layout change.- Specified by:
reflow
in interfaceIManagedForm
- Parameters:
changed
- iftrue
, discard cached layout information
-
fireSelectionChanged
public void fireSelectionChanged(IFormPart part, ISelection selection)
A part can use this method to notify other parts that implement IPartSelectionListener about selection changes.- Specified by:
fireSelectionChanged
in interfaceIManagedForm
- Parameters:
part
- the part that broadcasts the selectionselection
- the selection in the part- See Also:
IPartSelectionListener
-
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:
initialize
in 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.syncExec
orasyncExec
.- Specified by:
refresh
in interfaceIManagedForm
-
commit
public void commit(boolean onSave)
Description copied from interface:IManagedForm
Commits the dirty form. All pending changes in the widgets are flushed into the model.- Specified by:
commit
in 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
public boolean setInput(Object input)
Description copied from interface:IManagedForm
Sets the input of this page to the provided object.- Specified by:
setInput
in interfaceIManagedForm
- Parameters:
input
- the new page input- Returns:
true
if the form contains this object,false
otherwise.
-
getInput
public Object getInput()
Description copied from interface:IManagedForm
Returns the current page input.- Specified by:
getInput
in interfaceIManagedForm
- Returns:
- page input object or
null
if not applicable.
-
setFocus
public void setFocus()
Transfers the focus to the first form part.
-
isDirty
public boolean isDirty()
Description copied from interface:IManagedForm
Tests if form is dirty. A managed form is dirty if at least one managed part is dirty.- Specified by:
isDirty
in interfaceIManagedForm
- Returns:
true
if at least one managed part is dirty,false
otherwise.
-
isStale
public boolean isStale()
Description copied from interface:IManagedForm
Tests 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:
isStale
in interfaceIManagedForm
- Returns:
true
if the form is stale,false
otherwise.
-
dirtyStateChanged
public void dirtyStateChanged()
Description copied from interface:IManagedForm
Notifies 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:
dirtyStateChanged
in interfaceIManagedForm
- See Also:
IManagedForm.isDirty()
-
staleStateChanged
public void staleStateChanged()
Description copied from interface:IManagedForm
Notifies 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:
staleStateChanged
in interfaceIManagedForm
-
getContainer
public Object getContainer()
Description copied from interface:IManagedForm
Returns the container of this form.- Specified by:
getContainer
in interfaceIManagedForm
- Returns:
- the form container
-
setContainer
public void setContainer(Object container)
Description copied from interface:IManagedForm
Sets the container that owns this form. Depending on the context, the container may be wizard, editor page, editor etc.- Specified by:
setContainer
in interfaceIManagedForm
- Parameters:
container
- the container of this form
-
getMessageManager
public IMessageManager getMessageManager()
Description copied from interface:IManagedForm
Returns the message manager that will keep track of messages in this form.- Specified by:
getMessageManager
in interfaceIManagedForm
- Returns:
- the message manager instance
-
-