Package javax.swing.text

Examples of javax.swing.text.AbstractDocument


        assertEquals(new Dimension(1 * jta.getColumnWidth(), jta.getPreferredSize().height),
                jta.getPreferredScrollableViewportSize());
    }

    public void testGetLineStartEndOffset() {
        AbstractDocument doc = (AbstractDocument) jta.getDocument();
        int count = jta.getLineCount();
        doc.readLock();
        Element root = doc.getDefaultRootElement();
        for (int j = 0; j < count; j++) {
            Element currentElement = root.getElement(j);
            try {
                assertEquals(currentElement.getStartOffset(), jta.getLineStartOffset(j));
                int end = currentElement.getEndOffset();
                if (j == count - 1) {
                    end--;
                }
                assertEquals(end, jta.getLineEndOffset(j));
            } catch (BadLocationException e) {
            }
        }
        doc.readUnlock();
        try {
            jta.getLineStartOffset(count);
        } catch (BadLocationException e) {
            bWasException = true;
            message = e.getMessage();
View Full Code Here


        assertTrue(bWasException);
        assertEquals("Negative line", message);
    }

    public void testGetLineOfOffset() {
        AbstractDocument doc = (AbstractDocument) jta.getDocument();
        int length = doc.getLength();
        doc.readLock();
        Element root = doc.getDefaultRootElement();
        for (int j = 0; j < length; j++) {
            try {
                assertEquals(root.getElementIndex(j), jta.getLineOfOffset(j));
            } catch (BadLocationException e) {
            }
        }
        doc.readUnlock();
        try {
            jta.getLineOfOffset(length + 1);
        } catch (BadLocationException e) {
            bWasException = true;
            message = e.getMessage();
View Full Code Here

        assertTrue(bWasException);
        assertEquals("rows less than zero.", message);
    }

    public void testGetLineCount() {
        AbstractDocument doc_jta = (AbstractDocument) jta.getDocument();
        doc_jta.readLock();
        assertEquals(jta.getLineCount(), doc_jta.getDefaultRootElement().getElementCount());
        doc_jta.readUnlock();
        doc_jta = (AbstractDocument) bidiJta.getDocument();
        doc_jta.readLock();
        assertEquals(bidiJta.getLineCount(), doc_jta.getDefaultRootElement().getElementCount());
        doc_jta.readUnlock();
    }
View Full Code Here

    }

    public int[] findOrigin() throws InterruptedException, BadLocationException {
        int[] ret = null;

        AbstractDocument doc = (AbstractDocument) context.getDocument();
        doc.readLock();
        try {
            TokenHierarchy th = TokenHierarchy.get(doc);
            TokenSequence ts = th.tokenSequence();
            Token token = findTokenAtContext(ts, context.getSearchOffset());
            if (token == null) {
View Full Code Here

    }

    public int[] findMatches() throws InterruptedException, BadLocationException {
        int[] ret = null;

        AbstractDocument doc = (AbstractDocument) context.getDocument();
        doc.readLock();
        try {
            TokenHierarchy th = TokenHierarchy.get(doc);
            TokenSequence ts = th.tokenSequence();
            //System.out.println("--------------------");
            ret = findPaar(ts, context.getSearchOffset(), originToken, matchToken, searchForward);
View Full Code Here

    }

    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());
        assertEquals(sonRootView.getElement(), rootElement);
        assertEquals(rootView.getView(0).getElement(), rootElement);
        assertEquals(doc, rootView.getDocument());
        assertEquals(jta, rootView.getContainer());
        assertEquals(doc.getLength() + 1, rootView.getEndOffset());
        assertEquals(ui, rootView.getViewFactory());
        assertNull(rootView.getParent());
        /*
         * Next Functionality is not required try { rootView.setParent(new
         * PlainView(rootElement)); } catch (Error error) { bWasException =
View Full Code Here

    public void testInstallUninstall_Filters() {
        NavigationFilter navFilter = new NavigationFilter();
        formatter.setNavigationFilter(navFilter);
        DocumentFilter docFilter = new DocumentFilter();
        formatter.setDocumentFilter(docFilter);
        AbstractDocument doc = (AbstractDocument) tf.getDocument();
        assertNull(tf.getNavigationFilter());
        assertNull(doc.getDocumentFilter());
        formatter.install(tf);
        assertEquals(navFilter, tf.getNavigationFilter());
        assertEquals(docFilter, doc.getDocumentFilter());
        formatter.uninstall();
        assertNull(tf.getNavigationFilter());
        assertNull(doc.getDocumentFilter());
        formatter.install(tf);
        assertEquals(navFilter, tf.getNavigationFilter());
        assertEquals(docFilter, doc.getDocumentFilter());
        formatter.install(null);
        assertNull(tf.getNavigationFilter());
        assertNull(doc.getDocumentFilter());
    }
View Full Code Here

    }

    public void testInstallUninstall_Actions() {
        Action[] actions = new Action[] { new TextActionImpl("1"), new TextActionImpl("2") };
        formatter.setActions(actions);
        AbstractDocument doc = (AbstractDocument) tf.getDocument();
        ActionMap map1 = tf.getActionMap();
        ActionMap map2 = map1.getParent(); //keymap
        ActionMap map3 = map2.getParent(); //uiActionMap
        assertTrue(map3 instanceof UIResource);
        assertNull(tf.getNavigationFilter());
        assertNull(doc.getDocumentFilter());
        formatter.install(tf);
        ActionMap _map1 = tf.getActionMap();
        ActionMap _map2 = _map1.getParent(); //keymap
        ActionMap _map3 = _map2.getParent(); //formatter
        ActionMap _map4 = _map3.getParent();
View Full Code Here

    public void testReplaceSelectionWithAttributes() {
        if (true) {
            throw new UnsupportedOperationException("Not implemented");
        }
        AbstractDocument doc = new DefaultStyledDocument();
        SimpleAttributeSet as1 = new SimpleAttributeSet();
        as1.addAttribute("key1", "value1");
        SimpleAttributeSet as2 = new SimpleAttributeSet();
        as2.addAttribute("key2", "value2");
        try {
            doc.insertString(0, "testReplaceSelection", as1);
            doc.insertString(4, "INSERT", as2);
        } catch (final BadLocationException e) {
            assertFalse("unexpected exception :" + e.getMessage(), true);
        }
        //temporarily commented-out: HTMLEditorKit not implemented
        //jep.setEditorKit(new RTFEditorKit());
        jep.setEditorKit(new StyledEditorKit());
        jep.setDocument(doc);
        jep.setSelectionStart(6);
        jep.setSelectionEnd(7);
        jep.replaceSelection("YYY");
        for (int i = 0; i < doc.getLength(); i++) {
            AttributeSet as = getAttributeSetByIndex(doc, i);
            if (i > 3 && i < 12) {
                assertEquals(as2, as);
            } else {
                assertEquals(as1, as);
View Full Code Here

    }

    public void testUninstallUI() {
        // Regression for HARMONY-1475
        JTextComponent textComp = new JTextField();
        AbstractDocument doc = ((AbstractDocument) textComp.getDocument());
        assertTrue("listeners installed", doc.getDocumentListeners().length > 0);
        textComp.getUI().uninstallUI(textComp);
        assertEquals("no listeners installed", 0, doc.getDocumentListeners().length);
    }
View Full Code Here

TOP

Related Classes of javax.swing.text.AbstractDocument

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.