summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-01-30 22:30:10 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2011-01-30 22:30:10 +0000
commit6afef449a6560d469102ab0298d4cc925d76aa0f (patch)
tree7217fb00927065b2b1b80978cefb6a0488deddfd /sca-cpp/trunk/modules/edit/htdocs/graph/graph.html
parentdca2f20846323ff20758e76c9c90dae4f1dc325b (diff)
Add composite save function, improve UI a bit and some script cleanup and documentation.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1065409 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/graph/graph.html39
1 files changed, 29 insertions, 10 deletions
diff --git a/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html b/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html
index 5eb8c6cc1e..b078901a29 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/graph/graph.html
@@ -31,7 +31,7 @@
<body>
<table style="position: absolute; top: 0px; left: 0px;" width="100%">
-<tr><th style="width: 338px;">Palette</th><th style="padding-top: 0px; padding-bottom: 0px;"><span>App</span><span style="position: absolute; top: 2px; right: 8px;"><input type="button" id="saveButton" style="font-weight: bold;" Value="Save"/></span></th></tr>
+<tr><th style="width: 338px;">Palette</th><th style="padding-top: 0px; padding-bottom: 0px;"><span>Composition</span><span style="position: absolute; top: 2px; right: 8px;"><input type="button" id="saveButton" style="font-weight: bold;" Value="Save"/></span></th></tr>
</table>
<script type="text/javascript">
@@ -43,11 +43,14 @@ var apps = sca.reference(editWidget, "apps");
//rconsole = sca.defun(sca.reference(editWidget, "log"), "log");
/**
- * Return the current app name.
+ * The current app name.
*/
-function appname() {
- return ui.queryParams()['app'];
-}
+var appname = ui.queryParams()['app'];
+
+/**
+ * The current app composite.
+ */
+var composite;
/**
* Return the composite in an ATOM entry.
@@ -65,7 +68,8 @@ function getapp(name, g) {
if (isNil(name))
return;
apps.get(name, function(doc) {
- appendNodes(graph.composite(atomcomposite(doc), graph.mkpath().move(350,0)), g);
+ composite = atomcomposite(doc);
+ graph.edit(composite, graph.composite(composite, graph.mkpath().move(350,0)), g);
});
}
@@ -77,7 +81,7 @@ function getpalette(name, g, bg, palette, gpalettes) {
return;
palettes.get(name, function(doc) {
gpalettes[name] = graph.composite(atomcomposite(doc), graph.mkpath().move(150,0));
- appendNodes(gpalettes[name], name == spalette? g : bg);
+ graph.display(gpalettes[name], name == spalette? g : bg);
});
}
@@ -87,16 +91,31 @@ function getpalette(name, g, bg, palette, gpalettes) {
*/
function installpalette(name, pos, g, bg, palette, gpalettes) {
var b = graph.mkbutton(name, pos);
- appendNodes(mklist(b), g);
+ graph.display(mklist(b), g);
b.onclick = function() {
+
// Display the selected palette
spalette = name;
for (var pn in gpalettes)
- appendNodes(gpalettes[pn], pn == spalette? g : bg);
+ graph.display(gpalettes[pn], pn == spalette? g : bg);
}
getpalette(name, g, bg, palette, gpalettes);
}
+/**
+ * Save the current edited page.
+ */
+$('saveButton').onclick = function(e) {
+
+ // Update the page ATOM entry
+ var compxml = writeXML(composite, false);
+ var entry = '<entry xmlns="http://www.w3.org/2005/Atom">' +
+ '<title type="text">' + appname + '</title><id>' + appname + '</id><content type="application/xml"><item>' +
+ compxml + '</item></content></entry>';
+ apps.put(appname, entry, function() {
+ });
+};
+
// Create editor graph area
var g = graph.mkgraph(graph.mkpath().move(0,50));
var bg = graph.mkgroup(graph.mkpath());
@@ -111,7 +130,7 @@ installpalette('social', graph.mkpath().move(0,220), g, bg, spalette, gpalettes)
installpalette('sensors', graph.mkpath().move(0,290), g, bg, spalette, gpalettes);
// Get and display the current app
-getapp(appname(), g);
+getapp(appname, g);
</script>
</body>