|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsemorg.sql.util.Utility
public class Utility
Utility-Class which encapsulates some useful methods for the database and GUi layer.
| Field Summary | |
|---|---|
static String |
ATOSJ_COMPONENT_NAME_KEY
Needed for regression tests with ATOSj. |
static org.eclipse.swt.events.FocusListener |
checkCorrectFloatListener
Checks if the entered String is a valid float number. |
static org.eclipse.swt.events.FocusListener |
checkCorrectIntListener
Checks if the entered String is a valid integer. |
static org.eclipse.swt.events.FocusListener |
checkEmptyListener
Colors empty mandatory fields with red color if they loose the focus. |
static DateFormat |
dateAndTimeFormatter
Date and time formatter using standard localization. |
static DateFormat |
dateOnlyFormatter
Date formatter using standard localization. |
private static NumberFormat |
floatParser
Parses strings for floating-point numbers. |
private static org.eclipse.jface.resource.ImageRegistry |
imgReg
A registry containing all Image objects of the application. |
static org.eclipse.swt.graphics.Color |
LIGHT_RED
Color instance for yellow-coloring of text fields (mandatory
fields). |
static org.eclipse.swt.graphics.Color |
LIGHT_YELLOW
Color instance for red-coloring of text fields (unfilled
mandatory fields). |
static DateFormat |
timeOnlyFormatter
Time formatter using the format HH:mm. |
| Constructor Summary | |
|---|---|
Utility()
|
|
| Method Summary | |
|---|---|
static void |
alignRight(org.eclipse.swt.widgets.Control label)
Aligns a Label right. |
static Object[] |
castArray(Object[] array,
Class clazz)
Does a type cast of all elements of a given array. |
static Date |
convertToSQLDate(Date date)
Converts a JAVA date into SQL date. |
static Timestamp |
convertToTimestamp(Date date)
Converts a JAVA timestamp inti a SQL timestamp. |
static String |
createFloatText(Float theFloat)
Creates a string from a given Float object. |
static org.eclipse.swt.widgets.Text |
createTextTab(org.eclipse.swt.widgets.TabFolder parent,
String name,
org.eclipse.swt.graphics.Font font,
int limit)
Creates a tab whose contents is a Label and a Text field. |
static void |
disposeImages()
Disposes all images by disposing the ImageRegistry. |
static org.eclipse.swt.layout.FormData |
getFormData(Object topPercentage,
int topOffset,
Object bottomPercentage,
int bottomOffset,
Object leftPercentage,
int leftOffset,
Object rightPercentage,
int rightOffset)
Creates for a SWT control instance a FormData instance and
returns it. |
static org.eclipse.swt.graphics.Image |
getImage(String name)
Returns for a given image name a Image object from the
ImageRegistry imgReg. |
private static void |
initImage(String name)
Loads a image into a ImageRegistry. |
static void |
initUtilities()
Sets several properties for the FloatFormater/FloatParser: Maximal and minimal number of fraction digits. |
static boolean |
isCorrectFloat(String floatString)
Checks whether a given string is a valid float number. |
static boolean |
isCorrectInteger(String integerString)
Checks whether a given string is a valid integer. |
private static boolean |
isvalidPercentage(int val)
Checks if the given percentage is valid. |
static Float |
parseFloat(String floatString)
Parses a float-number from a given string. |
static Integer |
parseInteger(String integerString)
Parses a integer from a given string. |
static void |
setLength(org.eclipse.swt.widgets.Combo comp,
int size)
Sets the number of characters a Combo field can take as well as
the width of this Combo field. |
static void |
setLength(org.eclipse.swt.widgets.Text comp,
int size)
Sets the number of characters a Text field can take as well as
the width of this Text field. |
static void |
setLength(org.eclipse.swt.widgets.Text comp,
int textLength,
int lettersShown)
Sets the number of characters a Text field can take as well as
the number of characters shown. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String ATOSJ_COMPONENT_NAME_KEY
private static org.eclipse.jface.resource.ImageRegistry imgReg
Image objects of the application.
public static final org.eclipse.swt.graphics.Color LIGHT_YELLOW
Color instance for red-coloring of text fields (unfilled
mandatory fields).
public static final org.eclipse.swt.graphics.Color LIGHT_RED
Color instance for yellow-coloring of text fields (mandatory
fields).
public static final DateFormat dateOnlyFormatter
public static final DateFormat dateAndTimeFormatter
public static final DateFormat timeOnlyFormatter
HH:mm.
private static NumberFormat floatParser
public static org.eclipse.swt.events.FocusListener checkEmptyListener
public static org.eclipse.swt.events.FocusListener checkCorrectIntListener
public static org.eclipse.swt.events.FocusListener checkCorrectFloatListener
| Constructor Detail |
|---|
public Utility()
| Method Detail |
|---|
public static org.eclipse.swt.layout.FormData getFormData(Object topPercentage,
int topOffset,
Object bottomPercentage,
int bottomOffset,
Object leftPercentage,
int leftOffset,
Object rightPercentage,
int rightOffset)
FormData instance and
returns it.FormData object specifies how the FormLayout manager
should adjust the widget.The FormData instance itselfs is
specified by FormAttachments, which attach the four borders
(top, bottom, left, right) of a widget to several positions of shell.FormLayout, you MUST assign to every widget
a OWN FormData.
topPercentage - Position used to attach the top border of a widget.topOffset - Offset to the position of the top border.bottomPercentage - Position used to attach the bottom border of a widget.bottomOffset - Offset to the position of the bottom border.leftPercentage - Position used to attach the left border of a widget.leftOffset - Offset to the position of the left border.rightPercentage - Position used to attach the right border of a widget.rightOffset - Offset to the position of the left border.
FormData object created with the given parameters.private static boolean isvalidPercentage(int val)
val - value to check.
public static org.eclipse.swt.widgets.Text createTextTab(org.eclipse.swt.widgets.TabFolder parent,
String name,
org.eclipse.swt.graphics.Font font,
int limit)
Label and a Text field.
parent - TabFolder, which contains the tab.name - name of the tab.font - Desired font. null, if using the default
font.limit - size of the Text field.
Text field.public static Date convertToSQLDate(Date date)
public static Timestamp convertToTimestamp(Date date)
public static void setLength(org.eclipse.swt.widgets.Text comp,
int size)
Text field can take as well as
the width of this Text field.
comp - Text field, whose length should get modified.size - Number of characters which can be entered. The width is
set to 6*size.
public static void setLength(org.eclipse.swt.widgets.Text comp,
int textLength,
int lettersShown)
Text field can take as well as
the number of characters shown.
comp - Text field, whose length should get modified.textLength - Number of characters which can be entered.lettersShown - Number of characters shown.
public static void setLength(org.eclipse.swt.widgets.Combo comp,
int size)
Combo field can take as well as
the width of this Combo field.
comp - Combo field, whose length should get modified.size - Number of characters which can be entered. The width is
set to 6*size.public static void alignRight(org.eclipse.swt.widgets.Control label)
Label right.
label - the label to align.private static void initImage(String name)
ImageRegistry.
name - (file-)name of the image to add.public static org.eclipse.swt.graphics.Image getImage(String name)
Image object from the
ImageRegistry imgReg. If the image is not already
present in the registry it gets added.
name - (file-)name of the image.public static void disposeImages()
ImageRegistry.
public static Float parseFloat(String floatString)
Float object, if the parsing was successful otherwise
null.public static boolean isCorrectFloat(String floatString)
null, only whitespaces, a empty String or a
valid float number was given the method returns true,
otherwise false.public static Integer parseInteger(String integerString)
Integer object, if the parsing was successful otherwise
null.public static boolean isCorrectInteger(String integerString)
null, only whitespaces, a empty String or a
valid integer was given the method returns true,
otherwise false.public static String createFloatText(Float theFloat)
Float object.
null was given, otherwise the
created string.public static void initUtilities()
public static Object[] castArray(Object[] array,
Class clazz)
array - Array, whose elements get type casted.clazz - Desired class to cast the elements to.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||