Class Tooltip

java.lang.Object
overit.geocall.ui.Tooltip
All Implemented Interfaces:
SingleUseComponent

public class Tooltip extends Object implements SingleUseComponent
The class implements the user interface element that should be used to display on-screen messages that appears in popups but without blocking the user interaction. For this reason they can be informational messages or messages that contains some details that must be showed only on demand. When the tooltip appears, the user can interact with it or not. If the user click anywhere outside from the tooltip, the tooltip will be closed.
The tooltip can be active, so it can contain buttons and radio params that allows the user to make a choice from a list of possibilities.
The class implements the SingleUseComponent interface.
  • Field Details

  • Constructor Details

    • Tooltip

      public Tooltip(Teacher teacher)
      Creates an empty tooltip
      Parameters:
      teacher - The component that manage the translations (see Teacher)
    • Tooltip

      public Tooltip(String title, String message, Teacher teacher)
      Creates a tooltip with the specific title and message
      Parameters:
      title - The string that appears in the header of the tooltip
      message - The message that appears in the tooltip's body
      teacher - The component that manage the translations (see Teacher)
  • Method Details

    • getTeacher

      public Teacher getTeacher()
      Returns the Teacher, the object that manages the translations
      Returns:
      The Teacher that manages the translations
    • setTitle

      public void setTitle(String title)
      Sets the title of the tooltip, the string that appears in the tooltip's header
      Parameters:
      title - The title that appears in the header
    • setMessage

      public void setMessage(String message)
      Sets the message of the tooltip, the string that appears in the tooltip's body
      Parameters:
      message - The message that appears in the body
    • setMessage

      public void setMessage(String sMessage, Object[] oo)
      Sets the message (see TextFormat) of the tooltip and the objects that will be used to fill in the message
      Parameters:
      sMessage - The message that appears in the body
      oo - The objects that will be used to fill in the message
    • setMessage

      public void setMessage(String sMessage, Map params)
      Sets the message (see MapFormat) of the tooltip and the map that will be used to fill in the message
      Parameters:
      sMessage - The message that appears in the body
      params - The map that will be used to fill in the message
    • getTitle

      public String getTitle()
      Returns the tooltip's title
      Returns:
      The string that represents the tooltip title
    • getMessage

      public String getMessage()
      Returns the tooltip's message
      Returns:
      The string that represents the tooltip message
    • setDefaultButton

      public void setDefaultButton(int def)
      Sets wich one must be the default button for the tooltip
      Parameters:
      def - The integer that defines the position (from left to right) of the button that must be the default one
    • addButton

      public void addButton(String label, String icon, String event, String id)
      Adds a clickable button (Tooltip.Button) to the bottom of the tooltip
      Parameters:
      label - The label that appears on the button
      icon - The icon that appears on the button
      event - The event triggered when the user clicks on the button
      id - The target for the event
    • addButton

      public void addButton(String label, String icon, String event, String id, String param, String msg, String prompt)
      Adds a clickable button (Tooltip.Button) to the bottom of the tooltip
      Parameters:
      label - The label that appears on the button
      icon - The icon that appears on the button
      event - The event triggered when the user clicks on the button
      id - The target for the event
      param - The parameter passed to the event triggered when the user clicks the button
      msg - The string that appears as a message when the user clicks the button
      prompt - The string that appears as a prompt when the user clicks the button
    • addRadioParam

      public void addRadioParam(String label, String param, boolean def)
      Adds a radio param (Tooltip.RadioParam) to the body of the tooltip. Use this method to add multiple choices selectable with a single button, and prevent a large number of buttons.
      Parameters:
      label - The label string associated to the chioce
      param - The parameter associated to the chioce, passed to the event of the button of the tooltip
      def - true if this one must be the default selected choice when the tooltip appears, false otherwise
    • add

      public void add(Tooltip.Button button)
      Adds a Tooltip.Button to the bottom of the tooltip
      Parameters:
      button - The button to add to the tooltip
    • add

      public void add(Tooltip.RadioParam radio)
      Adds a Tooltip.RadioParam to the body of the tooltip
      Parameters:
      radio - The radio param to add to the tooltip
    • getButtons

      public ArrayList getButtons()
      Returns the list of Tooltip.Button of the tooltip
      Returns:
      The list of buttons
    • getHtml

      public org.apache.ecs.Element getHtml(EntitySet es, Window w)
      Returns the html code of the alert
      Specified by:
      getHtml in interface SingleUseComponent
      Parameters:
      es - The EntitySet to which the element belongs
      w - The Window currently displayed
      Returns:
      The html code of the alert
    • getFooter

      protected org.apache.ecs.Element getFooter(EntitySet es, Window w)
    • buildSetupScript

      public void buildSetupScript(StringBuilder sb)
      Every component can add a script to the StringBuilder, script executed when the component is created The method add the script that manage the creation and showing of the tooltip
      Specified by:
      buildSetupScript in interface SingleUseComponent
      Parameters:
      sb - The StringBuilder on which we want to add the script