Class FWClientContext

java.lang.Object
net.simplace.core.FWClientContext

public class FWClientContext extends Object
Access of the core (simulation, services) to the client that runs it: the layout settings and the interaction with the user. The core never opens windows itself; it asks the current context.

This class is the headless context used by console, REST service and wrappers: there is no user, no layout and no dialog; messages are logged and every question is answered with its default. A graphical client registers its own subclass with set(FWClientContext) at start-up.

Author:
Andreas Enders
  • Constructor Details

    • FWClientContext

      public FWClientContext()
  • Method Details

    • get

      public static FWClientContext get()
      Returns:
      the context in use, never null
    • set

      public static void set(FWClientContext aContext)
      Registers the context of a client.
      Parameters:
      aContext - the context; null restores the headless context
    • getLocalePrefix

      public String getLocalePrefix()
      Returns:
      locale prefix of the client layout (e.g. de.isdss.LAPClient), or null without layout
    • isDevelopmentMode

      public boolean isDevelopmentMode()
      Returns:
      true if the client runs in development mode (missing locale entries show their key)
    • getDefaultSystemSettings

      public Map<String,Object> getDefaultSystemSettings()
      Returns:
      default system settings of the client layout, or null without layout
    • doesScenarioNameExist

      public boolean doesScenarioNameExist(String aSystemID, String aName)
      Parameters:
      aSystemID - id of the system
      aName - scenario name
      Returns:
      true if the system already has a saved scenario with this name
    • showInfo

      public void showInfo(String aMessage)
      Shows an information to the user; headless it is logged.
      Parameters:
      aMessage - the message (may contain HTML)
    • showWarning

      public void showWarning(String aMessage)
      Shows a warning to the user; headless it is logged.
      Parameters:
      aMessage - the message
    • chooseEntryPair

      public String[] chooseEntryPair(String aTitle, String aMessage, List<String> aFirstList, List<String> aSecondList)
      Lets the user choose a pair of entries from two lists, e.g. a key of a resource.
      Parameters:
      aTitle - title of the question
      aMessage - explanation
      aFirstList - entries of the first list
      aSecondList - entries of the second list
      Returns:
      the chosen entries (first, second), or null if nothing was chosen; headless always null
    • askText

      public String askText(String aTitle, String aMessage, String aDefault, boolean aHidden)
      Asks the user for a text, e.g. a user name or a password.
      Parameters:
      aTitle - title of the question
      aMessage - explanation
      aDefault - preset text
      aHidden - true to hide the input (password)
      Returns:
      the entered text, or null if the question is cancelled; headless always null
    • chooseOption

      public int chooseOption(String aTitle, String aPreview, String[] aOptions, int aDefaultIndex)
      Lets the user choose one of several options.
      Parameters:
      aTitle - title of the question
      aPreview - text shown above the choice, e.g. the first lines of a file; may be null
      aOptions - the options
      aDefaultIndex - index of the preselected option
      Returns:
      index of the chosen option; the default index if the question is cancelled and headless