@Override public void unmute(UnmuteEventsMode mode) { listenersSuspended = false; if (mode == UnmuteEventsMode.FIRE_REFRESH_EVENT) { fireCollectionChanged(Operation.REFRESH, Collections.emptyList()); } }
@Override public void refresh() { backgroundWorker.checkUIAccess(); fireCollectionChanged(Operation.REFRESH, Collections.emptyList()); }
@Override public void sort(SortInfo[] sortInfos) { if (sortInfos.length != 1) { throw new UnsupportedOperationException("Supporting sort by one field only"); } //noinspection unchecked this.sortInfos = sortInfos; doSort(); fireCollectionChanged(Operation.REFRESH, Collections.emptyList()); }
@Override public void resumeListeners() { listenersSuspended = false; while(!suspendedEvents.isEmpty()) { CollectionChangeEvent<T,K> suspendedEvent = suspendedEvents.removeLast(); fireCollectionChanged(suspendedEvent.getOperation(), Collections.unmodifiableList(suspendedEvent.getItems())); } }
doSort(); fireCollectionChanged(Operation.UPDATE, Collections.singletonList(item));
@Override public void updateItem(T item) { checkNotNullArgument(item, "item is null"); backgroundWorker.checkUIAccess(); Collection<T> collection = getCollection(); if (collection != null) { // this method must not change the "modified" state by contract boolean saveModified = modified; for (T t : collection) { if (t.equals(item)) { metadata.getTools().copy(item, t); } } modified = saveModified; fireCollectionChanged(Operation.UPDATE, Collections.singletonList(item)); } }
fireCollectionChanged(Operation.UPDATE, Collections.singletonList(item));
fireCollectionChanged(Operation.REMOVE, Collections.singletonList(item));
@Override public void modifyItem(T item) { checkNotNullArgument(item, "item is null"); Collection<T> collection = getCollection(); if (collection != null) { for (T t : collection) { if (t.equals(item)) { EntityCopyUtils.copyCompositionsBack(item, t); modified = true; if (cascadeProperty) { final Entity parentItem = masterDs.getItem(); //noinspection unchecked ((DatasourceImplementation) masterDs).modified(parentItem); } else { modified(t); } } } fireCollectionChanged(Operation.UPDATE, Collections.singletonList(item)); } }
@Override public void clear() { backgroundWorker.checkUIAccess(); checkState(); Collection<T> collection = getCollection(); if (collection != null) { Collection<T> collectionItems = new ArrayList<>(collection); doNotModify = true; try { // Clear collection collection.clear(); // Notify listeners for (T item : collectionItems) { if (metaProperty.getRange().getCardinality() == Range.Cardinality.ONE_TO_MANY) { MetaProperty inverseProperty = metaProperty.getInverse(); if (inverseProperty == null) { throw new UnsupportedOperationException("No inverse property for " + metaProperty); } item.setValue(inverseProperty.getName(), null); } // detach listener only after setting value to the link property detachListener(item); } setItem(null); fireCollectionChanged(Operation.CLEAR, Collections.emptyList()); } finally { doNotModify = false; } } }
@Override public void excludeItem(T item) { checkNotNullArgument(item, "item is null"); backgroundWorker.checkUIAccess(); checkState(); checkPermission(); Collection<T> collection = getCollection(); if (collection != null) { if (this.item != null && this.item.equals(item)) { setItem(null); } doNotModify = true; try { collection.remove(item); MetaProperty inverseProperty = metaProperty.getInverse(); if (inverseProperty != null) item.setValue(inverseProperty.getName(), null); // detach listener only after setting value to the link property detachListener(item); fireCollectionChanged(Operation.REMOVE, Collections.singletonList(item)); } finally { doNotModify = false; } } }
fireItemChanged(prevItem); fireCollectionChanged(Operation.REFRESH, Collections.emptyList()); }); fireStateChanged(e.getPrevState()); fireCollectionChanged(Operation.REFRESH, Collections.emptyList()); }); fireCollectionChanged(Operation.REFRESH, Collections.emptyList());
protected void internalIncludeItem(T item, Runnable addToCollection) { backgroundWorker.checkUIAccess(); checkState(); checkPermission(); if (getCollection() == null) { initCollection(); } doNotModify = true; try { // Don't add the same object instance twice if (!containsObjectInstance(item)) addToCollection.run(); MetaProperty inverseProperty = metaProperty.getInverse(); if (inverseProperty != null) item.setValue(inverseProperty.getName(), masterDs.getItem()); // attach listener only after setting value to the link property attachListener(item); fireCollectionChanged(Operation.ADD, Collections.singletonList(item)); } finally { doNotModify = false; } }
fireCollectionChanged(Operation.ADD, Collections.singletonList(item));