Class MessageBox

All Implemented Interfaces:
EventListener, IClientSessionDisposeListener, IMessageBox, IGProp<GProp<?>[]>, IPropCnr, Cloneable

public class MessageBox extends PropCnr implements IMessageBox, IClientSessionDisposeListener
The message box is a container to display a message box on the client side and wait for the user reply.
Author:
Christopher Mindus
  • Constructor Details

    • MessageBox

      public MessageBox()
      Creates the container without name with a null value without name.
  • Method Details

    • shouldSerializeToXML

      protected boolean shouldSerializeToXML(int programType)
      Method used to check for serialization to XML.
      Overrides:
      shouldSerializeToXML in class GProp<GProp<?>[]>
      Parameters:
      programType - From PropFactory.getProgramType(): 0=PropFactory.CLIENT, 1=PropFactory.SERVER or 2=PropFactory.EDITOR.
      Returns:
      false, never to XML!
    • getAppSessionMessageBox

      public MessageBox getAppSessionMessageBox()
      Gets the original AppSession instance of the message box when used in a client session.
      Returns:
      The message box, null if not from AppSession.
    • clone

      public MessageBox clone()
      Clones the message box. The new instance has no listeners.
      Overrides:
      clone in class PropCnr
      Returns:
      A new instance of the message box.
    • cloneWithListeners

      public MessageBox cloneWithListeners()
      Clones the message box and keeps all the listeners.
      Returns:
      A new instance of the message box with all the listeners.
    • onDispose

      public void onDispose(IClientSessionGyro clientGyro)
      Called when the client session is disposed of. This will inform pending message boxes about session closure.
      Specified by:
      onDispose in interface IClientSessionDisposeListener
      Parameters:
      clientGyro - The client session gyro.
    • addReplyListener

      public boolean addReplyListener(IMessageBoxReply listener)
      Adds a listener for the callback when user chooses an action for the message box.
      Parameters:
      listener - The listener.
      Returns:
      true if added, false if already added.
    • removeReplyListener

      public boolean removeReplyListener(IMessageBoxReply listener)
      Removes a listener for the callback when user chooses an action for the message box.
      Parameters:
      listener - The listener.
      Returns:
      true if removed, false if not previously added.
    • messageBox

      public void messageBox(IMessageBoxReply reply, IMessageBox.Icon icon, KString title, KString message, KString... buttons)
      Displays a message box with the specified title and message. The icon can be specified as Informational, Question, Error or None. The buttons can be specified along with the default button (when the Enter key is pressed for keyboard/desktop systems).
      Specified by:
      messageBox in interface IMessageBox
      Parameters:
      reply - The reply callback that is called when the user chooses a button or session is closed, null for none.
      icon - Icon to display, see the ICON_* values, e.g. IMessageBox.ICON_INFORMATION.
      title - The title string, must be non-null.
      message - The message to display, must be non-null.
      buttons - The strings for the buttons to display, if none, just an OK button is displayed. This array of buttons defined the index value returned by this method.
      Throws:
      NullPointerException - If icon or message is null, or if any of the elements in buttons array is null.
    • getTitle

      public KString getTitle()
      Gets the title of the message box.
      Returns:
      The title, or null for none.
    • getTitlePlainString

      public String getTitlePlainString()
      Gets the title of the message box.
      Returns:
      The title plain string converted from HTML, or null for none.
    • getMessage

      public KString getMessage()
      Gets the message text of the message box.
      Returns:
      The message text, or null for none.
    • getMessagePlainString

      public String getMessagePlainString()
      Gets the message text of the message box.
      Returns:
      The message text plain string converted from HTML, or null for none.
    • show

      public void show()
      Called to display the message box on the client.
    • onRemoteEvent

      public void onRemoteEvent(RemoteEvent event)
      Called when a remote property event should be processed by this property.
      Specified by:
      onRemoteEvent in interface IGProp<GProp<?>[]>
      Overrides:
      onRemoteEvent in class GProp<GProp<?>[]>
      Parameters:
      event - The remote event.
    • cancel

      public void cancel()
      Called to remove the message box without further processing for user or notifications.