Search in sources :

Example 11 with Setting

use of org.eclipse.emf.ecore.EStructuralFeature.Setting in project InformationSystem by ObeoNetwork.

the class RequirementService method getLinkedRequirements.

private static Set<Requirement> getLinkedRequirements(Session session, EObject eObject) {
    ECrossReferenceAdapter crossReferenceAdapter = session.getSemanticCrossReferencer();
    HashSet<Requirement> linkedRequirements = new HashSet<Requirement>();
    for (Setting setting : crossReferenceAdapter.getInverseReferences(eObject)) {
        if (setting.getEObject() instanceof Requirement) {
            Requirement requirement = (Requirement) setting.getEObject();
            // duplicates
            if (requirement.getReferencedObject().contains(eObject)) {
                linkedRequirements.add(requirement);
            }
        }
    }
    return linkedRequirements;
}
Also used : ECrossReferenceAdapter(org.eclipse.emf.ecore.util.ECrossReferenceAdapter) Requirement(org.obeonetwork.dsl.requirement.Requirement) Setting(org.eclipse.emf.ecore.EStructuralFeature.Setting) HashSet(java.util.HashSet)

Example 12 with Setting

use of org.eclipse.emf.ecore.EStructuralFeature.Setting in project InformationSystem by ObeoNetwork.

the class RequirementServices method relatedRequirements.

/**
 * Returns the list of {@link Requirement} that reference the specified
 * eObject. For the service to work, eObject must be present in a
 *
 * @param eObject
 * @return the list of {@link Requirement} instances that reference the
 *         specified eObject.
 */
public List<Requirement> relatedRequirements(EObject eObject) {
    Resource resource = eObject.eResource();
    List<Requirement> result = new ArrayList<Requirement>();
    if (resource != null) {
        ResourceSet resourceSet = resource.getResourceSet();
        if (resourceSet != null) {
            Collection<Setting> settings = EcoreUtil.UsageCrossReferencer.find(eObject, resourceSet);
            for (Setting setting : settings) {
                if (setting.getEObject() instanceof Requirement) {
                    result.add(((Requirement) setting.getEObject()));
                }
            }
        }
    }
    return result;
}
Also used : Requirement(org.obeonetwork.dsl.requirement.Requirement) Setting(org.eclipse.emf.ecore.EStructuralFeature.Setting) Resource(org.eclipse.emf.ecore.resource.Resource) ArrayList(java.util.ArrayList) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet)

Example 13 with Setting

use of org.eclipse.emf.ecore.EStructuralFeature.Setting in project InformationSystem by ObeoNetwork.

the class ClassDiagramGenerator method replaceColorReferences.

private void replaceColorReferences(Group groupFromTemplate, Group newGroup, Collection<ColorInfo> generationColors, UserColorsPalette palette) {
    // Retrieve colors in the odesign templates
    Collection<UserColor> defaultUserColors = new ArrayList<UserColor>();
    for (ColorInfo generationColor : generationColors) {
        for (UserColorsPalette defaultPalette : groupFromTemplate.getUserColorsPalettes()) {
            for (UserColor defaultColor : defaultPalette.getEntries()) {
                if (defaultColor instanceof UserFixedColor && defaultColor.getName().equals(generationColor.getName())) {
                    defaultUserColors.add(defaultColor);
                }
            }
        }
    }
    // we have to change references to these colors to the corresponding ones in the new palette
    Map<UserColor, UserColor> colorCorrespondances = new HashMap<UserColor, UserColor>();
    for (UserColor userColor : defaultUserColors) {
        for (UserColor newColor : palette.getEntries()) {
            if (newColor instanceof UserFixedColor && userColor.getName().equals(newColor.getName())) {
                colorCorrespondances.put(userColor, newColor);
            }
        }
    }
    // find references to the default color
    for (Entry<UserColor, UserColor> entry : colorCorrespondances.entrySet()) {
        Collection<Setting> settings = EcoreUtil.UsageCrossReferencer.find(entry.getKey(), newGroup.eResource().getResourceSet());
        for (Setting setting : settings) {
            EcoreUtil.replace(setting.getEObject(), setting.getEStructuralFeature(), entry.getKey(), entry.getValue());
        }
    }
}
Also used : UserColorsPalette(org.eclipse.sirius.viewpoint.description.UserColorsPalette) UserFixedColor(org.eclipse.sirius.viewpoint.description.UserFixedColor) HashMap(java.util.HashMap) Setting(org.eclipse.emf.ecore.EStructuralFeature.Setting) ArrayList(java.util.ArrayList) UserColor(org.eclipse.sirius.viewpoint.description.UserColor) ColorInfo(org.obeonetwork.tools.classdiagramconfiguration.ColorInfo)

Example 14 with Setting

use of org.eclipse.emf.ecore.EStructuralFeature.Setting in project InformationSystem by ObeoNetwork.

the class DeleteServices method deleteObeoDSMObject.

public void deleteObeoDSMObject(StructuredType type) {
    // First we have to delete all references pointing towards this type
    Session session = getSession(type);
    ECrossReferenceAdapter crossReferencer = session.getSemanticCrossReferencer();
    Collection<Setting> inverseReferences = crossReferencer.getInverseReferences(type, true);
    for (Setting setting : inverseReferences) {
        if (EnvironmentPackage.Literals.REFERENCE__REFERENCED_TYPE == setting.getEStructuralFeature()) {
            delete((ObeoDSMObject) setting.getEObject(), session);
        }
    }
    delete(type);
}
Also used : ECrossReferenceAdapter(org.eclipse.emf.ecore.util.ECrossReferenceAdapter) Setting(org.eclipse.emf.ecore.EStructuralFeature.Setting) Session(org.eclipse.sirius.business.api.session.Session)

Example 15 with Setting

use of org.eclipse.emf.ecore.EStructuralFeature.Setting in project InformationSystem by ObeoNetwork.

the class TaskImpl method getReferencedBy.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
public EList<TaskReference> getReferencedBy() {
    Collection<Setting> referencingTasksReferences = new GraalUsageCrossReferencer() {

        @Override
        protected boolean crossReference(EObject eObject, EReference eReference, EObject crossReferencedEObject) {
            return eReference == GraalPackage.Literals.TASK_REFERENCE__TASK;
        }

        @Override
        protected boolean containment(EObject eObject) {
            // (We use Resource instead of CDOResource to avoid dependency on CDO)
            return (eObject instanceof Resource) || (eObject instanceof System) || (eObject instanceof TasksGroup) || (eObject instanceof Task) || (eObject instanceof Loop) || (eObject instanceof TaskReference);
        }
    }.findUsage(this);
    List<TaskReference> foundTasksReferences = new ArrayList<TaskReference>();
    for (Setting setting : referencingTasksReferences) {
        foundTasksReferences.add((TaskReference) setting.getEObject());
    }
    return ECollections.unmodifiableEList(new BasicEList<TaskReference>(foundTasksReferences));
}
Also used : Loop(org.obeonetwork.graal.Loop) AbstractTask(org.obeonetwork.graal.AbstractTask) Task(org.obeonetwork.graal.Task) Setting(org.eclipse.emf.ecore.EStructuralFeature.Setting) GraalUsageCrossReferencer(org.obeonetwork.graal.util.GraalUsageCrossReferencer) Resource(org.eclipse.emf.ecore.resource.Resource) ArrayList(java.util.ArrayList) System(org.obeonetwork.graal.System) TaskReference(org.obeonetwork.graal.TaskReference) TasksGroup(org.obeonetwork.graal.TasksGroup) EObject(org.eclipse.emf.ecore.EObject) EReference(org.eclipse.emf.ecore.EReference)

Aggregations

Setting (org.eclipse.emf.ecore.EStructuralFeature.Setting)16 EObject (org.eclipse.emf.ecore.EObject)11 ArrayList (java.util.ArrayList)7 Resource (org.eclipse.emf.ecore.resource.Resource)7 EReference (org.eclipse.emf.ecore.EReference)5 Collection (java.util.Collection)4 ECrossReferenceAdapter (org.eclipse.emf.ecore.util.ECrossReferenceAdapter)4 System (org.obeonetwork.graal.System)4 GraalUsageCrossReferencer (org.obeonetwork.graal.util.GraalUsageCrossReferencer)4 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 EDataType (org.eclipse.emf.ecore.EDataType)2 EPackage (org.eclipse.emf.ecore.EPackage)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 Session (org.eclipse.sirius.business.api.session.Session)2 Reference (org.obeonetwork.dsl.environment.Reference)2 Requirement (org.obeonetwork.dsl.requirement.Requirement)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URL (java.net.URL)1