public abstract class AbstractWindowManager<W> extends Object implements WindowManager<W>
Modifier and Type | Field and Description |
---|---|
protected static String |
ERROR_NAME_BLANK |
protected static String |
ERROR_WINDOW_NULL |
Constructor and Description |
---|
AbstractWindowManager(GriffonApplication application,
WindowDisplayHandler<W> windowDisplayHandler) |
Modifier and Type | Method and Description |
---|---|
void |
attach(String name,
W window)
Registers a window on this manager if an only if the window is not null
and it's not registered already.
|
boolean |
canShutdown(GriffonApplication app)
Asks this handler if the application's shutdown sequence can proceed or not.
|
int |
countVisibleWindows()
Counts how many Windows are visible regardless of their attached status to this WindowManager.
|
void |
detach(String name)
Removes the window from the list of manages windows if and only if it
is registered with this manager.
|
protected abstract void |
doAttach(W window) |
protected abstract void |
doDetach(W window) |
protected void |
event(ApplicationEvent evt,
List<?> args) |
protected void |
event(String evt,
List<?> args) |
W |
findWindow(String name)
Finds a Window by name.
|
protected GriffonApplication |
getApplication() |
W |
getAt(int index)
Convenience method to get a managed Window by index.
|
W |
getStartingWindow()
Finds the Window that should be displayed during the Ready phase of an application.
|
Collection<W> |
getWindows()
Returns the list of windows managed by this manager.
|
void |
hide(String name)
Hides the window.
|
void |
hide(W window)
Hides the window.
|
boolean |
isAutoShutdown()
Returns the value of the "application.autoShutdown" configuration flag.
|
protected abstract boolean |
isWindowVisible(W window) |
void |
onShutdown(GriffonApplication app)
Hides all visible windows
|
protected Object |
resolveStartingWindowFromConfiguration() |
protected WindowDisplayHandler<W> |
resolveWindowDisplayHandler() |
void |
show(String name)
Shows the window.
|
void |
show(W window)
Shows the window.
|
protected static final String ERROR_NAME_BLANK
protected static final String ERROR_WINDOW_NULL
@Inject public AbstractWindowManager(@Nonnull GriffonApplication application, @Nonnull WindowDisplayHandler<W> windowDisplayHandler)
protected GriffonApplication getApplication()
@Nullable public W findWindow(@Nonnull String name)
WindowManager
findWindow
in interface WindowManager<W>
name
- the value of the of the Window's name@Nullable public W getAt(int index)
WindowManager
Follows the Groovy conventions for overriding the [] operator.
getAt
in interface WindowManager<W>
index
- the index of the Window to be retrieved@Nullable public W getStartingWindow()
WindowManager
The WindowManager expects a configuration flag 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:
getStartingWindow
in interface WindowManager<W>
@Nullable protected Object resolveStartingWindowFromConfiguration()
@Nonnull public Collection<W> getWindows()
WindowManager
getWindows
in interface WindowManager<W>
public void attach(@Nonnull String name, @Nonnull W window)
WindowManager
attach
in interface WindowManager<W>
name
- the value of the of the Window's namewindow
- the window to be added to the list of managed windowspublic void detach(@Nonnull String name)
WindowManager
detach
in interface WindowManager<W>
name
- the value of the of the Window's namepublic void show(@Nonnull W window)
WindowManager
This method is executed SYNCHRONOUSLY in the UI thread.
show
in interface WindowManager<W>
window
- the window to showpublic void show(@Nonnull String name)
WindowManager
This method is executed SYNCHRONOUSLY in the UI thread.
show
in interface WindowManager<W>
name
- the name of window to showpublic void hide(@Nonnull W window)
WindowManager
This method is executed SYNCHRONOUSLY in the UI thread.
hide
in interface WindowManager<W>
window
- the window to hide@Nonnull protected WindowDisplayHandler<W> resolveWindowDisplayHandler()
public void hide(@Nonnull String name)
WindowManager
This method is executed SYNCHRONOUSLY in the UI thread.
hide
in interface WindowManager<W>
name
- the name of window to hidepublic boolean canShutdown(@Nonnull GriffonApplication app)
ShutdownHandler
Return false if the shutdown sequence must be aborted.
canShutdown
in interface ShutdownHandler
canShutdown
in interface WindowManager<W>
app
- the current running applicationpublic void onShutdown(@Nonnull GriffonApplication app)
WindowManager
onShutdown
in interface ShutdownHandler
onShutdown
in interface WindowManager<W>
app
- the current running applicationpublic int countVisibleWindows()
WindowManager
countVisibleWindows
in interface WindowManager<W>
public boolean isAutoShutdown()
WindowManager
isAutoShutdown
in interface WindowManager<W>
protected void event(@Nonnull ApplicationEvent evt, @Nonnull List<?> args)