@Retention(value=SOURCE)
@Target(value=FIELD)
public @interface ListChangeListener
Annotates a property.
This transformation provides a convenient way to register ListChangeListeners on an ObservableList by leveraging Groovy's closures and the Groovy cast operator.
The following code exemplifies what must be written by hand in order to register a ChangeListener.
import griffon.transform.ListChangeListener
import griffon.transform.FXObservable
import javafx.collections.FXCollections
import javafx.collections.ObservableList
import griffon.core.artifact.GriffonModel
@griffon.metadata.ArtifactProviderFor(GriffonModel)
class SampleModel {
def controller
@FXObservable
@ListChangeListener(snoop)
ObservableList list = FXCollections.observableArrayList()
def snoop = { change -> ... }
}
Applying @ChangeListener to the previous snippet results in the following code
import javafx.collections.ListChangeListener
import javafx.collections.FXCollections
import javafx.collections.ObservableList
import griffon.core.artifact.GriffonModel
@griffon.metadata.ArtifactProviderFor(GriffonModel)
class SampleModel {
def controller
@FXObservable ObservableList list = FXCollections.observableArrayList()
def snoop = { change -> ... }
SampleModel() {
listProperty().addListener(snoopAll as ListChangeListener)
}
}
Any closures found as the annotation's value will be either transformed into inner classes that implement ListChangeListener (when the value is a closure defined in place) or be casted as a proxy of ListChangeListener (when the value is a property reference found in the same class).
List of closures are also supported.
| Modifier and Type | Required Element and Description |
|---|---|
java.lang.String |
value |
| Modifier and Type | Optional Element and Description |
|---|---|
boolean |
weak
If the
ListChangeListener should be wrapped with a WeakListChangeListener or not |