/** * Refreshes the view by clearing cache, discarding buffered changes and * current query instance. New query is created on demand. */ @Override public void refresh() { for (final Property property : propertyItemMapCache.keySet()) { if (property instanceof ValueChangeNotifier) { final ValueChangeNotifier notifier = (ValueChangeNotifier) property; notifier.removeValueChangeListener(this); } } query = null; batchCount = 0; itemIdList = null; itemCache.clear(); itemCacheAccessLog.clear(); propertyItemMapCache.clear(); discard(); }
/** * Detach this listener from item properties */ public void detach() { if (trackedItemProperties != null) { for (WeakReference<Property<?>> itemProperty : trackedItemProperties) { Property<?> property = itemProperty.get(); if (property != null) { ((ValueChangeNotifier) property).removeValueChangeListener(this); } } } }
if (property instanceof ValueChangeNotifier) { final ValueChangeNotifier notifier = (ValueChangeNotifier) property; notifier.removeValueChangeListener(this); propertyItemMapCache.remove(property);
@SuppressWarnings("unchecked") @Override public void setPropertyDataSource(@SuppressWarnings("rawtypes") Property newDataSource) { // Stops listening the old data source changes if (dataSource != null && Property.ValueChangeNotifier.class.isAssignableFrom(dataSource.getClass())) { ((Property.ValueChangeNotifier) dataSource).removeValueChangeListener(this); } // Check if the current converter is compatible. if (newDataSource != null && !ConverterUtil.canConverterPossiblyHandle(getConverter(), getType(), newDataSource.getType())) { // There is no converter set or there is no way the current converter can be compatible Converter<T, Object> c = ConverterUtil.getConverter(getType(), newDataSource.getType(), getSession()); setConverter(c); } dataSource = newDataSource; if (dataSource != null) { // Update value from the data source updateValueFromDataSource(); } // Listens the new data source if (dataSource != null && Property.ValueChangeNotifier.class.isAssignableFrom(dataSource.getClass())) { ((Property.ValueChangeNotifier) dataSource).addValueChangeListener(this); } markAsDirty(); }
@Override public void remove() { notifier.removeValueChangeListener(listener); }