Updated Branches:
  refs/heads/master 529f75e8a -> 13f4cb2a9

Move all annotation constants to their own class>

https://reviews.apache.org/r/16435/


Project: http://git-wip-us.apache.org/repos/asf/incubator-wave/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-wave/commit/13f4cb2a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-wave/tree/13f4cb2a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-wave/diff/13f4cb2a

Branch: refs/heads/master
Commit: 13f4cb2a9ddcd8ff11adccce94a0c1e38bd8755f
Parents: 529f75e
Author: Ali Lown <[email protected]>
Authored: Sat Dec 21 15:44:38 2013 +0000
Committer: Ali Lown <[email protected]>
Committed: Sat Dec 21 17:02:50 2013 +0000

----------------------------------------------------------------------
 .../wave/client/doodad/link/Link.java           | 32 ++-----
 .../doodad/link/LinkAnnotationHandler.java      | 36 ++++----
 .../selection/SelectionAnnotationHandler.java   | 55 ++++++------
 .../plugins/video/VideoLinkPlugin.java          |  3 +-
 .../content/misc/StyleAnnotationHandler.java    | 33 +++-----
 .../wavepanel/impl/toolbar/LinkerHelper.java    |  5 +-
 .../model/conversation/AnnotationConstants.java | 89 ++++++++++++++++++++
 .../operation/wave/WorthyChangeChecker.java     | 19 ++---
 .../model/richtext/RichTextMutationBuilder.java | 51 +++++------
 9 files changed, 179 insertions(+), 144 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/13f4cb2a/src/org/waveprotocol/wave/client/doodad/link/Link.java
----------------------------------------------------------------------
diff --git a/src/org/waveprotocol/wave/client/doodad/link/Link.java 
b/src/org/waveprotocol/wave/client/doodad/link/Link.java
index 7b2b54a..e468f53 100644
--- a/src/org/waveprotocol/wave/client/doodad/link/Link.java
+++ b/src/org/waveprotocol/wave/client/doodad/link/Link.java
@@ -23,6 +23,7 @@ import com.google.common.base.Preconditions;
 
 import org.waveprotocol.wave.client.common.safehtml.EscapeUtils;
 import org.waveprotocol.wave.client.common.util.WaveRefConstants;
+import org.waveprotocol.wave.model.conversation.AnnotationConstants;
 import org.waveprotocol.wave.model.id.DualIdSerialiser;
 import org.waveprotocol.wave.model.id.InvalidIdException;
 import org.waveprotocol.wave.model.util.CollectionUtils;
@@ -67,31 +68,6 @@ public final class Link {
     }
   }
 
-  /** Key prefix */
-  public static final String PREFIX = "link";
-
-  /** The primary key used for links. This is the same as the prefix on its 
own. */
-  public static final String KEY = PREFIX;
-
-  /** Key for 'linky' agent created links. */
-  public static final String AUTO_KEY = PREFIX + "/auto";
-
-  /**
-   * Key for manually created links.
-   * @deprecated use the "link" key. Delete this after old links have been 
cleaned up.
-   */
-  @Deprecated
-  public static final String MANUAL_KEY = PREFIX + "/manual";
-  /**
-   * Key for wave links.
-   *
-   * @deprecated Use the key "link" with value of the form:
-   *             wave://example.com/w+1234/~/conv+root/b+abcd
-   *
-   *             Delete this after old links have been cleaned up.
-   */
-  @Deprecated
-  public static final String WAVE_KEY = PREFIX + "/wave";
   /**
    * Array of all link keys
    *
@@ -99,7 +75,11 @@ public final class Link {
    * should expose LINK_KEYS as a set, and have ORDERED_LINK_KEYS for code that
    * relies on specific ordering.
    */
-  public static final String[] LINK_KEYS = {KEY, AUTO_KEY, MANUAL_KEY, 
WAVE_KEY};
+  public static final String[] LINK_KEYS = {
+    AnnotationConstants.LINK_PREFIX,
+    AnnotationConstants.LINK_AUTO,
+    AnnotationConstants.LINK_MANUAL,
+    AnnotationConstants.LINK_WAVE};
 
   private Link() {
   }

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/13f4cb2a/src/org/waveprotocol/wave/client/doodad/link/LinkAnnotationHandler.java
----------------------------------------------------------------------
diff --git 
a/src/org/waveprotocol/wave/client/doodad/link/LinkAnnotationHandler.java 
b/src/org/waveprotocol/wave/client/doodad/link/LinkAnnotationHandler.java
index 60bfe91..9532001 100644
--- a/src/org/waveprotocol/wave/client/doodad/link/LinkAnnotationHandler.java
+++ b/src/org/waveprotocol/wave/client/doodad/link/LinkAnnotationHandler.java
@@ -19,13 +19,6 @@
 
 package org.waveprotocol.wave.client.doodad.link;
 
-import static org.waveprotocol.wave.client.doodad.link.Link.AUTO_KEY;
-import static org.waveprotocol.wave.client.doodad.link.Link.KEY;
-import static org.waveprotocol.wave.client.doodad.link.Link.LINK_KEYS;
-import static org.waveprotocol.wave.client.doodad.link.Link.MANUAL_KEY;
-import static org.waveprotocol.wave.client.doodad.link.Link.PREFIX;
-import static org.waveprotocol.wave.client.doodad.link.Link.WAVE_KEY;
-
 import org.waveprotocol.wave.client.doodad.suggestion.Suggestion;
 import org.waveprotocol.wave.client.doodad.suggestion.SuggestionRenderer;
 import org.waveprotocol.wave.client.editor.content.AnnotationPainter;
@@ -36,6 +29,7 @@ import 
org.waveprotocol.wave.client.editor.content.PainterRegistry;
 import org.waveprotocol.wave.client.editor.content.Registries;
 import org.waveprotocol.wave.client.editor.content.misc.AnnotationPaint;
 import 
org.waveprotocol.wave.client.editor.sugg.SuggestionsManager.HasSuggestions;
+import org.waveprotocol.wave.model.conversation.AnnotationConstants;
 import 
org.waveprotocol.wave.model.document.AnnotationBehaviour.AnnotationFamily;
 import 
org.waveprotocol.wave.model.document.AnnotationBehaviour.DefaultAnnotationBehaviour;
 import org.waveprotocol.wave.model.document.AnnotationMutationHandler;
@@ -86,7 +80,7 @@ public class LinkAnnotationHandler implements 
AnnotationMutationHandler {
   }
 
   /** Set of all link keys */
-  private static final ReadableStringSet KEYS = 
CollectionUtils.newStringSet(LINK_KEYS);
+  private static final ReadableStringSet KEYS = 
CollectionUtils.newStringSet(Link.LINK_KEYS);
   private static final ReadableStringSet BOUNDARY_KEYS = KEYS;
 
   /**
@@ -103,13 +97,13 @@ public class LinkAnnotationHandler implements 
AnnotationMutationHandler {
         new LinkAnnotationHandler(painterRegistry.getPainter());
 
     AnnotationRegistry annotationRegistry = 
registries.getAnnotationHandlerRegistry();
-    annotationRegistry.registerHandler(PREFIX, handler);
+    annotationRegistry.registerHandler(AnnotationConstants.LINK_PREFIX, 
handler);
     // Don't register behaviour on the link/auto key, since an external agent
     // puts it there resulting in surprising behaviour mid-typing (e.g. if
     // the text is bold, the bold will suddenly get ended because of the link)
-    registerBehaviour(annotationRegistry, KEY);
-    registerBehaviour(annotationRegistry, MANUAL_KEY);
-    registerBehaviour(annotationRegistry, WAVE_KEY);
+    registerBehaviour(annotationRegistry, AnnotationConstants.LINK_PREFIX);
+    registerBehaviour(annotationRegistry, AnnotationConstants.LINK_MANUAL);
+    registerBehaviour(annotationRegistry, AnnotationConstants.LINK_WAVE);
 
     painterRegistry.registerPaintFunction(KEYS, new RenderFunc(augmenter));
     painterRegistry.registerBoundaryFunction(BOUNDARY_KEYS, boundaryFunc);
@@ -146,16 +140,16 @@ public class LinkAnnotationHandler implements 
AnnotationMutationHandler {
   @SuppressWarnings("deprecation")
   public static String getLink(Map<String, Object> map) {
     Object ret = null;
-    if (map.containsKey(KEY)) {
-      ret = Link.toHrefFromUri((String) map.get(KEY));
-    } else if (map.containsKey(MANUAL_KEY)) {
-        ret = Link.toHrefFromUri((String) map.get(MANUAL_KEY));
-    } else if (map.containsKey(WAVE_KEY)) {
-      // This is for backwards compatibility. Stop supporting WAVE_KEY once
+    if (map.containsKey(AnnotationConstants.LINK_PREFIX)) {
+      ret = Link.toHrefFromUri((String) 
map.get(AnnotationConstants.LINK_PREFIX));
+    } else if (map.containsKey(AnnotationConstants.LINK_MANUAL)) {
+        ret = Link.toHrefFromUri((String) 
map.get(AnnotationConstants.LINK_MANUAL));
+    } else if (map.containsKey(AnnotationConstants.LINK_WAVE)) {
+      // This is for backwards compatibility. Stop supporting 
AnnotationConstants.LINK_WAVE once
       // the data is cleaned.
-      ret = Link.toHrefFromUri((String) map.get(WAVE_KEY));
-    } else if (map.containsKey(AUTO_KEY)) {
-      ret = Link.toHrefFromUri((String) map.get(AUTO_KEY));
+      ret = Link.toHrefFromUri((String) 
map.get(AnnotationConstants.LINK_WAVE));
+    } else if (map.containsKey(AnnotationConstants.LINK_AUTO)) {
+      ret = Link.toHrefFromUri((String) 
map.get(AnnotationConstants.LINK_AUTO));
     }
     if (ret instanceof String) {
       return (String) ret;

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/13f4cb2a/src/org/waveprotocol/wave/client/doodad/selection/SelectionAnnotationHandler.java
----------------------------------------------------------------------
diff --git 
a/src/org/waveprotocol/wave/client/doodad/selection/SelectionAnnotationHandler.java
 
b/src/org/waveprotocol/wave/client/doodad/selection/SelectionAnnotationHandler.java
index 158876a..b34cfe5 100644
--- 
a/src/org/waveprotocol/wave/client/doodad/selection/SelectionAnnotationHandler.java
+++ 
b/src/org/waveprotocol/wave/client/doodad/selection/SelectionAnnotationHandler.java
@@ -33,6 +33,7 @@ import org.waveprotocol.wave.client.editor.content.Registries;
 import org.waveprotocol.wave.client.scheduler.Scheduler;
 import org.waveprotocol.wave.client.scheduler.SchedulerInstance;
 import org.waveprotocol.wave.client.scheduler.TimerService;
+import org.waveprotocol.wave.model.conversation.AnnotationConstants;
 import org.waveprotocol.wave.model.document.AnnotationMutationHandler;
 import org.waveprotocol.wave.model.document.MutableDocument;
 import org.waveprotocol.wave.model.document.util.DocumentContext;
@@ -58,17 +59,17 @@ import java.util.Queue;
  *
  * Currently, a user's selection is defined as a group of two or three 
annotations.
  *
- *  - Data annotation, with the prefix {@link #DATA_PREFIX}
+ *  - Data annotation, with the prefix {@link #AnnotationConstants.USER_DATA}
  *    This annotation always covers the entire document.
  *    Its value is of the form "address,timestamp[,compositionstate]" where 
address is
  *    the user's id, timestamp is the number of milliseconds since the Epoch, 
UTC.
  *    An optional composition state may also be included, for indicating 
uncommitted
  *    IME composition text.
- *  - Hotspot annotation, with the prefix {@link #END_PREFIX}
+ *  - Hotspot annotation, with the prefix {@link #AnnotationConstants.USER_END}
  *    This annotation starts from where the user's blinking caret would be, and
  *    extends to the end of the document.
  *    Its value is their address
- *  - Range annotation, with the prefix {@link #RANGE_PREFIX}
+ *  - Range annotation, with the prefix {@link #AnnotationConstants.USER_RANGE}
  *    This annotation extends over the user's selected range. if their 
selection
  *    is collapsed, this annotation is not present.
  *    Its value is their address.
@@ -131,20 +132,12 @@ public class SelectionAnnotationHandler implements 
AnnotationMutationHandler, Pr
     Preconditions.checkNotNull(sessionId, "Session Id to ignore must not be 
null");
     SelectionAnnotationHandler selection = new SelectionAnnotationHandler(
         registries.getPaintRegistry(), sessionId, profiles, timer, carets);
-    registries.getAnnotationHandlerRegistry().registerHandler(PREFIX, 
selection);
+    registries.getAnnotationHandlerRegistry().
+      registerHandler(AnnotationConstants.USER_PREFIX, selection);
     profiles.addListener(selection);
     return selection;
   }
 
-  /**
-   * Annotation key prefix
-   */
-  private static final String PREFIX = "user";
-
-  private static final String RANGE_PREFIX = PREFIX + "/r/";
-  private static final String END_PREFIX = PREFIX + "/e/";
-  private static final String DATA_PREFIX = PREFIX + "/d/";
-
   // Do proper random colours at some point...
   private static final RgbColor[] COLOURS = new RgbColor[] {
     new RgbColor(252, 146, 41), // Orange
@@ -168,27 +161,27 @@ public class SelectionAnnotationHandler implements 
AnnotationMutationHandler, Pr
    * @return full annotation key
    */
   public static String rangeKey(String sessionId) {
-    return RANGE_PREFIX + sessionId;
+    return AnnotationConstants.USER_RANGE + sessionId;
   }
 
   public static String endKey(String sessionId) {
-    return END_PREFIX + sessionId;
+    return AnnotationConstants.USER_END + sessionId;
   }
 
   public static String dataKey(String sessionId) {
-    return DATA_PREFIX + sessionId;
+    return AnnotationConstants.USER_DATA + sessionId;
   }
 
   public static String rangeSuffix(String rangeKey) {
-    return rangeKey.substring(RANGE_PREFIX.length());
+    return rangeKey.substring(AnnotationConstants.USER_RANGE.length());
   }
 
   public static String endSuffix(String endKey) {
-    return endKey.substring(END_PREFIX.length());
+    return endKey.substring(AnnotationConstants.USER_END.length());
   }
 
   public static String dataSuffix(String dataKey) {
-    return dataKey.substring(DATA_PREFIX.length());
+    return dataKey.substring(AnnotationConstants.USER_DATA.length());
   }
 
   private final String ignoreSessionId;
@@ -331,7 +324,7 @@ public class SelectionAnnotationHandler implements 
AnnotationMutationHandler, Pr
       // discover which sessions have hilighted this range:
       String sessions = "";
       for (Map.Entry<String, Object> entry : from.entrySet()) {
-        if (entry.getKey().startsWith(RANGE_PREFIX)) {
+        if (entry.getKey().startsWith(AnnotationConstants.USER_RANGE)) {
           String sessionId = endSuffix(entry.getKey());
           String address = (String) entry.getValue();
           if (address == null || getActiveSessionData(sessionId) == null) {
@@ -358,7 +351,7 @@ public class SelectionAnnotationHandler implements 
AnnotationMutationHandler, Pr
       E usersContainer = null;
 
       for (Map.Entry<String, Object> entry : after.entrySet()) {
-        if (entry.getKey().startsWith(END_PREFIX)) {
+        if (entry.getKey().startsWith(AnnotationConstants.USER_END)) {
           // get the user's address:
           String address = (String) entry.getValue();
           if (address == null) {
@@ -469,14 +462,14 @@ public class SelectionAnnotationHandler implements 
AnnotationMutationHandler, Pr
 
     data.bundle = null;
     painterRegistry.unregisterBoundaryFunction(
-        CollectionUtils.newStringSet(END_PREFIX + data.sessionId), 
boundaryFunc);
+        CollectionUtils.newStringSet(AnnotationConstants.USER_END + 
data.sessionId), boundaryFunc);
     painterRegistry.unregisterPaintFunction(
-        CollectionUtils.newStringSet(RANGE_PREFIX + data.sessionId), 
spreadFunc);
+        CollectionUtils.newStringSet(AnnotationConstants.USER_RANGE + 
data.sessionId), spreadFunc);
 
     int size = document.size();
-    int rangeStart = document.firstAnnotationChange(0, size, RANGE_PREFIX + 
data.sessionId, null);
-    int rangeEnd = document.lastAnnotationChange(0, size, RANGE_PREFIX + 
data.sessionId, null);
-    int hotSpot = document.firstAnnotationChange(0, size, END_PREFIX + 
data.sessionId, null);
+    int rangeStart = document.firstAnnotationChange(0, size, 
AnnotationConstants.USER_RANGE + data.sessionId, null);
+    int rangeEnd = document.lastAnnotationChange(0, size, 
AnnotationConstants.USER_RANGE + data.sessionId, null);
+    int hotSpot = document.firstAnnotationChange(0, size, 
AnnotationConstants.USER_END + data.sessionId, null);
 
     if (rangeStart == -1) {
       rangeStart = rangeEnd = hotSpot;
@@ -492,13 +485,13 @@ public class SelectionAnnotationHandler implements 
AnnotationMutationHandler, Pr
        re-register the paint functions we just cleaned up.
 
     if (data.address.equals(currentUserAddress)) {
-      document.setAnnotation(0, size, DATA_PREFIX + data.sessionId, null);
+      document.setAnnotation(0, size, AnnotationConstants.USER_DATA + 
data.sessionId, null);
       if (rangeStart >= 0) {
         assert rangeEnd > rangeStart;
-        document.setAnnotation(rangeStart, rangeEnd, RANGE_PREFIX + 
data.sessionId, null);
+        document.setAnnotation(rangeStart, rangeEnd, 
AnnotationConstants.USER_RANGE + data.sessionId, null);
       }
       if (hotSpot >= 0) {
-        document.setAnnotation(hotSpot, size, END_PREFIX + data.sessionId, 
null);
+        document.setAnnotation(hotSpot, size, AnnotationConstants.USER_END + 
data.sessionId, null);
       }
     }
     */
@@ -555,9 +548,9 @@ public class SelectionAnnotationHandler implements 
AnnotationMutationHandler, Pr
       return;
     }
 
-    if (key.startsWith(DATA_PREFIX) && newValue != null) {
+    if (key.startsWith(AnnotationConstants.USER_DATA) && newValue != null) {
       updateCaretData(dataSuffix(key), (String) newValue, bundle);
-    } else if (key.startsWith(RANGE_PREFIX)) {
+    } else if (key.startsWith(AnnotationConstants.USER_RANGE)) {
       painterRegistry.registerPaintFunction(
           CollectionUtils.newStringSet(key), spreadFunc);
       painterRegistry.getPainter().scheduleRepaint(bundle, start, end);

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/13f4cb2a/src/org/waveprotocol/wave/client/doodad/suggestion/plugins/video/VideoLinkPlugin.java
----------------------------------------------------------------------
diff --git 
a/src/org/waveprotocol/wave/client/doodad/suggestion/plugins/video/VideoLinkPlugin.java
 
b/src/org/waveprotocol/wave/client/doodad/suggestion/plugins/video/VideoLinkPlugin.java
index c0105d2..c161f05 100644
--- 
a/src/org/waveprotocol/wave/client/doodad/suggestion/plugins/video/VideoLinkPlugin.java
+++ 
b/src/org/waveprotocol/wave/client/doodad/suggestion/plugins/video/VideoLinkPlugin.java
@@ -29,6 +29,7 @@ import 
org.waveprotocol.wave.client.editor.content.ContentNode;
 import org.waveprotocol.wave.client.editor.content.ContentTextNode;
 import org.waveprotocol.wave.client.editor.sugg.Menu;
 import org.waveprotocol.wave.client.gadget.StateMap;
+import org.waveprotocol.wave.model.conversation.AnnotationConstants;
 import org.waveprotocol.wave.model.document.util.RangeTracker;
 import org.waveprotocol.wave.model.util.StringMap;
 
@@ -104,7 +105,7 @@ public class VideoLinkPlugin implements Plugin {
 
       menu.addItem(EMBED_VIDEO,
           new GadgetCommand<ContentNode, ContentElement, 
ContentTextNode>(MOVIE_GADGET_URL,
-              stateMap, mutableDocument, Link.AUTO_KEY, 
replacementRangeHelper));
+              stateMap, mutableDocument, AnnotationConstants.LINK_AUTO, 
replacementRangeHelper));
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/13f4cb2a/src/org/waveprotocol/wave/client/editor/content/misc/StyleAnnotationHandler.java
----------------------------------------------------------------------
diff --git 
a/src/org/waveprotocol/wave/client/editor/content/misc/StyleAnnotationHandler.java
 
b/src/org/waveprotocol/wave/client/editor/content/misc/StyleAnnotationHandler.java
index 62f14f4..f0a68f8 100644
--- 
a/src/org/waveprotocol/wave/client/editor/content/misc/StyleAnnotationHandler.java
+++ 
b/src/org/waveprotocol/wave/client/editor/content/misc/StyleAnnotationHandler.java
@@ -24,6 +24,7 @@ import 
org.waveprotocol.wave.client.editor.content.AnnotationPainter.PaintFuncti
 import org.waveprotocol.wave.client.editor.content.PainterRegistry;
 import org.waveprotocol.wave.client.editor.content.Registries;
 
+import org.waveprotocol.wave.model.conversation.AnnotationConstants;
 import 
org.waveprotocol.wave.model.document.AnnotationBehaviour.AnnotationFamily;
 import 
org.waveprotocol.wave.model.document.AnnotationBehaviour.DefaultAnnotationBehaviour;
 import org.waveprotocol.wave.model.document.AnnotationMutationHandler;
@@ -44,18 +45,12 @@ import java.util.Map;
 public class StyleAnnotationHandler implements AnnotationMutationHandler {
 
   /**
-   * Annotation key prefix
-   * TODO(user): Move this to a package accessible by model code.
-   */
-  public static final String PREFIX = "style";
-
-  /**
    * Handy method for getting the style suffix, given a full annotation key
    * @param key
    * @return style suffix
    */
   private static final String suffix(String key) {
-    return key.substring(PREFIX.length() + 1);
+    return key.substring(AnnotationConstants.STYLE_PREFIX.length() + 1);
   }
 
   /**
@@ -64,7 +59,7 @@ public class StyleAnnotationHandler implements 
AnnotationMutationHandler {
    * @return full annotation key
    */
   public static final String key(String suffix) {
-    return PREFIX + "/" + suffix;
+    return AnnotationConstants.STYLE_PREFIX + "/" + suffix;
   }
 
   /**
@@ -76,8 +71,8 @@ public class StyleAnnotationHandler implements 
AnnotationMutationHandler {
   public static void register(Registries registries) {
     PainterRegistry painterRegistry = registries.getPaintRegistry();
     StyleAnnotationHandler handler = new 
StyleAnnotationHandler(painterRegistry.getPainter());
-    registries.getAnnotationHandlerRegistry().registerHandler(PREFIX, handler);
-    registries.getAnnotationHandlerRegistry().registerBehaviour(PREFIX,
+    
registries.getAnnotationHandlerRegistry().registerHandler(AnnotationConstants.STYLE_PREFIX,
 handler);
+    
registries.getAnnotationHandlerRegistry().registerBehaviour(AnnotationConstants.STYLE_PREFIX,
         new DefaultAnnotationBehaviour(AnnotationFamily.CONTENT));
     painterRegistry.registerPaintFunction(KEYS, renderFunc);
   }
@@ -88,7 +83,7 @@ public class StyleAnnotationHandler implements 
AnnotationMutationHandler {
     public Map<String, String> apply(Map<String, Object> from, boolean 
isEditing) {
       Map<String, String> map = new HashMap<String, String>();
       for (Map.Entry<String, Object> entry : from.entrySet()) {
-        if (entry.getKey().startsWith(PREFIX + "/")) {
+        if (entry.getKey().startsWith(AnnotationConstants.STYLE_PREFIX + "/")) 
{
           map.put(suffix(entry.getKey()), (String) entry.getValue());
         }
       }
@@ -97,14 +92,14 @@ public class StyleAnnotationHandler implements 
AnnotationMutationHandler {
   };
 
   public static final ReadableStringSet KEYS = CollectionUtils.newStringSet(
-      "style/backgroundColor",
-      "style/color",
-      "style/fontFamily",
-      "style/fontSize",
-      "style/fontStyle",
-      "style/fontWeight",
-      "style/textDecoration",
-      "style/verticalAlign"
+      AnnotationConstants.STYLE_BG_COLOR,
+      AnnotationConstants.STYLE_COLOR,
+      AnnotationConstants.STYLE_FONT_FAMILY,
+      AnnotationConstants.STYLE_FONT_SIZE,
+      AnnotationConstants.STYLE_FONT_STYLE,
+      AnnotationConstants.STYLE_FONT_WEIGHT,
+      AnnotationConstants.STYLE_TEXT_DECORATION,
+      AnnotationConstants.STYLE_VERTICAL_ALIGN
     );
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/13f4cb2a/src/org/waveprotocol/wave/client/wavepanel/impl/toolbar/LinkerHelper.java
----------------------------------------------------------------------
diff --git 
a/src/org/waveprotocol/wave/client/wavepanel/impl/toolbar/LinkerHelper.java 
b/src/org/waveprotocol/wave/client/wavepanel/impl/toolbar/LinkerHelper.java
index 97e9064..f7956dd 100644
--- a/src/org/waveprotocol/wave/client/wavepanel/impl/toolbar/LinkerHelper.java
+++ b/src/org/waveprotocol/wave/client/wavepanel/impl/toolbar/LinkerHelper.java
@@ -28,6 +28,7 @@ import 
org.waveprotocol.wave.client.doodad.link.Link.InvalidLinkException;
 import org.waveprotocol.wave.client.editor.EditorContext;
 import org.waveprotocol.wave.client.editor.util.EditorAnnotationUtil;
 import org.waveprotocol.wave.client.wavepanel.impl.toolbar.i18n.LinkerMessages;
+import org.waveprotocol.wave.model.conversation.AnnotationConstants;
 import org.waveprotocol.wave.model.document.util.DocHelper;
 import org.waveprotocol.wave.model.document.util.FocusedRange;
 import org.waveprotocol.wave.model.document.util.Range;
@@ -56,7 +57,7 @@ public class LinkerHelper {
       Range rg = range.asRange();
       String text = DocHelper.getText(editor.getDocument(), rg.getStart(), 
rg.getEnd());
       String linkAnnotationValue = Link.normalizeLink(text);
-      EditorAnnotationUtil.setAnnotationOverSelection(editor, Link.KEY, 
linkAnnotationValue);
+      EditorAnnotationUtil.setAnnotationOverSelection(editor, 
AnnotationConstants.LINK_PREFIX, linkAnnotationValue);
     } catch (InvalidLinkException e) {
       String rawLinkValue =
           Window.prompt(messages.enterLink(), 
WaveRefConstants.WAVE_URI_PREFIX);
@@ -66,7 +67,7 @@ public class LinkerHelper {
       }
       try {
         String linkAnnotationValue = Link.normalizeLink(rawLinkValue);
-        EditorAnnotationUtil.setAnnotationOverSelection(editor, Link.KEY, 
linkAnnotationValue);
+        EditorAnnotationUtil.setAnnotationOverSelection(editor, 
AnnotationConstants.LINK_PREFIX, linkAnnotationValue);
       } catch (InvalidLinkException e2) {
         Window.alert(e2.getLocalizedMessage());
       }

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/13f4cb2a/src/org/waveprotocol/wave/model/conversation/AnnotationConstants.java
----------------------------------------------------------------------
diff --git 
a/src/org/waveprotocol/wave/model/conversation/AnnotationConstants.java 
b/src/org/waveprotocol/wave/model/conversation/AnnotationConstants.java
new file mode 100644
index 0000000..3fe9284
--- /dev/null
+++ b/src/org/waveprotocol/wave/model/conversation/AnnotationConstants.java
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.waveprotocol.wave.model.conversation;
+
+/**
+ * Constants useful for annotations
+ * Refer to the conversation specification for more detailed information.
+ */
+public class AnnotationConstants {
+  // Style
+
+  /** Prefix for style annotations (follows CSS). */
+  public static final String STYLE_PREFIX = "style";
+
+  public static final String STYLE_BG_COLOR = STYLE_PREFIX + 
"/backgroundColor";
+
+  public static final String STYLE_COLOR = STYLE_PREFIX + "/color";
+
+  public static final String STYLE_FONT_FAMILY = STYLE_PREFIX + "/fontFamily";
+
+  public static final String STYLE_FONT_SIZE = STYLE_PREFIX + "/fontSize";
+
+  public static final String STYLE_FONT_STYLE = STYLE_PREFIX + "/fontStyle";
+
+  public static final String STYLE_FONT_WEIGHT = STYLE_PREFIX + "/fontWeight";
+
+  public static final String STYLE_TEXT_DECORATION = STYLE_PREFIX + 
"/textDecoration";
+
+  public static final String STYLE_VERTICAL_ALIGN = STYLE_PREFIX + 
"/verticalAlign";
+
+  // User
+
+  /** Prefix for user annotations. */
+  public static final String USER_PREFIX = "user";
+
+  /** The range of text selected by the user. */
+  public static final String USER_RANGE = USER_PREFIX + "/r/";
+
+  /** The user's selection focus, always extends to the document end. */
+  public static final String USER_END = USER_PREFIX + "/e/";
+
+  /** User activity annotation, always covers the whole document.  */
+  public static final String USER_DATA = USER_PREFIX + "/d/";
+
+  // Links
+
+  /** Prefix for link annotations. */
+  public static final String LINK_PREFIX = "link";
+
+  /** Used to denote automatically created links. (e.g. Linky) */
+  public static final String LINK_AUTO = LINK_PREFIX + "/auto";
+
+  /** Denotes a user-created link. */
+  public static final String LINK_MANUAL = LINK_PREFIX + "/manual";
+
+ /** A link to another wave */
+  public static final String LINK_WAVE = LINK_PREFIX + "/wave";
+
+  // Other
+
+  /** Prefix for spelling annotations. (e.g. Spelly) */
+  public static final String SPELLY_PREFIX = "spell";
+
+  /** Prefix for language annotations. */
+  public static final String LANGUAGE_PREFIX = "lang";
+
+  /** Prefix for translation annotations. (e.g. Rosy) */
+  public static final String ROSY_PREFIX = "tr";
+
+  /** An automatically translated section. */
+  public static final String ROSY_AUTO = ROSY_PREFIX + "/1";
+}

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/13f4cb2a/src/org/waveprotocol/wave/model/operation/wave/WorthyChangeChecker.java
----------------------------------------------------------------------
diff --git 
a/src/org/waveprotocol/wave/model/operation/wave/WorthyChangeChecker.java 
b/src/org/waveprotocol/wave/model/operation/wave/WorthyChangeChecker.java
index d049c2e..a41f813 100644
--- a/src/org/waveprotocol/wave/model/operation/wave/WorthyChangeChecker.java
+++ b/src/org/waveprotocol/wave/model/operation/wave/WorthyChangeChecker.java
@@ -21,6 +21,7 @@ package org.waveprotocol.wave.model.operation.wave;
 
 import com.google.common.annotations.VisibleForTesting;
 
+import org.waveprotocol.wave.model.conversation.AnnotationConstants;
 import org.waveprotocol.wave.model.document.operation.AnnotationBoundaryMap;
 import org.waveprotocol.wave.model.document.operation.Attributes;
 import org.waveprotocol.wave.model.document.operation.AttributesUpdate;
@@ -41,14 +42,6 @@ public class WorthyChangeChecker {
 
   private WorthyChangeChecker() {}
 
-  // NOTE(anorth): These constants are duplicated from internal models.
-  // Keep them in sync.
-  private static final String SELECTION_ANNOTATION_PREFIX = "user/";
-  private static final String LINKY_ANNOTATION = "link/auto";
-  private static final String SPELLY_ANNOTATION = "spell";
-  private static final String LANGUAGE_ANNOTATION = "lang";
-  private static final String ROSY_ANNOTATION = "tr/1";
-
   // Copied from Blips.
   @VisibleForTesting
   public static final String THREAD_INLINE_ANCHOR_TAGNAME = "reply";
@@ -138,11 +131,11 @@ public class WorthyChangeChecker {
         String oldValue = map.getOldValue(i);
         String newValue = map.getNewValue(i);
         if (!ValueUtils.equal(oldValue, newValue) &&
-            !key.startsWith(SELECTION_ANNOTATION_PREFIX) &&
-            !key.equals(SPELLY_ANNOTATION) &&
-            !key.equals(LINKY_ANNOTATION) &&
-            !key.equals(ROSY_ANNOTATION) &&
-            !key.equals(LANGUAGE_ANNOTATION)) {
+            !key.startsWith(AnnotationConstants.USER_PREFIX) &&
+            !key.startsWith(AnnotationConstants.SPELLY_PREFIX) &&
+            !key.startsWith(AnnotationConstants.LINK_PREFIX) &&
+            !key.startsWith(AnnotationConstants.ROSY_PREFIX) &&
+            !key.startsWith(AnnotationConstants.LANGUAGE_PREFIX)) {
           throw TRUE;
         }
       }

http://git-wip-us.apache.org/repos/asf/incubator-wave/blob/13f4cb2a/src/org/waveprotocol/wave/model/richtext/RichTextMutationBuilder.java
----------------------------------------------------------------------
diff --git 
a/src/org/waveprotocol/wave/model/richtext/RichTextMutationBuilder.java 
b/src/org/waveprotocol/wave/model/richtext/RichTextMutationBuilder.java
index 935c737..2a2d294 100644
--- a/src/org/waveprotocol/wave/model/richtext/RichTextMutationBuilder.java
+++ b/src/org/waveprotocol/wave/model/richtext/RichTextMutationBuilder.java
@@ -19,6 +19,7 @@
 
 package org.waveprotocol.wave.model.richtext;
 
+import org.waveprotocol.wave.model.conversation.AnnotationConstants;
 import org.waveprotocol.wave.model.document.ReadableDocument;
 import org.waveprotocol.wave.model.document.operation.Attributes;
 import org.waveprotocol.wave.model.document.operation.Nindo;
@@ -54,31 +55,19 @@ public class RichTextMutationBuilder {
 
   private static final String INDENT_ATTR = "i";
 
-  private static final String STYLE_KEY_FONT_WEIGHT = "style/fontWeight";
-
-  private static final String STYLE_KEY_FONT_STYLE = "style/fontStyle";
-
-  private static final String STYLE_KEY_TEXT_DECORATION = 
"style/textDecoration";
-
-  private static final String STYLE_KEY_COLOR = "style/color";
-
-  private static final String STYLE_KEY_BG_COLOR = "style/backgroundColor";
-
-  private static final String STYLE_KEY_FONT_FAMILY = "style/fontFamily";
-
   /** Default annotation values for certain keys */
   private static final StringMap<ReadableStringSet> defaultAnnotations =
       CollectionUtils.createStringMap();
 
   static {
-    defaultAnnotations.put(STYLE_KEY_TEXT_DECORATION, 
CollectionUtils.newStringSet("none"));
-    defaultAnnotations.put(STYLE_KEY_FONT_WEIGHT, 
CollectionUtils.newStringSet("normal"));
-    defaultAnnotations.put(STYLE_KEY_FONT_STYLE, 
CollectionUtils.newStringSet("normal"));
-    defaultAnnotations.put(STYLE_KEY_BG_COLOR, 
CollectionUtils.newStringSet("initial",
+    defaultAnnotations.put(AnnotationConstants.STYLE_TEXT_DECORATION, 
CollectionUtils.newStringSet("none"));
+    defaultAnnotations.put(AnnotationConstants.STYLE_FONT_WEIGHT, 
CollectionUtils.newStringSet("normal"));
+    defaultAnnotations.put(AnnotationConstants.STYLE_FONT_STYLE, 
CollectionUtils.newStringSet("normal"));
+    defaultAnnotations.put(AnnotationConstants.STYLE_BG_COLOR, 
CollectionUtils.newStringSet("initial",
         "transparent"));
     // Default font family and color are dependent on user-agent settings, but
     // make up a default color anyway
-    defaultAnnotations.put(STYLE_KEY_COLOR, 
CollectionUtils.newStringSet("black"));
+    defaultAnnotations.put(AnnotationConstants.STYLE_COLOR, 
CollectionUtils.newStringSet("black"));
   }
 
   /** This map records all annotations currently started. */
@@ -244,46 +233,46 @@ public class RichTextMutationBuilder {
         }
         break;
       case STYLE_FONT_WEIGHT_START:
-        startAnnotation(builder, STYLE_KEY_FONT_WEIGHT, tokenizer.getData());
+        startAnnotation(builder, AnnotationConstants.STYLE_FONT_WEIGHT, 
tokenizer.getData());
         break;
       case STYLE_FONT_WEIGHT_END:
-        endAnnotation(builder, STYLE_KEY_FONT_WEIGHT);
+        endAnnotation(builder, AnnotationConstants.STYLE_FONT_WEIGHT);
         break;
       case STYLE_FONT_STYLE_START:
-        startAnnotation(builder, STYLE_KEY_FONT_STYLE, tokenizer.getData());
+        startAnnotation(builder, AnnotationConstants.STYLE_FONT_STYLE, 
tokenizer.getData());
         break;
       case STYLE_FONT_STYLE_END:
-        endAnnotation(builder, STYLE_KEY_FONT_STYLE);
+        endAnnotation(builder, AnnotationConstants.STYLE_FONT_STYLE);
         break;
       case STYLE_TEXT_DECORATION_START:
-        startAnnotation(builder, STYLE_KEY_TEXT_DECORATION, 
tokenizer.getData());
+        startAnnotation(builder, AnnotationConstants.STYLE_TEXT_DECORATION, 
tokenizer.getData());
         break;
       case STYLE_TEXT_DECORATION_END:
-        endAnnotation(builder, STYLE_KEY_TEXT_DECORATION);
+        endAnnotation(builder, AnnotationConstants.STYLE_TEXT_DECORATION);
         break;
       case STYLE_COLOR_START:
-        startAnnotation(builder, STYLE_KEY_COLOR, tokenizer.getData());
+        startAnnotation(builder, AnnotationConstants.STYLE_COLOR, 
tokenizer.getData());
         break;
       case STYLE_COLOR_END:
-        endAnnotation(builder, STYLE_KEY_COLOR);
+        endAnnotation(builder, AnnotationConstants.STYLE_COLOR);
         break;
       case STYLE_BG_COLOR_START:
-        startAnnotation(builder, STYLE_KEY_BG_COLOR, tokenizer.getData());
+        startAnnotation(builder, AnnotationConstants.STYLE_BG_COLOR, 
tokenizer.getData());
         break;
       case STYLE_BG_COLOR_END:
-        endAnnotation(builder, STYLE_KEY_BG_COLOR);
+        endAnnotation(builder, AnnotationConstants.STYLE_BG_COLOR);
         break;
       case STYLE_FONT_FAMILY_START:
-        startAnnotation(builder, STYLE_KEY_FONT_FAMILY, tokenizer.getData());
+        startAnnotation(builder, AnnotationConstants.STYLE_FONT_FAMILY, 
tokenizer.getData());
         break;
       case STYLE_FONT_FAMILY_END:
-        endAnnotation(builder, STYLE_KEY_FONT_FAMILY);
+        endAnnotation(builder, AnnotationConstants.STYLE_FONT_FAMILY);
         break;
       case LINK_START:
-        startAnnotation(builder, "link/manual", tokenizer.getData());
+        startAnnotation(builder, AnnotationConstants.LINK_MANUAL, 
tokenizer.getData());
         break;
       case LINK_END:
-        endAnnotation(builder, "link/manual");
+        endAnnotation(builder, AnnotationConstants.LINK_MANUAL);
         break;
       case UNORDERED_LIST_START:
       case ORDERED_LIST_START:

Reply via email to