Package org.apache.pivot.wtk.text

Examples of org.apache.pivot.wtk.text.Document


            this.removed = removed;
        }

        @Override
        public void undo() {
            Document tmp = new Document();
            for (int i=0; i<removed.getLength(); i++) {
                tmp.add(removed.get(i));
            }
            node.insertRange(tmp, offset);
        }
View Full Code Here


     * because a Document may contain Components, and a Component may only be in one Container at a time.
     *
     * @param document
     */
    public void setDocument(Document document) {
        Document previousDocument = this.document;

        if (previousDocument != document) {
            if (previousDocument != null) {
                previousDocument.getNodeListeners().remove(documentListener);
                removeComponentNodes(previousDocument);
            }

            if (document != null) {
                document.getNodeListeners().add(documentListener);
View Full Code Here

            throw new IllegalStateException();
        }

        if (selectionLength > 0) {
            // Copy selection to clipboard
            Document selection = (Document)removeDocumentRange(selectionStart, selectionLength);

            String selectedText = null;
            try {
                PlainTextSerializer serializer = new PlainTextSerializer();
                StringWriter writer = new StringWriter();
View Full Code Here

                    // actions)
                    delete(true);
                }

                // Insert the clipboard contents
                Document documentLocal;
                int n;
                try {
                    PlainTextSerializer serializer = new PlainTextSerializer();
                    StringReader reader = new StringReader(text);
                    documentLocal = serializer.readObject(reader);
                    n = documentLocal.getCharacterCount();

                    bulkOperation = true;
                    int start = selectionStart;
                    this.document.insertRange(documentLocal, start);
                    bulkOperation = false;
View Full Code Here

     * Convenience method to get all the text from the current document
     * into a single string.
     * @see #setText
     */
    public String getText() {
        Document doc = getDocument();
        if (doc != null && getCharacterCount() != 0) {
            StringBuilder text = new StringBuilder(getCharacterCount());
            addToText(text, doc);
            return text.toString();
        }
View Full Code Here

    /**
     * Convenience method to create a text-only document consisting
     * of one paragraph per line of the given text.
     */
    public void setText(String text) {
        Document doc = new Document();
        String[] lines = text.split("\r?\n");
        for (int i = 0; i < lines.length; i++) {
            Paragraph paragraph = new Paragraph(lines[i]);
            doc.add(paragraph);
        }
        setDocument(doc);
    }
View Full Code Here

     */
    public String getSelectedText() {
        String selectedText = null;

        if (selectionLength > 0) {
            Document selection = (Document)document.getRange(selectionStart, selectionLength);

            try {
                PlainTextSerializer serializer = new PlainTextSerializer();
                StringWriter writer = new StringWriter();
                serializer.writeObject(selection, writer);
View Full Code Here

                    int offset = getNextInsertionPoint(mouseX, selectionEnd, scrollDirection);

                    if (offset != -1) {
                        // If the next character is a paragraph terminator and is not the
                        // final terminator character, increment the selection
                        Document document = textArea.getDocument();
                        if (document.getCharacterAt(offset) == '\n'
                            && offset < documentView.getCharacterCount() - 1) {
                            offset++;
                        }

                        textArea.setSelection(selectionStart, offset - selectionStart);
View Full Code Here

        textArea.getTextAreaListeners().add(this);
        textArea.getTextAreaSelectionListeners().add(this);

        textArea.setCursor(Cursor.TEXT);

        Document document = textArea.getDocument();
        if (document != null) {
            documentView = (DocumentView)createNodeView(document);
            documentView.attach();
            updateSelection();
        }
View Full Code Here

        boolean consumed = super.keyTyped(component, character);

        final TextArea textArea = (TextArea)getComponent();

        if (textArea.isEditable()) {
            Document document = textArea.getDocument();

            if (document != null) {
                // Ignore characters in the control range and the ASCII delete
                // character as well as meta key presses
                if (character > 0x1F
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.text.Document

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.