use of net.sf.sdedit.error.SemanticError in project abstools by abstools.
the class Engine method _render.
private synchronized void _render(final boolean syntaxCheckOnly) {
editor.getUI().leaveFilterMode();
Diagram diagram = editor.getUI().renderDiagram();
// method is not synchronized. Why?
if (diagram == null) {
return;
}
DiagramError error = editor.getUI().getDiagramError();
if (error == null) {
editor.getUI().setErrorStatus(false, "", -1, -1);
if (diagram.getFragmentManager().openFragmentsExist()) {
editor.getUI().setErrorStatus(true, "Warning: There are open comments. Use [c:<type> <text>]...[/c]", -1, -1);
}
int noteNumber = diagram.getNextFreeNoteNumber();
if (noteNumber == 0) {
editor.getUI().setStatus("");
} else {
editor.getUI().setStatus("Next note number: " + diagram.getNextFreeNoteNumber());
}
} else {
editor.getUI().setStatus("");
if (error instanceof FatalError) {
FatalError fatal = (FatalError) error;
System.err.println("********************************************************");
System.err.println("* *");
System.err.println("* A FATAL ERROR HAS OCCURED. *");
System.err.println("* *");
System.err.println("********************************************************");
error.getCause().printStackTrace();
// cautiously embedding this call into a try/catch-block
try {
handle(diagram, fatal.getCause());
} catch (Throwable t) {
t.printStackTrace();
}
} else {
TextHandler handler = (TextHandler) error.getProvider();
String prefix = "";
if (error instanceof SemanticError) {
prefix = diagram.isThreaded() && diagram.getCallerThread() != -1 ? "Thread " + diagram.getCallerThread() + ": " : "";
}
editor.getUI().setErrorStatus(false, prefix + error.getMessage(), handler.getLineBegin() - 1, handler.getLineEnd());
}
}
if (!syntaxCheckOnly) {
editor.getUI().redraw();
}
}
use of net.sf.sdedit.error.SemanticError in project abstools by abstools.
the class PrintDialog method reinitialize.
private void reinitialize() {
String source = ui.getCode();
Configuration configuration = ui.getConfiguration().getDataObject();
exporter = new MultipageExporter(printerProperties.getDataObject(), source, configuration);
try {
exporter.init();
} catch (RuntimeException re) {
throw re;
} catch (SemanticError se) {
/* ignored */
} catch (SyntaxError se) {
/* ignored */
}
int scale = (int) (100 * exporter.getScale());
scaleLabel.setText("Zoom factor: " + scale + " %");
preview.setViewportView(exporter);
}
use of net.sf.sdedit.error.SemanticError in project abstools by abstools.
the class MessageProcessor method findCaller.
/**
* Returns the Lifeline representation of the caller as specified by the
* given MessageData and sets the current thread to the thread that was used
* in order to activate the Lifeline.
*
* @param data
* @return the Lifeline representation of the caller
* @throws SemanticError
* @precondition caller is not an actor
*/
private Lifeline findCaller() throws SemanticError {
final String callerName = data.getCaller();
if (callerIsActor()) {
/*
* When multithreading is disabled and an actor sends a message,
* finish all ongoing activities.
*/
if (!diagram.isThreaded()) {
diagram.finish();
}
return rootCaller;
}
final String mnemonic = data.getCallerMnemonic();
/*
* If lineToBeFound is not null, we just look for it, ignoring level and
* thread specification of the MessageData.
*/
Lifeline lineToBeFound = null;
if (!mnemonic.equals("")) {
lineToBeFound = diagram.getLifelineByMnemonic(data.getCaller(), mnemonic);
if (lineToBeFound == null) {
throw new SemanticError(provider, "There is no lifeline named \"" + data.getCaller() + "\" associated to mnemonic \"" + mnemonic + "\"");
}
}
final LinkedList<Message> currentStack = diagram.currentStack();
if (currentStack == null) {
throw new SemanticError(provider, "Thread " + callerThread + " has died");
}
if (callerThread == 0 && currentStack.isEmpty() && diagram.firstCaller() == null) {
/*
* The message described by MessageData is the first that occurs on
* the thread 0, no object is yet active. So set the caller active
* and declare it the first caller.
*/
diagram.setFirstCaller(rootCaller);
rootCaller.setActive(true);
return rootCaller;
}
/*
* This number counts how often we have seen a lifeline with the same
* name, but with a wrong level (or not equal to lineToBeFound), as
* senders of answers on the stack.
*/
int occured = 0;
while (!currentStack.isEmpty()) {
final Message theAnswer = currentStack.getLast();
if (lineToBeFound != null) {
if (theAnswer.getCaller() == lineToBeFound) {
return lineToBeFound;
}
} else if (theAnswer.getCaller().getName().equals(data.getCaller())) {
// followers)
if (occured == data.getLevel()) {
return theAnswer.getCaller();
}
occured++;
}
/*
* All answers that have non matching lifelines as senders are
* popped from the stack and the answer is added to the diagram,
* thus, an arrow representation will appear.
*/
currentStack.removeLast();
diagram.sendAnswer(theAnswer);
}
if (diagram.firstCaller() != null && diagram.firstCaller().getName().equals(callerName)) {
/*
* We have not yet seen the lifeline we are looking for, the last
* chance is that it is the first caller on the thread.
*/
if (occured == data.getLevel()) {
return diagram.firstCaller();
}
/*
* This chance was also missed, we add 1 to occured in order to
* count the occurence as first caller.
*/
occured++;
}
throw objectNotFound(occured, lineToBeFound);
}
Aggregations