Class FWAbstractFunctionality

java.lang.Object
java.lang.Thread
net.simplace.pipe.functionality.FWAbstractFunctionality
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
BrowserFunctionality, EditXMLFunctionality, FormFunctionality, PDFViewerFunctionality, PipeLineFunctionality, RuleFunctionality, ShowImageFunctionality, SimEnvGraphFunctionality

public abstract class FWAbstractFunctionality extends Thread
Base class of functionalities, the functions of the GUI framework. A functionality is instantiated by class name via FWFunctionalityFactory from a FWFunctionalityModel; startFunctionality() is called whenever it is run.

The parameters of the function element and the parameters passed along the chain of functions are handled here; implementations have access to the main frame and the selected tab of the tab view.

Author:
Andreas Enders
  • Field Details

  • Constructor Details

    • FWAbstractFunctionality

      protected FWAbstractFunctionality()
      Protected default constructor, used for instantiation by class name.
  • Method Details

    • initialize

      protected void initialize(Map<String,Object> aParameterMap)
      Initialises the functionality with parameters only (no function model).
      Parameters:
      aParameterMap - initial parameters
    • initialize

      protected void initialize(FWFunctionalityModel aFunctionModel)
      Initialises the functionality with its model; the initial parameters are taken from the model.
      Parameters:
      aFunctionModel - the function model
    • startFunctionality

      protected abstract void startFunctionality() throws Exception
      Implements the function; called whenever the functionality is run.
      Throws:
      Exception - if the function fails
    • getFunctionElement

      protected org.jdom2.Element getFunctionElement()
      Returns:
      the function element of the model
    • runFunctionality

      public net.simplace.core.FWObservable runFunctionality() throws Exception
      Runs the functionality: in its own thread if the parameter own_thread is true, otherwise synchronously.
      Returns:
      the parameters after the run; when run in its own thread, the current parameters (possibly null) are returned immediately
      Throws:
      Exception - if the synchronous run fails
    • run

      public void run()
      Thread entry: calls startFunctionality(); errors are logged.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • getID

      public String getID()
      Returns:
      id of the function, or null without function model
    • getSystemID

      public String getSystemID()
      Returns:
      id of the system the function belongs to (the function id if none is set)
    • getOID

      public String getOID()
      Returns:
      unique object id of this functionality instance, or null without function model (created with a parameter map)
    • getStringParameterValue

      public String getStringParameterValue(String aKey)
      Parameters:
      aKey - parameter key
      Returns:
      the parameter as string (tokens replaced), or null if not set
    • getParameter

      public Object getParameter(String aKey)
      Parameters:
      aKey - parameter key
      Returns:
      the parameter value, or null if not set
    • getMainFrame

      public FWMainFrame getMainFrame()
      Returns:
      MainFrame of application
    • getMainComponent

      public Component getMainComponent()
      Returns:
      selected tab panel of TabView
    • getObservable

      public net.simplace.core.FWObservable getObservable()
      Returns:
      the parameters passed along the chain of functions (created from the initial parameters on first call)
    • getNextFunction

      public String getNextFunction()
      Returns:
      id of the next function (attribute nextFunction, tokens replaced), or null (also without function model)
    • getPreviousFunction

      public String getPreviousFunction()
      Returns:
      id of the previous function (attribute previousFunction, tokens replaced), or null (also without function model)
    • shouldFunctionBeRun

      public boolean shouldFunctionBeRun() throws PipeLineException
      Evaluates the attribute if of the function (see FWPipeLineHelper.checkIfExpression(String, FWObservable)).
      Returns:
      true if the function should be run (always without function model)
      Throws:
      PipeLineException - declared, not thrown
    • setOutputParameter

      public void setOutputParameter(String aKey, Object aValue)
      Parameters:
      aKey - parameter key
      aValue - the value
    • setObservable

      public void setObservable(net.simplace.core.FWObservable aOservable)
      Sets the parameters; the initial parameters are added (and overwrite existing ones).
      Parameters:
      aOservable - the new parameters
    • getLocaleValue

      protected String getLocaleValue(String aKey)
      Reads a localised text with the prefix of the layout provider plus SYSTEM_ID.
      Parameters:
      aKey - key of the text
      Returns:
      the localised text
    • stopThread

      public boolean stopThread()
      Interrupts the current thread if it is still running, and this functionality's thread.
      Returns:
      true if a current thread was set, false otherwise
    • setRunningThread

      protected void setRunningThread(Thread aCurrentThread)
      Parameters:
      aCurrentThread - the thread running the function
    • hasInfoElements

      public boolean hasInfoElements()
      Returns:
      true if the function element has info children (false without function model)
    • getInfoElements

      public Collection<org.jdom2.Element> getInfoElements()
      Returns:
      the info children of the function element (empty without function model)
    • getCenterPanel

      public JPanel getCenterPanel()
      Returns:
      center Panel
    • setCenterPanel

      public void setCenterPanel(JPanel aCenterPanel)
      Parameters:
      aCenterPanel - the center panel of the function
    • getCurrentThread

      public Thread getCurrentThread()
      Returns:
      the current Thread
    • toXML

      public org.jdom2.Element toXML()
      Returns:
      an XML description of this functionality; not implemented, always null