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 Details

    • 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 use
      form - form to manage
  • Method Details

    • addPart

      public void addPart(IFormPart part)
      Description copied from interface: IManagedForm
      Adds the new part to the form.
      Specified by:
      addPart in interface IManagedForm
      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 interface IManagedForm
      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 interface IManagedForm
      Returns:
      the managed parts
    • getToolkit

      public FormToolkit getToolkit()
      Description copied from interface: IManagedForm
      Returns the toolkit used by this form.
      Specified by:
      getToolkit in interface IManagedForm
      Returns:
      the toolkit
    • getForm

      public ScrolledForm getForm()
      Description copied from interface: IManagedForm
      Returns the form widget managed by this form.
      Specified by:
      getForm in interface IManagedForm
      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 interface IManagedForm
      Parameters:
      changed - if true, 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 interface IManagedForm
      Parameters:
      part - the part that broadcasts the selection
      selection - 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:
      initialize in interface IManagedForm
    • 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 in Display.syncExec or asyncExec.
      Specified by:
      refresh in interface IManagedForm
    • 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 interface IManagedForm
      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 interface IManagedForm
      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 interface IManagedForm
      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 interface IManagedForm
      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 interface IManagedForm
      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 interface IManagedForm
      See Also:
    • 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 interface IManagedForm
    • getContainer

      public Object getContainer()
      Description copied from interface: IManagedForm
      Returns the container of this form.
      Specified by:
      getContainer in interface IManagedForm
      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 interface IManagedForm
      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 interface IManagedForm
      Returns:
      the message manager instance