private IScope scope_EdgeBehaviorSectionCreateableIn(EObject context, EReference reference) { final Diagram diagram = EcoreUtil2.getContainerOfType(context, Diagram.class); final EdgeElement edgeElement = EcoreUtil2.getContainerOfType(context, EdgeElement.class); if (diagram == null || edgeElement == null) { return IScope.NULLSCOPE; } final EClass diagramModelType = diagram.getModelType(); Predicate<EReference> filter = new Predicate<EReference>() { @Override public boolean apply(EReference input) { boolean superType = false; if (edgeElement != null && edgeElement.getType() != null) { superType = input.getEReferenceType().isSuperTypeOf(edgeElement.getType()); } return superType; } }; // get all containments of EClass contained in this package List<EReference> containmentReferences = new ArrayList<EReference>(); containmentReferences.addAll(diagramModelType.getEAllContainments()); // // if the MetaClass is a connection take also the containment dependencies of the // source type // EClass sourceType = (EClass) ((EdgeBehaviorSection) // edgeElement.getBehavior()).getSource().getEType(); // if (sourceType != null) { // containmentReferences.addAll(sourceType.getEAllContainments()); // } return Scopes.scopeFor(Iterables.filter(containmentReferences, filter)); }
private void setEnabledAll(boolean enabled) { for (EClass e : elementSet) { prefs.putBoolean(e.getName(), enabled); for (EAttribute a : e.getEAllAttributes()) { prefs.putBoolean(e.getName() + "." + a.getName(), enabled); } for (EReference a : e.getEAllContainments()) { prefs.putBoolean(e.getName() + "." + a.getName(), enabled); } for (EReference a : e.getEAllReferences()) { prefs.putBoolean(e.getName() + "." + a.getName(), enabled); } } }
/** * Returns all containing references where <code>parentClass</code> is the container and <code> * childClass</code> the containment. * * @param childClass the EClass which shall be contained * @param parentClass the EClass to get containment references from * @return all possible container-references as a set */ public static Set<EReference> getAllPossibleContainingReferences( EClass childClass, EClass parentClass) { List<EReference> allReferences = parentClass.getEAllContainments(); Set<EReference> result = new LinkedHashSet<EReference>(); for (EReference reference : allReferences) { EClass referenceType = reference.getEReferenceType(); if (referenceType == null) { continue; } // is the reference type a perfect match? if (referenceType.equals(childClass)) { result.add(reference); // is the reference type either EObject or a super type? } else if (referenceType.equals(EcorePackage.eINSTANCE.getEObject()) || referenceType.isSuperTypeOf(childClass)) { result.add(reference); } } return result; }
public List<ToolEnablement> getAllElements() { ArrayList<ToolEnablement> ret = new ArrayList<ToolEnablement>(); for (EClass e : elementSet) { ToolEnablement tool = new ToolEnablement(); tool.setTool(e); tool.setEnabled(isEnabled(e)); ret.add(tool); HashSet<EStructuralFeature> possibleFeatures = new HashSet<EStructuralFeature>(); ArrayList<ToolEnablement> children = new ArrayList<ToolEnablement>(); for (EAttribute a : e.getEAllAttributes()) { possibleFeatures.add(a); } for (EReference a : e.getEAllContainments()) { possibleFeatures.add(a); } for (EReference a : e.getEAllReferences()) { possibleFeatures.add(a); } for (EStructuralFeature feature : possibleFeatures) { ToolEnablement toolEnablement = new ToolEnablement(feature, tool); toolEnablement.setEnabled(isEnabled(e, feature)); children.add(toolEnablement); } sortTools(children); tool.setChildren(children); } sortTools(ret); return ret; }