Ejemplo n.º 1
0
  @Override
  protected CommandExecutionResult executeArg(List<String> arg) {
    final String code = arg.get(2);
    if (getSystem().participants().containsKey(code)) {
      getSystem().putParticipantInLast(code);
      return CommandExecutionResult.ok();
    }

    List<String> strings = null;
    if (arg.get(1) != null) {
      strings = StringUtils.getWithNewlines(arg.get(1));
    }

    final ParticipantType type = ParticipantType.valueOf(arg.get(0).toUpperCase());
    final Participant participant = getSystem().createNewParticipant(type, code, strings);

    final String stereotype = arg.get(3);

    if (stereotype != null) {
      participant.setStereotype(
          new Stereotype(
              stereotype,
              getSystem().getSkinParam().getCircledCharacterRadius(),
              getSystem().getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null)));
    }
    participant.setSpecificBackcolor(arg.get(4));

    return CommandExecutionResult.ok();
  }
Ejemplo n.º 2
0
 public EntityImageUsecase(Entity entity) {
   super(entity);
   this.name =
       TextBlockUtils.create(
           StringUtils.getWithNewlines(entity.getDisplay()),
           new FontConfiguration(getFont14(), Color.BLACK),
           HorizontalAlignement.CENTER);
 }
Ejemplo n.º 3
0
 @Override
 protected CommandExecutionResult executeArg(List<String> arg) {
   final String code = arg.get(2);
   final String display = arg.get(1);
   final String stereotype = arg.get(3);
   if (getSystem().leafExist(code)) {
     return CommandExecutionResult.error("Object already exists : " + code);
   }
   final IEntity entity =
       getSystem().createLeaf(code, StringUtils.getWithNewlines(display), LeafType.OBJECT);
   if (stereotype != null) {
     entity.setStereotype(
         new Stereotype(
             stereotype,
             getSystem().getSkinParam().getCircledCharacterRadius(),
             getSystem().getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null)));
   }
   return CommandExecutionResult.ok();
 }
Ejemplo n.º 4
0
  @Override
  protected CommandExecutionResult executeArg(RegexResult arg) {

    final Code ent1 = Code.of(arg.get("ENT1", 1));
    final Code ent2 = Code.of(arg.get("ENT2", 1));

    final IEntity cl1;
    final IEntity cl2;
    final IEntity normalEntity;

    final String suffix = "lol" + UniqueSequence.getValue();
    if (arg.get("LOL_THEN_ENT", 0) == null) {
      assert arg.get("ENT_THEN_LOL", 0) != null;
      cl1 = getSystem().getOrCreateClass(ent1);
      cl2 =
          getSystem()
              .createLeaf(
                  cl1.getCode().addSuffix(suffix),
                  StringUtils.getWithNewlines(ent2),
                  LeafType.LOLLIPOP);
      normalEntity = cl1;
    } else {
      cl2 = getSystem().getOrCreateClass(ent2);
      cl1 =
          getSystem()
              .createLeaf(
                  cl2.getCode().addSuffix(suffix),
                  StringUtils.getWithNewlines(ent1),
                  LeafType.LOLLIPOP);
      normalEntity = cl2;
    }

    final LinkType linkType = getLinkType(arg);
    final String queue = getQueue(arg);

    int length = queue.length();
    if (length == 1 && getSystem().getNbOfHozizontalLollipop(normalEntity) > 1) {
      length++;
    }

    String firstLabel = arg.get("FIRST_LABEL", 0);
    String secondLabel = arg.get("SECOND_LABEL", 0);

    String labelLink = null;

    if (arg.get("LABEL_LINK", 0) != null) {
      labelLink = arg.get("LABEL_LINK", 0);
      if (firstLabel == null && secondLabel == null) {
        final Pattern p1 = Pattern.compile("^\"([^\"]+)\"([^\"]+)\"([^\"]+)\"$");
        final Matcher m1 = p1.matcher(labelLink);
        if (m1.matches()) {
          firstLabel = m1.group(1);
          labelLink =
              StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m1.group(2).trim()).trim();
          secondLabel = m1.group(3);
        } else {
          final Pattern p2 = Pattern.compile("^\"([^\"]+)\"([^\"]+)$");
          final Matcher m2 = p2.matcher(labelLink);
          if (m2.matches()) {
            firstLabel = m2.group(1);
            labelLink =
                StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m2.group(2).trim()).trim();
            secondLabel = null;
          } else {
            final Pattern p3 = Pattern.compile("^([^\"]+)\"([^\"]+)\"$");
            final Matcher m3 = p3.matcher(labelLink);
            if (m3.matches()) {
              firstLabel = null;
              labelLink =
                  StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m3.group(1).trim())
                      .trim();
              secondLabel = m3.group(2);
            }
          }
        }
      }
      labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(labelLink);
    } /*
       * else if (arg.get("LABEL_LINK_XT").get(0) != null ||
       * arg.get("LABEL_LINK_XT").get(1) != null ||
       * arg.get("LABEL_LINK_XT").get(2) != null) { labelLink =
       * arg.get("LABEL_LINK_XT").get(1); firstLabel = merge(firstLabel,
       * arg.get("LABEL_LINK_XT").get(0)); secondLabel =
       * merge(arg.get("LABEL_LINK_XT").get(2), secondLabel); }
       */

    final Link link =
        new Link(
            cl1,
            cl2,
            linkType,
            labelLink,
            length,
            firstLabel,
            secondLabel,
            getSystem().getLabeldistance(),
            getSystem().getLabelangle());
    getSystem().resetPragmaLabel();
    addLink(link, arg.get("HEADER", 0));

    return CommandExecutionResult.ok();
  }
Ejemplo n.º 5
0
 public final void addNote(String n, Position position, HtmlColor noteColor) {
   this.note = StringUtils.getWithNewlines(n);
   this.notePosition = position;
   this.noteColor = noteColor;
 }
  public CommandExecutionResult execute(List<String> lines) {
    StringUtils.trim(lines, false);
    final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());

    final IEntity entity1 = CommandLinkActivity.getEntity(getSystem(), line0, true);

    if (line0.get("STEREOTYPE", 0) != null) {
      entity1.setStereotype(new Stereotype(line0.get("STEREOTYPE", 0)));
    }
    if (line0.get("BACKCOLOR", 0) != null) {
      entity1.setSpecificBackcolor(HtmlColorUtils.getColorIfValid(line0.get("BACKCOLOR", 0)));
    }
    final StringBuilder sb = new StringBuilder();

    final String desc0 = line0.get("DESC", 0);
    Url urlActivity = null;
    if (StringUtils.isNotEmpty(desc0)) {
      final UrlBuilder urlBuilder =
          new UrlBuilder(getSystem().getSkinParam().getValue("topurl"), true);
      urlActivity = urlBuilder.getUrl(desc0);
      if (urlActivity == null) {
        sb.append(desc0);
        sb.append("\\n");
      }
    }
    for (int i = 1; i < lines.size() - 1; i++) {
      if (i == 1 && urlActivity == null) {
        final UrlBuilder urlBuilder =
            new UrlBuilder(getSystem().getSkinParam().getValue("topurl"), true);
        urlActivity = urlBuilder.getUrl(lines.get(i));
        if (urlActivity != null) {
          continue;
        }
      }
      sb.append(lines.get(i));
      if (i < lines.size() - 2) {
        sb.append("\\n");
      }
    }

    final List<String> lineLast =
        StringUtils.getSplit(Pattern.compile(getPatternEnd()), lines.get(lines.size() - 1));
    if (StringUtils.isNotEmpty(lineLast.get(0))) {
      if (sb.length() > 0 && sb.toString().endsWith("\\n") == false) {
        sb.append("\\n");
      }
      sb.append(lineLast.get(0));
    }

    final String display = sb.toString();
    final Code code = Code.of(lineLast.get(1) == null ? display : lineLast.get(1));

    String partition = null;
    if (lineLast.get(3) != null) {
      partition = lineLast.get(3);
      partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition);
    }
    if (partition != null) {
      getSystem()
          .getOrCreateGroup(
              Code.of(partition),
              StringUtils.getWithNewlines(partition),
              null,
              GroupType.PACKAGE,
              null);
    }
    final IEntity entity2 =
        getSystem().createLeaf(code, StringUtils.getWithNewlines(display), LeafType.ACTIVITY);
    if (partition != null) {
      getSystem().endGroup();
    }
    if (urlActivity != null) {
      entity2.addUrl(urlActivity);
    }

    if (lineLast.get(2) != null) {
      entity2.setStereotype(new Stereotype(lineLast.get(2)));
    }
    if (lineLast.get(4) != null) {
      entity2.setSpecificBackcolor(HtmlColorUtils.getColorIfValid(lineLast.get(4)));
    }

    if (entity1 == null || entity2 == null) {
      return CommandExecutionResult.error("No such entity");
    }

    final String arrow = StringUtils.manageArrowForCuca(line0.get("ARROW", 0));
    final int lenght = arrow.length() - 1;

    final String linkLabel = line0.get("BRACKET", 0);

    LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE);
    if (line0.get("ARROW", 0).contains(".")) {
      type = type.getDotted();
    }
    Link link = new Link(entity1, entity2, type, linkLabel, lenght);
    final Direction direction = StringUtils.getArrowDirection(line0.get("ARROW", 0));
    if (direction == Direction.LEFT || direction == Direction.UP) {
      link = link.getInv();
    }

    if (line0.get("URL", 0) != null) {
      final UrlBuilder urlBuilder =
          new UrlBuilder(getSystem().getSkinParam().getValue("topurl"), true);
      final Url urlLink = urlBuilder.getUrl(line0.get("URL", 0));
      link.setUrl(urlLink);
    }

    getSystem().addLink(link);

    return CommandExecutionResult.ok();
  }