if (p instanceof Property.ValueChangeNotifier) { ((Property.ValueChangeNotifier) p) .addValueChangeListener( getCaptionChangeListener()); captionChangeNotifiers.add(p); if (p instanceof Property.ValueChangeNotifier) { ((Property.ValueChangeNotifier) p) .addValueChangeListener(getCaptionChangeListener()); captionChangeNotifiers.add(p); if (p instanceof Property.ValueChangeNotifier) { ((Property.ValueChangeNotifier) p) .addValueChangeListener(getCaptionChangeListener()); captionChangeNotifiers.add(p);
((Property.ValueChangeNotifier) dataSource).removeListener(this); ((Property.ValueChangeNotifier) dataSource).addListener(this);
public void clear() { for (Object notifier : captionChangeNotifiers) { if (notifier instanceof Item.PropertySetChangeNotifier) { ((Item.PropertySetChangeNotifier) notifier) .removePropertySetChangeListener( getCaptionChangeListener()); } else { ((Property.ValueChangeNotifier) notifier) .removeValueChangeListener( getCaptionChangeListener()); } } captionChangeNotifiers.clear(); }
if (dataSource instanceof Property.ValueChangeNotifier) { ((Property.ValueChangeNotifier) dataSource) .removeListener(this); ((Property.ValueChangeNotifier) dataSource).addListener(this);
&& listenedProperties.contains(p)) { listenedProperties.remove(p); ((ValueChangeNotifier) p).removeListener(this);
/** * Helper method to remove listeners and maintain correct component * hierarchy. Detaches properties and components if those are no more * rendered in client. * * @param oldListenedProperties * set of properties that where listened in last render * @param oldVisibleComponents * set of components that where attached in last render */ private void unregisterPropertiesAndComponents( HashSet<Property<?>> oldListenedProperties, HashSet<Component> oldVisibleComponents) { if (oldVisibleComponents != null) { for (final Component c : oldVisibleComponents) { if (!visibleComponents.contains(c)) { unregisterComponent(c); } } } if (oldListenedProperties != null) { for (final Property<?> p : oldListenedProperties) { Property.ValueChangeNotifier o = (ValueChangeNotifier) p; if (!listenedProperties.contains(o)) { o.removeListener(this); } } } }
/** * Make this container listen to the given property provided it notifies * when its value changes. * * @param item * The {@link Item} that contains the property * @param propertyId * The id of the property */ private void addValueChangeListener(Item item, Object propertyId) { Property<?> property = item.getItemProperty(propertyId); if (property instanceof ValueChangeNotifier) { // avoid multiple notifications for the same property if // multiple filters are in use ValueChangeNotifier notifier = (ValueChangeNotifier) property; notifier.removeListener(this); notifier.addListener(this); } }
/** * Registers this as an event listener for events sent by the data source * (if any). Does nothing if * <code>isListeningToPropertyEvents == true</code>. */ private void addPropertyListeners() { if (!isListeningToPropertyEvents) { if (dataSource instanceof Property.ValueChangeNotifier) { ((Property.ValueChangeNotifier) dataSource).addListener(this); } if (dataSource instanceof Property.ReadOnlyStatusChangeNotifier) { ((Property.ReadOnlyStatusChangeNotifier) dataSource) .addListener(this); } isListeningToPropertyEvents = true; } }
/** * Make this container listen to the given property provided it notifies * when its value changes. * * @param item * The {@link Item} that contains the property * @param propertyId * The id of the property */ private void addValueChangeListener(Item item, Object propertyId) { Property<?> property = item.getItemProperty(propertyId); if (property instanceof ValueChangeNotifier) { // avoid multiple notifications for the same property if // multiple filters are in use ValueChangeNotifier notifier = (ValueChangeNotifier) property; notifier.removeListener(this); notifier.addListener(this); } }
/** * Stops listening to events sent by the data source (if any). Does nothing * if <code>isListeningToPropertyEvents == false</code>. */ private void removePropertyListeners() { if (isListeningToPropertyEvents) { if (dataSource instanceof Property.ValueChangeNotifier) { ((Property.ValueChangeNotifier) dataSource) .removeListener(this); } if (dataSource instanceof Property.ReadOnlyStatusChangeNotifier) { ((Property.ReadOnlyStatusChangeNotifier) dataSource) .removeListener(this); } isListeningToPropertyEvents = false; } }
/** * Remove this container as a listener for the given property. * * @param item * The {@link Item} that contains the property * @param propertyId * The id of the property */ private void removeValueChangeListener(Item item, Object propertyId) { Property<?> property = item.getItemProperty(propertyId); if (property instanceof ValueChangeNotifier) { ((ValueChangeNotifier) property).removeListener(this); } }
/** * Remove this container as a listener for the given property. * * @param item * The {@link Item} that contains the property * @param propertyId * The id of the property */ private void removeValueChangeListener(Item item, Object propertyId) { Property<?> property = item.getItemProperty(propertyId); if (property instanceof ValueChangeNotifier) { ((ValueChangeNotifier) property).removeListener(this); } }
private void listenProperty(Property<?> p, HashSet<Property<?>> oldListenedProperties) { if (p instanceof Property.ValueChangeNotifier) { if (oldListenedProperties == null || !oldListenedProperties.contains(p)) { ((Property.ValueChangeNotifier) p).addListener(this); } /* * register listened properties, so we can do proper cleanup to free * memory. Essential if table has loads of data and it is used for a * long time. */ listenedProperties.add(p); } }
@Override public void addValueChangeListener(ValueChangeListener listener) { if (itemProperty instanceof ValueChangeNotifier) { ((ValueChangeNotifier) itemProperty).addValueChangeListener(listener); } }
/** * Removes the ValueChangeListener from wrapped Property that was added by * TransactionalPropertyWrapper. * * @since 7.1.15 */ public void detachFromProperty() { if (wrappedProperty instanceof ValueChangeNotifier) { ((ValueChangeNotifier) wrappedProperty) .removeValueChangeListener(listener); } }
/** * Removes listeners from the container so no events are processed */ private void ignoreContainerEvents() { if (container instanceof ItemSetChangeNotifier) { ((ItemSetChangeNotifier) container) .removeItemSetChangeListener(this); } if (container instanceof ValueChangeNotifier) { ((ValueChangeNotifier) container).removeValueChangeListener(this); } }
/** * Registers a new value change listener for this Property. * * @param listener the new Listener to be registered * @return this (for method chaining) */ public default S withValueChangeListener( Property.ValueChangeListener listener) { ((ValueChangeNotifier) this).addValueChangeListener(listener); return (S) this; }
/** * Attaches listeners to the container so container events can be processed */ private void listenToContainerEvents() { if (container instanceof ItemSetChangeNotifier) { ((ItemSetChangeNotifier) container).addItemSetChangeListener(this); } if (container instanceof ValueChangeNotifier) { ((ValueChangeNotifier) container).addValueChangeListener(this); } }
public void removeColumns(Collection<Column> removedColumns) { for (final Column column : removedColumns) { final Property<?> property = item .getItemProperty(column.getPropertyId()); if (property instanceof ValueChangeNotifier) { ((ValueChangeNotifier) property) .removeValueChangeListener(this); } } } }
private void setScaleDataSource(Property<Double> scale) { // Listens the new data source if possible if (scale != null && Property.ValueChangeNotifier.class .isAssignableFrom(scale.getClass())) { ((Property.ValueChangeNotifier) scale).addValueChangeListener(this); } }