Class DialogMessageLogger

  • All Implemented Interfaces:
    MessageLogger

    public class DialogMessageLogger
    extends java.lang.Object
    implements MessageLogger

    A class to write log and status messages to a scrolling text area in a dialog box.

    • Constructor Summary

      Constructors 
      Constructor Description
      DialogMessageLogger​(java.lang.String titleMessage, int width, int height, boolean exitApplicationOnClose)
      Construct a logger and make it immediately visible.
      DialogMessageLogger​(java.lang.String titleMessage, int width, int height, boolean exitApplicationOnClose, boolean visible)
      Construct a slf4jlogger.
      DialogMessageLogger​(java.lang.String titleMessage, int width, int height, boolean exitApplicationOnClose, boolean visible, boolean showDateTime, java.lang.String dateTimeFormat)
      Construct a slf4jlogger.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void createGUI​(java.lang.String titleMessage, int width, int height, boolean exitApplicationOnClose, boolean visible, boolean showDateTime, java.lang.String dateTimeFormat)
      Construct the GUI for a slf4jlogger.
      void send​(java.lang.String message)
      Append the supplied text to the log.
      void sendLn​(java.lang.String message)
      Append the supplied text to the log, followed by a new line.
      void setDateTimeFormat​(java.lang.String pattern)
      Set the date format to use
      void setVisible​(boolean visible)  
      void showDateTime​(boolean showDateTime)
      Whether or not to show a timestamp.
      protected void timestamp()  
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • outputDialog

        protected javax.swing.JDialog outputDialog
      • outputScrollPane

        protected javax.swing.JScrollPane outputScrollPane
      • outputTextArea

        protected javax.swing.JTextArea outputTextArea
      • startTimeForLogging

        protected static long startTimeForLogging
      • showDateTime

        protected boolean showDateTime
      • dateFormatter

        protected java.text.SimpleDateFormat dateFormatter
    • Constructor Detail

      • DialogMessageLogger

        public DialogMessageLogger​(java.lang.String titleMessage,
                                   int width,
                                   int height,
                                   boolean exitApplicationOnClose)

        Construct a logger and make it immediately visible.

        Parameters:
        titleMessage - for the title bar of the dialog box
        width - initial width of the resizeable dialog box
        height - initial height of the resizeable dialog box
        exitApplicationOnClose - if true, when the dialog box is closed (X-d out), will exit the application with success status
      • DialogMessageLogger

        public DialogMessageLogger​(java.lang.String titleMessage,
                                   int width,
                                   int height,
                                   boolean exitApplicationOnClose,
                                   boolean visible)

        Construct a slf4jlogger.

        Parameters:
        titleMessage - for the title bar of the dialog box
        width - initial width of the resizeable dialog box
        height - initial height of the resizeable dialog box
        exitApplicationOnClose - if true, when the dialog box is closed (X-d out), will exit the application with success status
        visible - if true, will be made visible after construction
      • DialogMessageLogger

        public DialogMessageLogger​(java.lang.String titleMessage,
                                   int width,
                                   int height,
                                   boolean exitApplicationOnClose,
                                   boolean visible,
                                   boolean showDateTime,
                                   java.lang.String dateTimeFormat)

        Construct a slf4jlogger.

        Parameters:
        titleMessage - for the title bar of the dialog box
        width - initial width of the resizeable dialog box
        height - initial height of the resizeable dialog box
        exitApplicationOnClose - if true, when the dialog box is closed (X-d out), will exit the application with success status
        visible - if true, will be made visible after construction
        showDateTime - if true, show a timestamp
        dateTimeFormat - a java.text.SimpleDateFormat pattern
    • Method Detail

      • showDateTime

        public void showDateTime​(boolean showDateTime)

        Whether or not to show a timestamp.

        Parameters:
        showDateTime - if true, show a timestamp
      • setDateTimeFormat

        public void setDateTimeFormat​(java.lang.String pattern)

        Set the date format to use

        If not set will use relative time in ms from start of application

        Parameters:
        pattern - a java.text.SimpleDateFormat pattern
      • createGUI

        protected void createGUI​(java.lang.String titleMessage,
                                 int width,
                                 int height,
                                 boolean exitApplicationOnClose,
                                 boolean visible,
                                 boolean showDateTime,
                                 java.lang.String dateTimeFormat)

        Construct the GUI for a slf4jlogger.

        Parameters:
        titleMessage - for the title bar of the dialog box
        width - initial width of the resizeable dialog box
        height - initial height of the resizeable dialog box
        exitApplicationOnClose - if true, when the dialog box is closed (X-d out), will exit the application with success status
        visible - if true, will be made visible after construction
        showDateTime - if true, show a timestamp
        dateTimeFormat - a java.text.SimpleDateFormat pattern
      • setVisible

        public void setVisible​(boolean visible)
      • timestamp

        protected void timestamp()
      • send

        public void send​(java.lang.String message)
        Description copied from interface: MessageLogger

        Append the supplied text to the log.

        Specified by:
        send in interface MessageLogger
        Parameters:
        message - the (possibly multi-line) text to append to the log
      • sendLn

        public void sendLn​(java.lang.String message)
        Description copied from interface: MessageLogger

        Append the supplied text to the log, followed by a new line.

        Specified by:
        sendLn in interface MessageLogger
        Parameters:
        message - the (possibly multi-line) text to append to the log