/** * Creates a custom notification and sends it for proxy and loaded object. Registers adapters to loaded object. * * @param idx * index in the contents list (first or second slot) * @param oldProxy * the proxified object before being loaded */ protected void notifyProxyResolved(int idx, EObject oldProxy) { if (eNotificationRequired() && idx < contents.size()) { EObject newObject = contents.basicGet(idx); Notification notification = new NotificationImpl(Notification.RESOLVE, oldProxy, newObject) { @Override public Object getNotifier() { return N4JSResource.this; } @Override public int getFeatureID(Class<?> expectedClass) { return RESOURCE__CONTENTS; } }; eNotify(notification); for (Adapter adapter : eAdapters()) { if (adapter instanceof EContentAdapter && !newObject.eAdapters().contains(adapter)) { newObject.eAdapters().add(adapter); } } } }
@Override public boolean addAllUnique(int index, Collection<? extends E> objects) { int size = objects.size(); if (size > 0) { if (isNotificationRequired()) { boolean oldIsSet = isSet(); if (doAddAllUnique(index, objects)) { NotificationImpl notification = size == 1 ? createNotification( Notification.ADD, null, objects.iterator().next(), index, oldIsSet) : createNotification( Notification.ADD_MANY, null, objects, index, oldIsSet); dispatchNotification(notification); return true; } } else { return doAddAllUnique(index, objects); } } return false; }
@Override public E remove(int index) { if (isNotificationRequired()) { boolean oldIsSet = isSet(); NotificationImpl notification = createNotification( Notification.REMOVE, super.remove(index), null, index, oldIsSet); dispatchNotification(notification); @SuppressWarnings("unchecked") E oldValue = (E) notification.getOldValue(); return oldValue; } else { return super.remove(index); } }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated NOT */ @Override @SuppressWarnings("unchecked") public EList<DataPoint<T>> getDataPoints() { if (dataPoints == null) { dataPoints = new EDataTypeUniqueEList<DataPoint<T>>(DataPoint.class, this, JSciencePackage.PROFILE__DATA_POINTS) { @Override protected NotificationImpl createNotification(int eventType, boolean oldValue, boolean newValue) { return new TouchyNotification(owner, eventType, getFeatureID(), oldValue, newValue); } @Override protected NotificationImpl createNotification(int eventType, Object oldObject, Object newObject, int index, boolean wasSet) { return new TouchyNotification(owner, eventType, getFeatureID(), oldObject, newObject, index, wasSet); } @Override protected NotificationImpl createNotification(int eventType, Object oldObject, Object newObject, int index) { return new TouchyNotification(owner, eventType, getFeatureID(), oldObject, newObject, index); } }; } return dataPoints; }
public void setURI(URI uri) { URI oldURI = this.uri; this.uri = uri; if (eNotificationRequired()) { Notification notification = new NotificationImpl(Notification.SET, oldURI, uri) { @Override public Object getNotifier() { return ResourceImpl.this; } @Override public int getFeatureID(Class<?> expectedClass) { return RESOURCE__URI; } }; eNotify(notification); } }
public void setTimeStamp(long timeStamp) { long oldTimeStamp = this.timeStamp; this.timeStamp = timeStamp; if (eNotificationRequired()) { Notification notification = new NotificationImpl(Notification.SET, oldTimeStamp, timeStamp) { @Override public Object getNotifier() { return ResourceImpl.this; } @Override public int getFeatureID(Class<?> expectedClass) { return RESOURCE__TIME_STAMP; } }; eNotify(notification); } }
public void setModified(boolean isModified) { boolean oldIsModified = this.isModified; this.isModified = isModified; if (eNotificationRequired()) { Notification notification = new NotificationImpl(Notification.SET, oldIsModified, isModified) { @Override public Object getNotifier() { return ResourceImpl.this; } @Override public int getFeatureID(Class<?> expectedClass) { return RESOURCE__IS_MODIFIED; } }; eNotify(notification); } }
@Override public void addUnique(int index, E object) { if (isNotificationRequired()) { boolean oldIsSet = isSet(); super.add(index, validate(index, object)); NotificationImpl notification = createNotification( Notification.ADD, null, object, index, oldIsSet); dispatchNotification(notification); } else { super.add(index, validate(index, object)); } }
/** * Sets the load state as indicated, and returns a notification, if {@link org.eclipse.emf.common.notify.impl.BasicNotifierImpl#eNotificationRequired required}. * Clients are <b>not</b> expected to call this directly; it is managed by the implementation. * @param isLoaded whether the resource is loaded. * @return a notification. */ protected Notification setLoaded(boolean isLoaded) { boolean oldIsLoaded = this.isLoaded; this.isLoaded = isLoaded; if (eNotificationRequired()) { Notification notification = new NotificationImpl(Notification.SET, oldIsLoaded, isLoaded) { @Override public Object getNotifier() { return ResourceImpl.this; } @Override public int getFeatureID(Class<?> expectedClass) { return RESOURCE__IS_LOADED; } }; return notification; } else { return null; } }
public Object resolveProxy(EStructuralFeature feature, int entryIndex, int index, Object object) { EObject resolved = resolveProxy((EObject)object); if (resolved != object) { Entry oldObject = (Entry)data[entryIndex]; Entry entry = createEntry(feature, resolved); assign(entryIndex, validate(entryIndex, entry)); didSet(entryIndex, entry, oldObject); if (isNotificationRequired()) { NotificationImpl notifications = createNotification (Notification.RESOLVE, entry.getEStructuralFeature(), object, resolved, index, false); notifications.add(createNotification(Notification.RESOLVE, oldObject, entry, index, false)); notifications.dispatch(); } return resolved; } return object; }
public NotificationChain shadowAdd(FeatureMap.Entry.Internal entry, NotificationChain notifications) { EStructuralFeature feature = entry.getEStructuralFeature(); Object value = entry.getValue(); // EATM must fix isSet bits. NotificationImpl notification = feature.isMany() ? createNotification (Notification.ADD, feature, null, value, indexOf(feature, value), true) : createNotification (Notification.SET, feature, feature.getDefaultValue(), value, Notification.NO_INDEX, true); if (notifications != null) { notifications.add(notification); } else { notifications = notification; } return notifications; }
public NotificationChain shadowRemove(FeatureMap.Entry.Internal entry, NotificationChain notifications) { EStructuralFeature feature = entry.getEStructuralFeature(); Object value = entry.getValue(); NotificationImpl notification = feature.isMany() ? createNotification (Notification.REMOVE, feature, value, null, indexOf(feature, value), true) : createNotification (feature.isUnsettable() ? Notification.UNSET : Notification.SET, feature, value, feature.getDefaultValue(), Notification.NO_INDEX, true); if (notifications != null) { notifications.add(notification); } else { notifications = notification; } return notifications; }
@Override public NotificationChain shadowSet(Entry oldObject, Entry newObject, NotificationChain notifications) { if (isNotificationRequired()) { EStructuralFeature feature = oldObject.getEStructuralFeature(); Object oldValue = oldObject.getValue(); Object newValue = newObject.getValue(); NotificationImpl notification = createNotification (Notification.SET, feature, oldValue, newValue, feature.isMany() ? indexOf(feature, newValue) : Notification.NO_INDEX, true); if (notifications != null) { notifications.add(notification); } else { notifications = notification; } } return notifications; }
public NotificationChain inverseTouch(Object object, NotificationChain notifications) { if (isNotificationRequired()) { Entry entry = (Entry)object; EStructuralFeature feature = entry.getEStructuralFeature(); Object value = entry.getValue(); NotificationImpl notification = createNotification (Notification.SET, feature, value, value, feature.isMany() ? indexOf(feature, value) : Notification.NO_INDEX, true); if (notifications != null) { notifications.add(notification); } else { notifications = notification; } } return notifications; }
public Object resolveProxy(EStructuralFeature feature, int entryIndex, int index, Object object) { EObject resolved = resolveProxy((EObject)object); if (resolved != object) { Entry oldObject = delegateGet(entryIndex); Entry entry = createEntry(feature, resolved); delegateSet(entryIndex, validate(entryIndex, entry)); didSet(entryIndex, entry, oldObject); if (isNotificationRequired()) { NotificationImpl notifications = createNotification (Notification.RESOLVE, entry.getEStructuralFeature(), object, resolved, index, false); notifications.add(createNotification(Notification.RESOLVE, oldObject, entry, index, false)); notifications.dispatch(); } return resolved; } return object; }
@Override public NotificationChain shadowAdd(Entry object, NotificationChain notifications) { if (isNotificationRequired()) { EStructuralFeature feature = object.getEStructuralFeature(); Object value = object.getValue(); // EATM must fix isSet bits. NotificationImpl notification = feature.isMany() ? createNotification (Notification.ADD, feature, null, value, indexOf(feature, value), true) : createNotification (Notification.SET, feature, feature.getDefaultValue(), value, Notification.NO_INDEX, true); if (notifications != null) { notifications.add(notification); } else { notifications = notification; } } return notifications; }
@Override public NotificationChain shadowRemove(Entry object, NotificationChain notifications) { if (isNotificationRequired()) { EStructuralFeature feature = object.getEStructuralFeature(); Object value = object.getValue(); NotificationImpl notification = feature.isMany() ? createNotification (Notification.REMOVE, feature, value, null, indexOf(feature, value), true) : createNotification (feature.isUnsettable() ? Notification.UNSET : Notification.SET, feature, value, feature.getDefaultValue(), Notification.NO_INDEX, true); if (notifications != null) { notifications.add(notification); } else { notifications = notification; } } return notifications; }
protected NotificationImpl createNotification(int eventType, Object oldObject, Object newObject, int index, boolean wasSet) { return new ENotificationImpl(owner, eventType, featureID, oldObject, newObject, index, wasSet); }
/** * Test an invalid event type. */ @Test public void invalidEventType() { Assert.assertNull(converter.convert(new NotificationInfo(new NotificationImpl(Integer.MIN_VALUE, null, null)))); }
/** * Test a notification which is only touch. */ @Test public void onlyTouch() { Assert.assertNull(converter .convert(new NotificationInfo(new NotificationImpl(Notification.RESOLVE, null, null)))); }
@Override protected NotificationImpl createNotification(int eventType, Object oldObject, Object newObject, int index, boolean wasSet) { return new ENotificationImpl(owner, eventType, getFeatureID(), oldObject, newObject, index, wasSet); }
protected NotificationImpl createNotification(int eventType, boolean oldValue, boolean newValue) { return new ENotificationImpl(owner, eventType, getFeatureID(), oldValue, newValue); }
protected NotificationImpl createNotification (int eventType, EStructuralFeature feature, Object oldObject, Object newObject, int index, boolean wasSet) { return new FeatureMapUtil.FeatureENotificationImpl(owner, eventType, feature, oldObject, newObject, index, wasSet); }
@Override public NotificationChain basicRemove(Object object, NotificationChain notifications) { // This may be called directly on an EObject for the case of a containment. // if (object instanceof FeatureMap.Entry) { return super.basicRemove(object, notifications); } else { Entry match = null; EStructuralFeature feature = null; Entry [] entries = (Entry[])data; for (int i = 0; i < size; ++i) { Entry entry = entries[i]; if (object.equals(entry.getValue())) { feature = entry.getEStructuralFeature(); if (feature instanceof EReference && ((EReference)feature).isContainment()) { match = entry; break; } } } if (match != null) { if (isNotificationRequired()) { @SuppressWarnings("null") NotificationImpl notification = feature.isMany() ? createNotification (Notification.REMOVE, feature, object, null, indexOf(feature, object), true) : createNotification (feature.isUnsettable() ? Notification.UNSET : Notification.SET, feature, object, feature.getDefaultValue(), Notification.NO_INDEX, true); if (notifications != null) { notifications.add(notification); } else { notifications = notification; } } notifications = basicRemove(match, notifications); } return notifications; } }