public static ImportedNamesAdapter find(Resource resource) { for (Adapter adapter : resource.eAdapters()) { if (adapter instanceof ImportedNamesAdapter) { return (ImportedNamesAdapter) adapter; } } return null; }
public static ActiveAnnotationContexts installNew(final Resource resource) { ActiveAnnotationContexts result = IterableExtensions.<ActiveAnnotationContexts>head(Iterables.<ActiveAnnotationContexts>filter(resource.eAdapters(), ActiveAnnotationContexts.class)); if ((result != null)) { result.contexts.clear(); } else { ActiveAnnotationContexts _activeAnnotationContexts = new ActiveAnnotationContexts(); result = _activeAnnotationContexts; EList<Adapter> _eAdapters = resource.eAdapters(); _eAdapters.add(result); } return result; }
protected void addResource(Resource aResource) { getResources().add(aResource); aResource.eAdapters().add(resourceAdapter); }
public static DelegateResourceAdapter getAdapter(Resource resource) { DelegateResourceAdapter adapter = (DelegateResourceAdapter) EcoreUtil.getAdapter(resource.eAdapters(), DelegateResourceAdapter.class); if (adapter == null) { adapter = new DelegateResourceAdapter(); resource.eAdapters().add(adapter); } return adapter; }
public static ActiveAnnotationContexts find(final Resource resource) { return IterableExtensions.<ActiveAnnotationContexts>head(Iterables.<ActiveAnnotationContexts>filter(resource.eAdapters(), ActiveAnnotationContexts.class)); }
protected Data findDataAdapter(Resource resource) { return (Data) EcoreUtil.getAdapter(resource.eAdapters(), Data.class); }
/** * Remove reference to the aResource. */ protected boolean removeResource(Resource aResource) { if (aResource != null) { aResource.eAdapters().remove(resourceAdapter); return getResources().remove(aResource); } return false; }
/** * Remove reference to the aResource. */ protected boolean removeResource(Resource aResource) { if (aResource != null) { aResource.eAdapters().remove(resourceAdapter); return getResources().remove(aResource); } return false; }
/** * Returns the cache adapter that is associated with the resource. The lifecycle of the cache * is strongly connected to the resource and its change notifications. Will not return <code>null</code>. * @param resource the resource. May not be <code>null</code>. * @return the cache adapter for the given resource. Never <code>null</code>. */ public CacheAdapter getOrCreate(Resource resource) { CacheAdapter adapter = (CacheAdapter) EcoreUtil.getAdapter(resource.eAdapters(), CacheAdapter.class); if (adapter == null) { adapter = new CacheAdapter(); resource.eAdapters().add(adapter); adapter.setResource(resource); } return adapter; }
protected void revertAllResources() { List someResources = getSortedResources(); for (int i = 0; i < someResources.size(); i++) ((Resource) someResources.get(i)).unload(); getResources().removeAll(someResources); for (int i = 0; i < someResources.size(); i++) ((Resource) someResources.get(i)).eAdapters().remove(resourceAdapter); }
/** * Returns the cache adapter that is associated with the resource. The lifecycle of the cache * is strongly connected to the resource and its change notifications. Will not return <code>null</code>. * @param resource the resource. May not be <code>null</code>. * @return the cache adapter for the given resource. Never <code>null</code>. */ public CacheAdapter getOrCreate(Resource resource) { CacheAdapter adapter = (CacheAdapter) EcoreUtil.getAdapter(resource.eAdapters(), CacheAdapter.class); if (adapter == null) { adapter = new CacheAdapter(); resource.eAdapters().add(adapter); adapter.setResource(resource); } return adapter; }
protected ImportedNamesAdapter getImportedNamesAdapter(EObject context) { ImportedNamesAdapter adapter = ImportedNamesAdapter.find(context.eResource()); if (adapter!=null) return adapter; ImportedNamesAdapter importedNamesAdapter = importedNamesAdapterProvider.get(); context.eResource().eAdapters().add(importedNamesAdapter); return importedNamesAdapter; }
@Override protected NotificationChain inverseAdd(Resource resource, NotificationChain notifications) { NotificationChain chain = super.inverseAdd(resource, notifications); resource.eAdapters().add(getUriChangeListener()); registerURI(resource); return chain; }
public void detachData(Resource resource) { resource.eAdapters().remove(findDataAdapter(resource)); }
@Override public void notifyChanged(final Notification msg) { if ((((!this.running) && (!msg.isTouch())) && (Resource.RESOURCE__CONTENTS == msg.getFeatureID(Resource.class)))) { Object _notifier = msg.getNotifier(); final Resource resource = ((Resource) _notifier); resource.eAdapters().remove(this); this.contexts.clear(); this.compilationUnit = null; } }
@Override protected NotificationChain inverseRemove(Resource resource, NotificationChain notifications) { final NotificationChain inverseRemove = super.inverseRemove(resource, notifications); resource.eAdapters().remove(getUriChangeListener()); return inverseRemove; }
public void notifyChanged(Notification notification) { Resource res = (Resource) notification.getNotifier(); if (notification.getEventType() == Notification.SET && notification.getFeatureID(null) == Resource.RESOURCE__IS_LOADED && !res.isLoaded()) { J2EEApplicationItemProvider.this.children.remove(app); res.eAdapters().remove(ResourceAdapter.this); fireNotifyChanged(new J2EENotificationImpl(app, Notification.MOVE, (Object) null, (Object) null, 0)); } } }
public List<T> getAllIncoming() { for (Adapter a : element.eResource().eAdapters()) if (a instanceof IsInitializedMarker && ((IsInitializedMarker) a).builder == builder) return getIncoming(); element.eResource().eAdapters().add(new IsInitializedMarker(builder)); for (EObject root : element.eResource().getContents()) if (root instanceof Grammar) for (AbstractRule rule : ((Grammar) root).getRules()) if (rule.getType().getClassifier() instanceof EClass) for (AbstractElement ele : EcoreUtil2.eAllOfType(rule, AbstractElement.class)) if (!builder.filter(ele)) builder.getState(ele).getOutgoing(); return getIncoming(); }
/** * @since 3.2 */ protected void unloadDelegate(EObject eObject) { if (eObject instanceof EPackage) { EPackage ePackage = (EPackage)eObject; DelegateEPackageAdapter adapter = DelegateEPackageAdapter.findAdapter(ePackage); if (adapter != null) { adapter.unloadDelegates(); } unloadDelegates(ePackage.getESubpackages()); } Resource resource = getTarget(); if (resource != null) { resource.eAdapters().remove(this); } }
protected void addAdapter(EObject eObject) { if (eObject != null && !eObject.eIsProxy()) { Resource eResource = eObject.eResource(); if (eResource == null) { addAdapter(EcoreUtil.getRootContainer(eObject).eAdapters()); } else { ResourceSet resourceSet = eResource.getResourceSet(); if (resourceSet == null) { addAdapter(eResource.eAdapters()); } else { addAdapter(resourceSet.eAdapters()); } } } }