Here's an update on the current solution. Whenever a java.awt.Component (or subclass) is to be updated it will happen inside the EDT given the following rule:
- if the current thread is the EDT then the update will happen immediately
- else the update will happen the next time the EDT is free, that is, an event will be posted to the EventQueue using invokeLater()
If the bean to be updated is not a java.awt.Component or subclass then the update will happen in the current thread, whichever it happen to be.
The bind node accepts a new attribute named update, which controls the update strategy to use. Values are:
- mixed: proceed if current thread = EDT; else post event with invokeLater. This is the default for java.awt.Component
- async: post event with invokeLater always.
- sync: proceed if current thread = EDT; else call invokeAndWait
- outside: proceed if current thread != EDT; else submit to an ExecutorService (service is non-configurable)
- same: proceed in the current thread. This is the default for non java.awt.Component beans
- defer: submit to an ExecutorService (service is non-configurable)
It's worth nothing that java.awt.Component beans will use mixed all the time, you can only change the update strategy for all other beans
Sample usage:
model = new Model() textField(text: bind(target: model, 'text'))
textField(text: bind(target: model, 'text', update: 'defer'))
bean(model, text: bind(update: 'outside){ textFieldRef.text})
Here's an update on the current solution. Whenever a java.awt.Component (or subclass) is to be updated it will happen inside the EDT given the following rule:
If the bean to be updated is not a java.awt.Component or subclass then the update will happen in the current thread, whichever it happen to be.
The bind node accepts a new attribute named update, which controls the update strategy to use. Values are:
It's worth nothing that java.awt.Component beans will use mixed all the time, you can only change the update strategy for all other beans
Sample usage: