# Interface IManagedForm

All Known Implementing Classes:
  `ManagedForm`

public interface 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 no 1/1 mapping between widgets and form parts. A widget like Section can be a part by itself, but a number of widgets can gather around one form part.

This interface should not be extended or implemented. New form instances should be created using ManagedForm.

Since:
  3.0
See Also:
  - `ManagedForm`
Restriction:
  This interface is not intended to be implemented by clients.
Restriction:
  This interface is not intended to be extended by clients.

## Method Summary

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`
`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 refreshing every part that is stale.
`void`
`removePart(IFormPart part)`
Removes the part from the form.
`void`
`setContainer(Object container)`
Sets the container that owns this form.
`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.

## Method Details

### initialize

void initialize()
Initializes the form by looping through the managed parts and initializing them. Has no effect if already called once.

Since:
  3.1

### getToolkit

FormToolkit getToolkit()
Returns the toolkit used by this form.

Returns:
  the toolkit

### getForm

ScrolledForm getForm()
Returns the form widget managed by this form.

Returns:
  the form widget

### reflow

void reflow(boolean changed)
Reflows the form as a result of the layout change.

Parameters:
  `changed` - if `true`, discard cached layout information

### fireSelectionChanged

void fireSelectionChanged(IFormPart part, ISelection selection)
A part can use this method to notify other parts that implement IPartSelectionListener about selection changes.

Parameters:
  `part` - the part that broadcasts the selection
  `selection` - the selection in the part

### getParts

IFormPart[] getParts()
Returns all the parts currently managed by this form.

Returns:
  the managed parts

### addPart

void addPart(IFormPart part)
Adds the new part to the form.

Parameters:
  `part` - the part to add

### removePart

void removePart(IFormPart part)
Removes the part from the form.

Parameters:
  `part` - the part to remove

### setInput

boolean setInput(Object input)
Sets the input of this page to the provided object.

Parameters:
  `input` - the new page input
Returns:
  `true` if the form contains this object, `false` otherwise.

### getInput

Object getInput()
Returns the current page input.

Returns:
  page input object or `null` if not applicable.

### isDirty

boolean isDirty()
Tests if form is dirty. A managed form is dirty if at least one managed part is dirty.

Returns:
  `true` if at least one managed part is dirty, `false` otherwise.

### dirtyStateChanged

void dirtyStateChanged()
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'.

See Also:
  - `isDirty()`

### commit

void commit(boolean onSave)
Commits the dirty form. All pending changes in the widgets are flushed into the model.

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).

### isStale

boolean isStale()
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.

Returns:
  `true` if the form is stale, `false` otherwise.

### staleStateChanged

void staleStateChanged()
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'.

### refresh

void refresh()
Refreshes the form by refreshing every part that is stale.

### setContainer

void setContainer(Object container)
Sets the container that owns this form. Depending on the context, the container may be wizard, editor page, editor etc.

Parameters:
  `container` - the container of this form

### getContainer

Object getContainer()
Returns the container of this form.

Returns:
  the form container

### getMessageManager

IMessageManager getMessageManager()
Returns the message manager that will keep track of messages in this form.

Returns:
  the message manager instance
Since:
  3.3