use of java.beans.PropertyChangeListener in project JMRI by JMRI.
the class AbstractNamedBean method getListenerRefs.
/**
* Get a meaningful list of places where the bean is in use.
*
* @return ArrayList of the listeners
*/
@Override
public synchronized ArrayList<String> getListenerRefs() {
ArrayList<String> list = new ArrayList<String>();
Enumeration<PropertyChangeListener> en = listenerRefs.keys();
while (en.hasMoreElements()) {
PropertyChangeListener l = en.nextElement();
list.add(listenerRefs.get(l));
}
return list;
}
use of java.beans.PropertyChangeListener in project jdk8u_jdk by JetBrains.
the class Test4985020 method main.
public static void main(String[] args) {
PropertyChangeSupport pcs = new PropertyChangeSupport(args);
VetoableChangeSupport vcs = new VetoableChangeSupport(args);
Test4985020 listener = new Test4985020();
//PropertyChangeSupport.addPropertyChangeListener(null, listener)
System.out.println("PropertyChangeSupport.addPropertyChangeListener(null, listener)");
try {
pcs.addPropertyChangeListener(null, listener);
pcs.firePropertyChange(NAME, null, null);
} catch (Throwable error) {
print(error);
}
//PropertyChangeSupport.removePropertyChangeListener(null, listener)
System.out.println("PropertyChangeSupport.removePropertyChangeListener(null, listener)");
try {
pcs.removePropertyChangeListener(null, listener);
pcs.firePropertyChange(NAME, null, null);
} catch (Throwable error) {
print(error);
}
//PropertyChangeSupport.getPropertyChangeListeners(null)
System.out.println("PropertyChangeSupport.getPropertyChangeListeners(null)");
try {
PropertyChangeListener[] pcls = pcs.getPropertyChangeListeners(null);
if (pcls == null) {
throw new Error("getPropertyChangeListener() returned null");
}
if (pcls.length != 0) {
throw new Error("getPropertyChangeListener() did not return an empty array");
}
} catch (Throwable error) {
print(error);
}
//PropertyChangeSupport.hasListeners(null)
System.out.println("PropertyChangeSupport.hasListeners(null)");
try {
pcs.hasListeners(null);
} catch (Throwable error) {
print(error);
}
//PropertyChangeSupport.hasListeners(null): with a generic listener
System.out.println("PropertyChangeSupport.hasListeners(null) with a generic listener");
try {
pcs.addPropertyChangeListener(listener);
if (!pcs.hasListeners(null)) {
throw new Error("hasListeners(null) returned false, but there was a generic listener");
}
} catch (Throwable error) {
print(error);
}
// reset
pcs = new PropertyChangeSupport(args);
//PropertyChangeSupport.hasListeners(null): with a specific listener
System.out.println("PropertyChangeSupport.hasListeners(null) with a specific listener");
try {
pcs.addPropertyChangeListener(NAME, listener);
if (pcs.hasListeners(null)) {
throw new Error("hasListeners(null) returned true, but there were no generic listeners - only a specific listener");
}
} catch (Throwable error) {
print(error);
}
//VetoableChangeSupport.addVetoableChangeListener(null, listener)
System.out.println("VetoableChangeSupport.addVetoableChangeListener(null, listener)");
try {
vcs.addVetoableChangeListener(null, listener);
vcs.fireVetoableChange(NAME, null, null);
} catch (Throwable error) {
print(error);
}
//VetoableChangeSupport.removeVetoableChangeListener(null, listener)
System.out.println("VetoableChangeSupport.removeVetoableChangeListener(null, listener)");
try {
vcs.removeVetoableChangeListener(null, listener);
vcs.fireVetoableChange(NAME, null, null);
} catch (Throwable error) {
print(error);
}
//VetoableChangeSupport.getVetoableChangeListeners(null)
System.out.println("VetoableChangeSupport.getVetoableChangeListeners(null)");
try {
VetoableChangeListener[] pcls = vcs.getVetoableChangeListeners(null);
if (pcls == null) {
throw new Error("getVetoableChangeListener() returned null");
}
if (pcls.length != 0) {
throw new Error("getVetoableChangeListener() did not return an empty array");
}
} catch (Throwable error) {
print(error);
}
//VetoableChangeSupport.hasListeners(null)
System.out.println("VetoableChangeSupport.hasListeners(null)");
try {
boolean result = vcs.hasListeners(null);
} catch (Throwable error) {
print(error);
}
//VetoableChangeSupport.hasListeners(null): with a generic listener
System.out.println("VetoableChangeSupport.hasListeners(null) with a generic listener");
try {
vcs.addVetoableChangeListener(listener);
if (!vcs.hasListeners(null)) {
throw new Error("hasListeners(null) returned false, but there was a generic listener");
}
} catch (Throwable error) {
print(error);
}
// reset
vcs = new VetoableChangeSupport(args);
//VetoableChangeSupport.hasListeners(null): with a specific listener
System.out.println("VetoableChangeSupport.hasListeners(null) with a specific listener");
try {
vcs.addVetoableChangeListener(NAME, listener);
if (vcs.hasListeners(null)) {
throw new Error("hasListeners(null) returned true, but there were no generic listeners - only a specific listener");
}
} catch (Throwable error) {
print(error);
}
if (failed) {
throw new Error("TEST FAILED");
}
}
use of java.beans.PropertyChangeListener in project cayenne by apache.
the class TemplateCreator method initBindings.
protected void initBindings() {
BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), this);
builder.bindToAction(view.getCancelButton(), "cancelAction()");
builder.bindToAction(view.getOkButton(), "okAction()");
final FSPath path = getLastTemplateDirectory();
view.getTemplateChooser().setCurrentDirectory(path.getExistingDirectory(false));
view.getTemplateChooser().addPropertyChangeListener(FileChooser.CURRENT_DIRECTORY_PROPERTY, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
File directory = view.getTemplateChooser().getCurrentDirectory();
path.setDirectory(directory);
}
});
}
use of java.beans.PropertyChangeListener in project cayenne by apache.
the class ComponentGeometry method bindIntProperty.
/**
* Binds this preference object to synchronize its state with a given component
* property.
*/
public void bindIntProperty(final Component component, final String property, int defaultValue) {
updateIntProperty(component, property, defaultValue);
component.addPropertyChangeListener(property, new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
Object value = e.getNewValue();
getPreference().put(property, value != null ? value.toString() : null);
}
});
}
use of java.beans.PropertyChangeListener in project gradle by gradle.
the class AbstractTask method getActions.
@Override
public List<Action<? super Task>> getActions() {
if (observableActionList == null) {
observableActionList = new ObservableActionWrapperList(getTaskActions());
observableActionList.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
taskMutator.assertMutable("Task.getActions()", evt);
}
});
}
return observableActionList;
}
Aggregations