Class UI

java.lang.Object
org.jpos.ui.UI
All Implemented Interfaces:
UIFactory, UIObjectFactory
Direct Known Subclasses:
BSHUI

public class UI extends Object implements UIFactory, UIObjectFactory
Central controller for the jPOS Swing-based GUI; manages UI components and their factories.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    UI()
    Create a new UI object
    UI(org.jdom2.Element config)
    Creates a new UI object
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Configures this UI from the stored XML element.
    protected void
    configure(org.jdom2.Element ui)
    Configures the UI from the given XML element.
    create(org.jdom2.Element e)
    Creates a Swing component from the given XML element descriptor.
    create(UI ui, org.jdom2.Element e)
    UI is itself a UIFactory.
    void
    dispose this UI object
    protected JComponent
    doScript(JComponent component, org.jdom2.Element e)
    Applies any script element to the component; default implementation is a no-op.
    get(String id)
    Returns the component registered under the given id.
    Returns the Log instance, or null if none was set.
    Returns the application's main frame.
    UI uses a map to hold references to its components ("id" attribute)
    boolean
    Returns true if this UI object has been disposed.
    Instantiates an object by class name using the current thread's context class loader.
    void
    reconfigure(String elementName, String panelName)
    reconfigure can be used in order to re-configure components inside a container (i.e.
    void
    setConfig(org.jdom2.Element config)
    Sets the XML configuration element for this UI.
    void
    setLog(Log log)
    Sets the optional Log instance used for diagnostic output.
    protected void
    setLookAndFeel(org.jdom2.Element ui)
    Applies the look-and-feel specified in the UI configuration element.
    void
    Assigns an object factory use to create new object instances.
    protected void
    warn(Object obj)
    Logs a warning.
    protected void
    warn(Object obj, Exception ex)
    Logs a warning with an associated exception.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • UI

      public UI()
      Create a new UI object
    • UI

      public UI(org.jdom2.Element config)
      Creates a new UI object
      Parameters:
      config - configuration element
  • Method Details

    • setObjectFactory

      public void setObjectFactory(UIObjectFactory objFactory)
      Assigns an object factory use to create new object instances. If no object factory is asigned, UI uses the default classloader
      Parameters:
      objFactory - reference to an Object Factory
    • setConfig

      public void setConfig(org.jdom2.Element config)
      Sets the XML configuration element for this UI.
      Parameters:
      config - the Configuration element
    • setLog

      public void setLog(Log log)
      Sets the optional Log instance used for diagnostic output.
      Parameters:
      log - an optional Log instance
      See Also:
    • getLog

      public Log getLog()
      Returns the Log instance, or null if none was set.
      Returns:
      the Log, or null
    • getRegistrar

      public Map getRegistrar()
      UI uses a map to hold references to its components ("id" attribute)
      Returns:
      UI component registrar
    • get

      public Object get(String id)
      Returns the component registered under the given id.
      Parameters:
      id - Component id ("id" configuration attribute)
      Returns:
      the Object or null
    • create

      public JComponent create(UI ui, org.jdom2.Element e)
      UI is itself a UIFactory. This strategy is used to recursively instantiate components inside a container
      Specified by:
      create in interface UIFactory
      Parameters:
      ui - reference to this UI instance
      e - free form configuration Element
      Returns:
      JComponent
    • newInstance

      public Object newInstance(String clazz) throws Exception
      Instantiates an object by class name using the current thread's context class loader.
      Specified by:
      newInstance in interface UIObjectFactory
      Parameters:
      clazz - fully qualified class name
      Returns:
      new instance
      Throws:
      Exception - if the class cannot be found or instantiated
    • configure

      public void configure() throws org.jdom2.JDOMException
      Configures this UI from the stored XML element.
      Throws:
      org.jdom2.JDOMException - on XML processing error
    • reconfigure

      public void reconfigure(String elementName, String panelName)
      reconfigure can be used in order to re-configure components inside a container (i.e. changing a panel in response to an event).
      Parameters:
      elementName - the element name used as new configuration
      panelName - panel ID (see "id" attribute)
      See Also:
    • dispose

      public void dispose()
      dispose this UI object
    • isDestroyed

      public boolean isDestroyed()
      Returns true if this UI object has been disposed.
      Returns:
      true if this UI object has been disposed and is no longer valid
    • configure

      protected void configure(org.jdom2.Element ui) throws org.jdom2.JDOMException
      Configures the UI from the given XML element.
      Parameters:
      ui - the root UI configuration element
      Throws:
      org.jdom2.JDOMException - on XML processing error
    • setLookAndFeel

      protected void setLookAndFeel(org.jdom2.Element ui)
      Applies the look-and-feel specified in the UI configuration element.
      Parameters:
      ui - the UI configuration element
    • doScript

      protected JComponent doScript(JComponent component, org.jdom2.Element e)
      Applies any script element to the component; default implementation is a no-op.
      Parameters:
      component - the target component
      e - the script XML element
      Returns:
      the component after script application
    • create

      public JComponent create(org.jdom2.Element e)
      Creates a Swing component from the given XML element descriptor.
      Parameters:
      e - the XML element describing the component
      Returns:
      the created JComponent, or null if none was produced
    • getMainFrame

      public JFrame getMainFrame()
      Returns the application's main frame.
      Returns:
      the main JFrame
    • warn

      protected void warn(Object obj)
      Logs a warning.
      Parameters:
      obj - the warning object
    • warn

      protected void warn(Object obj, Exception ex)
      Logs a warning with an associated exception.
      Parameters:
      obj - the warning object
      ex - the associated exception