|
|||||||||
| Home >> All >> org >> eclipse >> jface >> [ window overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.eclipse.jface.window
Class Window

java.lang.Objectorg.eclipse.jface.window.Window
- Direct Known Subclasses:
- ApplicationWindow
- public abstract class Window
- extends java.lang.Object
A JFace window is an object that has no visual representation (no widgets) until it is told to open.
Creating a window involves the following steps:
- creating an instance of a concrete subclass of
Window - creating the window's shell and widget tree by calling
create(optional) - assigning the window to a window manager using
WindowManager.add(optional) - opening the window by calling
open
The JFace window framework (this package) consists of this class,
Window, the abstract base of all windows, and one concrete
window classes (ApplicationWindow) which may also be subclassed.
Clients may define additional window subclasses as required.
The Window class provides the following methods which subclasses
may override:
close- extend to free other SWT resourcesconfigureShell- extend or reimplement to set shell properties before window openscreateContents- extend or reimplement to create controls before window opensgetInitialSize- reimplement to give the initial size for the shellgetInitialLocation- reimplement to give the initial location for the shellgetShellListener- extend or reimplement to receive shell eventsgetToolTipText- reimplement to add tool tipshandleFontChange- reimplement to respond to font changeshandleShellCloseEvent- extend or reimplement to handle shell closings
| Nested Class Summary | |
private static class |
Window.DefaultExceptionHandler
Defines a default exception handler. |
private class |
Window.FontChangeListener
Internal class for informing this window when fonts change. |
static interface |
Window.IExceptionHandler
This interface defines a Exception Handler which can be set as a global handler and will be called if an exception happens in the event loop. |
| Field Summary | |
private boolean |
block
true if the open method should
not return until the window closes, and false if the
open method should return immediately;
initially false (non-blocking). |
static int |
CANCEL
Standard return code constant (value 1) indicating that the window was canceled. |
private org.eclipse.swt.widgets.Control |
contents
Top level SWT control, or null if none |
private static org.eclipse.swt.graphics.Image[] |
defaultImages
An array of images to be used for the window. |
private static Window.IExceptionHandler |
exceptionHandler
The exception handler for this application. |
private Window.FontChangeListener |
fontChangeListener
Internal font change listener. |
static int |
OK
Standard return code constant (value 0) indicating that the window was opened. |
private org.eclipse.swt.widgets.Shell |
parentShell
The parent shell. |
private boolean |
resizeHasOccurred
Internal fields to detect if shell size has been set |
private org.eclipse.swt.widgets.Listener |
resizeListener
|
private int |
returnCode
Window return code; initially OK. |
private org.eclipse.swt.widgets.Shell |
shell
Window shell, or null if none. |
private int |
shellStyle
Shell style bits. |
private WindowManager |
windowManager
Window manager, or null if none. |
| Constructor Summary | |
protected |
Window(org.eclipse.swt.widgets.Shell parentShell)
Creates a window instance, whose shell will be created under the given parent shell. |
| Method Summary | |
protected boolean |
canHandleShellCloseEvent()
Determines if the window should handle the close event or do nothing. |
boolean |
close()
Closes this window, disposes its shell, and removes this window from its window manager (if it has one). |
protected void |
configureShell(org.eclipse.swt.widgets.Shell newShell)
Configures the given shell in preparation for opening this window in it. |
protected void |
constrainShellSize()
Constrain the shell size to be no larger than the display bounds. |
void |
create()
Creates this window's widgetry in a new top-level shell. |
protected org.eclipse.swt.widgets.Control |
createContents(org.eclipse.swt.widgets.Composite parent)
Creates and returns this window's contents. |
protected org.eclipse.swt.widgets.Shell |
createShell()
Creates and returns this window's shell. |
private static org.eclipse.swt.widgets.Monitor |
getClosestMonitor(org.eclipse.swt.widgets.Display toSearch,
org.eclipse.swt.graphics.Point toFind)
Returns the monitor whose client area contains the given point. |
protected org.eclipse.swt.graphics.Rectangle |
getConstrainedShellBounds(org.eclipse.swt.graphics.Rectangle preferredSize)
Given the desired position of the window, this method returns an adjusted position such that the window is no larger than its monitor, and does not extend beyond the edge of the monitor. |
protected org.eclipse.swt.widgets.Control |
getContents()
Returns the top level control for this window. |
static org.eclipse.swt.graphics.Image |
getDefaultImage()
Returns the default image. |
static org.eclipse.swt.graphics.Image[] |
getDefaultImages()
Returns the array of default images to use for newly opened windows. |
protected org.eclipse.swt.graphics.Point |
getInitialLocation(org.eclipse.swt.graphics.Point initialSize)
Returns the initial location to use for the shell. |
protected org.eclipse.swt.graphics.Point |
getInitialSize()
Returns the initial size to use for the shell. |
protected org.eclipse.swt.widgets.Layout |
getLayout()
Creates the layout for the shell. |
protected org.eclipse.swt.widgets.Shell |
getParentShell()
Returns parent shell, under which this window's shell is created. |
int |
getReturnCode()
Returns this window's return code. |
org.eclipse.swt.widgets.Shell |
getShell()
Returns this window's shell. |
protected org.eclipse.swt.events.ShellListener |
getShellListener()
Returns a shell listener. |
protected int |
getShellStyle()
Returns the shell style bits. |
WindowManager |
getWindowManager()
Returns the window manager of this window. |
protected void |
handleFontChange(org.eclipse.jface.util.PropertyChangeEvent event)
Notifies of a font property change. |
protected void |
handleShellCloseEvent()
Notifies that the window's close button was pressed, the close menu was selected, or the ESCAPE key pressed. |
protected void |
initializeBounds()
Initializes the location and size of this window's SWT shell after it has been created. |
int |
open()
Opens this window, creating it first if it has not yet been created. |
private void |
runEventLoop(org.eclipse.swt.widgets.Shell shell)
Runs the event loop for the given shell. |
void |
setBlockOnOpen(boolean shouldBlock)
Sets whether the open method should block
until the window closes. |
static void |
setDefaultImage(org.eclipse.swt.graphics.Image image)
Sets the default image. |
static void |
setDefaultImages(org.eclipse.swt.graphics.Image[] images)
Sets the array of default images to use for newly opened windows. |
static void |
setExceptionHandler(Window.IExceptionHandler handler)
Sets the exception handler for this application. |
protected void |
setReturnCode(int code)
Sets this window's return code. |
protected void |
setShellStyle(int newShellStyle)
Sets the shell style bits. |
void |
setWindowManager(WindowManager manager)
Sets the window manager of this window. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
OK
public static final int OK
- Standard return code constant (value 0) indicating that the
window was opened.
- See Also:
open()55 , Constant Field Values
CANCEL
public static final int CANCEL
- Standard return code constant (value 1) indicating that the
window was canceled.
- See Also:
open()55 , Constant Field Values
defaultImages
private static org.eclipse.swt.graphics.Image[] defaultImages
- An array of images to be used for the window. It is
expected that the array will contain the same icon
rendered at different resolutions.
exceptionHandler
private static Window.IExceptionHandler exceptionHandler
- The exception handler for this application.
parentShell
private org.eclipse.swt.widgets.Shell parentShell
- The parent shell.
shellStyle
private int shellStyle
- Shell style bits.
- See Also:
setShellStyle(int)55
windowManager
private WindowManager windowManager
- Window manager, or
nullif none.
shell
private org.eclipse.swt.widgets.Shell shell
- Window shell, or
nullif none.
contents
private org.eclipse.swt.widgets.Control contents
- Top level SWT control, or
nullif none
returnCode
private int returnCode
- Window return code; initially
OK.- See Also:
setReturnCode(int)55
block
private boolean block
trueif theopenmethod should not return until the window closes, andfalseif theopenmethod should return immediately; initiallyfalse(non-blocking).- See Also:
setBlockOnOpen(boolean)55
fontChangeListener
private Window.FontChangeListener fontChangeListener
- Internal font change listener.
resizeHasOccurred
private boolean resizeHasOccurred
- Internal fields to detect if shell size has been set
resizeListener
private org.eclipse.swt.widgets.Listener resizeListener
| Constructor Detail |
Window
protected Window(org.eclipse.swt.widgets.Shell parentShell)
- Creates a window instance, whose shell will be created under the
given parent shell.
Note that the window will have no visual representation until it is told
to open. By default,
opendoes not block.
| Method Detail |
canHandleShellCloseEvent
protected boolean canHandleShellCloseEvent()
- Determines if the window should handle the close event
or do nothing.
The default implementation of this framework method returns
true, which will allow thehandleShellCloseEventmethod to be called. Subclasses may extend or reimplement.
close
public boolean close()
- Closes this window, disposes its shell, and removes this
window from its window manager (if it has one).
This framework method may be extended (
super.closemust be called).
configureShell
protected void configureShell(org.eclipse.swt.widgets.Shell newShell)
- Configures the given shell in preparation for opening this window
in it.
The default implementation of this framework method sets the shell's image and gives it a grid layout. Subclasses may extend or reimplement.
getLayout
protected org.eclipse.swt.widgets.Layout getLayout()
- Creates the layout for the shell. The layout
created here will be attached to the composite
passed into createContents. The default implementation
returns a GridLayout with no margins. Subclasses
that change the layout type by overriding this method
should also override createContents.
A return value of null indicates that no layout should be attached to the composite. In this case, the layout may be attached within createContents.
- Since:
- 3.0
constrainShellSize
protected void constrainShellSize()
- Constrain the shell size to be no larger than the display bounds.
- Since:
- 2.0
create
public void create()
- Creates this window's widgetry in a new top-level shell.
The default implementation of this framework method creates this window's shell (by calling
createShell), and its controls (by callingcreateContents), then initializes this window's shell bounds (by callinginitializeBounds).
createContents
protected org.eclipse.swt.widgets.Control createContents(org.eclipse.swt.widgets.Composite parent)
- Creates and returns this window's contents. Subclasses may attach
any number of children to the parent. As a convenience, the return value
of this method will be remembered and returned by subsequent calls to
getControl(). Subclasses may modify the parent's layout if they overload
getLayout() to return null.
It is common practise to create and return a single composite that contains the entire window contents.
The default implementation of this framework method creates an instance of
Composite. Subclasses may override.
createShell
protected final org.eclipse.swt.widgets.Shell createShell()
- Creates and returns this window's shell.
The default implementation of this framework method creates a new shell and configures it using
configureShell. Rather than override this method, subclasses should instead overrideconfigureShell.
getContents
protected org.eclipse.swt.widgets.Control getContents()
- Returns the top level control for this window.
The parent of this control is the shell.
getDefaultImage
public static org.eclipse.swt.graphics.Image getDefaultImage()
- Returns the default image. This is the image that will
be used for windows that have no shell image at the time they
are opened. There is no default image unless one is
installed via
setDefaultImage.
getDefaultImages
public static org.eclipse.swt.graphics.Image[] getDefaultImages()
- Returns the array of default images to use for newly opened windows.
It is expected that the array will contain the same icon rendered at
different resolutions.
- Since:
- 3.0
getInitialLocation
protected org.eclipse.swt.graphics.Point getInitialLocation(org.eclipse.swt.graphics.Point initialSize)
- Returns the initial location to use for the shell.
The default implementation centers the shell horizontally
(1/2 of the difference to the left and 1/2 to the right)
and vertically (1/3 above and 2/3 below) relative to the parent shell,
or display bounds if there is no parent shell.
getInitialSize
protected org.eclipse.swt.graphics.Point getInitialSize()
- Returns the initial size to use for the shell.
The default implementation returns the preferred size of the shell,
using
Shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).
getParentShell
protected org.eclipse.swt.widgets.Shell getParentShell()
- Returns parent shell, under which this window's shell is created.
getReturnCode
public int getReturnCode()
- Returns this window's return code.
A window's return codes are window-specific, although two standard
return codes are predefined:
OKandCANCEL.
getShell
public org.eclipse.swt.widgets.Shell getShell()
- Returns this window's shell.
getShellListener
protected org.eclipse.swt.events.ShellListener getShellListener()
- Returns a shell listener. This shell listener gets registered
with this window's shell.
The default implementation of this framework method returns a new listener that makes this window the active window for its window manager (if it has one) when the shell is activated, and calls the framework method
handleShellCloseEventwhen the shell is closed. Subclasses may extend or reimplement.
getShellStyle
protected int getShellStyle()
- Returns the shell style bits.
The default value is
SWT.CLOSE|SWT.MIN|SWT.MAX|SWT.RESIZE. Subclassers should callsetShellStyleto change this value, rather than overriding this method.
getWindowManager
public WindowManager getWindowManager()
- Returns the window manager of this window.
handleFontChange
protected void handleFontChange(org.eclipse.jface.util.PropertyChangeEvent event)
- Notifies of a font property change.
The default implementation of this framework method does nothing. Subclasses may reimplement.
handleShellCloseEvent
protected void handleShellCloseEvent()
- Notifies that the window's close button was pressed,
the close menu was selected, or the ESCAPE key pressed.
The default implementation of this framework method sets the window's return code to
CANCELand closes the window usingclose. Subclasses may extend or reimplement.
initializeBounds
protected void initializeBounds()
- Initializes the location and size of this window's SWT shell
after it has been created.
This framework method is called by the
createframework method. The default implementation callsgetInitialSizeandgetInitialLocationand passes the results toShell.setBounds. This is only done if the bounds of the shell have not already been modified. Subclasses may extend or reimplement.
open
public int open()
- Opens this window, creating it first if it has not yet been created.
If this window has been configured to block on open (
setBlockOnOpen), this method waits until the window is closed by the end user, and then it returns the window's return code; otherwise, this method returns immediately. A window's return codes are window-specific, although two standard return codes are predefined:OKandCANCEL.
runEventLoop
private void runEventLoop(org.eclipse.swt.widgets.Shell shell)
- Runs the event loop for the given shell.
setBlockOnOpen
public void setBlockOnOpen(boolean shouldBlock)
- Sets whether the
openmethod should block until the window closes.
setDefaultImage
public static void setDefaultImage(org.eclipse.swt.graphics.Image image)
- Sets the default image. This is the image that will
be used for windows that have no shell image at the time they
are opened. There is no default image unless one is
installed via this method.
setDefaultImages
public static void setDefaultImages(org.eclipse.swt.graphics.Image[] images)
- Sets the array of default images to use for newly opened windows.
It is expected that the array will contain the same icon rendered at
different resolutions.
- Since:
- 3.0
setReturnCode
protected void setReturnCode(int code)
- Sets this window's return code. The return code is automatically returned
by
openif block on open is enabled. For non-blocking opens, the return code needs to be retrieved manually usinggetReturnCode.
getClosestMonitor
private static org.eclipse.swt.widgets.Monitor getClosestMonitor(org.eclipse.swt.widgets.Display toSearch, org.eclipse.swt.graphics.Point toFind)
- Returns the monitor whose client area contains the given point. If no monitor
contains the point, returns the monitor that is closest to the point.
If this is ever made public, it should be moved into a separate utility class.
getConstrainedShellBounds
protected org.eclipse.swt.graphics.Rectangle getConstrainedShellBounds(org.eclipse.swt.graphics.Rectangle preferredSize)
- Given the desired position of the window, this method returns an
adjusted position such that the window is no larger than its monitor,
and does not extend beyond the edge of the monitor. This is used for
computing the initial window position, and subclasses can use this
as a utility method if they want to limit the region in which the
window may be moved.
- Since:
- 3.0
setShellStyle
protected void setShellStyle(int newShellStyle)
- Sets the shell style bits.
This method has no effect after the shell is created.
The shell style bits are used by the framework method
createShellwhen creating this window's shell.
setWindowManager
public void setWindowManager(WindowManager manager)
- Sets the window manager of this window.
Note that this method is used by
WindowManagerto maintain a backpointer. Clients must not call the method directly.
setExceptionHandler
public static void setExceptionHandler(Window.IExceptionHandler handler)
- Sets the exception handler for this application.
Note that only one handler may be set. Other calls to this method will be ignored.
|
|||||||||
| Home >> All >> org >> eclipse >> jface >> [ window overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.eclipse.jface.window.Window