use of net.sf.sdedit.message.ForwardMessage in project abstools by abstools.
the class MessageProcessor method _processMessage.
private ForwardMessage _processMessage(boolean openFragments) throws SemanticError {
checkSemantics();
if (diagram.isThreaded()) {
findThreadNumbers();
diagram.setCallerThread(callerThread);
} else {
noThreadingChecks();
}
caller = findCaller();
if (!isPrimitiveMessage()) {
callee = findCallee();
} else {
callee = null;
}
ForwardMessage message = getMessage();
// fixes bug 2019720
if (openFragments) {
diagram.getFragmentManager().openFragments();
}
return message;
}
use of net.sf.sdedit.message.ForwardMessage in project abstools by abstools.
the class Diagram method readNextMessage.
private void readNextMessage() throws SyntaxError, SemanticError {
MessageData data = provider.nextMessage();
noteManager.closeNote(data.getCaller());
String[] callees = data.getCallees();
if (callees.length == 1) {
throw new SyntaxError(provider, "A broadcast message must have at least two receivers");
}
if (callees.length >= 2) {
if (data.isSpawnMessage()) {
throw new SyntaxError(provider, "Broadcast messages are spawning by default");
}
Set<String> calleeSet = new HashSet<String>();
Lifeline[] allButLast = new Lifeline[callees.length - 1];
for (int i = 0; i < callees.length; i++) {
String callee = callees[i];
if (callee.length() == 0) {
throw new SyntaxError(provider, "Malformed broadcast message");
}
if (!calleeSet.add(callee)) {
throw new SyntaxError(provider, "Duplicate receiver: " + callee);
}
if (callee.equals(data.getCaller())) {
throw new SyntaxError(provider, "The sender " + callee + " cannot be a " + "receiver of the broadcast message");
}
noteManager.closeNote(callee);
MessageData part = new MessageData();
// TODO mnemonics
part.setCaller(data.getCaller());
part.setCallee(callee);
part.setLevel(data.getLevel());
part.setThread(data.getThread());
if (getLifeline(data.getCaller()) != null) {
if (!getLifeline(data.getCaller()).isAlwaysActive()) {
part.setSpawnMessage(true);
}
}
part.setReturnsInstantly(data.returnsInstantly());
if (i == 0) {
part.setNoteNumber(data.getNoteNumber());
part.setMessage(data.getMessage());
part.setBroadcastType(BroadcastMessage.FIRST);
} else if (i == callees.length - 1) {
part.setBroadcastType(BroadcastMessage.LAST);
} else {
part.setBroadcastType(BroadcastMessage.OTHER);
}
BroadcastMessage msg = (BroadcastMessage) processor.processMessage(part);
if (i < callees.length - 1) {
allButLast[i] = msg.getCallee();
} else {
msg.setOtherCallees(allButLast);
}
processor.execute(msg);
}
} else {
noteManager.closeNote(data.getCallee());
ForwardMessage msg = processor.processMessage(data);
processor.execute(msg);
}
fragmentManager.clearLabels();
}
Aggregations