public class ConfigurableWindowDisplayHandler<W> extends java.lang.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 java.lang.String |
ERROR_NAME_BLANK |
protected static java.lang.String |
ERROR_WINDOW_NULL |
Constructor and Description |
---|
ConfigurableWindowDisplayHandler(GriffonApplication application,
WindowDisplayHandler<W> delegateWindowsDisplayHandler) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
canBeRun(java.lang.Object obj) |
protected WindowDisplayHandler<W> |
fetchDefaultWindowDisplayHandler() |
protected GriffonApplication |
getApplication() |
WindowDisplayHandler<W> |
getDelegateWindowsDisplayHandler() |
protected boolean |
handleHideByInjectedHandler(java.lang.String name,
W window) |
protected boolean |
handleShowByInjectedHandler(java.lang.String name,
W window) |
void |
hide(java.lang.String name,
W window)
Callback for hiding a window.
|
protected void |
run(java.lang.Object handler,
java.lang.String name,
W window) |
void |
show(java.lang.String name,
W window)
Callback for displaying a window.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
windowBlock(java.lang.String windowName) |
protected java.util.Map<java.lang.String,java.lang.Object> |
windowManagerBlock() |
protected static final java.lang.String ERROR_NAME_BLANK
protected static final java.lang.String ERROR_WINDOW_NULL
@Inject public ConfigurableWindowDisplayHandler(@Nonnull GriffonApplication application, @Nonnull @Named(value="defaultWindowDisplayHandler") WindowDisplayHandler<W> delegateWindowsDisplayHandler)
public void show(@Nonnull java.lang.String name, @Nonnull W window)
WindowDisplayHandler
show
in interface WindowDisplayHandler<W>
window
- the window to be displayedpublic void hide(@Nonnull java.lang.String name, @Nonnull W window)
WindowDisplayHandler
hide
in interface WindowDisplayHandler<W>
window
- the window to hideprotected boolean handleShowByInjectedHandler(@Nonnull java.lang.String name, @Nonnull W window)
protected boolean handleHideByInjectedHandler(@Nonnull java.lang.String name, @Nonnull W window)
public WindowDisplayHandler<W> getDelegateWindowsDisplayHandler()
protected boolean canBeRun(@Nullable java.lang.Object obj)
protected void run(@Nonnull java.lang.Object handler, @Nonnull java.lang.String name, @Nonnull W window)
protected java.util.Map<java.lang.String,java.lang.Object> windowManagerBlock()
protected java.util.Map<java.lang.String,java.lang.Object> windowBlock(java.lang.String windowName)
protected GriffonApplication getApplication()
@Nonnull protected WindowDisplayHandler<W> fetchDefaultWindowDisplayHandler()