Java Code Examples for org.eclipse.emf.common.notify.Notifier

The following examples show how to use org.eclipse.emf.common.notify.Notifier. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: xtext-core   Author: eclipse   File: ResourceSetBasedSlotEntry.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected List<EObject> findEObjectsOfType(Set<EClass> eClasses, IResourceDescriptions resourceDescriptions,
		ResourceSet resourceSet) {
	List<EObject> result = Lists.newArrayList();
	for (Resource resource : resourceSet.getResources()) {
		if (!resource.isLoaded()) {
			try {
				resource.load(null);
			} catch (IOException e) {
				throw new WrappedException(e);
			}
		}
	}
	for (Iterator<Notifier> i = resourceSet.getAllContents(); i.hasNext();) {
		Notifier next = i.next();
		if (next instanceof EObject && matches(eClasses, (EObject) next)) {
			result.add((EObject) next);
		}
	}
	return result;
}
 
Example #2
Source Project: xtext-extras   Author: eclipse   File: TypeReferences.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @return a fresh {@link JvmMultiTypeReference} pointing to the given references or null if {@link Object} is not
 *         on the context's class path
 */
public JvmMultiTypeReference createMultiTypeReference(Notifier context, JvmTypeReference... references) {
	if (context == null)
		throw new NullPointerException("context");
	JvmMultiTypeReference result = factory.createJvmMultiTypeReference();
	if (references != null && references.length != 0) {
		for (JvmTypeReference reference : references) {
			result.getReferences().add(createDelegateTypeReference(reference));
		}
	}
	final JvmType findDeclaredType = findDeclaredType(Object.class, context);
	if (findDeclaredType == null)
		return null;
	result.setType(findDeclaredType);
	return result;
}
 
Example #3
Source Project: M2Doc   Author: ObeoNetwork   File: GenconfUtils.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Initializes the {@link Generation#getDefinitions() variable definitions} from the given {@link Generation} with the given
 * {@link ResourceSet}.
 * 
 * @param generation
 *            the {@link Generation} to initialize
 * @param queryEnvironment
 *            the {@link IReadOnlyQueryEnvironment}
 * @param properties
 *            the {@link TemplateCustomProperties}
 * @param resourceSetForModels
 *            the {@link ResourceSet} to get values from
 */
public static void initializeVariableDefinition(Generation generation, IReadOnlyQueryEnvironment queryEnvironment,
        TemplateCustomProperties properties, ResourceSet resourceSetForModels) {
    final AstValidator validator = new AstValidator(new ValidationServices(queryEnvironment));
    final Map<ModelDefinition, Set<IType>> toInitialilize = new HashMap<ModelDefinition, Set<IType>>();
    for (Definition definition : generation.getDefinitions()) {
        if (definition instanceof ModelDefinition && ((ModelDefinition) definition).getValue() == null) {
            final ModelDefinition modelDefinition = (ModelDefinition) definition;
            final Set<IType> possibleTypes = properties.getVariableTypes(validator, queryEnvironment,
                    properties.getVariables().get(modelDefinition.getKey()));
            toInitialilize.put(modelDefinition, possibleTypes);
        }
    }

    final Iterator<Notifier> it = resourceSetForModels.getAllContents();
    while (!toInitialilize.isEmpty() && it.hasNext()) {
        final Notifier notifier = it.next();
        if (notifier instanceof EObject) {
            EObject element = (EObject) notifier;
            final EClassifierType elementType = new EClassifierType(queryEnvironment, element.eClass());
            ModelDefinition initialized = null;
            for (Entry<ModelDefinition, Set<IType>> entry : toInitialilize.entrySet()) {
                for (IType definitionType : entry.getValue()) {
                    if (definitionType.isAssignableFrom(elementType)) {
                        initialized = entry.getKey();
                        initialized.setValue(element);
                    }
                }
            }
            if (initialized != null) {
                toInitialilize.remove(initialized);
            }
        }
    }
}
 
Example #4
Source Project: xtext-core   Author: eclipse   File: ChunkedResourceDescriptions.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public static ChunkedResourceDescriptions removeFromEmfObject(Notifier emfObject) {
	List<Adapter> adapters = emfObject.eAdapters();
	for (int i = 0; i < adapters.size(); i++) {
		Adapter adapter = adapters.get(i);
		if (adapter instanceof ChunkedResourceDescriptionsAdapter)
			return ((ChunkedResourceDescriptionsAdapter) emfObject.eAdapters().remove(i)).get();
	}
	return null;
}
 
Example #5
Source Project: xtext-core   Author: eclipse   File: FlattenedGrammarAccess.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public static FlattenedGrammarAccess removeFromEmfObject(Notifier emfObject) {
	List<Adapter> adapters = emfObject.eAdapters();
	for (int i = 0; i < adapters.size(); i++) {
		Adapter adapter = adapters.get(i);
		if (adapter instanceof FlattenedGrammarAccessAdapter)
			return ((FlattenedGrammarAccessAdapter) emfObject.eAdapters().remove(i)).get();
	}
	return null;
}
 
Example #6
Source Project: xtext-extras   Author: eclipse   File: ClassFileCache.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public void attachToEmfObject(Notifier emfObject) {
	ClassFileCache result = findInEmfObject(emfObject);
	if (result != null)
		throw new IllegalStateException("The given EMF object already contains an adapter for ClassFileCache");
	ClassFileCache.ClassFileCacheAdapter adapter = new ClassFileCache.ClassFileCacheAdapter(this);
	emfObject.eAdapters().add(adapter);
}
 
Example #7
Source Project: xtext-extras   Author: eclipse   File: AnnotationLookup.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public JvmAnnotationReference findOrAddAnnotation(/* @NonNull */ JvmAnnotationTarget annotationTarget, /* @NonNull */ Notifier context, /* @NonNull */ Class<? extends Annotation> type) {
	JvmAnnotationReference result = findAnnotation(annotationTarget, type);
	if (result != null)
		return result;
	JvmAnnotationType annotationType = findAnnotationType(type, context);
	if (annotationType != null) {
		result = typesFactory.createJvmAnnotationReference();
		result.setAnnotation(annotationType);
		return result;
	}
	return null;
}
 
Example #8
Source Project: xtext-extras   Author: eclipse   File: ClassFileCache.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public static ClassFileCache removeFromEmfObject(Notifier emfObject) {
	List<Adapter> adapters = emfObject.eAdapters();
	for (int i = 0, max = adapters.size(); i < max; i++) {
		Adapter adapter = adapters.get(i);
		if (adapter instanceof ClassFileCache.ClassFileCacheAdapter) {
			emfObject.eAdapters().remove(i);
			return ((ClassFileCache.ClassFileCacheAdapter) adapter).get();
		}
	}
	return null;
}
 
Example #9
Source Project: xtext-core   Author: eclipse   File: OriginalElement.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public static OriginalElement removeFromEmfObject(Notifier emfObject) {
	List<Adapter> adapters = emfObject.eAdapters();
	for (int i = 0, max = adapters.size(); i < max; i++) {
		Adapter adapter = adapters.get(i);
		if (adapter instanceof OriginalElement.OriginalElementAdapter) {
			emfObject.eAdapters().remove(i);
			return ((OriginalElement.OriginalElementAdapter) adapter).get();
		}
	}
	return null;
}
 
Example #10
Source Project: xtext-extras   Author: eclipse   File: TypeReferences.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public JvmTypeReference getTypeForName(String typeName, Notifier context, JvmTypeReference... params) {
	if (typeName == null)
		throw new NullPointerException("typeName");
	JvmType declaredType = findDeclaredType(typeName, context);
	if (declaredType == null)
		return getUnknownTypeReference(typeName);
	JvmParameterizedTypeReference result = createTypeRef(declaredType, params);
	return result;
}
 
Example #11
Source Project: xtext-extras   Author: eclipse   File: TypeReferences.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @return a fresh {@link JvmAnyTypeReference} or null if {@link Object} is not on the context's classpath
 */
public JvmAnyTypeReference createAnyTypeReference(Notifier context) {
	if (context == null)
		throw new NullPointerException("context");
	JvmAnyTypeReference result = factory.createJvmAnyTypeReference();
	final JvmType objectType = findDeclaredType(Object.class, context);
	if (objectType == null)
		return null;
	result.setType(objectType);
	return result;
}
 
Example #12
Source Project: xtext-core   Author: eclipse   File: EcoreUtil2.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public static ResourceSet getResourceSet(Notifier ctx) {
	if (ctx instanceof EObject) {
		Resource eResource = ((EObject) ctx).eResource();
		if (eResource != null)
			return eResource.getResourceSet();
	} else if (ctx instanceof Resource) {
		return ((Resource) ctx).getResourceSet();
	} else if (ctx instanceof ResourceSet) {
		return (ResourceSet) ctx;
	}
	return null;
}
 
Example #13
Source Project: xtext-core   Author: eclipse   File: CompositeNodeWithSemanticElement.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setTarget(Notifier newTarget) {
	if (newTarget == null || newTarget instanceof EObject)
		semanticElement = (EObject) newTarget;
	else
		throw new IllegalArgumentException("Notifier must be an Eobject");
}
 
Example #14
Source Project: xtext-core   Author: eclipse   File: RuleWithParameterValues.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public static RuleWithParameterValues findInEmfObject(Notifier emfObject) {
	for (Adapter adapter : emfObject.eAdapters()) {
		if (adapter instanceof RuleWithParameterValues.RuleWithParameterValuesAdapter) {
			return ((RuleWithParameterValues.RuleWithParameterValuesAdapter) adapter).get();
		}
	}
	return null;
}
 
Example #15
Source Project: xtext-core   Author: eclipse   File: CompositeNodeWithSemanticElement.java    License: Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Notifier getTarget() {
	return semanticElement;
}
 
Example #16
Source Project: xtext-extras   Author: eclipse   File: TypeReferences.java    License: Eclipse Public License 2.0 3 votes vote down vote up
/**
 * looks up a JVMType corresponding to the given {@link Class}. This method ignores any Jvm types created in non-
 * {@link TypeResource} in the given EObject's resourceSet, but goes straight to the Java-layer, using a
 * {@link IJvmTypeProvider}.
 * 
 * @return the JvmType with the same qualified name as the given {@link Class} object, or null if no such JvmType
 *         could be found using the context's resourceSet.
 */
public JvmType findDeclaredType(Class<?> clazz, Notifier context) {
	if (clazz == null)
		throw new NullPointerException("clazz");
	JvmType declaredType = findDeclaredType(clazz.getName(), context);
	return declaredType;
}
 
Example #17
Source Project: graphical-lsp   Author: eclipsesource   File: WfgraphAdapterFactory.java    License: Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Creates an adapter for the <code>target</code>.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @param target the object to adapt.
 * @return the adapter for the <code>target</code>.
 * @generated
 */
@Override
public Adapter createAdapter(Notifier target) {
	return modelSwitch.doSwitch((EObject) target);
}
 
Example #18
Source Project: neoscada   Author: eclipse   File: GlobalizeAdapterFactory.java    License: Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Creates an adapter for the <code>target</code>.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * 
 * @param target
 *            the object to adapt.
 * @return the adapter for the <code>target</code>.
 * @generated
 */
@Override
public Adapter createAdapter ( final Notifier target )
{
    return this.modelSwitch.doSwitch ( (EObject)target );
}
 
Example #19
Source Project: dsl-devkit   Author: dsldevkit   File: CheckAdapterFactory.java    License: Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Creates an adapter for the <code>target</code>.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @param target the object to adapt.
 * @return the adapter for the <code>target</code>.
 * @generated
 */
@Override
public Adapter createAdapter(Notifier target)
{
	return modelSwitch.doSwitch((EObject)target);
}
 
Example #20
Source Project: dsl-devkit   Author: dsldevkit   File: ValidAdapterFactory.java    License: Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Creates an adapter for the <code>target</code>.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @param target the object to adapt.
 * @return the adapter for the <code>target</code>.
 * @generated
 */
@Override
public Adapter createAdapter(Notifier target)
{
  return modelSwitch.doSwitch((EObject)target);
}
 
Example #21
Source Project: xtext-core   Author: eclipse   File: XtextGrammarTestAdapterFactory.java    License: Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Creates an adapter for the <code>target</code>.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @param target the object to adapt.
 * @return the adapter for the <code>target</code>.
 * @generated
 */
@Override
public Adapter createAdapter(Notifier target)
{
  return modelSwitch.doSwitch((EObject)target);
}
 
Example #22
Source Project: xtext-core   Author: eclipse   File: InheritanceTest2AdapterFactory.java    License: Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Creates an adapter for the <code>target</code>.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @param target the object to adapt.
 * @return the adapter for the <code>target</code>.
 * @generated
 */
@Override
public Adapter createAdapter(Notifier target)
{
  return modelSwitch.doSwitch((EObject)target);
}
 
Example #23
Source Project: xtext-eclipse   Author: eclipse   File: BracketmatchingAdapterFactory.java    License: Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Creates an adapter for the <code>target</code>.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @param target the object to adapt.
 * @return the adapter for the <code>target</code>.
 * @generated
 */
@Override
public Adapter createAdapter(Notifier target)
{
  return modelSwitch.doSwitch((EObject)target);
}
 
Example #24
Source Project: xtext-core   Author: eclipse   File: PartialParsingTestUtilAdapterFactory.java    License: Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Creates an adapter for the <code>target</code>.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @param target the object to adapt.
 * @return the adapter for the <code>target</code>.
 * @generated
 */
@Override
public Adapter createAdapter(Notifier target) {
	return modelSwitch.doSwitch((EObject)target);
}
 
Example #25
Source Project: ADT_Frontend   Author: abapGit   File: AbapgitrepositoriesAdapterFactory.java    License: MIT License 2 votes vote down vote up
/**
 * Creates an adapter for the <code>target</code>.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @param target the object to adapt.
 * @return the adapter for the <code>target</code>.
 * @generated
 */
@Override
public Adapter createAdapter(Notifier target) {
	return modelSwitch.doSwitch((EObject)target);
}
 
Example #26
Source Project: xtext-eclipse   Author: eclipse   File: DomainmodelAdapterFactory.java    License: Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Creates an adapter for the <code>target</code>.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @param target the object to adapt.
 * @return the adapter for the <code>target</code>.
 * @generated
 */
@Override
public Adapter createAdapter(Notifier target)
{
  return modelSwitch.doSwitch((EObject)target);
}
 
Example #27
Source Project: xtext-core   Author: eclipse   File: ActionLangAdapterFactory.java    License: Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Creates an adapter for the <code>target</code>.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @param target the object to adapt.
 * @return the adapter for the <code>target</code>.
 * @generated
 */
@Override
public Adapter createAdapter(Notifier target)
{
  return modelSwitch.doSwitch((EObject)target);
}
 
Example #28
Source Project: xtext-eclipse   Author: eclipse   File: Bug309949TestLanguageAdapterFactory.java    License: Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Creates an adapter for the <code>target</code>.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @param target the object to adapt.
 * @return the adapter for the <code>target</code>.
 * @generated
 */
@Override
public Adapter createAdapter(Notifier target)
{
  return modelSwitch.doSwitch((EObject)target);
}
 
Example #29
Source Project: xtext-core   Author: eclipse   File: WithtransientAdapterFactory.java    License: Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Creates an adapter for the <code>target</code>.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @param target the object to adapt.
 * @return the adapter for the <code>target</code>.
 * @generated
 */
@Override
public Adapter createAdapter(Notifier target)
{
	return modelSwitch.doSwitch((EObject)target);
}
 
Example #30
Source Project: xtext-core   Author: eclipse   File: Bug288432TestAdapterFactory.java    License: Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Creates an adapter for the <code>target</code>.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @param target the object to adapt.
 * @return the adapter for the <code>target</code>.
 * @generated
 */
@Override
public Adapter createAdapter(Notifier target)
{
  return modelSwitch.doSwitch((EObject)target);
}