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

Examples of org.waveprotocol.wave.client.editor.content.AnnotationPainter


    EditorTestingUtil.setupTestEnvironment();

    FakeTimerService timerService = new FakeTimerService();
    PainterRegistryImpl paintRegistry = new PainterRegistryImpl(
            AnnotationPaint.SPREAD_FULL_TAGNAME, AnnotationPaint.BOUNDARY_FULL_TAGNAME,
            new AnnotationPainter(timerService));

    Registries registries =
        new RegistriesImpl(Editor.ROOT_HANDLER_REGISTRY,
            Editor.ROOT_ANNOTATION_REGISTRY, paintRegistry);
View Full Code Here


  PersistentContent<Node, Element, Text> persistentDoc;
  FakeTimerService timerService = new FakeTimerService();

  public TestDocumentContext<Node, Element, Text> createAnnotationContext() {

    final AnnotationPainter painter = new AnnotationPainter(timerService);
    final PainterRegistry painterRegistry =
        new PainterRegistryImpl("l:p", "l:b", painter);
    painterRegistry.registerPaintFunction(rangeKeys, new PaintFunction() {
      @Override
      public Map<String, String> apply(Map<String, Object> from, boolean isEditing) {
        Map<String, String> ret = new HashMap<String, String>();
        for (Map.Entry<String, Object> entry : from.entrySet()) {
          ret.put(entry.getKey(), (String) entry.getValue());
        }
        return ret;
      }
    });
    boundaryKeys.each(new Proc() {
      @Override
      public void apply(String key) {
        final String k = key;
        painterRegistry.registerBoundaryFunction(boundaryKeys, new BoundaryFunction() {
          @Override
          public <N, E extends N, T extends N> E apply(LocalDocument<N, E, T> localDoc, E parent,
              N nodeAfter, Map<String, Object> before, Map<String, Object> after,
              boolean isEditing) {
            Point.checkRelationship(localDoc, parent, nodeAfter, "Test boundary function");

            if (before.containsKey(k) || after.containsKey(k)) {
              Map<String, String> attrs = new HashMap<String, String>();
              attrs.put("z", before.toString() + "->" + after.toString());
              return localDoc.transparentCreate("b-" + k, attrs, parent, nodeAfter);
            } else {
              return null;
            }
          }
        });
      }
    });

    // To get around initialisation circularity.
    // It's safe because we won't get any annotation changes in the initialisation.
    class Box {
      TestDocumentContext<Node, Element, Text> cxt;
    }
    final Box cxtBox = new Box();
    final TestDocumentContext<Node, Element, Text> cxt = ContextProviders.createTestPojoContext(
        "",
        null, new AnnotationSetListener<Object>() {
          public void onAnnotationChange(int start, int end, String key, Object newValue) {
            if (key.length() == 1) {
              if (key.charAt(0) < 'w') {
                painter.scheduleRepaint(cxtBox.cxt, start, end);
              } else {
                painter.scheduleRepaint(cxtBox.cxt, start, start);
                painter.scheduleRepaint(cxtBox.cxt, end, end);
              }
            }
          }
        }, null, DocumentSchema.NO_SCHEMA_CONSTRAINTS);
    cxtBox.cxt = cxt;
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.client.editor.content.AnnotationPainter

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.