Package org.cesilko.rachota.gui
Class Tools
java.lang.Object
org.cesilko.rachota.gui.Tools
Helper class providing support for time conversion between
long, Date and String formats and other static functions.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
beep
(int type) Produce couple of warning beeps at user when necessary.static Font
getFont()
Returns font that should be used for all UI components based on the language preferences or specified by user.static long
static String
getRID()
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
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
setupSelectAllListener
(JSpinner spinner) Sets up a focus gained listener to theJSpinner
that selects all text currently in the text field of the suppliedJSpinner
.
-
Field Details
-
title
Name and version of application.- See Also:
-
build
Build number.- See Also:
-
BEEP_WARNING
public static final int BEEP_WARNINGWarning type of beep.- See Also:
-
BEEP_NOTIFICATION
public static final int BEEP_NOTIFICATIONNotification type of beep.- See Also:
-
-
Constructor Details
-
Tools
public Tools()
-
-
Method Details
-
getTime
Transforms time in milliseconds to text string.- Parameters:
time
- Time in milliseconds.- Returns:
- Textual representation of time in format hh:mm:ss.
-
getTimeShort
Transforms time in milliseconds to text string.- Parameters:
time
- Time in milliseconds.- Returns:
- Textual representation of time in format hh:mm.
-
getTime
Transforms time of Date to text string.- Parameters:
time
- Time in Date object.- Returns:
- Textual representation of time in format hh:mm.
-
getTime
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
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
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
Returns unique Rachota identification string.- Returns:
- Rachota identification string.
-
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
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.
-