public class ApplicationWindow extends Window implements IRunnableContext
Creating an application window involves the following steps:
ApplicationWindow
open
An application window is also a suitable context in which to perform
long-running operations (that is, it implements IRunnableContext
).
Window.IExceptionHandler
Modifier and Type | Field and Description |
---|---|
protected Label |
seperator1
The seperator between the menu bar and the rest of the window.
|
CANCEL, OK, resizeHasOccurred
Constructor and Description |
---|
ApplicationWindow(Shell parentShell)
Create an application window instance, whose shell will be created under the
given parent shell.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addCoolBar(int style)
Configures this window to have a cool bar.
|
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.
|
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(Shell shell)
Extends the super implementation by creating the trim widgets using
createTrimWidgets . |
protected boolean |
coolBarChildrenExist()
Returns whether or not children exist for this application window's
cool bar control.
|
protected Control |
createCoolBarControl(Composite composite)
Creates the control for the cool bar manager.
|
protected CoolBarManager |
createCoolBarManager(int style)
Returns a new cool bar manager for the window.
|
protected ICoolBarManager |
createCoolBarManager2(int style)
Returns a new cool bar manager for the window.
|
protected MenuManager |
createMenuManager()
Returns a new menu manager for the window.
|
protected void |
createStatusLine(Shell shell)
Create the status line if required.
|
protected StatusLineManager |
createStatusLineManager()
Returns a new status line manager for the window.
|
protected Control |
createToolBarControl(Composite parent)
Creates the control for the tool bar manager.
|
protected ToolBarManager |
createToolBarManager(int style)
Returns a new tool bar manager for the window.
|
protected IToolBarManager |
createToolBarManager2(int style)
Returns a new tool bar manager for the window.
|
protected void |
createTrimWidgets(Shell shell)
Creates the trim widgets around the content area.
|
protected Control |
getCoolBarControl()
Returns the control for the window's cool bar.
|
CoolBarManager |
getCoolBarManager()
Returns the cool bar manager for this window.
|
ICoolBarManager |
getCoolBarManager2()
Returns the cool bar manager for this window.
|
protected Font |
getFont()
Returns the default font used for this window.
|
protected Layout |
getLayout()
Creates the layout for the shell.
|
MenuManager |
getMenuBarManager()
Returns the menu bar manager for this window (if it has one).
|
protected Label |
getSeperator1()
Return the top seperator.
|
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).
|
IToolBarManager |
getToolBarManager2()
Returns the tool bar manager for this window (if it has one).
|
void |
run(boolean fork,
boolean cancelable,
IRunnableWithProgress runnable)
This implementation of IRunnableContext#run(boolean, boolean,
IRunnableWithProgress) blocks until the runnable has been run,
regardless of the value of
fork . |
void |
setStatus(String message)
Sets or clears the message displayed in this window's status
line (if it has one).
|
protected boolean |
showTopSeperator()
Returns whether to show a top separator line between the menu bar
and the rest of the window contents.
|
protected boolean |
toolBarChildrenExist()
Returns whether or not children exist for the Application Window's
toolbar control.
|
constrainShellSize, create, createContents, createShell, getConstrainedShellBounds, getContents, getDefaultImage, getDefaultImages, getDefaultOrientation, getInitialLocation, getInitialSize, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, handleShellCloseEvent, initializeBounds, open, setBlockOnOpen, setDefaultImage, setDefaultImages, setDefaultModalParent, setDefaultOrientation, setExceptionHandler, setParentShell, setReturnCode, setShellStyle, setWindowManager
protected Label seperator1
public ApplicationWindow(Shell parentShell)
open
does not block.parentShell
- the parent shell, or null
to create a top-level shellprotected Label getSeperator1()
protected void addMenuBar()
protected void addStatusLine()
protected void addToolBar(int style)
style
- swt style bits used to create the ToolbarToolBarManager.ToolBarManager(int)
,
for style bits
protected void addCoolBar(int style)
style
- the cool bar styleprotected boolean canHandleShellCloseEvent()
Window
The default implementation of this framework method returns
true
, which will allow the
handleShellCloseEvent
method to be called. Subclasses may
extend or reimplement.
canHandleShellCloseEvent
in class Window
public boolean close()
Window
This framework method may be extended (super.close
must
be called).
Note that in order to prevent recursive calls to this method
it does not call Shell#close()
. As a result ShellListener
s
will not receive a shellClosed
event.
protected void configureShell(Shell shell)
createTrimWidgets
.configureShell
in class Window
shell
- the shellprotected void createTrimWidgets(Shell shell)
shell
- the shellprotected Layout getLayout()
Window
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.
protected boolean showTopSeperator()
true
to show the top separator, false
to not show itprotected void createStatusLine(Shell shell)
shell
- protected MenuManager createMenuManager()
Subclasses may override this method to customize the menu manager.
protected StatusLineManager createStatusLineManager()
Subclasses may override this method to customize the status line manager.
protected ToolBarManager createToolBarManager(int style)
Subclasses may override this method to customize the tool bar manager.
style
- swt style bits used to create the ToolbarToolBarManager.ToolBarManager(int)
,
for style bits
protected IToolBarManager createToolBarManager2(int style)
By default this method calls createToolBarManager
. Subclasses
may override this method to provide an alternative implementation for the
tool bar manager.
style
- swt style bits used to create the ToolbarcreateToolBarManager(int)
protected CoolBarManager createCoolBarManager(int style)
Subclasses may override this method to customize the cool bar manager.
style
- swt style bits used to create the CoolbarCoolBarManager.CoolBarManager(int)
,
for style bits
protected ICoolBarManager createCoolBarManager2(int style)
By default this method calls createCoolBarManager
. Subclasses
may override this method to provide an alternative implementation for the
cool bar manager.
style
- swt style bits used to create the CoolbarcreateCoolBarManager(int)
protected Control createToolBarControl(Composite parent)
Subclasses may override this method to customize the tool bar manager.
parent
- the parent used for the controlprotected Control createCoolBarControl(Composite composite)
Subclasses may override this method to customize the cool bar manager.
composite
- the parent used for the controlCoolBar
protected Font getFont()
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.
null
if nonepublic MenuManager getMenuBarManager()
null
if
this window does not have a menu baraddMenuBar()
protected StatusLineManager getStatusLineManager()
null
if
this window does not have a status lineaddStatusLine()
public String getSymbolicFontName()
public ToolBarManager getToolBarManager()
null
if
this window does not have a tool baraddToolBar(int)
public IToolBarManager getToolBarManager2()
null
if
this window does not have a tool baraddToolBar(int)
public CoolBarManager getCoolBarManager()
null
if
this window does not have a cool baraddCoolBar(int)
public ICoolBarManager getCoolBarManager2()
null
if
this window does not have a cool baraddCoolBar(int)
protected Control getToolBarControl()
Subclasses may override this method to customize the tool bar manager.
protected Control getCoolBarControl()
Subclasses may override this method to customize the cool bar manager.
CoolBar
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException
fork
.
It is recommended that fork
is set to
true in most cases. If fork
is set to false
,
the runnable will run in the UI thread and it is the runnable's
responsibility to call Display.readAndDispatch()
to ensure UI responsiveness.run
in interface IRunnableContext
fork
- true
if the runnable should be run in a separate thread,
and false
to run in the same threadcancelable
- true
to enable the cancelation, and
false
to make the operation uncancellablerunnable
- the runnable to runInvocationTargetException
- wraps any exception or error which occurs
while running the runnableInterruptedException
- propagated by the context if the runnable
acknowledges cancelation by throwing this exception. This should not be thrown
if cancelable is false
.public void setStatus(String message)
message
- the status message, or null
to clear itprotected boolean toolBarChildrenExist()
protected boolean coolBarChildrenExist()
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.