JMakiWidgetDoc < Projects < TWiki
|
TWiki . Projects . JMakiWidgetDoc
|
-- Main.carlavmott - 25 Jan 2008
This page describes the format of the widget.json file that is provided with the wrapped widgets. This file is read by tools such as NetBeans IDE and the widget documentation generator in the widget project (widgets.dev.java.net). Below is a sample of a widget.json file.
{
'name': 'Tree',
'type': 'yahoo',
'version': '1.0',
'jmakiVersion': '1.0',
'image': 'images/yahoo-tree.jpg',
'description': 'This widget is a dynamic tree that can easily be
configured.',
'docs' : [
'modelURL' : 'http://wiki.java.net/bin/view/Projects/jMakiTreeModel',
'jsDoc' : 'http://jmaki.dev.java.net/jsdoc/yahoo_tree
'usageDoc' : 'docs/index.html'
],
'args': [
],
'value': {'required':'true',
'type': 'OBJECT', 'defaultValue':{
'root':{id: 'bar', 'title': 'Default Yahoo Tree Root Node',
'expanded': true,
'children': [
{'title':'Yahoo Node 1.1', 'onclick': {'url':'foo'}},
{'title':'Yahoo Node 1.2', 'children': [{'title':'Node 3.1'}]}
]
}
}
},
'config' : {
'type' :
{ 'id' : 'yahoo.tree',
'libs' : [
'../resources/libs/yahoo/v2.4.1/yahoo/yahoo-min.js',
'../resources/libs/yahoo/v2.4.1/event/event-min.js',
'../resources/libs/yahoo/v2.4.1/treeview/treeview-min.js'
],
'styles' : [
'../resources/libs/yahoo/v2.4.1/treeview/assets/skins/sam/treeview.css'
],
'resources' : [
'../resources/libs/yahoo/v2.4.1/treeview/assets'
]
}
},
'topicInfo': {
'defaultPublish' : '/jmaki/yahoo/tree',
'defaultSubscribe' : ['/jmaki/yahoo/tree', '/tree'],
'commands' : [
{'name' : 'expand',
'payload' : '{'targetId' : 'bar'}',
'description' : 'expand the node whose id is the same as targetId property'},
{ 'name' : 'collapse',
'description' : 'collapse tree whose id is the same as targetId property'},
{ 'name' : 'select',
'description' : 'select the node whose id is the same as targetId property'},
],
'events' : [
{'name' : 'onClick',
'description' : 'publish the value of the selected node'}
]
}
}
Using JSON schema to describe widget.json
{
"description" : "jMaki Widget.json",
"type":"object",
"properties": {
"name" : {"type" : "string"},
"type": {"type" : "string"},
"version": {"type" : "string"},
"jmakiVersion": {"type" : "string"},
"image": {"type" : "string"},
"description": {"type" : "string"},
"docs": {"type": "array",
"items": "object",
"properites": {
"modelURL" : {"type":"string"},
"jsDoc":{"type":"string", "optional" : true},
"usageDoc":{"type":"string"}
}
},
"args": {"type": "array", "optional":true },
"value": {"type": "object", "optional":true,
"properties": {
"type":{"type":"string"},
"required":{"type":"boolean"},
"defaultValue":{"type":"object"}
}
},
"config":{"type": "object",
"properties": {
"type": {"type": "object",
"properties": {
"id": {"type": "string"},
"lib": {"type":"array", "optional":true},
"style":{"type":"array", "optional":true},
"resources":{"type":"array"}
}
}
}
},
"topicInfo": {
"defaultPublish" : {"type": "string"},
"defaultSubscribe": { "type": ["string" | "array"]},
"commands": {"type": "object",
"properties": {
"name": {"type": "string" }
}
},
"payload": {"type": "object",
"properties": {
"targetId": {"type": "string" },
"value" : {"type" : "object"}
}
},
"description": {"type":"string"},
"events" : {"type": "string" }
}
}
}
The specific JSON schema for the topicInfo sections is
topicInfo": {
"defaultPublish" : {"type": "string"},
"defaultSubscribe": { "type": ["string" | "array"]},
"commands": {"type": "object",
"properties": {
"name": {"type": "string",
"options": [
{"value": "expandNode"},
{"value": "collapseNode"},
{"value": "removeNode"},
{"value": "expandAll"},
{"value": "collapseAll"},
{"value": "addNodes"},
{"value": "removeChildren"}
]
}
}
},
"payload": {"type": "object",
"properties": {
"targetId": {"type": "string" },
"value" : {"type" : "object", optional}
}
}
},
"description": {"type":"string"},
"events" : {"type": "string",
"options" : [
{"value": "onClick"},
{"value": "onCollapse"},
{"value": "onExpand"}
]
}
}
}
}
----- Revision r9 - 05 Jun 2008 - 23:58:27 - Main.carlavmott
|