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;
}
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;
}
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());
}
}
}
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);
}
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));
}
Aggregations