fable.gui.dialog
Class DialogUtility

java.lang.Object
  extended by fable.gui.dialog.DialogUtility

public class DialogUtility
extends java.lang.Object

This class provides utilities to make a dialog box.

Author:
Wonsik Kim

Method Summary
static void createButtons(Shell parent, Listener selectionListener, int indent)
          Creates a OK button and a cancel button to the shell.
static void createButtons(Shell parent, Listener selectionListener, int indent, java.lang.String label, int columns)
          Creates a OK button and a cancel button to the shell.
static Tree createCustomFeedTree(Composite parent, Folder root, int style)
          Creates a Tree object with provided root and style.
static Tree createFeedTree(Composite parent, Folder root, int style)
          Creates a Tree object with provided root and style.
static Tree createFolderTree(Composite parent, Folder root, int style)
          Creates a Tree object with provided root and style.
static Tree createFolderTreeWithLabel(Composite parent, java.lang.String label, int labelSpan, Folder root, int height)
          Creates a label and a folder tree, and retrurns the created tree.
static Text createLargeTextWithLabel(Composite parent, java.lang.String label, int labelSpan, int height)
          Creates a label and text field with given layout, label, labelSpan.
static java.util.List<Button> createRadioButtonsWithLabel(Composite parent, java.lang.String label, java.util.List<java.lang.String> buttonLabels, int buttonsPerLine)
          Creates radio buttons in one group, and returns buttons as a list.
static Text createTextWithLabel(Composite parent, java.lang.String label, int labelSpan)
          Creates a label and text field with given layout, label, labelSpan.
static Text createTextWithLabel(Composite parent, java.lang.String label, int labelSpan, int fieldSpan)
          Creates a label and text field with given layout, label, labelSpan, and fieldSpan, and returns text field object.
static Tree createTree(Composite parent, Folder root, int style, fable.gui.dialog.DialogUtility.ConstructTreeStrategy strategy)
          Create a tree with specified parent composite, root of the tree structure, style, and strategy to build the tree.
static void error(Shell parent, java.lang.String message)
          Pop up a message box notifies users that there is some error.
static Shell initializeShell(Dialog dialog, java.lang.String title, int style, int numColumns)
          Initializes shell of the dialog box and return it.
static void launchShell(Dialog dialog, Shell shell)
          This method shows the shell until it is disposed.
static void launchShell(Dialog dialog, Shell shell, fable.gui.dialog.DialogUtility.Action action)
          This method shows the shell, but just before it opens the shell, it does some special action, and opens the shell until it is disposed.
static void message(Shell parent, java.lang.String message, int style, java.lang.String title)
          Pop up a message box notifies users.
static void selectCurrentPosition(Tree tree, java.lang.Object currentPosition)
          Let the tree select a current position as default.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

initializeShell

public static Shell initializeShell(Dialog dialog,
                                    java.lang.String title,
                                    int style,
                                    int numColumns)
Initializes shell of the dialog box and return it. This shell is configure to have a grid layout having provided number of columns, a title as provided, and a style with the default dialog box look.

Parameters:
dialog - dialog object that will use the shell.
title - title of the dialog box.
style - style of the dialog box. Some of the styles are already specified here, such as SWT.DIALOG_TRIM and SWT.APPLICATION_MODAL.
numColumns - number of columns that the grid layout of this dialog box will have.
Returns:
initialized shell object.
Requires:
dialog != null, title != null, style should be legal style for the dialog box, numColumns > 0.

launchShell

public static void launchShell(Dialog dialog,
                               Shell shell)
This method shows the shell until it is disposed.

Parameters:
dialog - dialog object that will be shown
shell - shell of the dialog object
Requires:
dialog != null, shell != null, shell should be the shell of the dialog object.

launchShell

public static void launchShell(Dialog dialog,
                               Shell shell,
                               fable.gui.dialog.DialogUtility.Action action)
This method shows the shell, but just before it opens the shell, it does some special action, and opens the shell until it is disposed.

Parameters:
dialog - dialog object that will be shown.
shell - shell of the dialog object.
action - action that will be done just before openning the dialog box.
Requires:
dialog != null, shell != null, shell should be the shell of the dialog object, action != null.

createTree

public static Tree createTree(Composite parent,
                              Folder root,
                              int style,
                              fable.gui.dialog.DialogUtility.ConstructTreeStrategy strategy)
Create a tree with specified parent composite, root of the tree structure, style, and strategy to build the tree. Returns the created tree object.

Parameters:
parent - parent composite of a tree.
root - root of a tree structure.
style - style of a tree
strategy - strategy to build a tree
Returns:
created tree object
Requires:
parent != null, root != null, style should be legal style for the tree, strategy != null.
Modifies:
parent

createFolderTree

public static Tree createFolderTree(Composite parent,
                                    Folder root,
                                    int style)
Creates a Tree object with provided root and style. This method only works for Folder root. The returning Tree object will contain only Folders.

Parameters:
parent - parent dialog box shell of the tree.
root - root of the tree.
style - style of the tree.
Returns:
Tree object which contains the all folders under the root.
Requires:
parent != null, root != null, style should be legal style for the tree.
Modifies:
parent

createFeedTree

public static Tree createFeedTree(Composite parent,
                                  Folder root,
                                  int style)
Creates a Tree object with provided root and style. This method only works for Folder root. The returning Tree object will also contain Feeds as well as Folders.

Parameters:
parent - parent dialog box shell of the tree.
root - root of the tree.
style - style of the tree.
Returns:
Tree object which contains the all Folders and Feeds under the root.
Requires:
parent != null, root != null, style should be legal style for the tree.
Modifies:
parent

createCustomFeedTree

public static Tree createCustomFeedTree(Composite parent,
                                        Folder root,
                                        int style)
Creates a Tree object with provided root and style. This method only works for Folder root. The returning Tree object will contain custom feeds and folders.

Parameters:
parent - parent dialog box shell of the tree.
root - root of the tree.
style - style of the tree.
Returns:
Tree object which contains the all Folders and custom feeds under the root.
Requires:
parent != null, root != null, style should be legal style for the tree.
Modifies:
parent

createButtons

public static void createButtons(Shell parent,
                                 Listener selectionListener,
                                 int indent,
                                 java.lang.String label,
                                 int columns)
Creates a OK button and a cancel button to the shell. OK button will have the selection listener as client provides in this method, so client should not forget to close the shell at the end of the listener.

Parameters:
parent - parent shell of the buttons.
selectionListener - listener that will be associated with the OK button.
indent - indentation that the OK button and cancel button will have.
label - label of the Ok button, if another name is desirable.
columns - number of columns to be filled, if not whole line should be filled.
Requires:
parent != null, selectionListener != null, indent >= 0, label != null, columns >= 2, parent.getLayout() instanceof GridLayout.
Modifies:
parent

createButtons

public static void createButtons(Shell parent,
                                 Listener selectionListener,
                                 int indent)
Creates a OK button and a cancel button to the shell. OK button will have the selection listener as client provides in this method, so client should not forget to close the shell at the end of the listener.

Parameters:
parent - parent shell of the buttons.
selectionListener - listener that will be associated with the OK button.
indent - indentation that the OK button and cancel button will have.
Requires:
parent != null, selectionListener != null, indent >= 0, parent.getLayout() instanceof GridLayout.
Modifies:
parent

createTextWithLabel

public static Text createTextWithLabel(Composite parent,
                                       java.lang.String label,
                                       int labelSpan,
                                       int fieldSpan)
Creates a label and text field with given layout, label, labelSpan, and fieldSpan, and returns text field object.

Parameters:
parent - parent dialog box shell of the label and text field.
label - label string.
labelSpan - number of cells that the label will consume.
fieldSpan - number of cells that the field will consume.
Returns:
created Text object.
Requires:
parent != null, label != null, labelSpan >= 1, fieldSpan >= 1, parent.getLayout() instanceof GridLayout.
Modifies:
parent

createTextWithLabel

public static Text createTextWithLabel(Composite parent,
                                       java.lang.String label,
                                       int labelSpan)
Creates a label and text field with given layout, label, labelSpan. It will completely fill one line of the grid layout. It returns created text field object.

Parameters:
parent - parent dialog box shell of the label and text field.
label - label string.
labelSpan - number of cells that the label will consume.
Returns:
created Text object.
Requires:
parent != null, label != null, labelSpan >= 1, parent.getLayout().numColumns > labelSpan, parent.getLayout() instanceof GridLayout.
Modifies:
parent

createLargeTextWithLabel

public static Text createLargeTextWithLabel(Composite parent,
                                            java.lang.String label,
                                            int labelSpan,
                                            int height)
Creates a label and text field with given layout, label, labelSpan. It will completely fill one line of the grid layout. It returns created text field object.

Parameters:
parent - parent dialog box shell of the label and text field.
label - label string.
labelSpan - number of cells that the label will consume.
Returns:
created Text object.
Requires:
parent != null, label != null, labelSpan >= 1, parent.getLayout().numColumns > labelSpan, parent.getLayout() instanceof GridLayout.
Modifies:
parent

createFolderTreeWithLabel

public static Tree createFolderTreeWithLabel(Composite parent,
                                             java.lang.String label,
                                             int labelSpan,
                                             Folder root,
                                             int height)
Creates a label and a folder tree, and retrurns the created tree.

Parameters:
parent - parent dialog box shell of the label and the tree.
label - label string.
labelSpan - number of cells that the label will consume.
root - root of the tree.
height - minimum height of the tree.
Returns:
the created tree object.
Requires:
parent != null, label != null, labelSpan >= 1, root != null, height >= 0, parent.getLayout().numColumns > labelSpan, parent.getLayout() instanceof GridLayout.
Modifies:
parent

createRadioButtonsWithLabel

public static java.util.List<Button> createRadioButtonsWithLabel(Composite parent,
                                                                 java.lang.String label,
                                                                 java.util.List<java.lang.String> buttonLabels,
                                                                 int buttonsPerLine)
Creates radio buttons in one group, and returns buttons as a list.

Parameters:
parent - parent dialog box shell of the group.
label - label of the group.
buttonLabels - labels of the buttons.
buttonsPerLine - the number of buttons in one line.
Returns:
created buttons.
Requires:
parent != null, label != null, buttonLabels != null, buttonLabels.get( i ) != null, buttonsPerLine >= 1, parent.getLayout() instanceof GridLayout.
Modifies:
parent

error

public static void error(Shell parent,
                         java.lang.String message)
Pop up a message box notifies users that there is some error.

Parameters:
parent - parent shell of the message box.
message - message to show.
Requires:
parent != null, message != null.

selectCurrentPosition

public static void selectCurrentPosition(Tree tree,
                                         java.lang.Object currentPosition)
Let the tree select a current position as default.

Parameters:
tree - tree to select a node.
currentPosition - a data associated with the desired TreeItem.
Requires:
tree != null, currentPosition should be one of the items in the tree's data.
Modifies:
tree

message

public static void message(Shell parent,
                           java.lang.String message,
                           int style,
                           java.lang.String title)
Pop up a message box notifies users.

Parameters:
parent - parent shell of the message box.
message - message to show.
style - style of the message box.
title - title of the message box.
Requires:
parent != null, message != null, style should be a legal style for the message dialog box, title != null.