org.elkoserver.server.context.mods
Class NoteMaker

java.lang.Object
  extended by org.elkoserver.server.context.Mod
      extended by org.elkoserver.server.context.mods.NoteMaker
All Implemented Interfaces:
Cloneable, DispatchTarget, Encodable, ContextMod, GeneralMod, ItemMod, UserMod

public class NoteMaker
extends Mod
implements GeneralMod

Mod to enable creation of notes. Notes are items with the Note mod attached. This mod is generally attached to a context, but this is not required.


Constructor Summary
NoteMaker(StyleOptions styleOptions)
          JSON-driven constructor.
 
Method Summary
 boolean allowedStyle(StyleDesc style)
          Test if this mod's style options are compatible with particular style settings.
 JSONLiteral encode(EncodeControl control)
          Encode this mod for transmission or persistence.
 void makenote(User from, OptString into, int left, int top, int width, int height, String text, StyleDesc style)
          Message handler for the 'makenote' message.
 
Methods inherited from class org.elkoserver.server.context.Mod
attachTo, clone, context, ensureHolding, ensureInContext, ensureReachable, ensureSameContext, ensureSameUser, holder, isEphemeral, markAsChanged, markAsEphemeral, object
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NoteMaker

@JSONMethod(value="styles")
public NoteMaker(StyleOptions styleOptions)
JSON-driven constructor.

Parameters:
styleOptions - Style options permitted in notes created by this mod.
Method Detail

allowedStyle

public boolean allowedStyle(StyleDesc style)
Test if this mod's style options are compatible with particular style settings.

Parameters:
style - The style to test.
Returns:
true if 'style' is acceptable to this NoteMaker, false if not.

encode

public JSONLiteral encode(EncodeControl control)
Encode this mod for transmission or persistence.

Specified by:
encode in interface Encodable
Parameters:
control - Encode control determining what flavor of encoding should be done.
Returns:
a JSON literal representing this mod.

makenote

@JSONMethod(value={"into","left","top","width","height","text","?style"})
public void makenote(User from,
                                     OptString into,
                                     int left,
                                     int top,
                                     int width,
                                     int height,
                                     String text,
                                     StyleDesc style)
              throws MessageHandlerException
Message handler for the 'makenote' message.

This is a request from a client to create a new note. If the creation operation is successful, a 'make' message will be broadcast to the context, describing the new note object.

recv: { to:REF, op:"makeNote", into:optREF, left:INT, top:INT, width:INT, height:INT, text:STR, style:optSTYLE }
send: { to:intoREF, op:"make", ... }

Parameters:
from - The user who sent the message.
into - Container into which the new note object should be placed (optional, defaults to the context).
left - X coordinate of new object relative to container.
top - Y coordinate of new object relative to container.
width - Width of note display.
height - Height of note display.
text - The text to show.
style - Style information for 'text' (optional, defaults to unstyled text).
Throws:
MessageHandlerException - if 'from' is not in the same context as this mod or if invalid style information is provided or if the proposed container is not valid.