Package org.waveprotocol.wave.client.editor

Examples of org.waveprotocol.wave.client.editor.ElementHandlerRegistry$HasHandlers


    when(el3.getTagName()).thenReturn("z");
  }


  public void testRegister() {
    ElementHandlerRegistry r1 = ElementHandlerRegistry.ROOT.createExtension();

    r1.registerRenderer("x", a);
    r1.registerEventHandler("y", f);
    assertSame(a, r1.getRenderer(el1));
    assertSame(f, r1.getEventHandler(el2));

    ElementHandlerRegistry r2 = r1.createExtension();

    // Check overriding in the same registry
    r1.registerEventHandler("y", h);
    assertSame(h, r1.getEventHandler(el2));

    // Check overriding in a child registry
    r2.registerRenderer("x", b);
    r2.registerEventHandler("y", g);
    assertSame(b, r2.getRenderer(el1));
    assertSame(g, r2.getEventHandler(el2));

    // Check propagation
    r1.registerRenderer("z", c);
    assertSame(c, r2.getRenderer(el3));
  }
View Full Code Here


    r1.registerRenderer("z", c);
    assertSame(c, r2.getRenderer(el3));
  }

  public void testConcurrent() {
    ElementHandlerRegistry r1 = ElementHandlerRegistry.ROOT.createExtension();
    ElementHandlerRegistry r2 = r1.createExtension();

    // Check overriding in the child registry with concurrent propagation
    r2.registerRenderer("x", a);
    r2.registerRenderer("x", b);
    r1.registerRenderer("x", c);
    r1.registerRenderer("x", d);
    assertSame(b, r2.getRenderer(el1));

  }
View Full Code Here

    assertSame(b, r2.getRenderer(el1));

  }

  public void testOverrideDifferentTypes() {
    ElementHandlerRegistry r1 = ElementHandlerRegistry.ROOT.createExtension();

    r1.registerRenderer("x", a);
    r1.registerEventHandler("x", e);

    ElementHandlerRegistry r2 = r1.createExtension();

    // Check overriding in the same registry
    r2.registerEventHandler("x", h);
    assertSame(h, r2.getEventHandler(el1));
    assertSame(a, r2.getRenderer(el1));
  }
View Full Code Here

    assertSame(a, r2.getRenderer(el1));
  }

  public void testDoubleRegister() {
    RenderingMutationHandler rmh = mock(RenderingMutationHandler.class);
    ElementHandlerRegistry r1 = ElementHandlerRegistry.ROOT.createExtension();
    r1.registerRenderingMutationHandler("x", rmh);

    assertSame(rmh, r1.getRenderer(el1));
    assertSame(rmh, r1.getMutationHandler(el1));
  }
View Full Code Here

  @SuppressWarnings({"unchecked", "fallthrough", "rawtypes"}) // NodeMutationHandler is generic
  private void setupBehaviour(ContentElement element, Level oldLevel) {
    AgentAdapter e = (AgentAdapter) element;

    ElementHandlerRegistry elementRegistry = registries.getElementHandlerRegistry();

    // bootstrapping for new nodes
    if (oldLevel == null) {
      NodeMutationHandler mutationHandler = elementRegistry.getMutationHandler(e);
      if (mutationHandler instanceof PermanentMutationHandler) {
        e.setNodeMutationHandler(mutationHandler);
      }
      oldLevel = Level.SHELVED;
    }

    boolean notRendered = (e.getRenderer() == AgentAdapter.noRenderer);
    assert notRendered == (oldLevel == Level.SHELVED) : "oldLevel: " + oldLevel + " notRendered:"+notRendered;
    boolean shouldBeRendered = level.isAtLeast(Level.RENDERED);

    // Increasing level
    switch (oldLevel) {
      case SHELVED: // -> RENDERED
        if (level.isAtMost(Level.SHELVED)) break;

        setupRenderer(e, true);
        if (e == fullRawSubstrate.getDocumentElement()) {
          initRootElementRendering(true);
        }
        e.setNodeMutationHandler(elementRegistry.getMutationHandler(e));

      case RENDERED: // -> INTERACTIVE
        if (level.isAtMost(Level.RENDERED)) break;

        e.setNodeEventHandler(elementRegistry.getEventHandler(e));
        maybeSetupGwtWidget(e);

      case INTERACTIVE: // -> EDITING
        if (level.isAtMost(Level.INTERACTIVE)) break;

        maybeSetupModeNotifications(e);
        break;
    }

    // Decreasing level
    switch (oldLevel) {
      case EDITING: // -> INTERACTIVE
        if (level.isAtLeast(Level.EDITING)) break;
        // No need to cleanup mode notifications

      case INTERACTIVE: // -> RENDERED
        if (level.isAtLeast(Level.INTERACTIVE)) break;

        maybeSetupGwtWidget(e);
        e.setNodeEventHandler(null);

      case RENDERED: // -> SHELVED
        if (level.isAtLeast(Level.RENDERED)) break;

        NodeMutationHandler mutationHandler = elementRegistry.getMutationHandler(e);
        if (mutationHandler instanceof PermanentMutationHandler) {
          e.setNodeMutationHandler(mutationHandler);
        } else {
          e.setNodeMutationHandler(null);
        }
View Full Code Here

  }

  private static void registerHandlers(Registries registries) {
    AnnotationRegistry annotationRegistry = registries.getAnnotationHandlerRegistry();
    PainterRegistry paintRegistry = registries.getPaintRegistry();
    ElementHandlerRegistry elementHandlerRegistry = registries.getElementHandlerRegistry();

    LineContainers.setTopLevelContainerTagname(Blips.BODY_TAGNAME);
    LineRendering.registerContainer(Blips.BODY_TAGNAME, elementHandlerRegistry);
    TestInlineDoodad.register(elementHandlerRegistry);
    StyleAnnotationHandler.register(registries);
View Full Code Here

    return ConversationSchemas.BLIP_SCHEMA_CONSTRAINTS;
  }

  public void registerDoodads(Registries registries) {

    ElementHandlerRegistry testHandlerRegistry =
        testEditorRegistries.getElementHandlerRegistry();

    LineRendering.registerContainer(TOPLEVEL_CONTAINER_TAGNAME,
        registries.getElementHandlerRegistry());
View Full Code Here

  }

  private static void registerHandlers(Registries registries) {
    AnnotationRegistry annotationRegistry = registries.getAnnotationHandlerRegistry();
    PainterRegistry paintRegistry = registries.getPaintRegistry();
    ElementHandlerRegistry elementHandlerRegistry = registries.getElementHandlerRegistry();

    ImageThumbnail.register(elementHandlerRegistry,
        new FakeAttachmentsManager(), null);

    StyleAnnotationHandler.register(registries);
View Full Code Here

  public static GlobalInstaller installer() {
    return new GlobalInstaller() {
      @Override
      public void install(Registries r) {
        ElementHandlerRegistry handlers = r.getElementHandlerRegistry();
        RenderingMutationHandler multiHandler = TemplateNodeMutationHandler.create();

        LineRendering.registerContainer(PART_TAG, handlers);
        handlers.registerRenderingMutationHandler(TEMPLATE_TAG, multiHandler);
        handlers.registerMutationHandler(NAMEVALUEPAIR_TAG, new NameValuePairNodeMutationHandler());
        handlers.registerEventHandler(TEMPLATE_TAG, ChunkyElementHandler.INSTANCE);
        handlers.registerEventHandler(PART_TAG, LineRendering.DEFAULT_PARAGRAPH_EVENT_HANDLER);
      }
    };
  }
View Full Code Here

  @SuppressWarnings({"unchecked", "fallthrough"}) // NodeMutationHandler is generic
  private void setupBehaviour(ContentElement element, Level oldLevel) {
    AgentAdapter e = (AgentAdapter) element;

    ElementHandlerRegistry elementRegistry = registries.getElementHandlerRegistry();

    // bootstrapping for new nodes
    if (oldLevel == null) {
      NodeMutationHandler mutationHandler = elementRegistry.getMutationHandler(e);
      if (mutationHandler instanceof PermanentMutationHandler) {
        e.setNodeMutationHandler(mutationHandler);
      }
      oldLevel = Level.SHELVED;
    }

    boolean notRendered = (e.getRenderer() == AgentAdapter.noRenderer);
    assert notRendered == (oldLevel == Level.SHELVED) : "oldLevel: " + oldLevel + " notRendered:"+notRendered;
    boolean shouldBeRendered = level.isAtLeast(Level.RENDERED);

    // Increasing level
    switch (oldLevel) {
      case SHELVED: // -> RENDERED
        if (level.isAtMost(Level.SHELVED)) break;

        setupRenderer(e, true);
        if (e == fullRawSubstrate.getDocumentElement()) {
          initRootElementRendering(true);
        }
        e.setNodeMutationHandler(elementRegistry.getMutationHandler(e));

      case RENDERED: // -> INTERACTIVE
        if (level.isAtMost(Level.RENDERED)) break;

        e.setNodeEventHandler(elementRegistry.getEventHandler(e));
        maybeSetupGwtWidget(e);

      case INTERACTIVE: // -> EDITING
        if (level.isAtMost(Level.INTERACTIVE)) break;

        maybeSetupModeNotifications(e);
        break;
    }

    // Decreasing level
    switch (oldLevel) {
      case EDITING: // -> INTERACTIVE
        if (level.isAtLeast(Level.EDITING)) break;
        // No need to cleanup mode notifications

      case INTERACTIVE: // -> RENDERED
        if (level.isAtLeast(Level.INTERACTIVE)) break;

        maybeSetupGwtWidget(e);
        e.setNodeEventHandler(null);

      case RENDERED: // -> SHELVED
        if (level.isAtLeast(Level.RENDERED)) break;

        NodeMutationHandler mutationHandler = elementRegistry.getMutationHandler(e);
        if (mutationHandler instanceof PermanentMutationHandler) {
          e.setNodeMutationHandler(mutationHandler);
        } else {
          e.setNodeMutationHandler(null);
        }
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.client.editor.ElementHandlerRegistry$HasHandlers

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.