BlocklyEvent

public abstract class BlocklyEvent extends Object
Known Direct Subclasses

Base class for all Blockly events.

Nested Class Summary

@interface BlocklyEvent.ChangeElement  
class BlocklyEvent.ChangeEvent Event fired when a property of a block changes. 
class BlocklyEvent.CreateEvent Event fired when a block is added to the workspace, possibly containing other child blocks and next blocks. 
class BlocklyEvent.DeleteEvent Event fired when a block is removed from the workspace. 
@interface BlocklyEvent.EventType  
class BlocklyEvent.MoveEvent Event fired when a block is moved on the workspace, or its parent connection is changed. 
@interface BlocklyEvent.UIElement  
class BlocklyEvent.UIEvent Event class for user interface related actions, including selecting blocks, opening/closing the toolbox or trash, and changing toolbox categories. 

Constant Summary

String ELEMENT_CATEGORY
String ELEMENT_CLICK
String ELEMENT_COLLAPSED
String ELEMENT_COMMENT
String ELEMENT_COMMENT_OPEN
String ELEMENT_DISABLED
String ELEMENT_FIELD
String ELEMENT_INLINE
String ELEMENT_MUTATE
String ELEMENT_MUTATOR_OPEN
String ELEMENT_SELECTED
String ELEMENT_TRASH
String ELEMENT_WARNING_OPEN
String TYPENAME_CHANGE
String TYPENAME_CREATE
String TYPENAME_DELETE
String TYPENAME_MOVE
String TYPENAME_UI
int TYPE_ALL
int TYPE_CHANGE
int TYPE_CREATE
int TYPE_DELETE
int TYPE_MOVE
int TYPE_UI
String WORKSPACE_ID_TOOLBOX
String WORKSPACE_ID_TRASH

Field Summary

protected final String mBlockId
protected String mGroupId
protected final int mTypeId
protected final String mWorkspaceId

Protected Constructor Summary

BlocklyEvent(int typeId, String workspaceId, String groupId, String blockId)
Base constructor for all BlocklyEvents.
BlocklyEvent(int typeId, JSONObject json)
Constructs BlocklyEvent with base attributes assigned from json.

Public Method Summary

static BlocklyEvent
fromJson(JSONObject json)
static BlocklyEvent
fromJson(String json)
String
String
int
String
String
getWorkspaceId()
This is the id of the "workspace", or similar container.
static void
log(String loggingTag, String prefix, List<BlocklyEvent> eventGroup)
Helper method for logging event groups.
String

Protected Method Summary

void
setGroupId(String groupId)
abstract void
writeJsonAttributes(JSONStringer out)

Inherited Method Summary

Constants

public static final String ELEMENT_CATEGORY

Constant Value: "category"

public static final String ELEMENT_CLICK

Constant Value: "click"

public static final String ELEMENT_COLLAPSED

Constant Value: "collapsed"

public static final String ELEMENT_COMMENT

Constant Value: "comment"

public static final String ELEMENT_COMMENT_OPEN

Constant Value: "commentOpen"

public static final String ELEMENT_DISABLED

Constant Value: "disabled"

public static final String ELEMENT_FIELD

Constant Value: "field"

public static final String ELEMENT_INLINE

Constant Value: "inline"

public static final String ELEMENT_MUTATE

Constant Value: "mutate"

public static final String ELEMENT_MUTATOR_OPEN

Constant Value: "mutatorOpen"

public static final String ELEMENT_SELECTED

Constant Value: "selected"

public static final String ELEMENT_TRASH

Constant Value: "trashOpen"

public static final String ELEMENT_WARNING_OPEN

Constant Value: "warningOpen"

public static final String TYPENAME_CHANGE

Constant Value: "change"

public static final String TYPENAME_CREATE

Constant Value: "create"

public static final String TYPENAME_DELETE

Constant Value: "delete"

public static final String TYPENAME_MOVE

Constant Value: "move"

public static final String TYPENAME_UI

Constant Value: "ui"

public static final int TYPE_ALL

Constant Value: 31

public static final int TYPE_CHANGE

Constant Value: 4

public static final int TYPE_CREATE

Constant Value: 1

public static final int TYPE_DELETE

Constant Value: 2

public static final int TYPE_MOVE

Constant Value: 8

public static final int TYPE_UI

Constant Value: 16

public static final String WORKSPACE_ID_TOOLBOX

Constant Value: "TOOLBOX"

public static final String WORKSPACE_ID_TRASH

Constant Value: "TRASH"

Fields

protected final String mBlockId

protected String mGroupId

protected final int mTypeId

protected final String mWorkspaceId

Protected Constructors

protected BlocklyEvent (int typeId, String workspaceId, String groupId, String blockId)

Base constructor for all BlocklyEvents.

Parameters
typeId The BlocklyEvent.EventType.
workspaceId The id of the Blockly workspace, or similar block container, if any.
groupId The id string of the event group. Usually null for local events (assigned later); non-null for remote events.
blockId The id string of the block affected. Null for a few event types (e.g., toolbox category).

protected BlocklyEvent (int typeId, JSONObject json)

Constructs BlocklyEvent with base attributes assigned from json.

Parameters
typeId The type of the event. Assumed to match ERROR(/#JSON_TYPE) in json.
json The JSON object with event attribute values.
Throws
JSONException

Public Methods

public static BlocklyEvent fromJson (JSONObject json)

Parameters
json
Throws
JSONException

public static BlocklyEvent fromJson (String json)

Parameters
json
Throws
JSONException

public String getBlockId ()

Returns
  • The id of the primary or root affected block.

public String getGroupId ()

Returns
  • The identifier for the group of related events.

public int getTypeId ()

Returns
  • The type identifier for this event.

public String getTypeName ()

Returns
  • The JSON type identifier string for this event.

public String getWorkspaceId ()

This is the id of the "workspace", or similar container. This may refer to a getId() workspace's id}, a toolbox (WORKSPACE_ID_TOOLBOX), or the trash (WORKSPACE_ID_TRASH).

Returns
  • The identifier for the root container where this event occured.

public static void log (String loggingTag, String prefix, List<BlocklyEvent> eventGroup)

Helper method for logging event groups.

Parameters
loggingTag The tag for this log message.
prefix A string to prefix the event group.
eventGroup The events received in one update.

public String toJsonString ()

Throws
JSONException

Protected Methods

protected void setGroupId (String groupId)

Parameters
groupId

protected abstract void writeJsonAttributes (JSONStringer out)

Parameters
out
Throws
JSONException