Repository: incubator-wave Updated Branches: refs/heads/swellrt [created] 041a3c0c0
http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/a768997c/wave/src/main/java/org/waveprotocol/wave/client/editor/content/paragraph/ParagraphRenderer.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/wave/client/editor/content/paragraph/ParagraphRenderer.java b/wave/src/main/java/org/waveprotocol/wave/client/editor/content/paragraph/ParagraphRenderer.java index 8bc98d9..5830abf 100644 --- a/wave/src/main/java/org/waveprotocol/wave/client/editor/content/paragraph/ParagraphRenderer.java +++ b/wave/src/main/java/org/waveprotocol/wave/client/editor/content/paragraph/ParagraphRenderer.java @@ -84,7 +84,11 @@ public class ParagraphRenderer extends RenderingMutationHandler { protected static MutationHandler getMutationHandler(ContentElement element) { ParagraphBehaviour b = ParagraphBehaviour.of(element.getAttribute(Paragraph.SUBTYPE_ATTR)); - return b == null ? null : Paragraph.mutationHandlerRegistry.get(b); + return getMutationHandler(b); + } + + protected static MutationHandler getMutationHandler(ParagraphBehaviour paragraphBehaviour) { + return paragraphBehaviour == null ? null : Paragraph.mutationHandlerRegistry.get(paragraphBehaviour); } // ---- Mutation Notification stuff end ---- @@ -158,6 +162,7 @@ public class ParagraphRenderer extends RenderingMutationHandler { } ParagraphBehaviour b = ParagraphBehaviour.of(newValue); + ParagraphBehaviour oldb = ParagraphBehaviour.of(oldValue); if (Paragraph.SUBTYPE_ATTR.equals(name) || Paragraph.LIST_STYLE_ATTR.equals(name)) { scheduleRenderUpdate(p); @@ -172,6 +177,20 @@ public class ParagraphRenderer extends RenderingMutationHandler { } updateEventHandler(p, b); + + if (!b.equals(oldb)) { + MutationHandler h = getMutationHandler(ParagraphBehaviour.HEADING); + if (h != null) { + if (b.equals(ParagraphBehaviour.HEADING)) { + // header is activated + h.onAdded(p); + } else if (oldb.equals(ParagraphBehaviour.HEADING)) { + // header is deactivated + h.onRemoved(p); + } + } + } + } @@ -278,7 +297,6 @@ public class ParagraphRenderer extends RenderingMutationHandler { } } - /** * Notify mutation handlers * @@ -302,6 +320,5 @@ public class ParagraphRenderer extends RenderingMutationHandler { public void onDescendantsMutated(ContentElement element) { scheduleMutationNotification(element); } - } http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/a768997c/wave/src/main/java/org/waveprotocol/wave/client/editor/harness/DefaultTestHarness.java ---------------------------------------------------------------------- diff --git a/wave/src/main/java/org/waveprotocol/wave/client/editor/harness/DefaultTestHarness.java b/wave/src/main/java/org/waveprotocol/wave/client/editor/harness/DefaultTestHarness.java index 895ee3e..dc48551 100644 --- a/wave/src/main/java/org/waveprotocol/wave/client/editor/harness/DefaultTestHarness.java +++ b/wave/src/main/java/org/waveprotocol/wave/client/editor/harness/DefaultTestHarness.java @@ -32,8 +32,9 @@ import com.google.gwt.user.client.ui.RootPanel; import org.waveprotocol.wave.client.common.util.JsoView; import org.waveprotocol.wave.client.common.util.KeyCombo; import org.waveprotocol.wave.client.doodad.annotation.AnnotationHandler; +import org.waveprotocol.wave.client.doodad.annotation.AnnotationHandler.Activator; import org.waveprotocol.wave.client.doodad.annotation.jso.JsoAnnotationController; -import org.waveprotocol.wave.client.doodad.annotation.jso.JsoEditorRange; +import org.waveprotocol.wave.client.doodad.annotation.jso.JsoRange; import org.waveprotocol.wave.client.doodad.attachment.ImageThumbnail; import org.waveprotocol.wave.client.doodad.attachment.ImageThumbnail.ThumbnailActionHandler; import org.waveprotocol.wave.client.doodad.attachment.render.ImageThumbnailWrapper; @@ -123,7 +124,13 @@ public class DefaultTestHarness implements EntryPoint { // JsoAnnotationController customController = JsoAnnotationController.getDefault(); - AnnotationHandler.register(registries, "generic/custom", customController); + AnnotationHandler.register(registries, "generic/custom", customController, new Activator() { + + @Override + public boolean shouldFireEvent() { + return true; + } + }); }