Search in sources :

Example 1 with WEditorError

use of us.mn.state.dot.tms.utils.wysiwyg.WEditorError in project iris by mnit-rtmc.

the class WMsgErrorPanel method updateErrorList.

/**
 * Update the error list from the error manager.
 */
public void updateErrorList() {
    // clear the list first
    errListModel.clear();
    // iterate over the errors in the manager and add them to the list
    Iterator<WEditorError> it = errMan.iterator();
    while (it.hasNext()) {
        WEditorError err = it.next();
        errListModel.addElement(err.getLongErrStr());
    }
}
Also used : WEditorError(us.mn.state.dot.tms.utils.wysiwyg.WEditorError)

Example 2 with WEditorError

use of us.mn.state.dot.tms.utils.wysiwyg.WEditorError in project iris by mnit-rtmc.

the class WMsgMultiPanel method highlightErrors.

/**
 * Highlight any error-producing tokens
 */
public void highlightErrors(WEditorErrorManager errMan) {
    if (errMan.hasErrors()) {
        Highlighter h = textBox.getHighlighter();
        HighlightPainter hp = new DefaultHighlighter.DefaultHighlightPainter(Color.RED);
        String txt = textBox.getText();
        Iterator<WEditorError> it = errMan.iterator();
        while (it.hasNext()) {
            WEditorError e = it.next();
            if (e.hasToken()) {
                String ts = e.getToken().toString();
                // if this error has a token, highlight it
                int a = txt.indexOf(ts);
                if (a < 0)
                    continue;
                int b = a + ts.length();
                String s = txt.substring(a, b);
                if (s == ts) {
                    try {
                        h.addHighlight(a, b, hp);
                    } catch (BadLocationException ex) {
                        // just ignore this
                        ex.printStackTrace();
                    }
                }
            }
        }
    }
}
Also used : HighlightPainter(javax.swing.text.Highlighter.HighlightPainter) BadLocationException(javax.swing.text.BadLocationException) DefaultHighlighter(javax.swing.text.DefaultHighlighter) Highlighter(javax.swing.text.Highlighter) WEditorError(us.mn.state.dot.tms.utils.wysiwyg.WEditorError)

Aggregations

WEditorError (us.mn.state.dot.tms.utils.wysiwyg.WEditorError)2 BadLocationException (javax.swing.text.BadLocationException)1 DefaultHighlighter (javax.swing.text.DefaultHighlighter)1 Highlighter (javax.swing.text.Highlighter)1 HighlightPainter (javax.swing.text.Highlighter.HighlightPainter)1