Eclipse Platform
2.0

org.eclipse.jface.window
Class ApplicationWindow

java.lang.Object
  |
  +--org.eclipse.jface.window.Window
        |
        +--org.eclipse.jface.window.ApplicationWindow
All Implemented Interfaces:
IRunnableContext

public class ApplicationWindow
extends Window
implements IRunnableContext

An application window is a high-level "main window", with built-in support for an optional menu bar with standard menus, an optional toolbar, and an optional status line.

Creating an application window involves the following steps:

Only on the last step, when the window is told to open, are the window's shell and widget tree created. When the window is closed, the shell and widget tree are disposed of and are no longer referenced, and the window is automatically removed from its window manager. Like all windows, an application window may be reopened.

An application window is also a suitable context in which to perform long-running operations (that is, it implements IRunnableContext).


Nested Class Summary
 
Nested classes inherited from class org.eclipse.jface.window.Window
Window.IExceptionHandler
 
Field Summary
 
Fields inherited from class org.eclipse.jface.window.Window
CANCEL, OK
 
Constructor Summary
ApplicationWindow(Shell parentShell)
          Create an application window instance, whose shell will be created under the given parent shell.
 
Method Summary
protected  void addMenuBar()
          Configures this window to have a menu bar.
protected  void addStatusLine()
          Configures this window to have a status line.
protected  void addToolBar(int style)
          Configures this window to have a tool bar.
 boolean close()
          Closes this window, disposes its shell, and removes this window from its window manager (if it has one).
protected  void configureShell(Shell shell)
          Configures the given shell in preparation for opening this window in it.
protected  MenuManager createMenuManager()
          Returns a new menu manager for the window.
protected  StatusLineManager createStatusLineManager()
          Returns a new status line manager for the window.
protected  Control createToolBarControl(Shell shell)
          Creates the control for the tool bar manager.
protected  ToolBarManager createToolBarManager(int style)
          Returns a new tool bar manager for the window.
protected  Font getFont()
          Returns the default font used for this window.
 MenuManager getMenuBarManager()
          Returns the menu bar manager for this window (if it has one).
protected  StatusLineManager getStatusLineManager()
          Returns the status line manager for this window (if it has one).
 String getSymbolicFontName()
          Returns the symbolic font name of the font to be used to display text in this window.
protected  Control getToolBarControl()
          Returns the control for the window's toolbar.
 ToolBarManager getToolBarManager()
          Returns the tool bar manager for this window (if it has one).
 void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable)
          Runs the given IRunnableWithProgress in this context.
 void setStatus(String message)
          Sets or clears the message displayed in this window's status line (if it has one).
protected  boolean toolBarChildrenExist()
          Returns whether or not children exist for the Application Window's toolbar control.
 
Methods inherited from class org.eclipse.jface.window.Window
constrainShellSize, create, createContents, createShell, getContents, getDefaultImage, getInitialLocation, getInitialSize, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, handleShellCloseEvent, initializeBounds, open, setBlockOnOpen, setDefaultImage, setExceptionHandler, setReturnCode, setShellStyle, setWindowManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApplicationWindow

public ApplicationWindow(Shell parentShell)
Create an application window instance, whose shell will be created under the given parent shell. Note that the window will have no visual representation (no widgets) until it is told to open. By default, open does not block.

Parameters:
parentShell - the parent shell, or null to create a top-level shell
Method Detail

addMenuBar

protected void addMenuBar()
Configures this window to have a menu bar. Does nothing if it already has one. This method must be called before this window's shell is created.


addStatusLine

protected void addStatusLine()
Configures this window to have a status line. Does nothing if it already has one. This method must be called before this window's shell is created.


addToolBar

protected void addToolBar(int style)
Configures this window to have a tool bar. Does nothing if it already has one. This method must be called before this window's shell is created.


close

public boolean close()
Description copied from class: Window
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.close must be called).

Overrides:
close in class Window
Returns:
true if the window is (or was already) closed, and false if it is still open

configureShell

protected void configureShell(Shell shell)
Description copied from class: Window
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.

Overrides:
configureShell in class Window
Parameters:
shell - the shell

createMenuManager

protected MenuManager createMenuManager()
Returns a new menu manager for the window.

Subclasses may override this method to customize the menu manager.

Returns:
a menu manager

createStatusLineManager

protected StatusLineManager createStatusLineManager()
Returns a new status line manager for the window.

Subclasses may override this method to customize the status line manager.

Returns:
a status line manager

createToolBarManager

protected ToolBarManager createToolBarManager(int style)
Returns a new tool bar manager for the window.

Subclasses may override this method to customize the tool bar manager.

Returns:
a tool bar manager

createToolBarControl

protected Control createToolBarControl(Shell shell)
Creates the control for the tool bar manager.

Subclasses may override this method to customize the tool bar manager.

Returns:
a Control

getFont

protected Font getFont()
Returns the default font used for this window.

The default implementation of this framework method obtains the symbolic name of the font from the getSymbolicFontName framework method and retrieves this font from JFace's font registry using JFaceResources.getFont. Subclasses may override to use a different registry, etc.

Returns:
the default font, or null if none

getMenuBarManager

public MenuManager getMenuBarManager()
Returns the menu bar manager for this window (if it has one).

Returns:
the menu bar manager, or null if this window does not have a menu bar
See Also:
addMenuBar()

getStatusLineManager

protected StatusLineManager getStatusLineManager()
Returns the status line manager for this window (if it has one).

Returns:
the status line manager, or null if this window does not have a status line
See Also:
addStatusLine()

getSymbolicFontName

public String getSymbolicFontName()
Returns the symbolic font name of the font to be used to display text in this window. This is not recommended and is included for backwards compatability. It is recommended to use the default font provided by SWT (that is, do not set the font).

Returns:
the symbolic font name

getToolBarManager

public ToolBarManager getToolBarManager()
Returns the tool bar manager for this window (if it has one).

Returns:
the tool bar manager, or null if this window does not have a tool bar
See Also:
addToolBar(int)

getToolBarControl

protected Control getToolBarControl()
Returns the control for the window's toolbar.

Subclasses may override this method to customize the tool bar manager.

Returns:
a Control

run

public void run(boolean fork,
                boolean cancelable,
                IRunnableWithProgress runnable)
         throws InvocationTargetException,
                InterruptedException
Description copied from interface: IRunnableContext
Runs the given IRunnableWithProgress in this context. For example, if this is a ProgressMonitorDialog then the runnable is run using this dialog's progress monitor.

Specified by:
run in interface IRunnableContext
Parameters:
fork - true if the runnable should be run in a separate thread, and false to run in the same thread
cancelable - true to enable the cancelation, and false to make the operation uncancellable
runnable - the runnable to run
Throws:
InvocationTargetException - wraps any exception or error which occurs while running the runnable
InterruptedException - propagated by the context if the runnable acknowledges cancelation by throwing this exception

setStatus

public void setStatus(String message)
Sets or clears the message displayed in this window's status line (if it has one). This method has no effect if the window does not have a status line.

Parameters:
message - the status message, or null to clear it

toolBarChildrenExist

protected boolean toolBarChildrenExist()
Returns whether or not children exist for the Application Window's toolbar control.

Returns:
boolean true if children exist, false otherwise

Eclipse Platform
2.0

Copyright (c) IBM Corp. and others 2000, 2002. All Rights Reserved.