use of javax.swing.text.Document in project cayenne by apache.
the class JCayenneTextPane method setDocumentTextDirect.
public void setDocumentTextDirect(String text) {
Document document = getDocument();
try {
if (!document.getText(0, document.getLength()).equals(text)) {
document.remove(0, document.getLength());
document.insertString(0, text, null);
}
} catch (BadLocationException ex) {
logObj.warn("Error reading document", ex);
}
}
use of javax.swing.text.Document in project suite by stupidsing.
the class EditorPane method replaceLines.
private void replaceLines(Fun<Segment, String> fun) throws BadLocationException {
Document document = getDocument();
int length = document.getLength();
int ss = getSelectionStart();
int se = max(ss, getSelectionEnd() - 1);
while (0 < ss && document.getText(ss, 1).charAt(0) != 10) ss--;
while (se < length && document.getText(se, 1).charAt(0) != 10) se++;
// do not include first and last LFs
int start = document.getText(ss, 1).charAt(0) == 10 ? ss + 1 : ss;
int end = se;
replace(document, start, end, fun);
}
Aggregations