|
Multivalent API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmultivalent.VObject
multivalent.Behavior
multivalent.std.ClipProvenance
Augment selection for clipboard with source URL. (Would like to augment with author and title, but that sort of metadata usually isn't available.) Elaborately commented to serve as a simple example of translating Multivalent protocols into Java methods.
for another elaborately commented behavior.
Field Summary | |
---|---|
static java.lang.String |
MENU_CATEGORY
Menu category for pasting-related options ("AuxSelect"). |
static java.lang.String |
MSG_SET
Augment pasted text with provenance or not. |
Fields inherited from class multivalent.Behavior |
---|
ATTR_BEHAVIOR, name_ |
Fields inherited from class multivalent.VObject |
---|
attr_ |
Constructor Summary | |
---|---|
ClipProvenance()
|
Method Summary | |
---|---|
boolean |
clipboardAfter(java.lang.StringBuffer sb,
Node node)
The clipboard protocol builds up the text in a StringBuffer. |
boolean |
semanticEventAfter(SemanticEvent se,
java.lang.String msg)
Catch the "setProvenance" event sent in semanticEventBefore, assuming it hasn't been short-circuited by some other behavior. |
boolean |
semanticEventBefore(SemanticEvent se,
java.lang.String msg)
When the Clipboard menu announces it is being built by sending a semantic event with message VMenu.MSG_CREATE_EDIT and the node of the menu root in the out field,
add an entry. |
Methods inherited from class multivalent.Behavior |
---|
buildAfter, buildBefore, checkRep, clipboardBefore, createUI, destroy, eventAfter, eventBefore, formatAfter, formatBefore, getBrowser, getDocument, getInstance, getInstance, getLayer, getLogger, getName, getPreference, getRoot, isEditable, paintAfter, paintBefore, putPreference, redo, restore, restoreChildren, save, setName, toString, undo |
Methods inherited from class multivalent.VObject |
---|
attrEntrySetIterator, attrKeysIterator, clearAttributes, getAttr, getAttr, getAttributes, getGlobal, getValue, hasAttributes, putAttr, removeAttr, setAttributes |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String MENU_CATEGORY
public static final java.lang.String MSG_SET
"setProvenance": arg= bollean or null
to toggle.
Constructor Detail |
---|
public ClipProvenance()
Method Detail |
---|
public boolean semanticEventBefore(SemanticEvent se, java.lang.String msg)
VMenu.MSG_CREATE_EDIT
and the node of the menu root in the out field,
add an entry. The entry uses Behavior.createUI(String, String, Object, INode, String, boolean)
to create a "checkbox" widget with title "Provenance",
which when invoked will execute the script which sends a semantic event named "setProvenance",
added to the menu in category "AuxSelect", and which is not disabled (diabled flag = false).
semanticEventBefore
in class Behavior
public boolean semanticEventAfter(SemanticEvent se, java.lang.String msg)
This behavior has its effect (if it's active) during the clipboard protocol,
but that protocol is based on a tree walk, so if it is to know of the tree
walk, it has to hook into the tree. So catch the Document.MSG_OPENED
semantic
event and hook onto its document field. It registers interest on the root of the document
in order to pick up clipboard extractions everywhere in the tree.
It's common for a behavior to register interest at the root as opposed to
smaller subtrees.
semanticEventAfter
in class Behavior
public boolean clipboardAfter(java.lang.StringBuffer sb, Node node)
clipboardAfter
in class Behavior
|
Multivalent API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |