Example #1
0
  /**
   * returns a flat list of Port scopes for a {@link ExternalPort}
   *
   * @param ar - the external port
   * @param ref - not used
   * @return a list of scopes
   */
  public IScope scope_ExternalPort_ifport(ExternalPort ep, EReference ref) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    ActorClass ac = getActorClass(ep);
    for (Port ip : ac.getIfPorts()) {
      scopes.add(EObjectDescription.create(ip.getName(), ip));
    }

    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
Example #2
0
  /**
   * returns a flat list of Port scopes for a {@link MessageFromIf}
   *
   * @param mfi - the message from interface
   * @param ref - not used
   * @return a list of scopes
   */
  public IScope scope_MessageFromIf_port(MessageFromIf mfi, EReference ref) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    ActorClass ac = getActorClass(mfi);
    for (Port p : ac.getIntPorts()) {
      scopes.add(EObjectDescription.create(p.getName(), p));
    }
    for (ExternalPort p : ac.getExtPorts()) {
      scopes.add(EObjectDescription.create(p.getIfport().getName(), p.getIfport()));
    }

    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
Example #3
0
  /**
   * returns a flat list of Port scopes for a {@link BindingEndPoint}
   *
   * @param ep - the endpoint
   * @param ref - not used
   * @return a list of scopes
   */
  public IScope scope_BindingEndPoint_port(BindingEndPoint ep, EReference ref) {
    final List<IEObjectDescription> scopes = new ArrayList<IEObjectDescription>();

    ActorContainerClass acc = getActorContainerClass(ep);

    if (ep.getActorRef() == null) {
      if (acc instanceof ActorClass) {
        ActorClass ac = (ActorClass) acc;
        // for all super classes (including this class)
        LinkedList<ActorClass> classes = getBaseClasses(ac);
        for (ActorClass a : classes) {
          // collect internal and relay ports, i.e.
          // structure ports not in interface (internal)
          for (Port p : a.getIntPorts()) {
            scopes.add(EObjectDescription.create(p.getName(), p));
          }
          // interface ports not in structure (relay)
          for (Port p : a.getIfPorts()) {
            if (!isContained(p, a.getExtPorts()))
              scopes.add(EObjectDescription.create(p.getName(), p));
          }
        }
      } else {
        // SubSystemClass has no internal end ports
      }
    } else {
      // all ports in the sub actor's interface
      if (ep.getActorRef() instanceof ActorRef) {
        ActorClass ac = ((ActorRef) ep.getActorRef()).getType();
        LinkedList<ActorClass> classes = getBaseClasses(ac);
        for (ActorClass a : classes) {
          for (Port p : a.getIfPorts()) {
            scopes.add(EObjectDescription.create(p.getName(), p));
          }
        }
      } else {
        SubSystemClass ssc = ((SubSystemRef) ep.getActorRef()).getType();
        for (Port p : ssc.getRelayPorts()) {
          scopes.add(EObjectDescription.create(p.getName(), p));
        }
      }
    }
    return new SimpleScope(IScope.NULLSCOPE, scopes);
  }
  @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();
  }