com.ibm.rational.common.test.editor.framework

Class EditorUiUtil

  • java.lang.Object
    • com.ibm.rational.ttt.common.protocols.ui.utils.GraphicsUtil
      • com.ibm.rational.common.test.editor.framework.EditorUiUtil


  • public final class EditorUiUtil
    extends com.ibm.rational.ttt.common.protocols.ui.utils.GraphicsUtil
    Some methods that can be used to create standard-looking UI components.
    • Field Detail

      • KEY_COMBO

        public static final String KEY_COMBO
        Key used to access combo box associated with toggle button.
      • KEY_BUTTON

        public static final String KEY_BUTTON
        Key used to access buttonassociated with combobox.
      • SEARCH_MATCH_RESULTS_KEY

        public static final String SEARCH_MATCH_RESULTS_KEY
    • Constructor Detail

      • EditorUiUtil

        public EditorUiUtil()
    • Method Detail

      • createOptions

        public static Control[] createOptions(Composite parent,
                              String prompt,
                              String[] contents,
                              int defaultSelection,
                              boolean sort,
                              SelectionListener selectionListener)
        Creates options UI. Options UI looks like a label prompt, followed by a combobox with several choices (options). User can select an option from the combobox.
        Parameters:
        parent - A parent composite (or derivative)
        prompt - Text to be displayed in the label prompt.
        contents - Strings to be displayed in the combobox. The combobox is non-modifiable.
        defaultSelection - Index of the content string to select. If the index is beyond the range of the content array, the first string will be selected.
        sort - indicates whether the content strings need to be sorted. Sorting is done using String.compareTo(String) method. If the defaultSelection is given, that string will be selected after the array is sorted.
        selectionListener - SelectionListener to be attached to the combobox or null.
        Returns:
        An array consisting of two controls which are the label and the combobox.
        See Also:
        EditorUiUtil.setComboType(Class), EditorUiUtil.createOptionsWithToggle(Composite, String, boolean, String[], int, boolean, SelectionListener)
      • createOptionsWithToggle

        public static Control[] createOptionsWithToggle(Composite parent,
                                        String prompt,
                                        boolean enabled,
                                        String[] contents,
                                        int defaultSelection,
                                        boolean sort,
                                        SelectionListener selectionListener)
        Creates toggle options UI. Toggle options UI looks like a checkbox with some prompt text, followed by a combobox with several choices (options). Use can select an option from the combobox, or enable/disable the the whole category by checking the checkbox.
        Parameters:
        parent - A parent composite (or derivative)
        prompt - Text to be displayed in the checkbox prompt.
        contents - Strings to be displayed in the combobox. The combobox is non-modifiable.
        defaultSelection - Index of the content string to select. If the index is beyond the range of the content array, the first string will be selected.
        sort - indicates whether the content strings need to be sorted. Sorting is done using String.compareTo(String) method. If the defaultSelection is given, that string will be selected after the array is sorted.
        selectionListener - SelectionListener to be attached to the combobox or null.
        Returns:
        An array consisting of two controls which are the checkbox button and the combobox.
        See Also:
        EditorUiUtil.createOptions(Composite, String, String[], int, boolean, SelectionListener)
      • createOptionsAsRadioButtons

        public static Control[] createOptionsAsRadioButtons(Composite parent,
                                            String prompt,
                                            String[] contents,
                                            int defaultSelection,
                                            SelectionListener selectionListener)
        This is a shortcut that calls
        createOptionsAsRadioButtons(parent, prompt, contents, defaultSelection, selectionListener, null )
        Parameters:
        parent - Composite.
        prompt - String. If not null, creates a Label or CLabel before any radio-buttons.
        contents - String[]. Labels for radio-buttons options. Must not be null and be non-empty.
        defaultSelection - int. -1 or zero-based index of the option (radio-button) that should be selected.
        selectionListener - SelectionListener. Optional SelectionListener. If not null, will be added to every radio-button.
        Returns:
        Control[]. Array of controls where first widget may be Label ot CLabel (if prompt argument was not null). The rest of the elements in the array are radio-buttons.
        See Also:
        EditorUiUtil.createOptionsAsRadioButtons(Composite, String, String[], int, SelectionListener, com.ibm.rational.common.test.editor.framework.EditorUiUtil.IOptionDescription)
      • createOptionsAsRadioButtons

        public static Control[] createOptionsAsRadioButtons(Composite parent,
                                            String prompt,
                                            String[] contents,
                                            int defaultSelection,
                                            SelectionListener selectionListener,
                                            EditorUiUtil.IOptionDescription optionDescription)
        Displays options as a set of radiobuttons.
        Parameters:
        parent - Composite.
        prompt - String. If not null, creates a Label or CLabel before any radio-buttons.
        contents - String[]. Labels for radio-buttons options. Must not be null and be non-empty.
        defaultSelection - int. -1 or zero-based index of the option (radio-button) that should be selected.
        selectionListener - SelectionListener. Optional SelectionListener. If not null, will be added to every radio-button.
        optionDescription - IOptionDescription. If not null, EditorUiUtil.IOptionDescription.draw(int, Composite, Button) will be called after each button is created. This allows for any widgets to be added between radio-buttons.
        Returns:
        Control[]. Array of controls where first widget may be Label ot CLabel (if prompt argument was not null). The rest of the elements in the array are radio-buttons.
      • loadImageDescriptor

        public static ImageDescriptor loadImageDescriptor(IConfigurationElement element,
                                          String name)
        This class is not intended to be used by client code.
        Parameters:
        element - IConfigurationElement
        name - String
        Returns:
        ImageDescriptor
      • setComboType

        public static Class setComboType(Class comboType)
        Indicator that tells what type of combo box to create. Clients are encouraged to store the return value, and reset back to it, when no longer needed.
        Parameters:
        comboType - The comboType to set.
        Possible values:
      • CCombo.class - the CCombo will be created.
      • Combo.class - the Combo widget will be created.

        The main difference is that Combo widget does not support FLAT look-and-feel, while CCombo does.

      • Returns:
        Class. Old type that must be preserved and restored after the UI is built.
        See Also:
        Combo, CCombo
      • setLabelType

        public static Class setLabelType(Class labelType)
        Indicator that tells what type of label to create. Clients are encouraged to store the return value, and reset back to it, when no longer needed.
        Parameters:
        labelType - The type of label to create.
        Possible values:
      • CLabel.class - the CLabel will be created.
      • Label.class - the Label widget will be created.
      • Returns:
        Class. Old type that must be preserved and restored after the UI is built.
        See Also:
        Label, CLabel
      • trimMenuText

        public static String trimMenuText(String mtext)
        Trims long text that is about to be used as a menu item. This is useful for menu items that represent DataSources and/or Substituters as they tend to be very long. The text is shortened to 48 characters.
        Parameters:
        mtext - String
        Returns:
        modified menu text + Dialog.ELLIPSIS
      • shortenText

        public static String shortenText(String text,
                         boolean isTooltip)
        Shortens (trims) given text accordings to the follwoing rules:
      • If the length is shorter than 100, the text is unmodified.
      • If the tooltip is false, or the length is less than 310, the first 100 characters are taken and Dialog.ELLIPSIS is appended.
      • If the tooltip is true, the text is broken into three lines of 100 each, and and Dialog.ELLIPSIS is appended.
Parameters:
text - String.
isTooltip - boolean.
Returns:
String [modified] text
  • setFlat

    public static boolean setFlat(boolean flat)
    Sets presentation mode.
    Parameters:
    flat - boolean. true is used for displaying UI in the Test Editor details. false is used for displaying UI where flat mode is undesirable (dialogs, preferences etc.)
    Returns:
    boolean. Previous value. Client code should save this value and restore the mode after the UI is built.
  • enableComposite

    public static void enableComposite(Composite group,
                       boolean enable,
                       boolean redraw)
  • enableHyperlink

    public static void enableHyperlink(Hyperlink hyperLink,
                       boolean enable)
  • calculateLocation

    public static Point calculateLocation(Menu mnu,
                          Rectangle size,
                          Point location,
                          int extraOffsetToRight)
  • computePolyline

    public static int[] computePolyline(Point left,
                        Point right,
                        int baseline,
                        int lineHeight)
  • createContentAssistForSearchWidget

    public static ContentAssistCommandAdapter createContentAssistForSearchWidget(Control textOrCombo,
                                                                 boolean enabled,
                                                                 boolean makeRoomForDecoration)
                                                                          throws IllegalArgumentException
    Sets up a content assist for fields that accept user input for search term. The content assist will display list of regular expressions. The client code is expected to manage the availability of context assist based on whether the regex search is enabled (by calling ContentAssistCommandAdapter.setEnabled(boolean).
    Parameters:
    textOrCombo - Widget for which the content assist needs to be set. Can only be Text or Combo.
    enabled - boolean. The initial state of content assist.
    makeRoomForDecoration - boolean. If true attempts to adjust layout data object of textOrCombo so that there is enough room to display the decoration. This argument will only have an effect if the existing layout data is of type GridData or null.
    Returns:
    ContentAssistCommandAdapter. Client code can customize further as needed.
    Throws:
    IllegalArgumentException - if the first argument is of non-supported type.
    See Also:
    TestEditor.getRegexSearchValue()
  • setButtonLayoutData

    public static void setButtonLayoutData(Button button)
  • disableControl

    public static void disableControl(Control ctrl,
                      boolean enabled)
  • createErrorControlDecorator

    public static ControlDecoration createErrorControlDecorator(Control ctrl,
                                                boolean visible)
  • getThemeColor

    public static Color getThemeColor(String _key,
                      boolean _register)
    Parameters:
    _key - String Color key
    register - boolean. If true, the color will be managed by the ColorRegistry and the 'dispose' method must not be called. If false, the caller is responsible for disposing of the color when no longer needed.
    Returns:
    Color defined by the key and declared in "org.eclipse.ui.themes" extension point.