public class ConfigurableWindowDisplayHandler<W> extends Object implements WindowDisplayHandler<W>
WindowDisplayHandler
that can be configured via a DSL.
This is the default WindowDisplayHandler
used by SwingApplication
. It expects a configuration
entry in griffon-app/conf/Config.groovy
that looks like the following one
windowManager { myWindowName = [ show: {name, window -> ... }, hide: {name, window -> ... } ] myOtherWindowName = [ show: {name, window -> ... } ] }For these settings to work you must specify a
name:
property on the Window/Frame instance. This
WindowDisplayHandler
is smart enough to use the default show/hide behavior should any or both are not specified
or if a window name does not have a matching configuration. The default behavior will also be used if the Window/Frame
does not have a value for its name:
property.
There's a third option that can be set for each configured window, and that is a delegate WindowDisplayHandler
that
will be used for that window alone. The following example shows how it can be configured
windowManager { myWindowName = [ handler: new MyCustomWindowDisplayHandler() ] myOtherWindowName = [ show: {name, window -> ... } ] }Lastly, a global handler can be specified for all windows that have not been configured. If specified, this handler will override the usage of the default one. It can be configured as follows
windowManager { defaultHandler = new MyCustomWindowDisplayHandler() myOtherWindowName = [ show: {name, window -> ... } ] }Fine grained control for default
show
and hide
is also possible, by specifying defaultShow
and/or defaultHide
properties at the global level. These properties take precedence over defaultHandler
.
windowManager { defaultHide = {name, window -> ... } myOtherWindowName = [ show: {name, window -> ... } ] }Note: the value for
show
and hide
can be either a Closure or a RunnableWithArgs
.Modifier and Type | Field and Description |
---|---|
protected static String |
ERROR_NAME_BLANK |
protected static String |
ERROR_WINDOW_NULL |
Constructor and Description |
---|
ConfigurableWindowDisplayHandler(GriffonApplication application,
WindowDisplayHandler<W> delegateWindowsDisplayHandler) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
canBeRun(Object obj) |
protected WindowDisplayHandler<W> |
fetchDefaultWindowDisplayHandler() |
protected GriffonApplication |
getApplication() |
WindowDisplayHandler<W> |
getDelegateWindowsDisplayHandler() |
protected boolean |
handleHideByInjectedHandler(String name,
W window) |
protected boolean |
handleShowByInjectedHandler(String name,
W window) |
void |
hide(String name,
W window)
Callback for hiding a window.
|
protected void |
run(Object handler,
String name,
W window) |
void |
show(String name,
W window)
Callback for displaying a window.
|
protected Map<String,Object> |
windowBlock(String windowName) |
protected Map<String,Object> |
windowManagerBlock() |
protected static final String ERROR_NAME_BLANK
protected static final String ERROR_WINDOW_NULL
@Inject public ConfigurableWindowDisplayHandler(@Nonnull GriffonApplication application, @Nonnull @Named(value="defaultWindowDisplayHandler") WindowDisplayHandler<W> delegateWindowsDisplayHandler)
public void show(@Nonnull String name, @Nonnull W window)
WindowDisplayHandler
show
in interface WindowDisplayHandler<W>
window
- the window to be displayedpublic void hide(@Nonnull String name, @Nonnull W window)
WindowDisplayHandler
hide
in interface WindowDisplayHandler<W>
window
- the window to hideprotected boolean handleShowByInjectedHandler(@Nonnull String name, @Nonnull W window)
protected boolean handleHideByInjectedHandler(@Nonnull String name, @Nonnull W window)
public WindowDisplayHandler<W> getDelegateWindowsDisplayHandler()
protected GriffonApplication getApplication()
@Nonnull protected WindowDisplayHandler<W> fetchDefaultWindowDisplayHandler()