Example #1
0
 private IScope scope_MetaClass_Type(EObject context, EReference reference) {
   Diagram diagram = EcoreUtil2.getContainerOfType(context, Diagram.class);
   // all eClasses that are direct containments of context's diagram model type
   final EClass diagramModelType = diagram.getModelType();
   if (diagramModelType == null || diagramModelType.getEPackage() == null) {
     return IScope.NULLSCOPE;
   }
   final Predicate<EClassifier> filter =
       new Predicate<EClassifier>() {
         @Override
         public boolean apply(EClassifier input) {
           return input instanceof EClass
               && input != diagramModelType
               && !((EClass) input).isAbstract();
         }
       };
   final Function<EClassifier, IEObjectDescription> toObjDesc =
       new Function<EClassifier, IEObjectDescription>() {
         @Override
         public IEObjectDescription apply(EClassifier input) {
           return EObjectDescription.create(qnProvider.apply(input), input);
         }
       };
   // Implicit import of the EPackage of the Diagram Model type
   final List<ImportNormalizer> normalizer =
       Collections.singletonList(
           new ImportNormalizer(qnProvider.apply(diagramModelType.getEPackage()), true, false));
   final ImportScope importDiagramTypePackage =
       new ImportScope(normalizer, delegateGetScope(context, reference), null, null, false);
   final Iterable<IEObjectDescription> descriptions =
       Iterables.transform(
           Iterables.filter(diagramModelType.getEPackage().getEClassifiers(), filter), toObjDesc);
   // the delegate scope will provide import scopes
   return MapBasedScope.createScope(importDiagramTypePackage, descriptions);
 }
Example #2
0
 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));
 }
Example #3
0
 private IScope scope_NodeBehaviorSectionCreateableIn(EObject context, EReference reference) {
   Diagram diagram = EcoreUtil2.getContainerOfType(context, Diagram.class);
   NodeElement nodeElement = EcoreUtil2.getContainerOfType(context, NodeElement.class);
   if (diagram == null || nodeElement == null) {
     return IScope.NULLSCOPE;
   }
   // all eClasses that are direct containments of context's diagram model type
   final EClass diagramModelType = diagram.getModelType();
   if (diagramModelType == null || diagramModelType.getEPackage() == null) {
     return IScope.NULLSCOPE;
   }
   List<EReference> containmentReferences = new ArrayList<EReference>();
   for (EClassifier eClassifiers : diagramModelType.getEPackage().getEClassifiers()) {
     if (eClassifiers instanceof EClass) {
       for (EReference ref : ((EClass) eClassifiers).getEAllContainments()) {
         if (ref.getEType() instanceof EClass
             && ((EClass) ref.getEType()).isSuperTypeOf(nodeElement.getType())) {
           containmentReferences.add(ref);
         }
       }
     }
   }
   return Scopes.scopeFor(containmentReferences);
 }