net.refractions.udig.ui
Class ZoomingDialog

java.lang.Object
  extended by Dialog
      extended by net.refractions.udig.ui.ZoomingDialog

public class ZoomingDialog
extends Dialog

A dialog that, on opening, will zoom from the start location/size the location of the provided dialog.

IMPORTANT: Since there is no way for ZoomingDialog to determine whether setBlockOnOpen is set on the wrapped/decorated Dialog setBlockOnOpen MUST be set on ZoomingDialog

Since:
1.1.0
Author:
Jesse

Field Summary
static int FAST
           
static int MEDIUM
           
static int SLOW
           
 
Constructor Summary
ZoomingDialog(Shell parentShell, Dialog dialog, int x, int y, int width, int height)
          Create new instance.
ZoomingDialog(Shell parentShell, Dialog delegate, Rectangle start)
          Creates a new instance.
 
Method Summary
static Rectangle calculateBounds(Control control)
          Calculates the bounds of the Control in Display coordinates (Required by ZoomingDialog constructor).
static Rectangle calculateBounds(TreeItem item, int columnIndex)
          Calculates the bounds of the Control in Display coordinates (Required by ZoomingDialog constructor).
 boolean close()
           
 void create()
           
protected  Control createButtonBar(Composite parent)
           
protected  Point getInitialLocation(Point initialSize)
           
protected  Point getInitialSize()
           
 int getReturnCode()
           
 int open()
          Opens the dialog.
static void openErrorMessage(Rectangle start, Shell parentShell, java.lang.String dialogTitle, java.lang.String dialogMessage)
           
static void openInformationMessage(Rectangle start, Shell parentShell, java.lang.String dialogTitle, java.lang.String dialogMessage)
           
static int openMessageDialog(Rectangle start, Shell parentShell, java.lang.String dialogTitle, Image dialogImage, java.lang.String dialogMessage, int dialogImageType, java.lang.String[] buttonLabels, int defaultIndex)
          Create a message dialog.
static boolean openQuestionMessage(Rectangle start, Shell parentShell, java.lang.String dialogTitle, java.lang.String dialogMessage)
           
static void openWarningMessage(Rectangle start, Shell parentShell, java.lang.String dialogTitle, java.lang.String dialogMessage)
           
 void setBlockOnOpen(boolean shouldBlock)
           
 void setZoomSpeed(int speed)
          Sets how long it takes for the Dialog to open, default is FAST.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FAST

public static final int FAST
See Also:
Constant Field Values

MEDIUM

public static final int MEDIUM
See Also:
Constant Field Values

SLOW

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

ZoomingDialog

public ZoomingDialog(Shell parentShell,
                     Dialog delegate,
                     Rectangle start)
Creates a new instance.

Parameters:
parentShell - shell to use as a parent
delegate - The dialog to open
start - the rectangle, in Display coordinates, to zoom from when opening.

ZoomingDialog

public ZoomingDialog(Shell parentShell,
                     Dialog dialog,
                     int x,
                     int y,
                     int width,
                     int height)
Create new instance. Will zoom from the provided rectangle to the dialog location.

Parameters:
parentShell - shell to use as a parent
dialog - dialog to open
x -
y -
width -
height -
Method Detail

setZoomSpeed

public void setZoomSpeed(int speed)
Sets how long it takes for the Dialog to open, default is FAST. Is one of FAST MEDIUM SLOW

Parameters:
speed - a constant indicating the speed at which the dialog zooms

setBlockOnOpen

public void setBlockOnOpen(boolean shouldBlock)

close

public boolean close()

create

public void create()

getReturnCode

public int getReturnCode()

getInitialLocation

protected Point getInitialLocation(Point initialSize)

getInitialSize

protected Point getInitialSize()

open

public int open()
Opens the dialog.

IMPORTANT: Since there is no way for ZoomingDialog to determine whether setBlockOnOpen is set on the wrapped/decorated Dialog setBlockOnOpen MUST be set on ZoomingDialog


toString

public java.lang.String toString()

createButtonBar

protected Control createButtonBar(Composite parent)

openMessageDialog

public static int openMessageDialog(Rectangle start,
                                    Shell parentShell,
                                    java.lang.String dialogTitle,
                                    Image dialogImage,
                                    java.lang.String dialogMessage,
                                    int dialogImageType,
                                    java.lang.String[] buttonLabels,
                                    int defaultIndex)
Create a message dialog. Notethat the dialog will have no visual representation (no widgets) until it is told to open.

The labels of the buttons to appear in the button bar are supplied in this constructor as an array. The open method will return the index of the label in this array corresponding to the button that was pressed to close the dialog. If the dialog was dismissed without pressing a button (ESC, etc.) then -1 is returned. Note that the open method blocks.

Parameters:
start - the location to zoom from.
parentShell - the parent shell
dialogTitle - the dialog title, or null if none
dialogTitleImage - the dialog title image, or null if none
dialogMessage - the dialog message
dialogImageType - one of the following values:
  • MessageDialog.NONE for a dialog with no image
  • MessageDialog.ERROR for a dialog with an error image
  • MessageDialog.INFORMATION for a dialog with an information image
  • MessageDialog.QUESTION for a dialog with a question image
  • MessageDialog.WARNING for a dialog with a warning image
dialogButtonLabels - an array of labels for the buttons in the button bar
defaultIndex - the index in the button label array of the default button
Returns:

openErrorMessage

public static void openErrorMessage(Rectangle start,
                                    Shell parentShell,
                                    java.lang.String dialogTitle,
                                    java.lang.String dialogMessage)

openWarningMessage

public static void openWarningMessage(Rectangle start,
                                      Shell parentShell,
                                      java.lang.String dialogTitle,
                                      java.lang.String dialogMessage)

openInformationMessage

public static void openInformationMessage(Rectangle start,
                                          Shell parentShell,
                                          java.lang.String dialogTitle,
                                          java.lang.String dialogMessage)

openQuestionMessage

public static boolean openQuestionMessage(Rectangle start,
                                          Shell parentShell,
                                          java.lang.String dialogTitle,
                                          java.lang.String dialogMessage)

calculateBounds

public static Rectangle calculateBounds(Control control)
Calculates the bounds of the Control in Display coordinates (Required by ZoomingDialog constructor).

Parameters:
control - control to use as the starting position
Returns:
the bounds of the Control in Display coordinates

calculateBounds

public static Rectangle calculateBounds(TreeItem item,
                                        int columnIndex)
Calculates the bounds of the Control in Display coordinates (Required by ZoomingDialog constructor).

Parameters:
item - TreeItem to use as the starting position
columnIndex - the index of the column to find the bounds for. If -1 bounds of entire item are found
Returns:
the bounds of the Control in Display coordinates