use of javax.swing.text.Highlighter in project cayenne by apache.
the class JCayenneTextPane method setHighlightText.
/**
* set underlines text in JCayenneTextPane
*
* @param line int - starting line for underlined text
* @param lastIndex int - starting position in line for underlined text
* @param size int
* @param message String - text for toolTip, contains the text of the error
*/
public void setHighlightText(int line, int lastIndex, int size, String message) {
Highlighter highlighter = pane.getHighlighter();
removeHighlightText(highlighter);
if (getText().length() > 0) {
try {
int position = getPosition(line, lastIndex);
int positionEnd = position + size;
highlighter.addHighlight(position, positionEnd, painter);
setToolTipPosition(line, message);
repaintPane();
} catch (BadLocationException e) {
logObj.warn("Error: ", e);
}
} else {
setToolTipPosition(0, "");
}
}
use of javax.swing.text.Highlighter in project zaproxy by zaproxy.
the class HttpPanelSyntaxHighlightTextArea method highlightEntryParser.
// Parse the TextArea data and search the HighlightEntry strings
// Highlight all found strings
private void highlightEntryParser(HighlightSearchEntry entry) {
String text;
int lastPos = 0;
text = this.getText();
Highlighter hilite = this.getHighlighter();
HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(entry.getColor());
while ((lastPos = text.indexOf(entry.getToken(), lastPos)) > -1) {
try {
hilite.addHighlight(lastPos, lastPos + entry.getToken().length(), painter);
lastPos += entry.getToken().length();
} catch (BadLocationException e) {
log.warn("Could not highlight entry", e);
}
}
}
use of javax.swing.text.Highlighter in project zaproxy by zaproxy.
the class HttpPanelTextArea method highlight.
protected void highlight(int start, int end) {
Highlighter hilite = this.getHighlighter();
HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(DisplayUtils.getHighlightColor());
try {
removeAllHighlights();
hilite.addHighlight(start, end, painter);
this.setCaretPosition(start);
} catch (BadLocationException e) {
log.error(e.getMessage(), e);
}
}
use of javax.swing.text.Highlighter in project zaproxy by zaproxy.
the class HttpPanelTextArea method removeAllHighlights.
private void removeAllHighlights() {
Highlighter hilite = this.getHighlighter();
hilite.removeAllHighlights();
}
use of javax.swing.text.Highlighter in project zaproxy by zaproxy.
the class HttpPanelTextArea method highlightEntryParser.
// Parse the TextArea data and search the HighlightEntry strings
// Highlight all found strings
private void highlightEntryParser(HighlightSearchEntry entry) {
String text;
int lastPos = 0;
text = this.getText();
Highlighter hilite = this.getHighlighter();
HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(entry.getColor());
while ((lastPos = text.indexOf(entry.getToken(), lastPos)) > -1) {
try {
hilite.addHighlight(lastPos, lastPos + entry.getToken().length(), painter);
lastPos += entry.getToken().length();
} catch (BadLocationException e) {
log.warn("Could not highlight entry", e);
}
}
}
Aggregations