Search in sources :

Example 71 with Document

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);
    }
}
Also used : Document(javax.swing.text.Document) BadLocationException(javax.swing.text.BadLocationException)

Example 72 with Document

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);
}
Also used : Document(javax.swing.text.Document)

Aggregations

Document (javax.swing.text.Document)72 BadLocationException (javax.swing.text.BadLocationException)35 DocumentEvent (javax.swing.event.DocumentEvent)10 DefaultStyledDocument (javax.swing.text.DefaultStyledDocument)8 DocumentAdapter (com.intellij.ui.DocumentAdapter)7 HTMLDocument (javax.swing.text.html.HTMLDocument)7 ActionEvent (java.awt.event.ActionEvent)5 PlainDocument (javax.swing.text.PlainDocument)5 ActionListener (java.awt.event.ActionListener)4 File (java.io.File)4 IOException (java.io.IOException)3 FieldPanel (com.intellij.ui.FieldPanel)2 CheckBox (com.intellij.util.ui.CheckBox)2 Color (java.awt.Color)2 NumberFormat (java.text.NumberFormat)2 ParseException (java.text.ParseException)2 AbstractAction (javax.swing.AbstractAction)2 DocumentListener (javax.swing.event.DocumentListener)2 AbstractDocument (javax.swing.text.AbstractDocument)2 Element (javax.swing.text.Element)2