Package org.waveprotocol.wave.client.editor.content.misc

Examples of org.waveprotocol.wave.client.editor.content.misc.CaretAnnotations


    doc = mutable;
  }

  // Converts the annotations passed into a CaretAnnotations bundle and stores in caret
  private void useCaretAnnotations(String... annotations) {
    CaretAnnotations localCaret = new CaretAnnotations();
    for (String value : annotations) {
      String[] dup = value.split(":");
      localCaret.setAnnotation(dup[0], dup[1]);
    }
    caret = localCaret;
    caret.setAnnotationResolver(annotationResolver);
  }
View Full Code Here


  private final String RESOLVER_VALUE = "RESOLVER_KEY_!_!@)_#";

  /** Make sure the simple set/get work as required. */
  public void testBasic() {
    // initialise:
    CaretAnnotations annotations = new CaretAnnotations();

    // simple set-get
    annotations.setAnnotation(TEST_KEY, TEST_VALUE);
    assertTrue("Must have a set annotation.",
        annotations.hasAnnotation(TEST_KEY));
    assertTrue("Must be annotated with the key/value pair set.",
        annotations.isAnnotated(TEST_KEY, TEST_VALUE));
    assertEquals("Get annotation must match the set value.",
        annotations.getAnnotation(TEST_KEY), TEST_VALUE);
    assertTrue("Must have the set annotation in key set.",
        annotations.getAnnotationKeys().contains(TEST_KEY));

    // reset the key to null (not the same as remove)
    annotations.setAnnotation(TEST_KEY, null);
    assertTrue("Must have a set annotation.",
        annotations.hasAnnotation(TEST_KEY));
    assertFalse("Must no longer be annotated with the key/value pair set.",
        annotations.isAnnotated(TEST_KEY, TEST_VALUE));
    assertNull("Get annotation must match the set value.",
        annotations.getAnnotation(TEST_KEY));
    assertTrue("Must have the set annotation in key set.",
        annotations.getAnnotationKeys().contains(TEST_KEY));

    // remove the key
    annotations.removeAnnotation(TEST_KEY);
    assertFalse("Must not have a removed annotation.",
        annotations.hasAnnotation(TEST_KEY));
    assertNull("Get annotation for removed key should be null.",
        annotations.getAnnotation(TEST_KEY));
    assertFalse("Must not have removed annotation in key set.",
        annotations.getAnnotationKeys().contains(TEST_KEY));

    // test clearing, then setting multiple:
    annotations.setAnnotation(TEST_KEY, TEST_VALUE);
    assertEquals("Must have the right size key set.",
        annotations.getAnnotationKeys().size(), 1);
    annotations.clear();
    assertEquals("Must have empty key set after clear.",
        annotations.getAnnotationKeys().size(), 0);

    // test setting many:
    for (int i = 0; i < 10; i++) {
      annotations.setAnnotation("" + i, "" + i);
    }
    assertEquals("Must have the right number of annotations.",
        annotations.getAnnotationKeys().size(), 10);
    assertEquals("Must keep annotations when setting multiple.",
        annotations.getAnnotation("4"), "4"); // check random one in the middle.

  }
View Full Code Here

    doc = mutable;
  }

  // Converts the annotations passed into a CaretAnnotations bundle and stores in caret
  private void useCaretAnnotations(String... annotations) {
    CaretAnnotations localCaret = new CaretAnnotations();
    for (String value : annotations) {
      String[] dup = value.split(":");
      localCaret.setAnnotation(dup[0], dup[1]);
    }
    caret = localCaret;
    caret.setAnnotationResolver(annotationResolver);
  }
View Full Code Here

  }

  /** Ensure the resolver is being delegated to when needed. */
  public void testResolver() {
    // initialise:
    CaretAnnotations annotations = new CaretAnnotations();
    MockResolver mockResolver = new MockResolver();
    annotations.setAnnotationResolver(mockResolver);

    // make sure a known annotation isn't resolved.
    annotations.setAnnotation(TEST_KEY, TEST_VALUE);
    annotations.getAnnotation(TEST_KEY);
    assertFalse("Known annotations shouldn't be resolved.",
        mockResolver.wasResolved(TEST_KEY));

    // check that unknown annotations were resolved properly:
    annotations.removeAnnotation(TEST_KEY);
    assertEquals("Unknown annotations should be fetched from resolver.",
        RESOLVER_VALUE, annotations.getAnnotation(TEST_KEY));
    assertTrue("Unknown annotations should be fetched from resolver.",
        mockResolver.wasResolved(TEST_KEY));

    // unset resolver, ensure unknown keys are no longer resolved:
    annotations.setAnnotationResolver(null);
    assertNull("Unknown annotations should be null when no resolver present.",
        annotations.getAnnotation(TEST_KEY));
  }
View Full Code Here

    doc = mutable;
  }

  // Converts the annotations passed into a CaretAnnotations bundle and stores in caret
  private void useCaretAnnotations(String... annotations) {
    CaretAnnotations localCaret = new CaretAnnotations();
    for (String value : annotations) {
      String[] dup = value.split(":");
      localCaret.setAnnotation(dup[0], dup[1]);
    }
    caret = localCaret;
    caret.setAnnotationResolver(annotationResolver);
  }
View Full Code Here

      });

      repairer.hideDeath(full().getDocumentElement());

      // set up empty styles
      caretStyles = new CaretAnnotations();
      caretStyles.setAnnotationResolver(annotationResolver);

      // Force rendering of annotations
      // TODO(danilatos): Make this only apply to the current editor.
      AnnotationPainter.repaintNow(content.getContext());
View Full Code Here

      });

      repairer.hideDeath(full().getDocumentElement());

      // set up empty styles
      caretStyles = new CaretAnnotations();
      caretStyles.setAnnotationResolver(annotationResolver);

      // Force rendering of annotations
      // TODO(danilatos): Make this only apply to the current editor.
      AnnotationPainter.repaintNow(content.getContext());
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.client.editor.content.misc.CaretAnnotations

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.