Package javax.swing.text

Examples of javax.swing.text.AbstractDocument$BidiRoot


        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 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 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

    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 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

     *
     * @param doc document
     * @return TokenSequence
     */
    public static TokenSequence<PHPTokenId> getTokenSequence(Document doc) {
        AbstractDocument abstractDoc = (AbstractDocument) doc;
        abstractDoc.readLock();
        TokenSequence<PHPTokenId> ts;
        try {
            TokenHierarchy<Document> hierarchy = TokenHierarchy.get(doc);
            ts = hierarchy.tokenSequence(PHPTokenId.language());
        } finally {
            abstractDoc.readUnlock();
        }
        return ts;
    }
View Full Code Here

    etaLbl.setText("ETA:");

    sceneNameLbl.setText("Scene name: ");
    sceneNameField.setColumns(15);
    AbstractDocument document = (AbstractDocument) sceneNameField.getDocument();
    document.setDocumentFilter(new SceneNameFilter());
    document.addDocumentListener(sceneNameListener);
    sceneNameField.addActionListener(sceneNameActionListener);
    updateSceneNameField();

    saveSceneBtn.setText("Save");
    saveSceneBtn.setIcon(Icon.disk.imageIcon());
View Full Code Here

    setModalityType(ModalityType.APPLICATION_MODAL);

    JLabel lbl = new JLabel("Enter name for the new 3D scene:");
    final JTextField sceneNameField = new JTextField(20);
    sceneNameField.setText(SceneManager.preferredSceneName(context, defaultSceneName));
    AbstractDocument document = (AbstractDocument) sceneNameField.getDocument();
    document.setDocumentFilter(new SceneNameFilter());
    sceneNameField.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        JTextField source = (JTextField) e.getSource();
        tryAccept(source.getText());
View Full Code Here

TOP

Related Classes of javax.swing.text.AbstractDocument$BidiRoot

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.