Class FWAbstractFormComponent

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
net.simplace.pipe.formcomponents.FWAbstractFormComponent
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, net.simplace.core.FWBusyIndicator, net.simplace.core.FWObserver
Direct Known Subclasses:
FWAbstractExtendedFormComponent, FWCalibrationFormComponent, FWChartFormComponent, FWChoiceFormComponent, FWDateFormComponent, FWDoubleFormComponent, FWFileChooserFormComponent, FWGroupFormComponent, FWImageFormComponent, FWIntegerFormComponent, FWLabelFormComponent, FWMemoryMonitorFormComponent, FWProcessorButtonFormComponent, FWResultFormComponent, FWTextFormComponent

public abstract class FWAbstractFormComponent extends JPanel implements net.simplace.core.FWObserver, net.simplace.core.FWBusyIndicator
Base class of the form components shown in a form panel. A component is described by its form element (attributes title, required, enabled, visible, captionLocation (north, east, south, invisible; default west), default, requiredWarning; child elements as parameters, e.g. formFiller, formFiller.contentfield, formFiller.jumper; optional configuration element). The attributes may contain parameter tokens.

The component observes the parameters of the functionality: when a parameter used in enabled, visible, default or the form filler jumper rule changes, the component is updated. Implementations must call notifyDependentComponents() whenever their value changes, so that other components are informed.

Components can be detachable (see the DETACH_* constants): they then get buttons to copy, print, export and detach their content into a separate window.

Author:
Andreas Enders, Christoph Kunze
See Also:
  • Field Details

    • iObservable

      protected net.simplace.core.FWObservable iObservable
    • iDetachContentPanel

      protected JPanel iDetachContentPanel
    • DETACH_TRUE

      public static final int DETACH_TRUE
      Component is to be detachable
      See Also:
    • DETACH_FALSE

      public static final int DETACH_FALSE
      Default! Component looks and behaves as any other component
      See Also:
    • DETACH_AUTO

      public static final int DETACH_AUTO
      Component detaches automatically while opening the form
      See Also:
    • DETACH_BUTTON

      public static final int DETACH_BUTTON
      Component shows only a frame - while klicking the frame is extended and outpoped.
      See Also:
    • DETACH_LINKED

      public static final int DETACH_LINKED
      Component detaches automatically while opening the form, but stays linked
      See Also:
    • DETATCH_BORDER_WIDTH

      protected static final int DETATCH_BORDER_WIDTH
      See Also:
    • DETATCH_BORDER_DEFAULT_COLOR

      protected static final Color DETATCH_BORDER_DEFAULT_COLOR
    • DETATCH_BORDER_HIGHLIGHT_COLOR

      protected static final Color DETATCH_BORDER_HIGHLIGHT_COLOR
    • DETATCH_BUTTON_DEFAULT_IMAGE

      protected static final ImageIcon DETATCH_BUTTON_DEFAULT_IMAGE
    • DETATCH_BUTTON_HIGHLIGHT_IMAGE

      protected static final ImageIcon DETATCH_BUTTON_HIGHLIGHT_IMAGE
    • DETATCH_BUTTON_DISABLED_IMAGE

      protected static final ImageIcon DETATCH_BUTTON_DISABLED_IMAGE
    • COPY_BUTTON_DEFAULT_IMAGE

      protected static final ImageIcon COPY_BUTTON_DEFAULT_IMAGE
    • COPY_BUTTON_HIGHLIGHT_IMAGE

      protected static final ImageIcon COPY_BUTTON_HIGHLIGHT_IMAGE
    • COPY_BUTTON_DISABLED_IMAGE

      protected static final ImageIcon COPY_BUTTON_DISABLED_IMAGE
    • EXPORT_BUTTON_DEFAULT_IMAGE

      protected static final ImageIcon EXPORT_BUTTON_DEFAULT_IMAGE
    • EXPORT_BUTTON_HIGHLIGHT_IMAGE

      protected static final ImageIcon EXPORT_BUTTON_HIGHLIGHT_IMAGE
    • EXPORT_BUTTON_DISABLED_IMAGE

      protected static final ImageIcon EXPORT_BUTTON_DISABLED_IMAGE
  • Constructor Details

    • FWAbstractFormComponent

      protected FWAbstractFormComponent()
      Creates an uninitialised component; init(String, String, boolean, int, Element, FWObservable) has to be called by the implementation.
    • FWAbstractFormComponent

      protected FWAbstractFormComponent(String aFormID, String aFieldID, boolean aShowLabel, org.jdom2.Element aFormElement, net.simplace.core.FWObservable aObservable)
      Creates a non-detachable component.
      Parameters:
      aFormID - id of the form the component is placed in
      aFieldID - id of the component, unique within the form; also the parameter key of its value
      aShowLabel - true to show a caption label; false for use in tables
      aFormElement - the form element describing the component
      aObservable - parameters of the functionality
    • FWAbstractFormComponent

      protected FWAbstractFormComponent(String aFormID, String aFieldID, boolean aShowLabel, int aDetachable, org.jdom2.Element aFormElement, net.simplace.core.FWObservable aObservable)
      Parameters:
      aFormID - id of the form the component is placed in
      aFieldID - id of the component, unique within the form; also the parameter key of its value
      aShowLabel - true to show a caption label; false for use in tables
      aDetachable - detachability, one of the DETACH_* constants
      aFormElement - the form element describing the component
      aObservable - parameters of the functionality
  • Method Details

    • init

      protected void init(String aFormID, String aFieldID, boolean aShowLabel, int aDetachable, org.jdom2.Element aFormElement, net.simplace.core.FWObservable aObservable)
      Initialises the component: reads the attributes of the form element, sets up the detach controls and the caption label (wrapped to the label width), instantiates the form filler (parameter formFiller, old de.isdss.util.framework.ui.form.filler. class names are mapped) and calls processFormFiller(), and sets the visibility.
      Parameters:
      aFormID - id of the form the component is placed in
      aFieldID - id of the component, unique within the form; also the parameter key of its value
      aShowLabel - true to show a caption label; false for use in tables
      aDetachable - detachability, one of the DETACH_* constants
      aFormElement - the form element describing the component, or null
      aObservable - parameters of the functionality
    • setUpDetachControl

      protected void setUpDetachControl(int aDetachability)
      Sets the detachability and, for detachable components, creates the detach panel with its controls.
      Parameters:
      aDetachability - one of the DETACH_* constants
    • getValue

      public abstract Object getValue()
      Returns:
      value of the implemented component
    • setValue

      public abstract void setValue(Object aValue)
      Parameters:
      aValue - the new value of the component
    • processFormFiller

      public abstract void processFormFiller()
      Fills the component from its form filler (e.g. options or a chart); called after initialisation and whenever the jumper rule of the form filler changes.
    • getFieldID

      public String getFieldID()
      Returns:
      field id of the implemented component
    • setFormID

      public void setFormID(String aFormID)
      Parameters:
      aFormID - id of the form the component is placed in
    • getFormID

      public String getFormID()
      Returns:
      form id of the implemented component
    • setFieldID

      public void setFieldID(String aFieldID)
      Parameters:
      aFieldID - id of the component, also the parameter key of its value
    • getFormElement

      public org.jdom2.Element getFormElement()
      Returns:
      the formElement
    • getOriginalComponentParameteterValue

      protected String getOriginalComponentParameteterValue(String aKey)
      Parameters:
      aKey - parameter key
      Returns:
      the raw value of the parameter of the form element (tokens not replaced), or null
    • getComponentParameteterValue

      protected String getComponentParameteterValue(String aKey)
      Parameters:
      aKey - parameter key
      Returns:
      the value of the parameter of the form element with tokens replaced from the observable, or null
    • isRequired

      public boolean isRequired()
      Returns:
      true if the attribute required (JEXL expression) is true
    • setRequired

      public void setRequired(boolean aRequiredness)
      Sets whether the component is required; has no effect if the attribute required is set.
      Parameters:
      aRequiredness - true if a value is required
    • isEnabled

      public boolean isEnabled()
      Overrides:
      isEnabled in class Component
      Returns:
      true if the attribute enabled (JEXL expression) is true or not set
    • notifyDependentComponents

      protected void notifyDependentComponents()
      Updates the functionalities' parameter map with the current value of this control so other form components that observe the parameter map get notified. Implementations MUST call this function, whenever their value changes.
    • getConfiguration

      protected org.jdom2.Element getConfiguration()
      Returns:
      the configuration child of the form element, or null
    • setConfiguration

      protected void setConfiguration(String aClassname, org.jdom2.Element aConfigurationElement)
      Adds a configuration element to the form element.
      Parameters:
      aClassname - not used
      aConfigurationElement - the configuration element
    • hasConfiguration

      protected boolean hasConfiguration()
      Returns:
      true if the form element has a configuration child
    • getLocaleValue

      protected String getLocaleValue(String aKey, String aDefault)
      Reads a localised text <locale prefix>.FormComponent.<key> from the locale bundle of the system (LocaleBundle_<SYSTEM_ID>, or LocaleBundle).
      Parameters:
      aKey - key of the text
      aDefault - text returned if the key is missing
      Returns:
      the localised text
    • getLocaleValue

      protected String getLocaleValue(String aKey)
      Reads a localised text <locale prefix>.FormComponent.<key> from the locale bundle of the system (LocaleBundle_<SYSTEM_ID>, or LocaleBundle).
      Parameters:
      aKey - key of the text
      Returns:
      the localised text; without main frame the part of the key after the first dot
    • getPreferredSize

      public Dimension getPreferredSize()
      Overrides:
      getPreferredSize in class JComponent
    • getMaximumSize

      public Dimension getMaximumSize()
      Overrides:
      getMaximumSize in class JComponent
    • exportData

      protected void exportData()
      Called by the export button of detachable components; to be overridden by components that support export. The default only logs a warning.
    • update

      public void update(net.simplace.core.FWObservable aObservable, Object aKeyOfParameterChanged)
      Reacts to a changed parameter: re-evaluates enabled and visible (a disabled or hidden component is reset to its default), resets the default value and re-runs the form filler, if the changed parameter is used in them. Changes of the component's own value are ignored.
      Specified by:
      update in interface net.simplace.core.FWObserver
      Parameters:
      aObservable - the parameters
      aKeyOfParameterChanged - key of the changed parameter
    • hasFormFiller

      protected boolean hasFormFiller()
      Returns:
      true if a form filler was instantiated
    • getFormFiller

      protected FWAbstractFormComponentFiller getFormFiller()
      Returns:
      the form filler, or null
    • getJumper

      protected String getJumper()
      Returns:
      the jumper rule of the form filler with tokens replaced (the key passed to the filler), or the raw rule if not yet evaluated
    • getJumperRule

      protected String getJumperRule()
      Returns:
      the raw jumper rule (parameter formFiller.jumper), or null
    • getObservable

      public net.simplace.core.FWObservable getObservable()
      Returns:
      the parameters of the functionality
    • setObservable

      public void setObservable(net.simplace.core.FWObservable aObservable)
      Parameters:
      aObservable - the parameters of the functionality
    • setFormElement

      public void setFormElement(org.jdom2.Element aFormElement)
      Parameters:
      aFormElement - the form element describing the component
    • getDetachability

      public int getDetachability()
      Returns:
      the detachability, one of the DETACH_* constants
    • createDetachControls

      protected void createDetachControls(JPanel aContentPanel)
      Creates the header with the copy, print, export and detach buttons and the mouse handling (highlighting, button actions; a click elsewhere detaches the content).
      Parameters:
      aContentPanel - not used
    • attachPanel

      public void attachPanel(FWDetachFrame aDetachFrame)
      Moves the content of a detach window back into the component.
      Parameters:
      aDetachFrame - the detach window
    • disposePanel

      public void disposePanel(FWDetachFrame aDetachFrame)
      Closes a detach window without moving its content back.
      Parameters:
      aDetachFrame - the detach window
    • detachPanel

      public void detachPanel(boolean aUpdateContent)
      Moves the content into a separate window (if the component is detachable) and shows a placeholder in the form; for DETACH_AUTO and DETACH_LINKED the window stays on top.
      Parameters:
      aUpdateContent - true to update the first existing detach window (a new one is opened if there is none), false to open a new one
    • setDetachControlsHighlighted

      protected void setDetachControlsHighlighted(boolean aHighlighted)
      Makes the detach button and related controls appear highlighted or not (no effect while they are disabled).
      Parameters:
      aHighlighted - true to highlight
    • setDetachControlsEnabled

      protected void setDetachControlsEnabled(boolean aEnabled)
      Sets the enabled state of the detach button to aEnabled and clears the highlighted state if aEnabled is false. To query the enabled state, use the isEnabled method of iDetachButton!
      Parameters:
      aEnabled - true to enable the detach controls
    • remove

      public void remove(Component aComp)
      Removes a component; for detachable components content is removed from the detach panel (DETACH_BUTTON: ignored).
      Overrides:
      remove in class Container
      Parameters:
      aComp - the component to remove
    • add

      public void add(Component aComp, Object aConstraints)
      Adds a component without scroll bar (see add(Component, Object, boolean)).
      Overrides:
      add in class Container
      Parameters:
      aComp - the component to add
      aConstraints - layout constraints
    • add

      public void add(Component aComp, Object aConstraints, boolean aUseScrollbar)
      Adds a component. For detachable components the component becomes the detachable content (it must be a JPanel) and is placed in the detach panel, replacing a placeholder; DETACH_BUTTON components only show a placeholder.
      Parameters:
      aComp - the component to add
      aConstraints - layout constraints
      aUseScrollbar - true to wrap detachable content in a scroll pane
    • isClosingRequired

      public boolean isClosingRequired()
      Returns:
      true if detach windows of this component are still open (and may have to be closed with the form)
    • closeFormComponent

      public void closeFormComponent()
      Called when the form is closed: disposes the open detach windows.
    • getTitle

      public String getTitle()
      Returns:
      the Title of Component
    • getSystemID

      public String getSystemID()
      Returns:
      the SystemID of Component
    • setTitle

      public void setTitle(String aTitle)
      Sets the title and updates the caption label.
      Parameters:
      aTitle - the title; null is ignored
    • setDefault

      public void setDefault()
      Sets the value to the attribute default (tokens replaced), if given.
    • toString

      public String toString()
      Overrides:
      toString in class Component
    • getRequiredWarning

      public String getRequiredWarning()
      Returns:
      the attribute requiredWarning (tokens replaced), or the localised default warning
    • getCells

      public com.lowagie.text.Rectangle[] getCells(int aType)
      Creates the iText cells for printing or exporting the form: caption cell and value cell, or a value cell spanning two columns if no caption is shown.
      Parameters:
      aType - output type, e.g. PrintHelper.TYPE_PDF
      Returns:
      the cells
    • getValueCell

      protected abstract com.lowagie.text.Rectangle getValueCell(int aType)
      Returns the value cell used for generating the RTF, PDF or HTML version of the form.
      Parameters:
      aType - output type, e.g. PrintHelper.TYPE_PDF
      Returns:
      an iText cell (PdfPCell for PDF, Cell otherwise)
    • showBusy

      public void showBusy(int aStep)
      Shows the progress cursor of the given step while the parameters notify their observers.
      Specified by:
      showBusy in interface net.simplace.core.FWBusyIndicator
      See Also:
      • FWBusyIndicator.showBusy(int)
    • hideBusy

      public void hideBusy()
      Restores the default cursor.
      Specified by:
      hideBusy in interface net.simplace.core.FWBusyIndicator
      See Also:
      • FWBusyIndicator.hideBusy()