Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## semorg.sql.util
Class Utility

    java.lang.Object
      semorg.sql.util.Utility

    public class Utility

extends Object

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

### ATOSJ_COMPONENT_NAME_KEY

    public static final String ATOSJ_COMPONENT_NAME_KEY

  Needed for regression tests with ATOSj. (for identifying the GUI elements).

  See Also:
    Constant Field Values

### imgReg

    private static org.eclipse.jface.resource.ImageRegistry imgReg

  A registry containing all `Image` objects of the application.

### LIGHT_YELLOW

    public static final org.eclipse.swt.graphics.Color LIGHT_YELLOW

  `Color` instance for red-coloring of text fields (unfilled mandatory fields).

### LIGHT_RED

    public static final org.eclipse.swt.graphics.Color LIGHT_RED

  `Color` instance for yellow-coloring of text fields (mandatory fields).

### dateOnlyFormatter

    public static final DateFormat dateOnlyFormatter

  Date formatter using standard localization.

### dateAndTimeFormatter

    public static final DateFormat dateAndTimeFormatter

  Date and time formatter using standard localization.

### timeOnlyFormatter

    public static final DateFormat timeOnlyFormatter

  Time formatter using the format `HH:mm`.

### floatParser

    private static NumberFormat floatParser

  Parses strings for floating-point numbers.

### checkEmptyListener

    public static org.eclipse.swt.events.FocusListener checkEmptyListener

  Colors empty mandatory fields with red color if they loose the focus. The field get colored yellow if they regain the focus.
  Thus this listener marks input errors in the GUI.

### checkCorrectIntListener

    public static org.eclipse.swt.events.FocusListener checkCorrectIntListener

  Checks if the entered String is a valid integer. If not it colors the text field red. Otherwise the field gets the color white.

### checkCorrectFloatListener

    public static org.eclipse.swt.events.FocusListener checkCorrectFloatListener

  Checks if the entered String is a valid float number. If not it colors the text field red. Otherwise the field gets the color white.

Constructor Detail

### Utility

    public Utility()

Method Detail

### getFormData

    public 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.
  The `FormData` object specifies how the `FormLayout` manager should adjust the widget.The `FormData` instance itselfs is specified by `FormAttachment`s, which attach the four borders (top, bottom, left, right) of a widget to several positions of shell.
  Hint:
  - If you use the `FormLayout`, you MUST assign to every widget a OWN `FormData`.

  Parameters:
    `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.
  Returns:
    `FormData` object created with the given parameters.

### isvalidPercentage

    private static boolean isvalidPercentage(int val)

  Checks if the given percentage is valid.

  Parameters:
    `val` - value to check.
  Returns:
    `true` if the given value is a valid percentage, `false` otherwise.

### createTextTab

    public 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.

  Parameters:
    `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.
  Returns:
    created `Text` field.

### convertToSQLDate

    public static Date convertToSQLDate(Date date)

  Converts a JAVA date into SQL date.

### convertToTimestamp

    public static Timestamp convertToTimestamp(Date date)

  Converts a JAVA timestamp inti a SQL timestamp.

### setLength

    public 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.

  Parameters:
    `comp` - `Text` field, whose length should get modified.
    `size` - Number of characters which can be entered. The width is set to `6*size`.

### setLength

    public 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.

  Parameters:
    `comp` - `Text` field, whose length should get modified.
    `textLength` - Number of characters which can be entered.
    `lettersShown` - Number of characters shown.

### setLength

    public 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.

  Parameters:
    `comp` - `Combo` field, whose length should get modified.
    `size` - Number of characters which can be entered. The width is set to `6*size`.

### alignRight

    public static void alignRight(org.eclipse.swt.widgets.Control label)

  Aligns a `Label` right.

  Parameters:
    `label` - the label to align.

### initImage

    private static void initImage(String name)

  Loads a image into a `ImageRegistry`.

  Parameters:
    `name` - (file-)name of the image to add.

### getImage

    public static org.eclipse.swt.graphics.Image getImage(String name)

  Returns for a given image name a `Image` object from the `ImageRegistry` `imgReg`. If the image is not already present in the registry it gets added.

  Parameters:
    `name` - (file-)name of the image.

### disposeImages

    public static void disposeImages()

  Disposes all images by disposing the `ImageRegistry`.

### parseFloat

    public static Float parseFloat(String floatString)

  Parses a float-number from a given string.

  Returns:
    `Float` object, if the parsing was successful otherwise `null`.

### isCorrectFloat

    public static boolean isCorrectFloat(String floatString)

  Checks whether a given string is a valid float number.

  Returns:
    If `null`, only whitespaces, a empty String or a valid float number was given the method returns `true`, otherwise `false`.

### parseInteger

    public static Integer parseInteger(String integerString)

  Parses a integer from a given string.

  Returns:
    `Integer` object, if the parsing was successful otherwise `null`.

### isCorrectInteger

    public static boolean isCorrectInteger(String integerString)

  Checks whether a given string is a valid integer.

  Returns:
    If `null`, only whitespaces, a empty String or a valid integer was given the method returns `true`, otherwise `false`.

### createFloatText

    public static String createFloatText(Float theFloat)

  Creates a string from a given `Float` object.

  Returns:
    Empty string, if `null` was given, otherwise the created string.

### initUtilities

    public static void initUtilities()

  Sets several properties for the FloatFormater/FloatParser:
  - Maximal and minimal number of fraction digits.
  - No grouping of numbers, e.g. grouping: 1223786 -> 1.234.786

### castArray

    public static Object[] castArray(Object[] array,
                                     Class clazz)

  Does a type cast of all elements of a given array.

  Parameters:
    `array` - Array, whose elements get type casted.
    `clazz` - Desired class to cast the elements to.
  Returns:
    Array with type casted elements.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD