Class FWFormPanel

All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, FWFormComponentFactory

public class FWFormPanel extends FWDefaultPanel implements ActionListener, FWFormComponentFactory
Form panel that shows the form components described by a form element of the layout provider. The child elements are turned into form components by their element name (label, text, integer, double, file, dir, choice, date, result, image, processbutton, memorymonitor, cal, extend, plus group); further element names can be handled by registered component factories (addComponentFactory(FWFormComponentFactory)), unknown ones become text fields. All components observe the parameters of the functionality; before going on, required fields are checked. The form can be exported as PDF, RTF or HTML document.
Author:
Andreas Enders
See Also:
  • Constructor Details

    • FWFormPanel

      public FWFormPanel(org.jdom2.Element aFormElement, FormFunctionality aFunctionality)
      Constructs the panel from the form element using the parameters of the functionality.
      Parameters:
      aFormElement - the form element
      aFunctionality - the form functionality
    • FWFormPanel

      public FWFormPanel(org.jdom2.Element aFormElement, net.simplace.core.FWObservable aObservable)
      Constructs the panel from the form element without functionality.
      Parameters:
      aFormElement - the form element
      aObservable - the parameters
  • Method Details

    • checkRequired

      public void checkRequired() throws RequiredFieldEmptyException
      Checks that all required, enabled and visible components have a value; for the first empty one a warning dialog is shown.
      Throws:
      RequiredFieldEmptyException - if a required field is empty
    • createFormComponent

      public FWAbstractFormComponent createFormComponent(org.jdom2.Element aElement, boolean aShowLabel)
      Creates and registers the form component for an element (built-in types, then the registered factories, otherwise a text component).
      Parameters:
      aElement - the component element
      aShowLabel - true to show a caption label (false e.g. for table cells)
      Returns:
      the component
    • createFormComponent

      public FWAbstractFormComponent createFormComponent(org.jdom2.Element aElement, String aID, String aFormID, net.simplace.core.FWObservable aObservable, boolean aShowLabel, int aDetachibility)
      Creates the built-in form component for the element name (see class description).
      Specified by:
      createFormComponent in interface FWFormComponentFactory
      Parameters:
      aElement - the component element
      aID - id of the component
      aFormID - id of the form
      aObservable - parameters of the functionality
      aShowLabel - true to show a caption label
      aDetachibility - detachability, one of the DETACH_* constants
      Returns:
      the component, or null for unknown element names
    • parseDetachability

      public int parseDetachability(org.jdom2.Element aElement)
      Parameters:
      aElement - the component element (attribute detachable: true, auto, button, linked)
      Returns:
      the detachability, one of the DETACH_* constants
    • fillGroupComponent

      public void fillGroupComponent(List<org.jdom2.Element> aComponentList, FWGroupFormComponent aGroupPanel)
      Replaces the components of a group (the old ones are unregistered and their parameters removed).
      Parameters:
      aComponentList - elements of the new components
      aGroupPanel - the group
    • go

      protected void go()
      Goes on to the next function, if all required fields are filled; detached windows are closed.
      Overrides:
      go in class FWDefaultPanel
    • back

      protected void back()
      Goes back to the previous function; detached windows are closed.
      Overrides:
      back in class FWDefaultPanel
    • reset

      protected void reset()
      Resets all components to their default values; called by the reset button.
      Overrides:
      reset in class FWDefaultPanel
    • cancel

      protected void cancel()
      Cancels the process; detached windows are closed.
      Overrides:
      cancel in class FWDefaultPanel
    • getLocaleValue

      protected String getLocaleValue(String aKey)
      Reads a localised text <locale prefix>.FormComponent.<key>.
      Overrides:
      getLocaleValue in class FWDefaultPanel
      Parameters:
      aKey - key of the text
      Returns:
      the localised text, or the key if it is missing or there is no main frame
    • getObservable

      public net.simplace.core.FWObservable getObservable()
      Returns:
      the parameters of the form
    • getDocument

      public com.lowagie.text.Document getDocument(int aType, String aFile)
      Writes the form as a two-column table (caption, value) to a document file.
      Parameters:
      aType - document type: PrintHelper.TYPE_RTF, PrintHelper.TYPE_HTML, otherwise PDF
      aFile - path of the file to write
      Returns:
      the (closed) document
    • addComponentFactory

      public static void addComponentFactory(FWFormComponentFactory aFactory)
      Registers a factory for additional form component types (used by all form panels).
      Parameters:
      aFactory - the factory