org.eclipse.datatools.sqltools.result.internal.ui.utils
Class UIUtil

java.lang.Object
  extended by org.eclipse.datatools.sqltools.result.internal.ui.utils.UIUtil

public class UIUtil
extends java.lang.Object

UI related utility methods.

Author:
Dafan Yang

Field Summary
static int DEFAULT_BUTTON_WIDTH
           
static int DEFAULT_COMBO_WIDTH
           
static int DEFAULT_RADIO_FILL
           
static int DEFAULT_TEXTBOX_WIDTH
           
 
Constructor Summary
UIUtil()
           
 
Method Summary
static int convertHeightInCharsToPixels(int chars, org.eclipse.swt.widgets.Control control)
          Returns the height in pixels given the characters number.
static int convertWidthInCharsToPixels(int chars, org.eclipse.swt.widgets.Control control)
          Returns the width in pixels given the characters number.
static org.eclipse.swt.widgets.Button createCheckBox(org.eclipse.swt.widgets.Composite parent)
          Creates a new checkbox and sets the default layout data.
static org.eclipse.swt.widgets.Button createCheckBox(org.eclipse.swt.widgets.Composite parent, java.lang.String label, int numColumns)
          Creates a new checkbox and sets the default layout data.
static org.eclipse.swt.widgets.Button createCheckBox(org.eclipse.swt.widgets.Composite parent, java.lang.String label, int numColumns, int indent)
          Creates a new checkbox and sets the default layout data.
static org.eclipse.swt.widgets.Combo createCombo(org.eclipse.swt.widgets.Composite parent, java.lang.String[] items, int numColumns, int minWidth)
          Creates a combo box and sets the default layout data.
static org.eclipse.swt.widgets.Combo createCombo(org.eclipse.swt.widgets.Composite parent, java.lang.String[] items, int numColumns, int minWidth, boolean editable)
          Creates a combo box and sets the default layout data.
static org.eclipse.swt.widgets.Combo createCombo(org.eclipse.swt.widgets.Composite parent, java.lang.String tokenString, int numColumns)
          Creates a combo box and sets the default layout data.
static org.eclipse.swt.widgets.Combo createCombo(org.eclipse.swt.widgets.Composite parent, java.lang.String tokenString, int numColumns, int minWidth)
          Creates a combo box and sets the default layout data.
static org.eclipse.swt.widgets.Combo createCombo(org.eclipse.swt.widgets.Composite parent, java.lang.String tokenString, int numColumns, int minWidth, boolean editable)
          Creates a combo box and sets the default layout data.
static org.eclipse.swt.widgets.Group createGroup(org.eclipse.swt.widgets.Composite parent, java.lang.String title, int numColumns)
          Utility method that creates a group and sets the default layout data.
static org.eclipse.swt.widgets.Group createGroup(org.eclipse.swt.widgets.Composite parent, java.lang.String title, int numColumns, int horizontalSpan, int gridDataFill)
          Utility method that creates a group and sets the default layout data.
static org.eclipse.swt.widgets.Label createLabel(org.eclipse.swt.widgets.Composite parent, java.lang.String text, int numColumns)
          Utility method that creates a label instance and sets the default layout data.
static org.eclipse.swt.widgets.Label createLabel(org.eclipse.swt.widgets.Composite parent, java.lang.String text, int numColumns, int indent)
          Utility method that creates a label instance and sets the default layout data.
static org.eclipse.swt.widgets.Button createPushButton(org.eclipse.swt.widgets.Composite parent, java.lang.String label)
           
static org.eclipse.swt.widgets.Button createPushButton(org.eclipse.swt.widgets.Composite parent, java.lang.String label, int widthHint)
          Utility method that creates a push button instance and sets the default layout data.
static org.eclipse.swt.widgets.Text createTextBox(org.eclipse.swt.widgets.Composite parent)
          Creates a text field
static org.eclipse.swt.widgets.Text createTextBox(org.eclipse.swt.widgets.Composite parent, int numColumns)
          Creates a text field
static org.eclipse.swt.widgets.Text createTextBox(org.eclipse.swt.widgets.Composite parent, int numColumns, int minWidth)
          Creates a text field
static org.eclipse.swt.widgets.Text createTextBox(org.eclipse.swt.widgets.Composite parent, int numColumns, int minWidth, int minHeight)
          Creates a text field
static org.eclipse.swt.widgets.Text createTextBox(org.eclipse.swt.widgets.Composite parent, java.lang.String text)
          Creates a text field
static java.lang.String[] getTokenNames(java.lang.String tokenString)
          Builds an array of strings from a token list string.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUTTON_WIDTH

public static final int DEFAULT_BUTTON_WIDTH
See Also:
Constant Field Values

DEFAULT_COMBO_WIDTH

public static final int DEFAULT_COMBO_WIDTH
See Also:
Constant Field Values

DEFAULT_TEXTBOX_WIDTH

public static final int DEFAULT_TEXTBOX_WIDTH
See Also:
Constant Field Values

DEFAULT_RADIO_FILL

public static final int DEFAULT_RADIO_FILL
See Also:
Constant Field Values
Constructor Detail

UIUtil

public UIUtil()
Method Detail

convertWidthInCharsToPixels

public static int convertWidthInCharsToPixels(int chars,
                                              org.eclipse.swt.widgets.Control control)
Returns the width in pixels given the characters number.

Parameters:
chars - number of characters
control - the widget which contains font information, should not be null
Returns:
the width in pixels

convertHeightInCharsToPixels

public static int convertHeightInCharsToPixels(int chars,
                                               org.eclipse.swt.widgets.Control control)
Returns the height in pixels given the characters number.

Parameters:
chars - number of characters
control - the widget which contains font information, should not be null
Returns:
the width in pixels

createLabel

public static org.eclipse.swt.widgets.Label createLabel(org.eclipse.swt.widgets.Composite parent,
                                                        java.lang.String text,
                                                        int numColumns,
                                                        int indent)
Utility method that creates a label instance and sets the default layout data.

Parameters:
parent - the parent for the new label
text - the text for the new label
numColumns - the number of columns for the new composite
indent - number of pixels to indent from the left
Returns:
the new label

createLabel

public static org.eclipse.swt.widgets.Label createLabel(org.eclipse.swt.widgets.Composite parent,
                                                        java.lang.String text,
                                                        int numColumns)
Utility method that creates a label instance and sets the default layout data.

Parameters:
parent - the parent for the new label
text - the text for the new label
numColumns - the number of columns for the new composite
Returns:
the new label

createPushButton

public static org.eclipse.swt.widgets.Button createPushButton(org.eclipse.swt.widgets.Composite parent,
                                                              java.lang.String label)

createPushButton

public static org.eclipse.swt.widgets.Button createPushButton(org.eclipse.swt.widgets.Composite parent,
                                                              java.lang.String label,
                                                              int widthHint)
Utility method that creates a push button instance and sets the default layout data.

Parameters:
parent - the parent for the new button
label - the label for the new button
widthHint - use this width for the button.
Returns:
the newly-created button

createGroup

public static org.eclipse.swt.widgets.Group createGroup(org.eclipse.swt.widgets.Composite parent,
                                                        java.lang.String title,
                                                        int numColumns)
Utility method that creates a group and sets the default layout data.

Parameters:
parent - the parent for the new group
title - the label for the new group
numColumns - the number of columns for the new group
Returns:
the newly created group

createGroup

public static org.eclipse.swt.widgets.Group createGroup(org.eclipse.swt.widgets.Composite parent,
                                                        java.lang.String title,
                                                        int numColumns,
                                                        int horizontalSpan,
                                                        int gridDataFill)
Utility method that creates a group and sets the default layout data.

Parameters:
parent - the parent for the new group
title - the label for the new group
numColumns - the number of columns for the new group
horizontalSpan - the number of columns this group should span on the parent composite.
fill - the fill style of the new group -- set to for filling just around the object: GridData.BEGINNING | GridData.CENTER
Returns:
the newly created group

createCheckBox

public static org.eclipse.swt.widgets.Button createCheckBox(org.eclipse.swt.widgets.Composite parent)
Creates a new checkbox and sets the default layout data.

Parameters:
parent - the composite in which to create the checkbox
label - the string to set into the checkbox
numColumns - the number of columns the new checkbox is to occupy
Returns:
the new checkbox

createCheckBox

public static org.eclipse.swt.widgets.Button createCheckBox(org.eclipse.swt.widgets.Composite parent,
                                                            java.lang.String label,
                                                            int numColumns)
Creates a new checkbox and sets the default layout data.

Parameters:
parent - the composite in which to create the checkbox
label - the string to set into the checkbox
numColumns - the number of columns the new checkbox is to occupy
Returns:
the new checkbox

createCheckBox

public static org.eclipse.swt.widgets.Button createCheckBox(org.eclipse.swt.widgets.Composite parent,
                                                            java.lang.String label,
                                                            int numColumns,
                                                            int indent)
Creates a new checkbox and sets the default layout data.

Parameters:
parent - the composite in which to create the checkbox
label - the string to set into the checkbox
numColumns - the number of columns the new checkbox is to occupy
indent - the number of pixels to indent from the left
Returns:
the new checkbox

createTextBox

public static org.eclipse.swt.widgets.Text createTextBox(org.eclipse.swt.widgets.Composite parent)
Creates a text field

Parameters:
parent - the parent of the new text field
Returns:
the new text field

createTextBox

public static org.eclipse.swt.widgets.Text createTextBox(org.eclipse.swt.widgets.Composite parent,
                                                         java.lang.String text)
Creates a text field

Parameters:
parent - the parent of the new text field
Returns:
the new text field

createTextBox

public static org.eclipse.swt.widgets.Text createTextBox(org.eclipse.swt.widgets.Composite parent,
                                                         int numColumns)
Creates a text field

Parameters:
parent - the parent of the new text field
numColumns - number of columns the text box is to occupy
Returns:
the new text field

createTextBox

public static org.eclipse.swt.widgets.Text createTextBox(org.eclipse.swt.widgets.Composite parent,
                                                         int numColumns,
                                                         int minWidth)
Creates a text field

Parameters:
parent - the parent of the new text field
numColumns - number of columns the text box is to occupy
minWidth - minimum width of text field
Returns:
the new text field

createTextBox

public static org.eclipse.swt.widgets.Text createTextBox(org.eclipse.swt.widgets.Composite parent,
                                                         int numColumns,
                                                         int minWidth,
                                                         int minHeight)
Creates a text field

Parameters:
parent - the parent of the new text field
numColumns - number of columns the text box is to occupy
minWidth - minimum width of text field
Returns:
the new text field

createCombo

public static org.eclipse.swt.widgets.Combo createCombo(org.eclipse.swt.widgets.Composite parent,
                                                        java.lang.String tokenString,
                                                        int numColumns)
Creates a combo box and sets the default layout data.

Parameters:
parent - the composite in which to create the combo
tokenString - a tokenized string that will be split into the fields.
numColumns - the number of columns the new combo is to occupy
Returns:
the new combo box

createCombo

public static org.eclipse.swt.widgets.Combo createCombo(org.eclipse.swt.widgets.Composite parent,
                                                        java.lang.String tokenString,
                                                        int numColumns,
                                                        int minWidth)
Creates a combo box and sets the default layout data.

Parameters:
parent - the composite in which to create the combo
tokenString - a tokenized string that will be split into the fields.
numColumns - the number of columns the new combo is to occupy
minWidth - minimum width of combo box in pixels
Returns:
the new combo box

createCombo

public static org.eclipse.swt.widgets.Combo createCombo(org.eclipse.swt.widgets.Composite parent,
                                                        java.lang.String[] items,
                                                        int numColumns,
                                                        int minWidth)
Creates a combo box and sets the default layout data.

Parameters:
parent - the composite in which to create the combo
items - the items in the combo
numColumns - the number of columns the new combo is to occupy
minWidth - minimum width of combo box in pixels
Returns:
the new combo box

createCombo

public static org.eclipse.swt.widgets.Combo createCombo(org.eclipse.swt.widgets.Composite parent,
                                                        java.lang.String tokenString,
                                                        int numColumns,
                                                        int minWidth,
                                                        boolean editable)
Creates a combo box and sets the default layout data.

Parameters:
parent - the composite in which to create the combo
items - the items in the combo
numColumns - the number of columns the new combo is to occupy
minWidth - minimum width of combo box in pixels
editable - whether the items in the combo is editable
Returns:
the new combo box

createCombo

public static org.eclipse.swt.widgets.Combo createCombo(org.eclipse.swt.widgets.Composite parent,
                                                        java.lang.String[] items,
                                                        int numColumns,
                                                        int minWidth,
                                                        boolean editable)
Creates a combo box and sets the default layout data.

Parameters:
parent - the composite in which to create the combo
items - the items in the combo
numColumns - the number of columns the new combo is to occupy
minWidth - minimum width of combo box in pixels
editable - whether the items in the combo is editable
Returns:
the new combo box

getTokenNames

public static java.lang.String[] getTokenNames(java.lang.String tokenString)
Builds an array of strings from a token list string. The token separator is a comma (',').

Parameters:
tokenString -
Returns:
String[]