Package pivot.wtk.text

Examples of pivot.wtk.text.Element


        }

        @Override
        protected void attach() {
            Element element = (Element)getNode();
            element.getElementListeners().add(this);

            // NOTE We don't attach child views here because this may not
            // be efficient for all subclasses (e.g. paragraph views need to
            // recreate child views when breaking across multiple lines)
        }
View Full Code Here


            // recreate child views when breaking across multiple lines)
        }

        @Override
        protected void detach() {
            Element element = (Element)getNode();
            element.getElementListeners().remove(this);

            // Detach child node views
            remove(0, getLength());
        }
View Full Code Here

    @Override
    protected void setParent(ElementAdapter parent) {
        super.setParent(parent);

        Element element = (Element)getNode();

        if (parent == null) {
            // Remove all adapters
            Sequence<NodeAdapter> removed = nodeAdapters.remove(0, nodeAdapters.getLength());

            for (int i = 0, n = removed.getLength(); i < n; i++) {
                NodeAdapter nodeAdapter = removed.get(i);
                nodeAdapter.setParent(null);
            }

            element.getElementListeners().remove(elementListener);
        } else {
            // Build adapter list
            for (Node node : element) {
                NodeAdapter nodeAdapter = createNodeAdapter(node);
                nodeAdapters.add(nodeAdapter);
                nodeAdapter.setParent(this);
            }

            element.getElementListeners().add(elementListener);
        }
    }
View Full Code Here

                paragraph.add(new TextNode(text));
            }
        } else {
            // The caret is positioned on a non-text character node; insert
            // the text into the descendant's parent
            Element parent = descendant.getParent();
            int index = parent.indexOf(descendant);
            parent.insert(new TextNode(text), index);
        }

        // Set the selection start to the character following the insertion
        setSelection(selectionStart + text.length(), selectionLength);
    }
View Full Code Here

        int offset = selectionStart - leadingSegment.getDocumentOffset();
        int characterCount = leadingSegment.getCharacterCount() - offset;

        Paragraph trailingSegment = (Paragraph)leadingSegment.removeRange(offset, characterCount);

        Element parent = leadingSegment.getParent();
        int index = parent.indexOf(leadingSegment);
        parent.insert(trailingSegment, index + 1);

        // Set the selection start to the character following the insertion
        setSelection(selectionStart + 1, selectionLength);
    }
View Full Code Here

                if (descendant instanceof Paragraph) {
                    // We are deleting a paragraph terminator
                    Paragraph paragraph = (Paragraph)descendant;

                    Element parent = paragraph.getParent();
                    int index = parent.indexOf(paragraph);

                    // Attempt to merge any successive content into the paragraph
                    if (index < parent.getLength() - 1) {
                        // TODO This won't always be a paragraph - we'll need to
                        // find the next paragraph by walking the tree, then
                        // remove any empty nodes
                        Sequence<Node> removed = parent.remove(index + 1, 1);
                        Paragraph nextParagraph = (Paragraph)removed.get(0);
                        paragraph.insertRange(nextParagraph, paragraph.getCharacterCount() - 1);

                        // Move the caret to the merge point
                        setSelection(offset, 0);
View Full Code Here

        }

        @Override
        protected void attach() {
            Element element = (Element)getNode();
            element.getElementListeners().add(this);

            // NOTE We don't attach child views here because this may not
            // be efficient for all subclasses (e.g. paragraph views need to
            // recreate child views when breaking across multiple lines)
        }
View Full Code Here

            // recreate child views when breaking across multiple lines)
        }

        @Override
        protected void detach() {
            Element element = (Element)getNode();
            element.getElementListeners().remove(this);

            // Detach child node views
            remove(0, getLength());
        }
View Full Code Here

TOP

Related Classes of pivot.wtk.text.Element

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.