Examples of PlainDocument


Examples of javax.swing.text.PlainDocument

  }

  private void test03(TestHarness h)
  {
    h.checkPoint("test03");
    PlainDocument doc = new PlainDocument();
    doc.addDocumentListener(new TestListener());

    try
      {
        doc.insertString(0, "abcd", null);
        doc.insertString(0, "abcde\nabcdef\nabcde\n", null);
      }
    catch (BadLocationException ex)
      {
        h.fail("Unexpected BadLocationException");
      }

    DocumentEvent.ElementChange change = ev.getChange(doc.getDefaultRootElement());

    h.check(change.getIndex(), 0);

    Element[] added = change.getChildrenAdded();
    h.check(added.length, 4);
View Full Code Here

Examples of javax.swing.text.PlainDocument

public class getViewIndexAtPosition implements Testlet
{

  public void test(TestHarness h)
  {
    PlainDocument doc = new PlainDocument();
    try
      {
        doc.insertString(0, "0123456789", null);
      }
    catch (BadLocationException ex)
      {
        RuntimeException rte = new RuntimeException();
        rte.initCause(ex);
        throw rte;
      }
    Element el = doc.getDefaultRootElement();
    TestZoneView zv = new TestZoneView(el, View.X_AXIS);
    zv.append(zv.createZone(0, 3));
    zv.append(zv.createZone(3, 7));
    zv.append(zv.createZone(7, 10));
View Full Code Here

Examples of javax.swing.text.PlainDocument

  }
 
  public void testArguments(TestHarness harness)
  {
    harness.checkPoint("testArguments");
    PlainDocument d = new PlainDocument();
    try
    {
      d.insertString(0, "ABC", null);
    }
    catch (BadLocationException e)
    {
    }
   
    // negative index
    boolean pass = false;
    try
    {
      d.remove(-1, 1);
    }
    catch (BadLocationException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // index too high
    pass = false;
    try
    {
      d.remove(4, 0);
    }
    catch (BadLocationException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    // index + length to high
    pass = false;
    try
    {
      d.remove(2, 99);
    }
    catch (BadLocationException e)
    {
      pass = true;
    }
    harness.check(pass);

    // negative length
    pass = false;
    try
    {
      d.remove(2, -1);
    }
    catch (BadLocationException e)
    {
      pass = true;
    }
View Full Code Here

Examples of javax.swing.text.PlainDocument

    testOversize(harness);
  }

  private void testSimple(TestHarness h)
  {
    PlainDocument doc = new PlainDocument();
    try
      {
        doc.insertString(0, "0123456789", null);
      }
    catch (BadLocationException ex)
      {
        RuntimeException rte = new RuntimeException();
        rte.initCause(ex);
        throw rte;
      }
    Element el = doc.getDefaultRootElement();
    TestZoneView zv = new TestZoneView(el, View.Y_AXIS);
    zv.loadChildren(zv.getViewFactory());
    h.check(zv.getViewCount(), 1);
    View child = zv.getView(0);
    h.check(child.getStartOffset(), 0);
View Full Code Here

Examples of javax.swing.text.PlainDocument

    h.check(child.getEndOffset(), el.getEndOffset());
  }

  private void testOversize(TestHarness h)
  {
    PlainDocument doc = new PlainDocument();
    try
      {
        doc.insertString(0, "0123456789", null);
      }
    catch (BadLocationException ex)
      {
        RuntimeException rte = new RuntimeException();
        rte.initCause(ex);
        throw rte;
      }
   
    BranchElement el = (BranchElement) doc.getDefaultRootElement();
    // Modify the element structure a little and seen how the initial
    // elements are created then.
    LeafElement el1 = doc.new LeafElement(el, null, 0, 3);
    LeafElement el2 = doc.new LeafElement(el, null, 3, 7);
    LeafElement el3 = doc.new LeafElement(el, null, 7, 11);
View Full Code Here

Examples of javax.swing.text.PlainDocument

  }

  public void testPositions(TestHarness harness)
  {
    harness.checkPoint("testPositions");
    PlainDocument d = new PlainDocument();
    try
    {
      d.insertString(0, "ABCDEF", null);
      Position p0 = d.createPosition(0);
      harness.check(p0.getOffset(), 0);
      Position p1 = d.createPosition(1);
      harness.check(p1.getOffset(), 1);
      Position p2 = d.createPosition(2);
      harness.check(p2.getOffset(), 2);
      Position p3 = d.createPosition(3);
      harness.check(p3.getOffset(), 3);
      Position p4 = d.createPosition(4);
      harness.check(p4.getOffset(), 4);
      Position p5 = d.createPosition(5);
      harness.check(p5.getOffset(), 5);
      Position p6 = d.createPosition(6);
      harness.check(p6.getOffset(), 6);
     
      d.remove(2, 2);
      harness.check(p0.getOffset(), 0);
      harness.check(p1.getOffset(), 1);
      harness.check(p2.getOffset(), 2);
      harness.check(p3.getOffset(), 2);     
      harness.check(p4.getOffset(), 2);     
      harness.check(p5.getOffset(), 3);     
      harness.check(p6.getOffset(), 4);
     
      d.remove(0, 1);
      harness.check(p0.getOffset(), 0);
      harness.check(p1.getOffset(), 0);
      harness.check(p2.getOffset(), 1);
      harness.check(p3.getOffset(), 1);     
      harness.check(p4.getOffset(), 1);     
View Full Code Here

Examples of javax.swing.text.PlainDocument

 
  private void testBehavior(TestHarness harness)
  {
    harness.checkPoint("testArguments");

    PlainDocument pd = new PlainDocument();
    int index0 = -1;
    int index1 = -1;

    try
      {
        pd.insertString(0, "abc\ndef\n", null);

        // Delete the 'c'.
        pd.remove(2, 1);

        Element re = pd.getDefaultRootElement();
       
        // There should still be two separate lines
        // (no Element merge should have taken place).
        index0 = re.getElementIndex(2);
        index1 = re.getElementIndex(3);
View Full Code Here

Examples of javax.swing.text.PlainDocument

public class createZone implements Testlet
{

  public void test(TestHarness h)
  {
    PlainDocument doc = new PlainDocument();
    try
      {
        doc.insertString(0, "123456789", null);
      }
    catch (BadLocationException ex)
      {
        RuntimeException rte = new RuntimeException();
        rte.initCause(ex);
        throw rte;
      }
    Element el = doc.getDefaultRootElement();
    TestZoneView zv = new TestZoneView(el, View.X_AXIS);

    // Try valid zone.
    View zone = zv.createZone(0, 9);
    h.check(zone instanceof AsyncBoxView);
    h.check(zone.getStartOffset(), 0);
    h.check(zone.getEndOffset(), 9);
    // Check if the zone follows document insertions (via Positions).
    try
      {
        doc.insertString(5, "abcde", null);
      }
    catch (BadLocationException ex)
      {
        RuntimeException rte = new RuntimeException();
        rte.initCause(ex);
View Full Code Here

Examples of javax.swing.text.PlainDocument

   *
   * @param h the test harness
   */
  private void testSimple(TestHarness h)
  {
    PlainDocument doc = new PlainDocument();
    Element el = doc.getDefaultRootElement();
    ZoneView zv = new ZoneView(el, View.X_AXIS);
    h.check(zv.getAxis(), View.X_AXIS);
    h.check(zv.getElement(), el);
    zv = new ZoneView(el, View.Y_AXIS);
    h.check(zv.getAxis(), View.Y_AXIS);
View Full Code Here

Examples of javax.swing.text.PlainDocument

    h.check(zv.getElement(), el);
  }

  private void testDefaultValues(TestHarness h)
  {
    PlainDocument doc = new PlainDocument();
    Element el = doc.getDefaultRootElement();
    ZoneView zv = new ZoneView(el, View.X_AXIS);
    h.check(zv.getMaximumZoneSize(), 8192);
    h.check(zv.getMaxZonesLoaded(), 3);
  }
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.