use of com.codename1.rad.models.PropertyChangeEvent in project CodeRAD by shannah.
the class ComponentBinder method bindFocus.
public static void bindFocus(Bindable bindable, PropertySelector property, Component cmp) {
cmp.addFocusListener(new FocusListener() {
@Override
public void focusGained(Component cmp) {
if (property.isFalsey()) {
property.setBoolean(true);
}
}
@Override
public void focusLost(Component cmp) {
if (!property.isFalsey()) {
property.setBoolean(false);
}
}
});
ActionListener<PropertyChangeEvent> pcl = evt -> {
boolean isFocused = !property.isFalsey();
if (isFocused && !cmp.hasFocus()) {
cmp.requestFocus();
}
};
bindable.addBindListener(() -> {
property.addPropertyChangeListener(pcl);
});
bindable.addUnbindListener(() -> {
property.removePropertyChangeListener(pcl);
});
}
use of com.codename1.rad.models.PropertyChangeEvent in project CodeRAD by shannah.
the class PropertySelector method addPropertyChangeListener.
/**
* Adds a change listener on property.
* @param l The listener to add.
*/
public void addPropertyChangeListener(ActionListener<PropertyChangeEvent> l) {
if (root != null) {
Property prop = property;
if (prop == null && tags != null) {
prop = root.getEntity().findProperty(tags);
}
if (prop != null) {
root.getEntity().addPropertyChangeListener(prop, pcl());
}
} else {
Entity leafEntity = getLeafEntity();
Property leafProperty = getLeafProperty();
if (leafEntity != null && leafProperty != null) {
leafEntity.getEntity().addPropertyChangeListener(leafProperty, pcl());
}
parent.addVetoablePropertyChangeListener(vpcl());
parent.addListChangeListener(listChangeListener());
}
if (listeners == null) {
listeners = new EventDispatcher();
}
listeners.addListener(l);
}
Aggregations