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.
|
String |
findWindowName(W window)
Lookups a name related to a Window.
|
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.
|
Set<String> |
getWindowNames()
Returns a set of names related to all windows managed by this manager.
|
Collection<W> |
getWindows()
Returns the collection of windows managed by this manager.
|
void |
hide(String name)
Hides the window.
|
void |
hide(W window)
Hides the window.
|
int |
indexOf(W window)
Lookups the index related to a 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()
@Nonnull public Set<String> getWindowNames()
WindowManager
getWindowNames
in interface WindowManager<W>
@Nullable public String findWindowName(@Nonnull W window)
WindowManager
findWindowName
in interface WindowManager<W>
window
- the window to be looked uppublic int indexOf(@Nonnull W window)
WindowManager
indexOf
in interface WindowManager<W>
window
- the window to be looked up@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)