Search in sources :

Example 1 with NamespacesContainer

use of org.obeonetwork.dsl.environment.NamespacesContainer in project InformationSystem by ObeoNetwork.

the class TypesServices method collectAllContainers.

private void collectAllContainers(Collection<? extends EObject> elements, Collection<ObeoDSMObject> containers) {
    Collection<EObject> newContainers = new ArrayList<EObject>();
    for (EObject element : elements) {
        EObject container = element.eContainer();
        if (container instanceof NamespacesContainer || container instanceof TypesDefinition) {
            if (!containers.contains(container)) {
                containers.add((ObeoDSMObject) container);
                newContainers.add((EObject) container);
            }
        }
    }
    if (!newContainers.isEmpty()) {
        collectAllContainers(newContainers, containers);
    }
}
Also used : NamespacesContainer(org.obeonetwork.dsl.environment.NamespacesContainer) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) TypesDefinition(org.obeonetwork.dsl.environment.TypesDefinition)

Example 2 with NamespacesContainer

use of org.obeonetwork.dsl.environment.NamespacesContainer in project InformationSystem by ObeoNetwork.

the class BindingService method getAllStructuredTypes.

private Collection<StructuredType> getAllStructuredTypes(EObject any) {
    // Collect all structured types
    Collection<StructuredType> structuredTypes = new ArrayList<StructuredType>();
    // First, get all semantic resources in session
    Collection<Resource> semanticResources = getAllSemanticResourcesInSession(any);
    for (Resource resource : semanticResources) {
        TreeIterator<EObject> iterator = EcoreUtil.getAllContents(resource, true);
        while (iterator.hasNext()) {
            EObject eObject = (EObject) iterator.next();
            if (eObject instanceof StructuredType) {
                structuredTypes.add((StructuredType) eObject);
            } else {
                if (!(eObject instanceof TypesDefinition || eObject instanceof NamespacesContainer || isOverviewRootInstance(eObject))) {
                    iterator.prune();
                }
            }
        }
    }
    return structuredTypes;
}
Also used : NamespacesContainer(org.obeonetwork.dsl.environment.NamespacesContainer) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) Resource(org.eclipse.emf.ecore.resource.Resource) StructuredType(org.obeonetwork.dsl.environment.StructuredType) TypesDefinition(org.obeonetwork.dsl.environment.TypesDefinition)

Aggregations

ArrayList (java.util.ArrayList)2 EObject (org.eclipse.emf.ecore.EObject)2 NamespacesContainer (org.obeonetwork.dsl.environment.NamespacesContainer)2 TypesDefinition (org.obeonetwork.dsl.environment.TypesDefinition)2 Resource (org.eclipse.emf.ecore.resource.Resource)1 StructuredType (org.obeonetwork.dsl.environment.StructuredType)1