Examples of AbstractDocument


Examples of com.gistlabs.mechanize.document.AbstractDocument

    addPageRequest("http://test.com",
        newHtml("Test Page", newForm("form").method("post").id("form").enctype("multipart/form-data").addFileInput("fileUpload", "")));
    addPageRequest("POST", "http://test.com/form", newHtml("OK", ""));

    AbstractDocument page = agent().get("http://test.com");
    Form form = page.forms().find("#form");
    form.findUpload(byIdOrName("fileUpload")).setValue(tmpFile);
    AbstractDocument response = form.submit();
    assertEquals("OK", response.getTitle());
  }
View Full Code Here

Examples of it.unimi.dsi.mg4j.document.AbstractDocument

  public int size() {
    return size;
  }

  public Document document( final int index ) throws IOException {
    return new AbstractDocument() {

      public CharSequence title() {
        return "Document " + index;
      }
View Full Code Here

Examples of it.unimi.dsi.mg4j.document.AbstractDocument

  public FieldType fieldType( final int field ) {
    return FieldType.TEXT;
  }
 
  public Document getDocument( final InputStream rawContent, final Reference2ObjectMap<Enum<?>,Object> metadata ) {
    return new AbstractDocument() {
     
      public CharSequence title() {
        return "dummy title";
      }
     
View Full Code Here

Examples of it.unimi.dsi.mg4j.document.AbstractDocument

  public FieldType fieldType( final int field ) {
    return FieldType.TEXT;
  }
 
  public Document getDocument( final InputStream rawContent, final Reference2ObjectMap<Enum<?>,Object> metadata ) {
    return new AbstractDocument() {
     
      public CharSequence title() {
        return "dummy title";
      }
     
View Full Code Here

Examples of javax.swing.text.AbstractDocument

                    final String sender = getOwnIdentitiesComboBox().getEditor().getItem().toString();
                    updateHeaderArea(sender);
                }
            });

            final AbstractDocument doc = (AbstractDocument) editor.getDocument();
            doc.setDocumentFilter(new DocumentFilter() {
                @Override
                public void insertString(final DocumentFilter.FilterBypass fb, final int offset, String string,
                        final AttributeSet attr) throws BadLocationException
                {
                    if (((TextComboBoxEditor)getOwnIdentitiesComboBox().getEditor()).isSigned() == false ) {
View Full Code Here

Examples of javax.swing.text.AbstractDocument

        eventCounter = null;
    }

    public void guiTestConstructors() {
        JTextField textComponent = new JTextField();
        AbstractDocument document = (AbstractDocument) textComponent.getDocument();
        int initialDocumentListenerCount = document.getDocumentListeners().length;
        TextFilterator<String> textFilterator = GlazedLists.toStringTextFilterator();
        TextComponentMatcherEditor<String> tcme;

        tcme = new TextComponentMatcherEditor<String>(textComponent, textFilterator);
        assertEquals(0, textComponent.getActionListeners().length);
        assertEquals(initialDocumentListenerCount+1, document.getDocumentListeners().length);
        assertSame(textFilterator, tcme.getFilterator());
        assertTrue(tcme.isLive());

        tcme.dispose();
        tcme = new TextComponentMatcherEditor<String>(textComponent, textFilterator, true);
        assertEquals(0, textComponent.getActionListeners().length);
        assertEquals(initialDocumentListenerCount+1, document.getDocumentListeners().length);
        assertSame(textFilterator, tcme.getFilterator());
        assertTrue(tcme.isLive());

        tcme.dispose();
        tcme = new TextComponentMatcherEditor<String>(textComponent, textFilterator, false);
        assertEquals(1, textComponent.getActionListeners().length);
        assertEquals(initialDocumentListenerCount, document.getDocumentListeners().length);
        assertSame(textFilterator, tcme.getFilterator());
        assertFalse(tcme.isLive());

        tcme.dispose();
        tcme = new TextComponentMatcherEditor<String>(document, textFilterator);
        assertEquals(0, textComponent.getActionListeners().length);
        assertEquals(initialDocumentListenerCount+1, document.getDocumentListeners().length);
        assertSame(textFilterator, tcme.getFilterator());
        assertTrue(tcme.isLive());

        tcme.dispose();
        assertEquals(0, textComponent.getActionListeners().length);
        assertEquals(initialDocumentListenerCount, document.getDocumentListeners().length);
    }
View Full Code Here

Examples of javax.swing.text.AbstractDocument

        }
    }

    public void guiTestDocumentSwap() throws Exception {
        final JTextField textField = new JTextField();
        final AbstractDocument documentA = (AbstractDocument) textField.getDocument();
        documentA.insertString(0, "documentA", null);
        final AbstractDocument documentB = new PlainDocument();
        documentB.insertString(0, "documentB", null);

        final int originalDocumentAListenerCount = documentA.getDocumentListeners().length;
        final int originalDocumentBListenerCount = documentB.getDocumentListeners().length;

        // using the textField in a TextComponentMatcherEditor will install a DocumentListener
        TextComponentMatcherEditor<String> textMatcherEditor = new TextComponentMatcherEditor<String>(textField, GlazedLists.toStringTextFilterator(), true);
        assertEquals(originalDocumentAListenerCount+1, documentA.getDocumentListeners().length);
        assertEquals(originalDocumentBListenerCount, documentB.getDocumentListeners().length);
        TextMatcher textMatcher = (TextMatcher) textMatcherEditor.getMatcher();
        assertEquals("documentA", textMatcher.getSearchTerms()[0].getText());

        // replace DocumentA with DocumentB, which should update the filter with the text from DocumentB
        textField.setDocument(documentB);
        assertEquals(0, documentA.getDocumentListeners().length);
        assertEquals(originalDocumentBListenerCount+3, documentB.getDocumentListeners().length);
        textMatcher = (TextMatcher) textMatcherEditor.getMatcher();
        assertEquals("documentB", textMatcher.getSearchTerms()[0].getText());

        // changing the text in DocumentB should alter the filter
        documentB.replace(0, documentB.getLength(), "blah", null);
        textMatcher = (TextMatcher) textMatcherEditor.getMatcher();
        assertEquals("blah", textMatcher.getSearchTerms()[0].getText());
    }
View Full Code Here

Examples of javax.swing.text.AbstractDocument

        assertEquals("blah", textMatcher.getSearchTerms()[0].getText());
    }

    public void guiTestListeners() {
        final JTextField textField = new JTextField();
        final AbstractDocument document = (AbstractDocument) textField.getDocument();

        final int originalPropertyChangeListenerCount = textField.getPropertyChangeListeners().length;
        final int originalActionListenerCount = textField.getActionListeners().length;
        final int originalDocumentListenerCount = document.getDocumentListeners().length;

        // live
        TextComponentMatcherEditor<String> textMatcherEditor = new TextComponentMatcherEditor<String>(textField, GlazedLists.toStringTextFilterator(), true);
        assertEquals(originalPropertyChangeListenerCount+1, textField.getPropertyChangeListeners().length);
        assertEquals(originalActionListenerCount, textField.getActionListeners().length);
        assertEquals(originalDocumentListenerCount+1, document.getDocumentListeners().length);

        textMatcherEditor.dispose();
        assertEquals(originalPropertyChangeListenerCount, textField.getPropertyChangeListeners().length);
        assertEquals(originalActionListenerCount, textField.getActionListeners().length);
        assertEquals(originalDocumentListenerCount, document.getDocumentListeners().length);

        // not live
        textMatcherEditor = new TextComponentMatcherEditor<String>(textField, GlazedLists.toStringTextFilterator(), false);
        assertEquals(originalPropertyChangeListenerCount+1, textField.getPropertyChangeListeners().length);
        assertEquals(originalActionListenerCount+1, textField.getActionListeners().length);
        assertEquals(originalDocumentListenerCount, document.getDocumentListeners().length);

        textMatcherEditor.dispose();
        assertEquals(originalPropertyChangeListenerCount, textField.getPropertyChangeListeners().length);
        assertEquals(originalActionListenerCount, textField.getActionListeners().length);
        assertEquals(originalDocumentListenerCount, document.getDocumentListeners().length);
    }
View Full Code Here

Examples of javax.swing.text.AbstractDocument

    }

    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

Examples of javax.swing.text.AbstractDocument

    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
TOP
Copyright © 2018 www.massapi.com. 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.