Class FormPage

  • All Implemented Interfaces:
    IAdaptable, IExecutableExtension, IFormPage, IEditorPart, ISaveablePart, IWorkbenchPart, IWorkbenchPart2, IWorkbenchPart3, IWorkbenchPartOrientation

    public class FormPage
    extends EditorPart
    implements IFormPage
    A base class that all pages that should be added to FormEditor must subclass. Form page has an instance of PageForm that extends managed form. Subclasses should override method 'createFormContent(ManagedForm)' to fill the form with content. Note that page itself can be loaded lazily (on first open). Consequently, the call to create the form content can come after the editor has been opened for a while (in fact, it is possible to open and close the editor and never create the form because no attempt has been made to show the page).
    • Constructor Detail

      • FormPage

        public FormPage​(FormEditor editor,
                        String id,
                        String title)
        A constructor that creates the page and initializes it with the editor.
        editor - the parent editor
        id - the unique identifier
        title - the page title
      • FormPage

        public FormPage​(String id,
                        String title)
        The constructor. The parent editor need to be passed in the initialize method if this constructor is used.
        id - a unique page identifier
        title - a user-friendly page title
    • Method Detail

      • initialize

        public void initialize​(FormEditor editor)
        Primes the form page with the parent editor instance.
        Specified by:
        initialize in interface IFormPage
        editor - the parent editor
      • getEditor

        public FormEditor getEditor()
        Returns the parent editor.
        Specified by:
        getEditor in interface IFormPage
        parent editor instance
      • getManagedForm

        public IManagedForm getManagedForm()
        Returns the managed form owned by this page.
        Specified by:
        getManagedForm in interface IFormPage
        the managed form
      • setActive

        public void setActive​(boolean active)
        Implements the required method by refreshing the form when set active. Subclasses must call super when overriding this method.
        Specified by:
        setActive in interface IFormPage
        active - true if page should be visible, false otherwise.
      • isActive

        public boolean isActive()
        Tests if the page is active by asking the parent editor if this page is the currently active page.
        Specified by:
        isActive in interface IFormPage
        true if the page is currently active, false otherwise.
      • createPartControl

        public void createPartControl​(Composite parent)
        Creates the part control by creating the managed form using the parent editor's toolkit. Subclasses should override createFormContent(IManagedForm) to populate the form with content.
        Specified by:
        createPartControl in interface IWorkbenchPart
        Specified by:
        createPartControl in class WorkbenchPart
        parent - the page parent composite
      • createFormContent

        protected void createFormContent​(IManagedForm managedForm)
        Subclasses should override this method to create content in the form hosted in this page.
        managedForm - the form hosted in this page.
      • getPartControl

        public Control getPartControl()
        Returns the form page control.
        Specified by:
        getPartControl in interface IFormPage
        managed form's control
      • getId

        public String getId()
        Returns the unique identifier that can be used to reference this page.
        Specified by:
        getId in interface IFormPage
        the unique page identifier
      • doSave

        public void doSave​(IProgressMonitor monitor)
        Description copied from interface: ISaveablePart
        Saves the contents of this part.

        If the save is successful, the part should fire a property changed event reflecting the new dirty state (PROP_DIRTY property).

        If the save is cancelled through user action, or for any other reason, the part should invoke setCancelled on the IProgressMonitor to inform the caller.

        This method is long-running; progress and cancellation are provided by the given progress monitor.

        Specified by:
        doSave in interface ISaveablePart
        Specified by:
        doSave in class EditorPart
        monitor - the progress monitor
        See Also:
      • doSaveAs

        public void doSaveAs()
        Description copied from interface: ISaveablePart
        Saves the contents of this part to another object.

        Implementors are expected to open a "Save As" dialog where the user will be able to select a new name for the contents. After the selection is made, the contents should be saved to that new name. During this operation a IProgressMonitor should be used to indicate progress.

        If the save is successful, the part fires a property changed event reflecting the new dirty state (PROP_DIRTY property).

        Specified by:
        doSaveAs in interface ISaveablePart
        Specified by:
        doSaveAs in class EditorPart
        See Also:
      • setIndex

        public void setIndex​(int index)
        Preserves the page index.
        Specified by:
        setIndex in interface IFormPage
        index - the assigned page index
      • getIndex

        public int getIndex()
        Returns the saved page index.
        Specified by:
        getIndex in interface IFormPage
        the page index
      • isEditor

        public boolean isEditor()
        Form pages are not editors.
        Specified by:
        isEditor in interface IFormPage
      • selectReveal

        public boolean selectReveal​(Object object)
        Attempts to select and reveal the given object by passing the request to the managed form.
        Specified by:
        selectReveal in interface IFormPage
        object - the object to select and reveal in the page if possible.
        true if the page has been successfully selected and revealed by one of the managed form parts, false otherwise.
      • canLeaveThePage

        public boolean canLeaveThePage()
        By default, editor will be allowed to flip the page.
        Specified by:
        canLeaveThePage in interface IFormPage