Package org.cesilko.rachota.gui
Class Tools
- java.lang.Object
-
- org.cesilko.rachota.gui.Tools
-
public class Tools extends java.lang.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 int
BEEP_NOTIFICATION
Notification type of beep.static int
BEEP_WARNING
Warning type of beep.static java.lang.String
build
Build number.static java.lang.String
title
Name and version of application.
-
Constructor Summary
Constructors Constructor Description Tools()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
beep(int type)
Produce couple of warning beeps at user when necessary.static java.awt.Font
getFont()
Returns font that should be used for all UI components based on the language preferences or specified by user.static long
getInactivity()
static java.lang.String
getRID()
Returns unique Rachota identification string.static java.lang.String
getTime(double time)
Transforms time in milliseconds to text string.static long
getTime(java.lang.String text)
Transforms text string to time in milliseconds.static java.lang.String
getTime(java.util.Date time)
Transforms time of Date to text string.static java.lang.String
getTimeShort(double time)
Transforms time in milliseconds to text string.static long
getTotalTime(boolean includeIdleTime, boolean includePrivateTime, java.util.Vector days)
Returns total time measured in selected period.static void
recordActivity()
static java.lang.String
replaceAll(java.lang.String text, java.lang.String oldText, java.lang.String newText)
Returns text string that has all occurences of oldText strings replaced by newText string.static void
setupSelectAllListener(javax.swing.JSpinner spinner)
Sets up a focus gained listener to theJSpinner
that selects all text currently in the text field of the suppliedJSpinner
.
-
-
-
Field Detail
-
title
public static final java.lang.String title
Name and version of application.- See Also:
- Constant Field Values
-
build
public static final java.lang.String build
Build number.- See Also:
- Constant Field Values
-
BEEP_WARNING
public static final int BEEP_WARNING
Warning type of beep.- See Also:
- Constant Field Values
-
BEEP_NOTIFICATION
public static final int BEEP_NOTIFICATION
Notification type of beep.- See Also:
- Constant Field Values
-
-
Method Detail
-
getTime
public static java.lang.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 java.lang.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 java.lang.String getTime(java.util.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(java.lang.String text) throws java.lang.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:
java.lang.NumberFormatException
- in case format of time does not comply with hh:mm:ss format.
-
getTotalTime
public static long getTotalTime(boolean includeIdleTime, boolean includePrivateTime, java.util.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 java.lang.String replaceAll(java.lang.String text, java.lang.String oldText, java.lang.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 java.lang.String getRID()
Returns unique Rachota identification string.- Returns:
- Rachota identification string.
-
getFont
public static java.awt.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(javax.swing.JSpinner spinner)
Sets up a focus gained listener to theJSpinner
that selects all text currently in the text field of the suppliedJSpinner
.- Parameters:
spinner
- TheJSpinner
to add a select all listener to.
-
-