Package javax.swing.text

Examples of javax.swing.text.Element


    public void testGetRootView() {
        BasicTextUI ui = getBasicTextUI(jta);
        View rootView = ui.getRootView(jta);
        AbstractDocument doc = (AbstractDocument) jta.getDocument();
        Element rootElement = jta.getDocument().getDefaultRootElement();
        assertEquals(1, rootView.getViewCount());
        View sonRootView = rootView.getView(0);
        assertNotNull(sonRootView);
        assertEquals(0, sonRootView.getViewCount());
        assertEquals(rootElement, rootView.getElement());
View Full Code Here


         *
         */
    }

    public void testCreateElementintint() {
        Element elem = jta.getDocument().getDefaultRootElement();
        assertNull(basicTextUI.create(elem));
        assertNull(basicTextUI.create(elem, 0, 5));
    }
View Full Code Here

           
            parseBuffer.clear();
        }

        private void removeDefaultBody() {
            Element impliedLF = getCharacterElement(getLength() - 1);
            try {
                remove(getLength() - 1, 1);
            } catch (BadLocationException e) {
            }
            BranchElement root = (BranchElement)getDefaultRootElement();
            final int oddBodyIndex = root.getElementCount() - 1;
            Element oddBody = root.getElement(oddBodyIndex);
            final Element[] emptyArray = new Element[0];
            root.replace(oddBodyIndex, 1, emptyArray);
           
            Element lf = getCharacterElement(getLength());
            writeLock();
            try {
                ((MutableAttributeSet)lf).removeAttributes(lf.getAttributes().getAttributeNames());
                ((MutableAttributeSet)lf).addAttributes(impliedLF.getAttributes());
            } finally {
                writeUnlock();
            }
           
View Full Code Here

    public Element getElement(final Element e, final Object attribute,
                              final Object value) {
        final ElementIterator it = new ElementIterator(e);
        while (it.next() != null) {
            final Element current = it.current();
            if (current.getAttributes().containsAttribute(attribute, value)) {
                return current;
            }
        }
        return null;
    }
View Full Code Here

        if (TARGET_TOP.equals(target)){
            return;
        }

        final Element source = event.getSourceElement();
        final String src = event.getURL().toString();
        if (source != null && TARGET_SELF.equals(target)) {
            processTarget(source, src);
        } else if (source != null && TARGET_PARENT.equals(target)) {
            final Element parent = source.getParentElement();
            if (getParser() == null) {
                setParser(new ParserDelegator());
            }
            try {
                setOuterHTML(parent, "<frame src=\"" + src + "\">");
            } catch (BadLocationException e) {
            } catch (IOException e) {
            }
        } else {
            final ElementIterator frameIterator = new ElementIterator(getDefaultRootElement());
            if (frameIterator != null) {
                while (frameIterator.next() != null) {
                    final Element element = frameIterator.current();
                    if (Tag.FRAME.equals(element.getName())
                        && element.getAttributes().containsAttribute(HTML.Attribute.NAME, target)) {
                       
                        processTarget(element, src);
                    }
                }
            }
View Full Code Here

        fireRemoveUpdate(removeEvent);
    }

    private void insertHTMLText(final Element elem, final int offset,
                                final String htmlText) throws IOException {
        Element preceedBranch = getInsertionStartElement(offset - 1);
        int pop = -1;
        int push = -1;
        do {
            pop++;
            preceedBranch = preceedBranch.getParentElement();
            push = getAncestorDepth(preceedBranch, elem);
        } while (preceedBranch != null && push < 0);
        if (push == -1) {
            return;
        }
View Full Code Here

        }
        return -1;
    }
   
    private Element getInsertionStartElement(final int offset) {
        Element result = getDefaultRootElement();
        do {
            result = result.getElement(result.getElementIndex(offset));
        } while (!result.isLeaf());
       
        return result;
    }
View Full Code Here

        return result;
    }

    private int getAncestorDepth(final Element elem, final Element child) {
        int depth = 0;
        Element parent = child;
        while (parent != null) {
            if (elem == parent) {
                return depth;
            }
            depth++;
            parent = parent.getParentElement();
        }
        return -1;
    }
View Full Code Here

        assertNull(elem.getAttributes().getAttribute(StyleConstants
                  .ModelAttribute));
    }

    private Element createElement() {
        return new Element() {

            private MutableAttributeSet attrs = new SimpleAttributeSet();

            public AttributeSet getAttributes() {
                return attrs;
View Full Code Here

    {
      throw new IllegalStateException();
    }

    final FormulaElement replacementElement;
    final Element origElement = getElement(idx);
    if ((hasDummyParams) && (origElement instanceof FormulaTextElement))
    {
      // Replace the dummy parameter with the user specified parameter
      replacementElement = new FormulaTextElement((FormulaDocument)formulaTextElement.getDocument(),
                                                  (FormulaRootElement)origElement.getParentElement(),
                                                  formulaTextElement.getText());
    } else {
      replacementElement = formulaTextElement;
    }
View Full Code Here

TOP

Related Classes of javax.swing.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.