use of java.beans.PropertyChangeEvent in project felix by apache.
the class Activator method firePropertyChangedEvent.
public void firePropertyChangedEvent(String name, Object oldValue, Object newValue) {
// System.out.println("[Gui Activator] fire PCE("+name+","+oldValue+","+newValue+")");
PropertyChangeEvent event = null;
// Guaranteed to return a non-null array
Object[] listeners = m_listenerList.getListenerList();
// those that are interested in this event
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == PropertyChangeListener.class) {
// Lazily create the event:
if (event == null) {
event = new PropertyChangeEvent(this, name, oldValue, newValue);
}
((PropertyChangeListener) listeners[i + 1]).propertyChange(event);
}
}
}
use of java.beans.PropertyChangeEvent in project felix by apache.
the class Activator method firePropertyChangedEvent.
protected void firePropertyChangedEvent(String name, Object oldValue, Object newValue) {
PropertyChangeEvent event = null;
// Guaranteed to return a non-null array
Object[] listeners = m_listenerList.getListenerList();
// those that are interested in this event
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == PropertyChangeListener.class) {
// Lazily create the event:
if (event == null) {
event = new PropertyChangeEvent(this, name, oldValue, newValue);
}
((PropertyChangeListener) listeners[i + 1]).propertyChange(event);
}
}
}
use of java.beans.PropertyChangeEvent in project felix by apache.
the class ClockDevice method update.
/**
*/
public void update() {
Clock clock = Clock.getInstance();
Calendar cal = clock.getCalendar();
Date date = cal.getTime();
UPnPStateVariable variable = timerService.getStateVariable("Time");
notifier.propertyChange(new PropertyChangeEvent(variable, "Time", null, date));
}
use of java.beans.PropertyChangeEvent in project jdk8u_jdk by JetBrains.
the class BeanContextChildSupport method setBeanContext.
/**
* Sets the <code>BeanContext</code> for
* this <code>BeanContextChildSupport</code>.
* @param bc the new value to be assigned to the <code>BeanContext</code>
* property
* @throws PropertyVetoException if the change is rejected
*/
public synchronized void setBeanContext(BeanContext bc) throws PropertyVetoException {
if (bc == beanContext)
return;
BeanContext oldValue = beanContext;
BeanContext newValue = bc;
if (!rejectedSetBCOnce) {
if (rejectedSetBCOnce = !validatePendingSetBeanContext(bc)) {
throw new PropertyVetoException("setBeanContext() change rejected:", new PropertyChangeEvent(beanContextChildPeer, "beanContext", oldValue, newValue));
}
try {
fireVetoableChange("beanContext", oldValue, newValue);
} catch (PropertyVetoException pve) {
rejectedSetBCOnce = true;
// re-throw
throw pve;
}
}
if (beanContext != null)
releaseBeanContextResources();
beanContext = newValue;
rejectedSetBCOnce = false;
firePropertyChange("beanContext", oldValue, newValue);
if (beanContext != null)
initializeBeanContextResources();
}
use of java.beans.PropertyChangeEvent in project jabref by JabRef.
the class JTextFieldChangeListenerUtil method addChangeListener.
/**
* Installs a listener to receive notification when the text of any
* {@code JTextComponent} is changed. Internally, it installs a
* {@link DocumentListener} on the text component's {@link Document},
* and a {@link PropertyChangeListener} on the text component to detect
* if the {@code Document} itself is replaced.
*
* Taken from
*
* @param text any text component, such as a {@link JTextField}
* or {@link JTextArea}
* @param changeListener a listener to receive {@link ChangeEvent}s
* when the text is changed; the source object for the events
* will be the text component
* @throws NullPointerException if either parameter is null
*/
public static void addChangeListener(JTextComponent text, ChangeListener changeListener) {
Objects.requireNonNull(text);
Objects.requireNonNull(changeListener);
DocumentListener dl = new DocumentListener() {
private int lastChange;
private int lastNotifiedChange;
@Override
public void insertUpdate(DocumentEvent e) {
changedUpdate(e);
}
@Override
public void removeUpdate(DocumentEvent e) {
changedUpdate(e);
}
@Override
public void changedUpdate(DocumentEvent e) {
lastChange++;
SwingUtilities.invokeLater(() -> {
if (lastNotifiedChange != lastChange) {
lastNotifiedChange = lastChange;
changeListener.stateChanged(new ChangeEvent(text));
}
});
}
};
text.addPropertyChangeListener("document", (PropertyChangeEvent e) -> {
Document d1 = (Document) e.getOldValue();
Document d2 = (Document) e.getNewValue();
if (d1 != null) {
d1.removeDocumentListener(dl);
}
if (d2 != null) {
d2.addDocumentListener(dl);
}
dl.changedUpdate(null);
});
Document d = text.getDocument();
if (d != null) {
d.addDocumentListener(dl);
}
}
Aggregations