Created by user-448c7 on Jan 12, 2018
2 minute read
The PropertyChangeEvents support provides the ability to listen to the event by different scopes. The scope depends on how the listener is registered:
If the listener is registered at the whole repository, it receives events about the changes in all the elements.
If the listener is registered at the specific element, it receives events about the changes in any property of this element.
If the listener registered with the specific property at the element, it receives events about the changes in this property.
If the listener is registered with the specific property for the element type, it receives events about the changes in all the elements of the specific type.
The java.beans.PropertyChangeListener should be registered to receive these events. There are several different ways to register a listener:
This listener will be notified, when any property of any element in the project with this type is changed. If “configs” is NULL, the listener will get all property change events.
EventSupport could be disabled from the event firing:
These examples show, how to create the property change listeners to listen to the different kind of properties.
Listener for listening to the specific element’s any property changes:
element.addPropertyChangeListener(new PropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent evt)
{
// evt.getPropertyName() is changed
}
});
Listener for listening to the specific property (NAME) of the specific element:
element.addPropertyChangeListener(new PropertyChangeListener()
{
public void propertyChange(PropertyChangeEvent evt)
{
if (PropertyNames.NAME.equals(evt.getPropertyName()))
{
// name is Changed
}
}
});