Revision: 3974 http://vexi.svn.sourceforge.net/vexi/?rev=3974&view=rev Author: clrg Date: 2010-12-20 16:56:02 +0000 (Mon, 20 Dec 2010)
Log Message: ----------- Fix [rewrite] broken biscuits demo (needs further improvement) Modified Paths: -------------- trunk/org.vexi-vexi.demo/src_main/org/vexi/demo/feature/biscuits.t Modified: trunk/org.vexi-vexi.demo/src_main/org/vexi/demo/feature/biscuits.t =================================================================== --- trunk/org.vexi-vexi.demo/src_main/org/vexi/demo/feature/biscuits.t 2010-12-20 16:54:55 UTC (rev 3973) +++ trunk/org.vexi-vexi.demo/src_main/org/vexi/demo/feature/biscuits.t 2010-12-20 16:56:02 UTC (rev 3974) @@ -7,74 +7,84 @@ static.category = "Core Features"; <lay:pad orient="vertical" padding="10"> + <ui:box height="10" /> + <ui:box text="Local preferences stored using Vexi biscuits" align="bottomleft" shrink="true" /> + <ui:box height="20"/> <ui:box> - <ui:box> - <ui:box text="Preferences (override Persistent prefs)" align="bottomleft" shrink="true"/> - <ui:box text="Persistent Preferences" align="bottomleft" shrink="true"/> + <list id="prefs" fill="white" /> + <ui:box orient="vertical"> + <ui:box vshrink="true"> + <ui:box width="40" /> + <ui:box orient="vertical" hshrink="true"> + <ui:box align="right" text="Name " /> + <ui:box align="right" text="Value " /> + </ui:box> + <ui:box orient="vertical" vshrink="true"> + <textfield id="paramname" vshrink="true" /> + <textfield id="paramvalue" vshrink="true" /> + </ui:box> + <ui:box width="40" /> + </ui:box> + <button id="set" text="Set Preference" vshrink="true" /> + <ui:box /> </ui:box> - <ui:box> - <scrollpane align="topleft" fill="white" autohidehorizontal="true" autohidevertical="true"> - <list id="prefs" vshrink="true" fill="white"/> - </scrollpane> - <scrollpane align="topleft" fill="white" autohidehorizontal="true" autohidevertical="true"> - <list id="persistprefs" vshrink="true" fill="white"/> - </scrollpane> - </ui:box> </ui:box> - <ui:box height="20"/> + var prefs; - <ui:box orient="vertical"> - <ui:box> - <ui:box text="name" align="bottomleft" shrink="true"/> - <textfield id="paramname" vshrink="true"/> - </ui:box> - <ui:box> - <ui:box text="value" align="bottomleft" shrink="true"/> - <textfield id="paramvalue" vshrink="true"/> - </ui:box> - </ui:box> - <button text="Set Preference" id="set"/> - - thisbox.loadParams = function() { - var parms = vexi.prefs.getAllPreferences(); - fillList($prefs, parms); - var prefs = vexi.prefs.getPersistentPreferences(); - fillList($persistprefs, prefs); - } - - thisbox.fillList = function(listbox, valueObj) { - while (listbox.numchildren > 0) - listbox[0]=null; + var loadPrefs = function() { + var parser = { + startElement : function(name, attrs) { prefs = attrs; }, + endElement : function(name) { }, + characters : function(val) { } + }; + vexi.stream.parsexml(vexi.biscuits["prefs"], parser); + vexi.trace(prefs); + $prefs.clear(); + if (prefs==null) { + prefs = {}; + return; + } + var keys = []; - for (var i in valueObj) - keys[keys.length] = i; + for (var i in prefs) { + keys.push(i); + } + keys.sort(); - keys.sort(); - for (var i=0; keys.length > i; i++) { - newbox = .item(vexi.box); - newbox.text = keys[i] + " = " + valueObj[keys[i]]; - newbox.value = keys[i]; - listbox[listbox.numchildren] = newbox; + for (var i,key in keys) { + var newitem = new .item(); + newitem.text = key + " = " + prefs[key]; + newitem.value = key; + $prefs.add(newitem); } } + loadPrefs(); - loadParams(); + var savePrefs = function() { + // Create a biscuit + var writer = vexi.stream.xmlwriter(vexi.biscuits["prefs"]); + writer.startElement("obj", prefs); + writer.endElement(); + // refresh preferences list UI + loadPrefs(); + } $set.action ++= function(a) { var n = $paramname.text; var v = $paramvalue.text; if (n.length > 0) { - vexi.prefs.setPreference(n, v); - loadParams(); + prefs[n] = v; + savePrefs(); } } - $prefs.value ++= function(v) { + $prefs.selected ++= function(v) { if (v != null) { - $paramname.text = v; - $paramvalue.text = vexi.prefs.getPreference(v); + var key = v.value; + $paramname.text = key; + $paramvalue.text = prefs[key]; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Lotusphere 2011 Register now for Lotusphere 2011 and learn how to connect the dots, take your collaborative environment to the next level, and enter the era of Social Business. http://p.sf.net/sfu/lotusphere-d2d _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn