Class DetailsPart

  • All Implemented Interfaces:
    IFormPart, IPartSelectionListener

    public final class DetailsPart
    extends Object
    implements IFormPart, IPartSelectionListener
    This managed form part handles the 'details' portion of the 'master/details' block. It has a page book that manages pages of details registered for the current selection.

    By default, details part accepts any number of pages. If dynamic page provider is registered, this number may be excessive. To avoid running out of steam (by creating a large number of pages with widgets on each), maximum number of pages can be set to some reasonable value (e.g. 10). When this number is reached, old pages (those created first) will be removed and disposed as new ones are added. If the disposed pages are needed again after that, they will be created again.

    Since:
    3.0
    • Constructor Detail

      • DetailsPart

        public DetailsPart​(IManagedForm mform,
                           ScrolledPageBook pageBook)
        Creates a details part by wrapping the provided page book.
        Parameters:
        mform - the parent form
        pageBook - the page book to wrap
      • DetailsPart

        public DetailsPart​(IManagedForm mform,
                           Composite parent,
                           int style)
        Creates a new details part in the provided form by creating the page book.
        Parameters:
        mform - the parent form
        parent - the composite to create the page book in
        style - the style for the page book
    • Method Detail

      • registerPage

        public void registerPage​(Object objectClass,
                                 IDetailsPage page)
        Registers the details page to be used for all the objects of the provided object class.
        Parameters:
        objectClass - an object of type 'java.lang.Class' to be used as a key for the provided page
        page - the page to show for objects of the provided object class
      • setPageProvider

        public void setPageProvider​(IDetailsPageProvider provider)
        Sets the dynamic page provider. The dynamic provider can return different pages for objects of the same class based on their state.
        Parameters:
        provider - the provider to use
      • commit

        public void commit​(boolean onSave)
        Commits the part by committing the current page.
        Specified by:
        commit in interface IFormPart
        Parameters:
        onSave - true if commit is requested as a result of the 'save' action, false otherwise.
      • getCurrentPage

        public IDetailsPage getCurrentPage()
        Returns the current page visible in the part.
        Returns:
        the current page
      • dispose

        public void dispose()
        Description copied from interface: IFormPart
        Disposes the part allowing it to release allocated resources.
        Specified by:
        dispose in interface IFormPart
      • initialize

        public void initialize​(IManagedForm form)
        Description copied from interface: IFormPart
        Initializes the part.
        Specified by:
        initialize in interface IFormPart
        Parameters:
        form - the managed form that manages the part
      • isDirty

        public boolean isDirty()
        Tests if the currently visible page is dirty.
        Specified by:
        isDirty in interface IFormPart
        Returns:
        true if the page is dirty, false otherwise.
      • isStale

        public boolean isStale()
        Tests if the currently visible page is stale and needs refreshing.
        Specified by:
        isStale in interface IFormPart
        Returns:
        true if the page is stale, false otherwise.
      • refresh

        public void refresh()
        Refreshes the current page.
        Specified by:
        refresh in interface IFormPart
      • setFocus

        public void setFocus()
        Sets the focus to the currently visible page.
        Specified by:
        setFocus in interface IFormPart
      • setFormInput

        public boolean setFormInput​(Object input)
        Description copied from interface: IFormPart
        Notifies the part that an object has been set as overall form's input. The part can elect to react by revealing or selecting the object, or do nothing if not applicable.
        Specified by:
        setFormInput in interface IFormPart
        Returns:
        true if the part has selected and revealed the input object, false otherwise.
      • getPageLimit

        public int getPageLimit()
        Returns the maximum number of pages that should be maintained in this part. When an attempt is made to add more pages, old pages are removed and disposed based on the order of creation (the oldest pages are removed). The exception is made for the page that should otherwise be disposed but is currently active.
        Returns:
        maximum number of pages for this part
      • setPageLimit

        public void setPageLimit​(int pageLimit)
        Sets the page limit for this part.
        Parameters:
        pageLimit - the maximum number of pages that should be maintained in this part.
        See Also:
        getPageLimit()