Class Tools

java.lang.Object
org.cesilko.rachota.gui.Tools

public class Tools extends Object
Helper class providing support for time conversion between long, Date and String formats and other static functions.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Notification type of beep.
    static final int
    Warning type of beep.
    static final String
    Build number.
    static final String
    Name and version of application.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    beep(int type)
    Produce couple of warning beeps at user when necessary.
    static Font
    Returns font that should be used for all UI components based on the language preferences or specified by user.
    static long
     
    static String
    Returns unique Rachota identification string.
    static String
    getTime(double time)
    Transforms time in milliseconds to text string.
    static long
    Transforms text string to time in milliseconds.
    static String
    getTime(Date time)
    Transforms time of Date to text string.
    static String
    getTimeShort(double time)
    Transforms time in milliseconds to text string.
    static long
    getTotalTime(boolean includeIdleTime, boolean includePrivateTime, Vector days)
    Returns total time measured in selected period.
    static void
     
    static String
    replaceAll(String text, String oldText, String newText)
    Returns text string that has all occurences of oldText strings replaced by newText string.
    static void
    Sets up a focus gained listener to the JSpinner that selects all text currently in the text field of the supplied JSpinner.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Tools

      public Tools()
  • Method Details

    • getTime

      public static String getTime(double time)
      Transforms time in milliseconds to text string.
      Parameters:
      time - Time in milliseconds.
      Returns:
      Textual representation of time in format hh:mm:ss.
    • getTimeShort

      public static String getTimeShort(double time)
      Transforms time in milliseconds to text string.
      Parameters:
      time - Time in milliseconds.
      Returns:
      Textual representation of time in format hh:mm.
    • getTime

      public static String getTime(Date time)
      Transforms time of Date to text string.
      Parameters:
      time - Time in Date object.
      Returns:
      Textual representation of time in format hh:mm.
    • getTime

      public static long getTime(String text) throws NumberFormatException
      Transforms text string to time in milliseconds.
      Parameters:
      text - Textual representation of time in format hh:mm or hh:mm:ss.
      Returns:
      Time in milliseconds.
      Throws:
      NumberFormatException - in case format of time does not comply with hh:mm:ss format.
    • getTotalTime

      public static long getTotalTime(boolean includeIdleTime, boolean includePrivateTime, Vector days)
      Returns total time measured in selected period.
      Parameters:
      includeIdleTime - Should idle time be included in the total time?
      includePrivateTime - Should private time be included in the total time?
      days - Vector of days whose total time should be counted.
      Returns:
      Total time measured in selected period including idle time and private time if desired.
    • replaceAll

      public static String replaceAll(String text, String oldText, String newText)
      Returns text string that has all occurences of oldText strings replaced by newText string.
      Parameters:
      text - String where all occurences of oldText should be replaced.
      oldText - Substring to be searched for in text string.
      newText - New replacement string for all occurences of oldText string.
      Returns:
      Text string with all occurences of oldText replaced by newText strings.
    • beep

      public static void beep(int type)
      Produce couple of warning beeps at user when necessary.
      Parameters:
      type - Type of beep i.e. BEEP_NOTIFICATION or BEEP_WARNING.
    • getRID

      public static String getRID()
      Returns unique Rachota identification string.
      Returns:
      Rachota identification string.
    • getFont

      public static Font getFont()
      Returns font that should be used for all UI components based on the language preferences or specified by user.
      Returns:
      Font to be used across Rachota UI components.
    • recordActivity

      public static void recordActivity()
    • getInactivity

      public static long getInactivity()
    • setupSelectAllListener

      public static void setupSelectAllListener(JSpinner spinner)
      Sets up a focus gained listener to the JSpinner that selects all text currently in the text field of the supplied JSpinner.
      Parameters:
      spinner - The JSpinner to add a select all listener to.