Groovy Documentation

griffon.swing
[Java] Class WindowManager

java.lang.Object
  griffon.swing.WindowManager
All Implemented Interfaces:
ShutdownHandler

public final class WindowManager
extends Object

Controls a set of windows that belong to the application.

Windows that are controlled by a WindowManager can be shown/hidden using a custom strategy (WindowDisplayHandler)

Authors:
Andres Almiray
See Also:
WindowDisplayHandler
Since:
0.3.1


Nested Class Summary
private class WindowManager.ComponentHelper

ComponentAdapter that triggers application events when a window is shown/hidden.

private class WindowManager.InternalFrameHelper

InternalFrameAdapter that triggers application events when a window is shown/hidden, it also invokes hide() when the window is about to be closed.

private class WindowManager.WindowHelper

WindowAdapter that optionally invokes hide() when the window is about to be closed.

 
Field Summary
private static org.slf4j.Logger LOG

private SwingGriffonApplication app

private WindowManager.ComponentHelper componentHelper

private boolean hideBeforeHandler

private WindowManager.InternalFrameHelper internalFrameHelper

private List internalFrames

private WindowManager.WindowHelper windowHelper

private List windows

 
Constructor Summary
WindowManager(SwingGriffonApplication app)

Creates a new WindowManager tied to an specific application.

 
Method Summary
void attach(Window window)

Registers a window on this manager if an only if the window is not null and it's not registered already.

void attach(JInternalFrame internalFrame)

Registers an internal frame on this manager if an only if the internal frame is not null and it's not registered already.

boolean canShutdown(GriffonApplication app)

int countVisibleWindows()

Counts how many Windows are visible regardless of their attached status to this WindowManager.

void detach(Window window)

Removes the window from the list of manages windows if and only if it is registered with this manager.

void detach(JInternalFrame internalFrame)

Removes the internal frame from the list of manages internal frames if and only if it is registered with this manager.

JInternalFrame findInternalFrame(String name)

Finds a JInternalFrame by name.

Window findWindow(String name)

Finds a Window by name.

Window getAt(int index)

Convenience method to get a managed Window by index.

List getInternalFrames()

Returns the list of internal frames managed by this manager.

Window getStartingWindow()

Finds the Window that should be displayed during the Ready phase of an application.

List getWindows()

Returns the list of windows managed by this manager.

void hide(Window window)

Hides the window.

void hide(JInternalFrame internalFrame)

Hides the internal frame.

void hide(String name)

Hides the window.

boolean isAutoShutdown()

Returns the value of the "application.autoShutdown" configuration flag.

boolean isHideBeforeHandler()

Should the window be hidden before all ShutdownHandlers be called ?

void onShutdown(GriffonApplication app)

Hides all visible windows

void setHideBeforeHandler(boolean hideBeforeHandler)

Set if the window should be hidden before all ShutdownHandler be called.

void show(Window window)

Shows the window.

void show(JInternalFrame internalFrame)

Shows the internal frame.

void show(String name)

Shows the window.

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

LOG

private static final org.slf4j.Logger LOG


app

private final SwingGriffonApplication app


componentHelper

private final WindowManager.ComponentHelper componentHelper


hideBeforeHandler

private boolean hideBeforeHandler


internalFrameHelper

private final WindowManager.InternalFrameHelper internalFrameHelper


internalFrames

private final List internalFrames


windowHelper

private final WindowManager.WindowHelper windowHelper


windows

private final List windows


 
Constructor Detail

WindowManager

public WindowManager(SwingGriffonApplication app)
Creates a new WindowManager tied to an specific application.
Parameters:
app - an application


 
Method Detail

attach

public void attach(Window window)
Registers a window on this manager if an only if the window is not null and it's not registered already.
Parameters:
window - the window to be added to the list of managed windows


attach

public void attach(JInternalFrame internalFrame)
Registers an internal frame on this manager if an only if the internal frame is not null and it's not registered already.
Parameters:
internalFrame - the internal frame to be added to the list of managed internal frames
Since:
0.9.5


canShutdown

public boolean canShutdown(GriffonApplication app)


countVisibleWindows

public int countVisibleWindows()
Counts how many Windows are visible regardless of their attached status to this WindowManager.
Returns:
the number of visible Windows
Since:
1.3.0


detach

public void detach(Window window)
Removes the window from the list of manages windows if and only if it is registered with this manager.
Parameters:
window - the window to be removed


detach

public void detach(JInternalFrame internalFrame)
Removes the internal frame from the list of manages internal frames if and only if it is registered with this manager.
Parameters:
internalFrame - the internal frame to be removed
Since:
0.9.5


findInternalFrame

public JInternalFrame findInternalFrame(String name)
Finds a JInternalFrame by name.
Parameters:
name - the value of the name: property
Returns:
a JInternalFrame if a match is found, null otherwise.
Since:
0.9.5


findWindow

public Window findWindow(String name)
Finds a Window by name.
Parameters:
name - the value of the name: property
Returns:
a Window if a match is found, null otherwise.


getAt

public Window getAt(int index)
Convenience method to get a managed Window by index.

Follows the Groovy conventions for overriding the [] operator.

throws:
ArrayIndexOutOfBoundsException if the index is invalid (below 0 or greater than the size of the managed windows list)
Parameters:
index - the index of the Window to be retrieved
Returns:
the Window found at the specified index


getInternalFrames

public List getInternalFrames()
Returns the list of internal frames managed by this manager.
Returns:
a List of currently managed internal frames
Since:
0.9.5


getStartingWindow

public Window getStartingWindow()
Finds the Window that should be displayed during the Ready phase of an application.

The WindowManager expects a configuration flag swing.windowManager.startingWindow to be present in order to determine which Window will be displayed during the Ready phase. If no configuration is found the WindowManager will pick the first Window found in the list of managed windows.

The configuration flag accepts two value types:

Returns:
a Window that matches the given criteria or null if no match is found.


getWindows

public List getWindows()
Returns the list of windows managed by this manager.
Returns:
a List of currently managed windows


hide

public void hide(Window window)
Hides the window.

This method is executed SYNCHRONOUSLY in the UI thread.

Parameters:
window - the window to hide


hide

public void hide(JInternalFrame internalFrame)
Hides the internal frame.

This method is executed SYNCHRONOUSLY in the UI thread.

Parameters:
internalFrame - the internal frame to hide
Since:
0.9.5


hide

public void hide(String name)
Hides the window.

This method is executed SYNCHRONOUSLY in the UI thread.

Parameters:
name - the name of window to hide


isAutoShutdown

public boolean isAutoShutdown()
Returns the value of the "application.autoShutdown" configuration flag.
Returns:
the value of the "application.autoShutdown" configuration flag.
Since:
1.3.0


isHideBeforeHandler

public boolean isHideBeforeHandler()
Should the window be hidden before all ShutdownHandlers be called ?
Returns:
current value


onShutdown

public void onShutdown(GriffonApplication app)
Hides all visible windows


setHideBeforeHandler

public void setHideBeforeHandler(boolean hideBeforeHandler)
Set if the window should be hidden before all ShutdownHandler be called.
Parameters:
hideBeforeHandler - new value


show

public void show(Window window)
Shows the window.

This method is executed SYNCHRONOUSLY in the UI thread.

Parameters:
window - the window to show


show

public void show(JInternalFrame internalFrame)
Shows the internal frame.

This method is executed SYNCHRONOUSLY in the UI thread.

Parameters:
internalFrame - the internal frame to show
Since:
0.9.5


show

public void show(String name)
Shows the window.

This method is executed SYNCHRONOUSLY in the UI thread.

Parameters:
name - the name of window to show


 

Groovy Documentation