@Override public PropertyChangeUnsubscribeHandle addPropertyChangeHandler(final PropertyChangeHandler<?> handler) { propertyChangeHandlerSupport.addPropertyChangeHandler(handler); final PropertyChangeUnsubscribeHandle agentUnsubHandle = getAgent().addPropertyChangeHandler(handler); return new OneTimeUnsubscribeHandle() { @Override public void doUnsubscribe() { agentUnsubHandle.unsubscribe(); } }; }
@Override public <P> PropertyChangeUnsubscribeHandle addPropertyChangeHandler(final String property, final PropertyChangeHandler<P> handler) { propertyChangeHandlerSupport.addPropertyChangeHandler(property, handler); final PropertyChangeUnsubscribeHandle agentUnsubHandle = getAgent().addPropertyChangeHandler(property, handler); return new OneTimeUnsubscribeHandle() { @Override public void doUnsubscribe() { agentUnsubHandle.unsubscribe(); } }; }
/** * Merges the provided {@link PropertyChangeHandler}s of the provided agent * instance. If a handler instance is already registered on this agent, it * will NOT be added again. * * @param pchs * the instance who's change handlers will be merged, must not be * null. */ public void mergePropertyChangeHandlers(final PropertyChangeHandlerSupport pchs) { Assert.notNull(pchs); for (final PropertyChangeHandler pch : pchs.handlers) { if (!propertyChangeHandlerSupport.handlers.contains(pch)) { addPropertyChangeHandler(pch); } } for (final String pchKey : pchs.specificPropertyHandlers.keys()) { for (final PropertyChangeHandler pch : pchs.specificPropertyHandlers.get(pchKey)) { if (!propertyChangeHandlerSupport.specificPropertyHandlers.containsEntry(pchKey, pch)) { addPropertyChangeHandler(pchKey, pch); } } } }
@Override public PropertyChangeUnsubscribeHandle addPropertyChangeHandler(final PropertyChangeHandler<?> handler) { propertyChangeHandlerSupport.addPropertyChangeHandler(handler); final PropertyChangeUnsubscribeHandle agentUnsubHandle = getAgent().addPropertyChangeHandler(handler); return new OneTimeUnsubscribeHandle() { @Override public void doUnsubscribe() { agentUnsubHandle.unsubscribe(); } }; }
@Override public PropertyChangeUnsubscribeHandle addPropertyChangeHandler(final PropertyChangeHandler<?> handler) { propertyChangeHandlerSupport.addPropertyChangeHandler(handler); final PropertyChangeUnsubscribeHandle agentUnsubHandle = getAgent().addPropertyChangeHandler(handler); return new OneTimeUnsubscribeHandle() { @Override public void doUnsubscribe() { agentUnsubHandle.unsubscribe(); } }; }
@Override public <P> PropertyChangeUnsubscribeHandle addPropertyChangeHandler(final String property, final PropertyChangeHandler<P> handler) { propertyChangeHandlerSupport.addPropertyChangeHandler(property, handler); final PropertyChangeUnsubscribeHandle agentUnsubHandle = getAgent().addPropertyChangeHandler(property, handler); return new OneTimeUnsubscribeHandle() { @Override public void doUnsubscribe() { agentUnsubHandle.unsubscribe(); } }; }
@Override public <P> PropertyChangeUnsubscribeHandle addPropertyChangeHandler(final String property, final PropertyChangeHandler<P> handler) { propertyChangeHandlerSupport.addPropertyChangeHandler(property, handler); final PropertyChangeUnsubscribeHandle agentUnsubHandle = getAgent().addPropertyChangeHandler(property, handler); return new OneTimeUnsubscribeHandle() { @Override public void doUnsubscribe() { agentUnsubHandle.unsubscribe(); } }; }
/** * Merges the provided {@link PropertyChangeHandler}s of the provided agent * instance. If a handler instance is already registered on this agent, it * will NOT be added again. * * @param pchs * the instance who's change handlers will be merged, must not be * null. */ public void mergePropertyChangeHandlers(final PropertyChangeHandlerSupport pchs) { Assert.notNull(pchs); for (final PropertyChangeHandler pch : pchs.handlers) { if (!propertyChangeHandlerSupport.handlers.contains(pch)) { addPropertyChangeHandler(pch); } } for (final String pchKey : pchs.specificPropertyHandlers.keys()) { for (final PropertyChangeHandler pch : pchs.specificPropertyHandlers.get(pchKey)) { if (!propertyChangeHandlerSupport.specificPropertyHandlers.containsEntry(pchKey, pch)) { addPropertyChangeHandler(pchKey, pch); } } } }
private Object convertToProxy(Object element) { if (BindableProxyFactory.isBindableType(element)) { element = BindableProxyFactory.getBindableProxy(element); final BindableProxyAgent<?> agent = ((BindableProxy<?>) element).getBindableProxyAgent(); if (!elementChangeHandlers.containsKey(agent)) { // Register a property change handler on the element to fire a change // event for the list when the element changes PropertyChangeHandler<Object> handler = new PropertyChangeHandler<Object>() { @Override public void onPropertyChange(PropertyChangeEvent<Object> event) { final int index = list.indexOf(event.getSource()); final List<M> source = new ArrayList<M>(list); if (index == -1) return; // yikes! we do this to alter the source list (otherwise the change event won't get fired). source.add(null); for (BindableListChangeHandler<M> handler : handlers) { handler.onItemChanged(source, index, (M) event.getSource()); } } }; unsubscribeHandlesByHandler.put(handler, agent.addPropertyChangeHandler(handler)); elementChangeHandlers.put(agent, handler); } } return element; }
private Object convertToProxy(Object element) { if (BindableProxyFactory.isBindableType(element)) { element = BindableProxyFactory.getBindableProxy(element); final BindableProxyAgent<?> agent = ((BindableProxy<?>) element).getBindableProxyAgent(); if (!elementChangeHandlers.containsKey(agent)) { // Register a property change handler on the element to fire a change // event for the list when the element changes PropertyChangeHandler<Object> handler = new PropertyChangeHandler<Object>() { @Override public void onPropertyChange(PropertyChangeEvent<Object> event) { final int index = list.indexOf(event.getSource()); final List<M> source = new ArrayList<M>(list); if (index == -1) return; // yikes! we do this to alter the source list (otherwise the change event won't get fired). source.add(null); for (BindableListChangeHandler<M> handler : handlers) { handler.onItemChanged(source, index, (M) event.getSource()); } } }; unsubscribeHandlesByHandler.put(handler, agent.addPropertyChangeHandler(handler)); elementChangeHandlers.put(agent, handler); } } return element; }