Search in sources :

Example 1 with DiagramError

use of net.sf.sdedit.error.DiagramError 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();
    }
}
Also used : FatalError(net.sf.sdedit.error.FatalError) SemanticError(net.sf.sdedit.error.SemanticError) TextHandler(net.sf.sdedit.text.TextHandler) DiagramError(net.sf.sdedit.error.DiagramError) Diagram(net.sf.sdedit.diagram.Diagram)

Example 2 with DiagramError

use of net.sf.sdedit.error.DiagramError in project abstools by abstools.

the class Tab method renderDiagram.

void renderDiagram() {
    PanelPaintDevice paintDevice = new PanelPaintDevice(true);
    for (PanelPaintDeviceListener listener : ppdListeners) {
        paintDevice.addListener(listener);
    }
    TextHandler textHandler = new TextHandler(getCode());
    Diagram diagram = new Diagram(configuration.getDataObject(), textHandler, paintDevice);
    DiagramError newError = null;
    try {
        diagram.generate();
    } catch (RuntimeException e) {
        newError = new FatalError(textHandler, e);
    } catch (DiagramError e) {
        newError = e;
    }
    synchronized (diagramStack) {
        diagramStack.addLast(diagram);
        synchronized (this) {
            error = newError;
        }
    }
}
Also used : FatalError(net.sf.sdedit.error.FatalError) PanelPaintDeviceListener(net.sf.sdedit.ui.PanelPaintDeviceListener) PanelPaintDevice(net.sf.sdedit.ui.PanelPaintDevice) TextHandler(net.sf.sdedit.text.TextHandler) DiagramError(net.sf.sdedit.error.DiagramError) Diagram(net.sf.sdedit.diagram.Diagram)

Aggregations

Diagram (net.sf.sdedit.diagram.Diagram)2 DiagramError (net.sf.sdedit.error.DiagramError)2 FatalError (net.sf.sdedit.error.FatalError)2 TextHandler (net.sf.sdedit.text.TextHandler)2 SemanticError (net.sf.sdedit.error.SemanticError)1 PanelPaintDevice (net.sf.sdedit.ui.PanelPaintDevice)1 PanelPaintDeviceListener (net.sf.sdedit.ui.PanelPaintDeviceListener)1