use of org.eclipse.emf.common.notify.impl.NotificationImpl in project n4js by eclipse.
the class N4JSResource method notifyProxyResolved.
/**
* 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);
}
}
}
}
use of org.eclipse.emf.common.notify.impl.NotificationImpl in project statecharts by Yakindu.
the class DerivedEObjectEList method addUnique.
@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));
}
}
use of org.eclipse.emf.common.notify.impl.NotificationImpl in project statecharts by Yakindu.
the class DerivedEObjectEList method addAllUnique.
@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;
}
use of org.eclipse.emf.common.notify.impl.NotificationImpl in project webtools.sourceediting by eclipse.
the class XSDRedefineAdapter method notifyChanged.
public void notifyChanged(final Notification msg) {
class CategoryNotification extends NotificationImpl {
protected Object category;
public CategoryNotification(Object category) {
super(msg.getEventType(), msg.getOldValue(), msg.getNewValue(), msg.getPosition());
this.category = category;
}
public Object getNotifier() {
return category;
}
public Object getFeature() {
return msg.getFeature();
}
}
if (children == null) {
getChildren();
}
Object newValue = msg.getNewValue();
Object oldValue = msg.getOldValue();
if (XSDPackage.eINSTANCE.getXSDRedefine_Contents() == msg.getFeature()) {
if ((newValue instanceof XSDAttributeGroupDefinition) || oldValue instanceof XSDAttributeGroupDefinition) {
CategoryAdapter adapter = getCategory(CategoryAdapter.ATTRIBUTES);
Assert.isTrue(adapter != null);
List list = getCategoryChildren(CategoryAdapter.ATTRIBUTES);
adapter.setChildren(list);
adapter.setAllChildren(list);
if (adapter.getModel() instanceof XSDSchemaAdapter) {
XSDSchemaAdapter schemaAdapter = (XSDSchemaAdapter) adapter.getModel();
schemaAdapter.notifyChanged(msg);
}
notifyListeners(new CategoryNotification(adapter), adapter.getText());
return;
} else if ((newValue instanceof XSDComplexTypeDefinition || newValue instanceof XSDSimpleTypeDefinition) || (oldValue instanceof XSDComplexTypeDefinition || oldValue instanceof XSDSimpleTypeDefinition)) {
CategoryAdapter adapter = getCategory(CategoryAdapter.TYPES);
Assert.isTrue(adapter != null);
List types = getCategoryChildren(CategoryAdapter.TYPES);
adapter.setChildren(types);
adapter.setAllChildren(types);
if (adapter.getModel() instanceof XSDSchemaAdapter) {
XSDSchemaAdapter schemaAdapter = (XSDSchemaAdapter) adapter.getModel();
schemaAdapter.notifyChanged(msg);
}
notifyListeners(new CategoryNotification(adapter), adapter.getText());
return;
} else if (newValue instanceof XSDModelGroupDefinition || oldValue instanceof XSDModelGroupDefinition) {
CategoryAdapter adapter = getCategory(CategoryAdapter.GROUPS);
Assert.isTrue(adapter != null);
List list = getCategoryChildren(CategoryAdapter.GROUPS);
adapter.setChildren(list);
adapter.setAllChildren(list);
if (adapter.getModel() instanceof XSDSchemaAdapter) {
XSDSchemaAdapter schemaAdapter = (XSDSchemaAdapter) adapter.getModel();
schemaAdapter.notifyChanged(msg);
}
notifyListeners(new CategoryNotification(adapter), adapter.getText());
return;
} else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_Annotations()) {
return;
}
}
super.notifyChanged(msg);
}
use of org.eclipse.emf.common.notify.impl.NotificationImpl in project webtools.sourceediting by eclipse.
the class XSDSchemaAdapter method notifyChanged.
public void notifyChanged(final Notification msg) {
class CategoryNotification extends NotificationImpl {
protected Object category;
public CategoryNotification(Object category) {
super(msg.getEventType(), msg.getOldValue(), msg.getNewValue(), msg.getPosition());
this.category = category;
}
public Object getNotifier() {
return category;
}
public Object getFeature() {
return msg.getFeature();
}
}
if (children == null) {
getChildren();
}
Object newValue = msg.getNewValue();
Object oldValue = msg.getOldValue();
// Bug 245480 - Deletion of Include, Import and Redefine is not reflected in the Outline view
// We only want to refresh the Directives folder for any changes to XSDDirectives. The first case covers
// changes to one directive, whereas the missing case as reported in bug 245480 covers changes to a list
// of directives.
boolean updateDirectivesCategory = false;
if (oldValue instanceof XSDSchemaDirective) {
updateDirectivesCategory = true;
} else if (oldValue instanceof Collection) {
Iterator iterator = ((Collection) oldValue).iterator();
while (iterator.hasNext()) {
Object obj = iterator.next();
if (obj instanceof XSDSchemaDirective) {
// if we find at least one directive, then we should refresh the folder
updateDirectivesCategory = true;
break;
}
}
}
if (newValue instanceof XSDInclude || newValue instanceof XSDImport || newValue instanceof XSDRedefine || // handle the case for delete directive
(msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_Contents() && updateDirectivesCategory) || // updates to the imports/includes
msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_IncorporatedVersions()) {
CategoryAdapter adapter = getCategory(CategoryAdapter.DIRECTIVES);
Assert.isTrue(adapter != null);
XSDSchema xsdSchema = adapter.getXSDSchema();
adapter.setChildren(getDirectives(xsdSchema));
adapter.setAllChildren(getDirectives(xsdSchema));
notifyListeners(new CategoryNotification(adapter), adapter.getText());
return;
} else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_ElementDeclarations()) {
CategoryAdapter adapter = getCategory(CategoryAdapter.ELEMENTS);
Assert.isTrue(adapter != null);
XSDSchema xsdSchema = adapter.getXSDSchema();
adapter.setChildren(getGlobalElements(xsdSchema));
adapter.setAllChildren(getGlobalElements(xsdSchema, true));
notifyListeners(new CategoryNotification(adapter), adapter.getText());
return;
} else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_AttributeDeclarations() || msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_AttributeGroupDefinitions()) {
CategoryAdapter adapter = getCategory(CategoryAdapter.ATTRIBUTES);
Assert.isTrue(adapter != null);
XSDSchema xsdSchema = adapter.getXSDSchema();
adapter.setChildren(getAttributeList(xsdSchema));
adapter.setAllChildren(getAttributeList(xsdSchema, true));
notifyListeners(new CategoryNotification(adapter), adapter.getText());
return;
} else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_TypeDefinitions()) {
CategoryAdapter adapter = getCategory(CategoryAdapter.TYPES);
Assert.isTrue(adapter != null);
XSDSchema xsdSchema = adapter.getXSDSchema();
List types = getComplexTypes(xsdSchema);
types.addAll(getSimpleTypes(xsdSchema));
adapter.setChildren(types);
adapter.setAllChildren(getTypes(xsdSchema, true));
notifyListeners(new CategoryNotification(adapter), adapter.getText());
return;
} else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_ModelGroupDefinitions()) {
CategoryAdapter adapter = getCategory(CategoryAdapter.GROUPS);
Assert.isTrue(adapter != null);
XSDSchema xsdSchema = adapter.getXSDSchema();
adapter.setChildren(getGroups(xsdSchema));
adapter.setAllChildren(getGroups(xsdSchema, true));
notifyListeners(new CategoryNotification(adapter), adapter.getText());
return;
} else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_Annotations()) {
return;
} else if (msg.getFeature() == XSDPackage.eINSTANCE.getXSDSchema_SchemaLocation()) {
notifyListeners(msg, null);
return;
}
types = null;
getTypes();
super.notifyChanged(msg);
}
Aggregations