Class ApplicationWindow
- java.lang.Object
-
- org.eclipse.jface.window.Window
-
- org.eclipse.jface.window.ApplicationWindow
-
- All Implemented Interfaces:
IRunnableContext
,IShellProvider
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:
- creating an instance of
ApplicationWindow
- assigning the window to a window manager (optional)
- opening the window by calling
open
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/interfaces inherited from class org.eclipse.jface.window.Window
Window.IExceptionHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected Label
seperator1
The seperator between the menu bar and the rest of the window.-
Fields inherited from class org.eclipse.jface.window.Window
CANCEL, OK, resizeHasOccurred
-
-
Constructor Summary
Constructors Constructor Description ApplicationWindow(Shell parentShell)
Create an application window instance, whose shell will be created under the given parent shell.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 usingcreateTrimWidgets
.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 offork
.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.-
Methods inherited from class org.eclipse.jface.window.Window
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
-
-
-
-
Field Detail
-
seperator1
protected Label seperator1
The seperator between the menu bar and the rest of the window.
-
-
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, ornull
to create a top-level shell
-
-
Method Detail
-
getSeperator1
protected Label getSeperator1()
Return the top seperator.- Returns:
- Label
-
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.- Parameters:
style
- swt style bits used to create the Toolbar- See Also:
ToolBarManager(int)
,for style bits
-
addCoolBar
protected void addCoolBar(int style)
Configures this window to have a cool bar. Does nothing if it already has one. This method must be called before this window's shell is created.- Parameters:
style
- the cool bar style- Since:
- 3.0
-
canHandleShellCloseEvent
protected boolean canHandleShellCloseEvent()
Description copied from class:Window
Determines if the window should handle the close event or do nothing.The default implementation of this framework method returns
true
, which will allow thehandleShellCloseEvent
method to be called. Subclasses may extend or reimplement.- Overrides:
canHandleShellCloseEvent
in classWindow
- Returns:
- whether the window should handle the close event.
-
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).Note that in order to prevent recursive calls to this method it does not call
Shell#close()
. As a resultShellListener
s will not receive ashellClosed
event.
-
configureShell
protected void configureShell(Shell shell)
Extends the super implementation by creating the trim widgets usingcreateTrimWidgets
.- Overrides:
configureShell
in classWindow
- Parameters:
shell
- the shell
-
createTrimWidgets
protected void createTrimWidgets(Shell shell)
Creates the trim widgets around the content area.- Parameters:
shell
- the shell- Since:
- 3.0
-
getLayout
protected Layout getLayout()
Description copied from class:Window
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.
-
showTopSeperator
protected boolean showTopSeperator()
Returns whether to show a top separator line between the menu bar and the rest of the window contents. On some platforms such as the Mac, the menu is separated from the main window already, so a separator line is not desired.- Returns:
true
to show the top separator,false
to not show it- Since:
- 3.0
-
createStatusLine
protected void createStatusLine(Shell shell)
Create the status line if required.- Parameters:
shell
- the shell to create status line into
-
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.
- Parameters:
style
- swt style bits used to create the Toolbar- Returns:
- a tool bar manager
- See Also:
ToolBarManager(int)
,for style bits
-
createToolBarManager2
protected IToolBarManager createToolBarManager2(int style)
Returns a new tool bar manager for the window.By default this method calls
createToolBarManager
. Subclasses may override this method to provide an alternative implementation for the tool bar manager.- Parameters:
style
- swt style bits used to create the Toolbar- Returns:
- a tool bar manager
- Since:
- 3.2
- See Also:
createToolBarManager(int)
-
createCoolBarManager
protected CoolBarManager createCoolBarManager(int style)
Returns a new cool bar manager for the window.Subclasses may override this method to customize the cool bar manager.
- Parameters:
style
- swt style bits used to create the Coolbar- Returns:
- a cool bar manager
- Since:
- 3.0
- See Also:
CoolBarManager(int)
,for style bits
-
createCoolBarManager2
protected ICoolBarManager createCoolBarManager2(int style)
Returns a new cool bar manager for the window.By default this method calls
createCoolBarManager
. Subclasses may override this method to provide an alternative implementation for the cool bar manager.- Parameters:
style
- swt style bits used to create the Coolbar- Returns:
- a cool bar manager
- Since:
- 3.2
- See Also:
createCoolBarManager(int)
-
createToolBarControl
protected Control createToolBarControl(Composite parent)
Creates the control for the tool bar manager.Subclasses may override this method to customize the tool bar manager.
- Parameters:
parent
- the parent used for the control- Returns:
- a Control
-
createCoolBarControl
protected Control createCoolBarControl(Composite composite)
Creates the control for the cool bar manager.Subclasses may override this method to customize the cool bar manager.
- Parameters:
composite
- the parent used for the control- Returns:
- an instance of
CoolBar
- Since:
- 3.0
-
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 usingJFaceResources.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)
-
getToolBarManager2
public IToolBarManager getToolBarManager2()
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 - Since:
- 3.2
- See Also:
addToolBar(int)
-
getCoolBarManager
public CoolBarManager getCoolBarManager()
Returns the cool bar manager for this window.- Returns:
- the cool bar manager, or
null
if this window does not have a cool bar - Since:
- 3.0
- See Also:
addCoolBar(int)
-
getCoolBarManager2
public ICoolBarManager getCoolBarManager2()
Returns the cool bar manager for this window.- Returns:
- the cool bar manager, or
null
if this window does not have a cool bar - Since:
- 3.2
- See Also:
addCoolBar(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
-
getCoolBarControl
protected Control getCoolBarControl()
Returns the control for the window's cool bar.Subclasses may override this method to customize the cool bar manager.
- Returns:
- an instance of
CoolBar
- Since:
- 3.0
-
run
public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException
This implementation of IRunnableContext#run(boolean, boolean, IRunnableWithProgress) blocks until the runnable has been run, regardless of the value offork
. It is recommended thatfork
is set to true in most cases. Iffork
is set tofalse
, the runnable will run in the UI thread and it is the runnable's responsibility to callDisplay.readAndDispatch()
to ensure UI responsiveness.- Specified by:
run
in interfaceIRunnableContext
- Parameters:
fork
-true
if the runnable should be run in a separate thread, andfalse
to run in the same threadcancelable
-true
to enable the cancelation, andfalse
to make the operation uncancellablerunnable
- the runnable to run- Throws:
InvocationTargetException
- 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 isfalse
.
-
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, ornull
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
-
coolBarChildrenExist
protected boolean coolBarChildrenExist()
Returns whether or not children exist for this application window's cool bar control.- Returns:
- boolean true if children exist, false otherwise
- Since:
- 3.0
-
-