Groovy Documentation

griffon.javafx
[Java] Class ConfigurableWindowDisplayHandler

java.lang.Object
  griffon.javafx.ConfigurableWindowDisplayHandler
All Implemented Interfaces:
WindowDisplayHandler

public class ConfigurableWindowDisplayHandler
extends Object

Implementation of a per window WindowDisplayHandler that can be configured via a DSL.

This is the default WindowDisplayHandler used by javafxApplication. It expects a configuration entry in griffon-app/conf/Config.groovy that looks like the following one

 javafx {
     windowManager {
         myWindowName = [
             show: {window, app -> ... },
             hide: {window, app -> ... }
         ]
         myOtherWindowName = [
             show: {window, app -> ... }
         ]
     }
 }
 

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

 javafx {
     windowManager {
         myWindowName = [
             handler: new MyCustomWindowDisplayHandler()
         ]
         myOtherWindowName = [
             show: {window, app -> ... }
         ]
     }
 }
 

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

 javafx {
     windowManager {
         defaultHandler = new MyCustomWindowDisplayHandler()
         myOtherWindowName = [
             show: {window, app -> ... }
         ]
     }
 }
 

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 .

 javafx {
     windowManager {
         defaultHide = {window, app -> ... }
         myOtherWindowName = [
             show: {window, app -> ... }
         ]
     }
 }
 

Note: the value for show and hide can be either a Closure or a RunnableWithArgs.

Authors:
Andres Almiray


Field Summary
private static WindowDisplayHandler DEFAULT_WINDOW_DISPLAY_HANDLER

 
Constructor Summary
ConfigurableWindowDisplayHandler()

 
Method Summary
private boolean canBeRun(Object obj)

private WindowDisplayHandler fetchDefaultWindowDisplayHandler(GriffonApplication application)

void hide(javafx.stage.Window window, JavaFXApplication application)

private void run(Object obj, javafx.stage.Window window, GriffonApplication application)

void show(javafx.stage.Window window, JavaFXApplication application)

private Map windowBlock(GriffonApplication application, String windowName)

private Map windowManagerBlock(GriffonApplication application)

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

Field Detail

DEFAULT_WINDOW_DISPLAY_HANDLER

private static final WindowDisplayHandler DEFAULT_WINDOW_DISPLAY_HANDLER


 
Constructor Detail

ConfigurableWindowDisplayHandler

ConfigurableWindowDisplayHandler()


 
Method Detail

canBeRun

private boolean canBeRun(Object obj)


fetchDefaultWindowDisplayHandler

private WindowDisplayHandler fetchDefaultWindowDisplayHandler(GriffonApplication application)


hide

public void hide(javafx.stage.Window window, JavaFXApplication application)


run

@SuppressWarnings("rawtypes")
private void run(Object obj, javafx.stage.Window window, GriffonApplication application)


show

public void show(javafx.stage.Window window, JavaFXApplication application)


windowBlock

@SuppressWarnings("unchecked")
private Map windowBlock(GriffonApplication application, String windowName)


windowManagerBlock

@SuppressWarnings("unchecked")
private Map windowManagerBlock(GriffonApplication application)


 

Groovy Documentation