public final CommandExecutionResult execute(List<String> lines) { final List<String> line0 = StringUtils.getSplit(getStartingPattern(), lines.get(0).trim()); final String pos = line0.get(0); final IEntity activity = getSystem().getLastEntityConsulted(); if (activity == null) { // activity = getSystem().getStart(); return CommandExecutionResult.error("No activity defined"); } final List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1)); // final String s = StringUtils.getMergedLines(strings); final IEntity note = getSystem().createLeaf(UniqueSequence.getCode("GMN"), strings, LeafType.NOTE); note.setSpecificBackcolor(HtmlColorUtils.getColorIfValid(line0.get(1))); final Link link; final Position position = Position.valueOf(pos.toUpperCase()).withRankdir(getSystem().getRankdir()); final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getDashed(); if (position == Position.RIGHT) { link = new Link(activity, note, type, null, 1); } else if (position == Position.LEFT) { link = new Link(note, activity, type, null, 1); } else if (position == Position.BOTTOM) { link = new Link(activity, note, type, null, 2); } else if (position == Position.TOP) { link = new Link(note, activity, type, null, 2); } else { throw new IllegalArgumentException(); } getSystem().addLink(link); return CommandExecutionResult.ok(); }
public CommandExecutionResult execute(List<String> lines) { final List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1)); if (strings.size() > 0) { final List<CharSequence> n = StringUtils.manageEmbededDiagrams(strings); final Link link = getSystem().getLastStateLink(); if (link == null) { return CommandExecutionResult.error("No link defined"); } Position position = Position.BOTTOM; final Matcher m = getStartingPattern().matcher(lines.get(0)); if (m.find()) { final String pos = m.group(1); if (pos != null) { position = Position.valueOf(pos.toUpperCase()); } } link.addNote(n, position); return CommandExecutionResult.ok(); } return CommandExecutionResult.error("No note defined"); }