protected void fireSizeChangedEvent(int oldValue, int newValue) { pcs.firePropertyChange(new PropertyChangeEvent(this, SIZE_PROPERTY, oldValue, newValue)); }
protected void fireSizeChangedEvent(int oldValue, int newValue) { pcs.firePropertyChange(new PropertyChangeEvent(this, SIZE_PROPERTY, oldValue, newValue)); }
protected void fireSizeChangedEvent(int oldValue, int newValue) { pcs.firePropertyChange(new PropertyChangeEvent(this, SIZE_PROPERTY, oldValue, newValue)); }
/** * Fires a {@link PropertyChangeEvent} with the given name, old value and * new value. As source the bean used to initialize this instance is used. * If the old value and the new value are not null and equal the event will * not be fired. * * @param propertyName * the name of the property * @param oldValue * the old value of the property * @param newValue * the new value of the property */ public void firePropertyChange(String propertyName, Object oldValue, Object newValue) { firePropertyChange(new PropertyChangeEvent(sourceBean, propertyName, oldValue, newValue)); }
@Nullable private Object convertIfNecessary(@Nullable String propertyName, @Nullable Object oldValue, @Nullable Object newValue, @Nullable Class<?> requiredType, @Nullable TypeDescriptor td) throws TypeMismatchException { Assert.state(this.typeConverterDelegate != null, "No TypeConverterDelegate"); try { return this.typeConverterDelegate.convertIfNecessary(propertyName, oldValue, newValue, requiredType, td); } catch (ConverterNotFoundException | IllegalStateException ex) { PropertyChangeEvent pce = new PropertyChangeEvent(getRootInstance(), this.nestedPath + propertyName, oldValue, newValue); throw new ConversionNotSupportedException(pce, requiredType, ex); } catch (ConversionException | IllegalArgumentException ex) { PropertyChangeEvent pce = new PropertyChangeEvent(getRootInstance(), this.nestedPath + propertyName, oldValue, newValue); throw new TypeMismatchException(pce, requiredType, ex); } }
public void updateTargetValue(Object value) { listener.propertyChange(new PropertyChangeEvent(proxyObject, propertyName, InvokerHelper.getProperty(proxyObject, propertyName), value)); } }
final void firePropertyChange(String name, Object o, Object n, Object propagationId) { if (changeSupport == null) { return; } if ((o != null) && (n != null) && o.equals(n)) { return; } PropertyChangeEvent e = new PropertyChangeEvent(this, name, o, n); e.setPropagationId(propagationId); changeSupport.firePropertyChange(e); }
@Nullable private Object convertIfNecessary(@Nullable String propertyName, @Nullable Object oldValue, @Nullable Object newValue, @Nullable Class<?> requiredType, @Nullable TypeDescriptor td) throws TypeMismatchException { Assert.state(this.typeConverterDelegate != null, "No TypeConverterDelegate"); try { return this.typeConverterDelegate.convertIfNecessary(propertyName, oldValue, newValue, requiredType, td); } catch (ConverterNotFoundException | IllegalStateException ex) { PropertyChangeEvent pce = new PropertyChangeEvent(getRootInstance(), this.nestedPath + propertyName, oldValue, newValue); throw new ConversionNotSupportedException(pce, requiredType, ex); } catch (ConversionException | IllegalArgumentException ex) { PropertyChangeEvent pce = new PropertyChangeEvent(getRootInstance(), this.nestedPath + propertyName, oldValue, newValue); throw new TypeMismatchException(pce, requiredType, ex); } }
public void setProperty(final String property) { final String oldValue = this.property; this.property = property; listeners.fire().propertyChange(new PropertyChangeEvent(this, "property", oldValue, property)); }
/** * Test setting the session expiration via a property change as would happen under normal * deployment conditions. */ @Test public void testSessionExpiration2() throws Exception { // TestSessions only live for a minute sessionManager.propertyChange(new PropertyChangeEvent(server.getRootContext(), "sessionTimeout", new Integer(30), new Integer(1))); // Check that the value has been set to 60 seconds assertEquals(60, sessionManager.getMaxInactiveInterval()); }
/** Fires property vetoable event. * @param name name of the property * @param o old value of the property * @param n new value of the property * @exception PropertyVetoException if an listener vetoed the change */ protected final void fireVetoableChange(String name, Object o, Object n) throws PropertyVetoException { if (vetoableChangeList == null) { return; } PropertyChangeEvent e = null; for (VetoableChangeListener l : vetoableChangeList.getAllListeners()) { if (e == null) { e = new PropertyChangeEvent(this, name, o, n); } l.vetoableChange(e); } }
/** * {@inheritDoc} */ @Override public boolean setValue(T newValue) { Preconditions.checkNotNull(newValue, formatWarning("The value of a setting cannot be null.")); if (!validate(newValue)) { return false; } PropertyChangeEvent event = new PropertyChangeEvent(this, id.toString(), this.value, newValue); this.value = newValue; dispatchChangedEvent(event); return true; }
TypeMismatchException tme2 = new TypeMismatchException( new PropertyChangeEvent( hkp, fullpath,
PropertyChangeEvent propertyChangeEvent = new PropertyChangeEvent( getRootInstance(), this.nestedPath + tokens.canonicalName, oldValue, pv.getValue()); if (ex.getTargetException() instanceof ClassCastException) { PropertyChangeEvent pce = new PropertyChangeEvent( getRootInstance(), this.nestedPath + tokens.canonicalName, oldValue, pv.getValue()); throw new MethodInvocationException(pce, ex);
@Test public void testBindFilteredEventsToMethod() { final MultipleEventSource src = new MultipleEventSource(); final EventCounter counter = new EventCounter(); EventUtils.bindEventsToMethod(counter, "eventOccurred", src, MultipleEventListener.class, "event1"); assertEquals(0, counter.getCount()); src.listeners.fire().event1(new PropertyChangeEvent(new Date(), "Day", Integer.valueOf(0), Integer.valueOf(1))); assertEquals(1, counter.getCount()); src.listeners.fire().event2(new PropertyChangeEvent(new Date(), "Day", Integer.valueOf(1), Integer.valueOf(2))); assertEquals(1, counter.getCount()); }
@Test public void testEventDispatchOrder() throws PropertyVetoException { final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class); final List<VetoableChangeListener> calledListeners = new ArrayList<>(); final VetoableChangeListener listener1 = createListener(calledListeners); final VetoableChangeListener listener2 = createListener(calledListeners); listenerSupport.addListener(listener1); listenerSupport.addListener(listener2); listenerSupport.fire().vetoableChange(new PropertyChangeEvent(new Date(), "Day", 4, 5)); assertEquals(calledListeners.size(), 2); assertSame(calledListeners.get(0), listener1); assertSame(calledListeners.get(1), listener2); }
final PropertyChangeEvent evt = new PropertyChangeEvent(new Date(), "Day", 7, 9); listener.vetoableChange(evt); EasyMock.replay(listener);
PropertyChangeEvent propertyChangeEvent = new PropertyChangeEvent( getRootInstance(), this.nestedPath + tokens.canonicalName, oldValue, pv.getValue()); if (ex.getTargetException() instanceof ClassCastException) { PropertyChangeEvent pce = new PropertyChangeEvent( getRootInstance(), this.nestedPath + tokens.canonicalName, oldValue, pv.getValue()); throw new MethodInvocationException(pce, ex);
eventListenerSupport.addListener(listener); final Object source = new Date(); final PropertyChangeEvent ignore = new PropertyChangeEvent(source, "Hour", 5, 6); final PropertyChangeEvent respond = new PropertyChangeEvent(source, "Day", 6, 7); listener.vetoableChange(respond); EasyMock.replay(listener);
@Test public void testRemoveListenerDuringEvent() throws PropertyVetoException { final EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class); for (int i = 0; i < 10; ++i) { addDeregisterListener(listenerSupport); } assertEquals(listenerSupport.getListenerCount(), 10); listenerSupport.fire().vetoableChange(new PropertyChangeEvent(new Date(), "Day", 4, 5)); assertEquals(listenerSupport.getListenerCount(), 0); }