Esempio n. 1
0
 public void testStaticMethods() throws Exception {
   XbaseScopeProvider provider = get(XbaseScopeProvider.class);
   XExpression expression = expression("'x' != 'y'", true);
   IScope scope =
       provider.getScope(expression, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE);
   final List<IEObjectDescription> allElements = newArrayList(scope.getAllElements());
   try {
     find(
         allElements,
         new Predicate<IEObjectDescription>() {
           public boolean apply(IEObjectDescription input) {
             return input.getName().toString().equals("!=");
           }
         });
   } catch (NoSuchElementException e) {
     fail("operator not found : " + allElements.toString());
   }
   try {
     find(
         allElements,
         new Predicate<IEObjectDescription>() {
           public boolean apply(IEObjectDescription input) {
             return input.getName().toString().equals("-");
           }
         });
     fail("operator + is not defined for type string");
   } catch (NoSuchElementException e) {
     // expected
   }
 }
 @Override
 protected Iterable<IEObjectDescription> getAllLocalElements() {
   Map<String, IEObjectDescription> result = new HashMap<String, IEObjectDescription>();
   for (IEObjectDescription ePkgDesc : parentScope.getAllElements()) {
     EPackage ePkg = (EPackage) ePkgDesc.getEObjectOrProxy();
     ePkg = (EPackage) EcoreUtil.resolve(ePkg, context);
     result.put(ePkg.getNsURI(), EObjectDescription.create(ePkg.getNsURI(), ePkg));
   }
   return result.values();
 }
  public IScope getScope(
      Resource context, EReference reference, Predicate<IEObjectDescription> filter) {
    IScope scope = super.getScope(context, reference, filter);
    IScope globalScope = delegate.getScope(context, reference, filter);
    FilteringScope filteringScope =
        new FilteringScope(
            globalScope,
            new Predicate<IEObjectDescription>() {

              public boolean apply(IEObjectDescription input) {
                return input.getEClass() == SGraphPackage.Literals.STATECHART;
              }
            });
    return new SimpleScope(
        Iterables.concat(scope.getAllElements(), filteringScope.getAllElements()));
  }
Esempio n. 4
0
  @Override
  protected void createContent(
      IManagedForm mform, Composite body, DataBindingContext bindingContext) {
    Result notReferenced = ValidationUtil.isFreeOfReferences(port);
    boolean multiplicityAnyAllowed = true;
    ActorContainerClass parent = (ActorContainerClass) port.eContainer();
    if (parent instanceof ActorClass) {
      if (ValidationUtil.isReferencedAsReplicatedInModel((ActorClass) parent))
        multiplicityAnyAllowed = false;
    }
    NameValidator nv = new NameValidator();
    ProtocolValidator pv = new ProtocolValidator();
    MultiplicityValidator mv =
        new MultiplicityValidator(
            newPort || notReferenced.isOk(), port.getMultiplicity(), multiplicityAnyAllowed);

    ArrayList<IEObjectDescription> protocols = new ArrayList<IEObjectDescription>();
    Iterator<IEObjectDescription> it = scope.getAllElements().iterator();
    while (it.hasNext()) {
      IEObjectDescription desc = it.next();
      EObject obj = desc.getEObjectOrProxy();
      if (obj instanceof GeneralProtocolClass) protocols.add(desc);
    }

    Text name = createText(body, "&Name:", port, RoomPackage.eINSTANCE.getInterfaceItem_Name(), nv);
    Combo protocol =
        createComboUsingDesc(
            body,
            "&Protocol:",
            port,
            GeneralProtocolClass.class,
            RoomPackage.eINSTANCE.getPort_Protocol(),
            protocols,
            RoomPackage.eINSTANCE.getRoomClass_Name(),
            pv);
    Button conj =
        createCheck(body, "&Conjugated:", port, RoomPackage.eINSTANCE.getPort_Conjugated());
    if (!internal && !refitem && (acc instanceof ActorClass))
      createRelayCheck(body, notReferenced, mform.getToolkit());

    Multiplicity2StringConverter m2s = new Multiplicity2StringConverter();
    String2MultiplicityConverter s2m = new String2MultiplicityConverter();
    Text multi =
        createText(
            body,
            "&Multiplicity:",
            port,
            RoomPackage.eINSTANCE.getPort_Multiplicity(),
            mv,
            s2m,
            m2s,
            false);

    if (!newPort) {
      if (!notReferenced.isOk()) {
        protocol.setEnabled(false);
        createInfoDecorator(protocol, notReferenced.getMsg());
        conj.setEnabled(false);
        createInfoDecorator(conj, notReferenced.getMsg());
        if (port.getMultiplicity() == 1) {
          multi.setEnabled(false);
          createInfoDecorator(multi, notReferenced.getMsg());
        }
      }

      if (refitem) {
        name.setEnabled(false);
        createInfoDecorator(name, "inherited");
        protocol.setEnabled(false);
        createInfoDecorator(protocol, "inherited");
        conj.setEnabled(false);
        createInfoDecorator(conj, "inherited");
        multi.setEnabled(false);
        createInfoDecorator(multi, "inherited");
      }
    }

    createDecorator(name, "invalid name");
    createDecorator(protocol, "no protocol selected");
    createDecorator(multi, "multiplicity must be greater 1");

    name.selectAll();
    name.setFocus();
  }