Revision: 3727 http://vexi.svn.sourceforge.net/vexi/?rev=3727&view=rev Author: clrg Date: 2009-10-28 02:25:34 +0000 (Wed, 28 Oct 2009)
Log Message: ----------- Updates related to Vexi syntax improvements Modified Paths: -------------- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/cardpane.t trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/grid.t trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/icon.t trunk/widgets/org.vexi.widgets/src/org/vexi/lib/role/selectlist.t trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/numfield.t trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/submenu.t trunk/widgets/org.vexi.widgets/src/vexi/util/queue.t trunk/widgets/org.vexi.widgets/src/vexi/util/redirect.t trunk/widgets/org.vexi.widgets/src_vunit/test/util/orderedlist_large.t trunk/widgets/org.vexi.widgets/src_vunit/test/util/orderedlist_simple.t Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/cardpane.t =================================================================== --- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/cardpane.t 2009-10-28 02:07:45 UTC (rev 3726) +++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/cardpane.t 2009-10-28 02:25:34 UTC (rev 3727) @@ -29,12 +29,20 @@ var showlock = false; var displayFunc = function(v) { - if (showlock) { cascade = v; return; } + if (showlock) { + cascade = v; + return; + } cascade = false; - if (prevstep) show = prevstep; - else if (prevcard) show = prevcard; - else if (nextstep) show = nextstep; - else if (nextcard) show = nextcard; + if (prevstep) { + show = prevstep; + } else if (prevcard) { + show = prevcard; + } else if (nextstep) { + show = nextstep; + } else if (nextcard) { + show = nextcard; + } } /** card management */ @@ -93,7 +101,9 @@ // display nothing and reset stepping if (v == null) { showlock = true; - if (show) show.display = false; + if (show) { + show.display = false; + } showlock = false; stepmarker = 0; stepping = false; @@ -104,18 +114,24 @@ // validate show by index if (typeof(v) == "number") { - if (v >= v_content.numchildren) + if (v >= v_content.numchildren) { throw "Invalid card index put to cardpane.show: "+v; + } card = v_content[v]; // validate show by card } else if (typeof(v) == "box") { - if (0 > v_content.indexof(v)) + if (0 > v_content.indexof(v)) { throw "Invalid card object put to cardpane.show: "+v; + } card = v; - } else throw "Put a value other than a box or box index to cardpane.show"; + } else { + throw "Put a value other than a box or box index to cardpane.show"; + } // nothing to do - if (card == show) return; + if (card == show) { + return; + } // hide the previously shown card and show the new one showlock = true; @@ -126,8 +142,12 @@ // remember where we are if (remembersteps and !stepping) { stepmarker ++; - if (stepmarker != steps.length) steps.splice(stepmarker, steps.length - stepmarker); - if (stepmarker > 100) steps.splice(0); + if (stepmarker != steps.length) { + steps.splice(stepmarker, steps.length - stepmarker); + } + if (stepmarker > 100) { + steps.splice(0); + } steps[stepmarker] = card; } @@ -157,53 +177,63 @@ /** read trap to fetch the next card in the cardpane */ static.ncReadFunc = function() { var ind = trapee.v_content.indexof(trapee.show); - if (trapee.show and trapee.v_content.numchildren-1 > ind) + if (trapee.show and trapee.v_content.numchildren-1 > ind) { return trapee.v_content[ind+1]; - else return null; + } + return null; } /** write trap to step forward to the next in the show-chain */ static.nsWriteFunc = function(v) { trapee.stepping = true; - if (trapee.nextstep) trapee.show = trapee.nextstep; + if (trapee.nextstep) { + trapee.show = trapee.nextstep; + } trapee.stepping = false; cascade = v; } /** read trap to fetch the next step in the show-chain */ static.nsReadFunc = function() { - if (trapee.remembersteps and trapee.steps.length-1 > trapee.stepmarker) + if (trapee.remembersteps and trapee.steps.length-1 > trapee.stepmarker) { return trapee.steps[trapee.stepmarker+1]; - else return false; + } + return false; } /** write trap to show the previous card in the cardpane */ static.pcWriteFunc = function(v) { cascade = v; - if (trapee.prevcard) + if (trapee.prevcard) { trapee.show = trapee.prevcard; + } } /** read trap to fetch the previous card in the cardpane */ static.pcReadFunc = function() { var ind = trapee.v_content.indexof(trapee.show); - if (trapee.show and ind > 0) return trapee.v_content[ind-1]; - else return false; + if (trapee.show and ind > 0) { + return trapee.v_content[ind-1]; + } + return false; } /** write trap to step back to the previous in the show-chain */ static.psWriteFunc = function(v) { trapee.stepping = true; - if (trapee.prevstep) trapee.show = trapee.prevstep; + if (trapee.prevstep) { + trapee.show = trapee.prevstep; + } trapee.stepping = false; cascade = v; } /** read trap to fetch the previous step in the show-chain */ static.psReadFunc = function() { - if (trapee.remembersteps and trapee.stepmarker > 0) + if (trapee.remembersteps and trapee.stepmarker > 0) { return trapee.steps[trapee.stepmarker - 1]; - else return false; + } + return false; } </vexi> Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/grid.t =================================================================== --- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/grid.t 2009-10-28 02:07:45 UTC (rev 3726) +++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/grid.t 2009-10-28 02:25:34 UTC (rev 3727) @@ -34,9 +34,9 @@ var max = function(a, b) { return a > b ? a : b; } // used to track what regions of the grid a child affects - var colregions = .orderedlist({}); + var colregions = new .orderedlist(); var colregrefs = {}; - var rowregions = .orderedlist({}); + var rowregions = new .orderedlist(); var rowregrefs = {}; /* Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/icon.t =================================================================== --- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/icon.t 2009-10-28 02:07:45 UTC (rev 3726) +++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/layout/icon.t 2009-10-28 02:25:34 UTC (rev 3727) @@ -24,7 +24,9 @@ /** set the emblem, a 1/4 size image in the bottom right corner */ static.emblemWrite = function(v) { cascade = v; - if (!trapee.size) return; + if (!trapee.size) { + return; + } trapee[0][1].fill = v ? icon["icon"+(trapee.size/2)][v] : null; } @@ -37,10 +39,13 @@ /** sets the icon's image to an existing icon */ static.iconWrite = function(v) { cascade = v; - if (!trapee.size) return; + if (!trapee.size) { + return; + } if (v and !static["listicon"+trapee.size][v] and typeof(v)=="string") { - try { throw "icon not found: "+v+" ("+trapee.size+")"; } - catch(e) { vexi.log.info(vexi.debug ? e : e.message); } + if (vexi.debug) { + vexi.trace(new vexi.js.Exception("icon not found: "+v+" ("+trapee.size+")")); + } v = "filenew"; } trapee[0][0].fill = v ? icon["icon"+trapee.size][v] : null; @@ -49,10 +54,15 @@ /** sets the size, in pixels, of this icon */ static.sizeWrite = function(v) { cascade = v; - trapee[0].width = v; - trapee[0].height = v; - if (trapee.icon) trapee.icon = trapee.icon; - if (trapee.image) trapee.image = trapee.image; + var i = trapee[0]; + i.width = v; + i.height = v; + if (trapee.icon) { + trapee.icon = trapee.icon; + } + if (trapee.image) { + trapee.image = trapee.image; + } } //////// @@ -60,18 +70,30 @@ static.listicon32 = {}; static.listicon16 = {}; + static.listicon8 = {}; for (var k in icon.icon32) { var d = k.indexOf('.'); - if (d==0) continue; - if (d>=1) k = k.substring(0, d); + if (d==0) { + // skips hidden dirs e.g. .svn + continue; + } + if (d>=1) { + // image files should have an extension e.g. image.png + k = k.substring(0, d); + } listicon32[k] = true; } for (var k in icon.icon16) { var d = k.indexOf('.'); - if (d==0) continue; - if (d>=1) k = k.substring(0, d); + if (d==0) { + // skips hidden dirs e.g. .svn + continue; + } + if (d>=1) { + k = k.substring(0, d); + } listicon16[k] = true; } Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/role/selectlist.t =================================================================== --- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/role/selectlist.t 2009-10-28 02:07:45 UTC (rev 3726) +++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/role/selectlist.t 2009-10-28 02:25:34 UTC (rev 3727) @@ -86,12 +86,10 @@ /** return selected elements as an array */ static.selectionRead = function() { - var content = trapee.v_content; - var n = content.numchildren; var s = []; - for (var i=0; n>i; i++) { - if (content[i].selected) { - s[s.length] = content[i]; + for (var i,child in trapee.v_content) { + if (child.selected) { + s.push(child); } } return s; Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/numfield.t =================================================================== --- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/numfield.t 2009-10-28 02:07:45 UTC (rev 3726) +++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/numfield.t 2009-10-28 02:25:34 UTC (rev 3727) @@ -81,7 +81,9 @@ } cascade = v; - if (t.valid!=newvalid) t.valid = newvalid; + if (t.valid!=newvalid) { + t.valid = newvalid; + } } /** constrain value to min */ @@ -131,7 +133,9 @@ return r; } if (dpsWanted>dpsActual) { - if (dpsActual==0) r += '.'; + if (dpsActual==0) { + r += '.'; + } var addzeros = dpsWanted-dpsActual; while ((addzeros--)>0) { r += '0'; Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/submenu.t =================================================================== --- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/submenu.t 2009-10-28 02:07:45 UTC (rev 3726) +++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/submenu.t 2009-10-28 02:25:34 UTC (rev 3727) @@ -32,10 +32,14 @@ c.group = v_itemgroup; v_content.Leave ++= function(v) { var s = v_itemgroup.selected; - if (s and !s.popped) s.selected = false; + if (s and !s.popped) { + s.selected = false; + } cascade = v; } - } else v_itemgroup = c.group; + } else { + v_itemgroup = c.group; + } c.action ++= childActionWrite; c.v_level = v_level+1; } else { @@ -66,7 +70,9 @@ var t = trapee; var n = t.numchildren; t.v_popbox.popgroup = "subv_level" + v; - for (var i=0; n>i; i++) t[i].v_level = v+1; + for (var i=0; n>i; i++) { + t[i].v_level = v+1; + } cascade = v; } @@ -74,15 +80,24 @@ static.keypressWrite = function(v) { var t = trapee; var g = g; - if (v=="up" or v=="down") cascade = v; - else if (g and g.selected) { + if (v=="up" or v=="down") { + cascade = v; + } else if (g and g.selected) { if (v == "left") { - if (g.selected.popped) g.selected.KeyPressed = v; - else t.popdown = true; + if (g.selected.popped) { + g.selected.KeyPressed = v; + } else { + t.popdown = true; + } } else if (v == "right") { - if (!t.popped) t.popup = true; - else g.selected.KeyPressed = v; - } else g.selected.KeyPressed = v; + if (!t.popped) { + t.popup = true; + } else { + g.selected.KeyPressed = v; + } + } else { + g.selected.KeyPressed = v; + } return; } cascade = v; @@ -92,9 +107,13 @@ static.popdownWrite = function(v) { var t = trapee; var g = t.v_itemgroup; - if (g and g.selected) g.selected.selected = false; + if (g and g.selected) { + g.selected.selected = false; + } // action causes parent (sub)menu to popdown - if (t.selected) t.action = true; + if (t.selected) { + t.action = true; + } // must cascade last as action invokes popup cascade = v; } @@ -102,8 +121,11 @@ /** popup/down when selected/unselected */ static.selectWrite = function(v) { cascade = v; - if (v) trapee.popup = true; - else trapee.popdown = true; + if (v) { + trapee.popup = true; + } else { + trapee.popdown = true; + } } /** set up popbox */ Modified: trunk/widgets/org.vexi.widgets/src/vexi/util/queue.t =================================================================== --- trunk/widgets/org.vexi.widgets/src/vexi/util/queue.t 2009-10-28 02:07:45 UTC (rev 3726) +++ trunk/widgets/org.vexi.widgets/src/vexi/util/queue.t 2009-10-28 02:25:34 UTC (rev 3727) @@ -9,7 +9,9 @@ var loop = function(action) { while (!action.cancel and action.execute[1]) { - if (action.delay) vexi.thread.sleep(action.delay); + if (action.delay) { + vexi.thread.sleep(action.delay); + } action.execute[0].apply(null, action.execute[1]); action.execute[1] = action.queue; action.queue = null; @@ -19,9 +21,12 @@ } var queueWrite = function(v) { - if (trapee.going) cascade = v; - else if (v) { - if (typeof(v)!="array") throw "illegal queue args"; + if (trapee.going) { + cascade = v; + } else if (v) { + if (typeof(v)!="array") { + throw "illegal queue args"; + } trapee.execute[1] = v; trapee.start = true; } @@ -29,19 +34,25 @@ var startWrite = function(v) { if (trapee.going) { - if (trapee.cancel) + if (trapee.cancel) { trapee.cancel = false; + } } else { var action = trapee; action.going = true; - if (action.nothread) loop(action); - else vexi.thread = function() { loop(action); } + if (action.nothread) { + loop(action); + } else { + vexi.thread = function() { loop(action); } + } } return; } var stopWrite = function(v) { - if (trapee.going) trapee.cancel = true; + if (trapee.going) { + trapee.cancel = true; + } return; } Modified: trunk/widgets/org.vexi.widgets/src/vexi/util/redirect.t =================================================================== --- trunk/widgets/org.vexi.widgets/src/vexi/util/redirect.t 2009-10-28 02:07:45 UTC (rev 3726) +++ trunk/widgets/org.vexi.widgets/src/vexi/util/redirect.t 2009-10-28 02:25:34 UTC (rev 3727) @@ -5,11 +5,10 @@ <author>Charles Goodwin</author> </meta:doc> - // whether to throw exceptions or handle collisions - var throwExceptions = false; var reportCollision = function(p, m) { - if (throwExceptions) throw m; - if (vexi.debug) vexi.log.warn(m); + if (vexi.debug) { + vexi.trace(new vexi.js.Exception(m)); + } } /** write function for the main box of a full redirect */ @@ -33,8 +32,11 @@ var from = trapee.redirect_from[trapname]; if (!from.redirect_lock[trapname]) { from.redirect_lockfrom[trapname] = true; - try { from[trapname] = v; } - finally { from.redirect_lockfrom[trapname] = null; } + try { + from[trapname] = v; + } finally { + from.redirect_lockfrom[trapname] = null; + } } } @@ -45,7 +47,9 @@ reportCollision(p, "Redirected property '"+p+"' more than once from a particular box"); static.drop(b1, p); } - if (!b1.redirect_to) b1.redirect_to = {}; + if (!b1.redirect_to) { + b1.redirect_to = {}; + } b1.redirect_to[p] = b2; // hash for locking property redirects @@ -59,7 +63,9 @@ reportCollision(p, "Redirected property '"+p+"' to same destination box more than once"); static.drop(b2.redirect_from[p], p); } - if (!b2.redirect_from) b2.redirect_from = {}; + if (!b2.redirect_from) { + b2.redirect_from = {}; + } b2.redirect_from[p] = b1; // wrap in try/catch clauses in case target properties don't allow trapping @@ -75,8 +81,11 @@ // clean up in the event of failure } catch(e) { var m = "Redirect failed on property '"+p+"' with error: "+e.message; - if (vexi.debug) throw m; - else vexi.log.warn(m); + if (vexi.debug) { + throw m; + } else { + vexi.log.warn(m); + } b1[p] --= mainWrite; b1[p] --= mainRead; b2[p] --= targWrite; @@ -94,7 +103,10 @@ // clean up references for b1 b1.redirect_to[p] = null; var count = 0; - for (var key in b1.redirect_to) { count++; break; } + for (var key in b1.redirect_to) { + count++; + break; + } if (count == 0) { b1.redirect_to = null; b1.redirect_lock = null; @@ -103,23 +115,36 @@ // clean up references for b2 b2.redirect_from[p] = null; count = 0; - for (var key in b2.redirect_from) { count++; break; } - if (count == 0) b2.redirect_from = null; + for (var key in b2.redirect_from) { + count++; + break; + } + if (count == 0) { + b2.redirect_from = null; + } } /** add redirects 'arguments[2+]' from a to b */ static.addRedirect = function(a, b) { - if (a == null) throw "Tried to redirect from a null box or object"; - if (b == null) throw "Tried to redirect to a null box or object"; - if (a == b) throw "Redirects must be between two different boxes"; - for (var i=2, arg; arg = arguments[i]; i++) - static.add(a, b, arg); + if (a == null) { + throw "Tried to redirect from a null box or object"; + } + if (b == null) { + throw "Tried to redirect to a null box or object"; + } + if (a == b) { + throw "Redirects must be between two different boxes"; + } + for (var i=2; arguments.length>i; i++) { + static.add(a, b, arguments[i]); + } } /** delete redirects 'arguments[1+]' from box v */ static.delRedirect = function(v) { - for (var i=1, arg; arg = arguments[i]; i++) - static.drop(v, arg); + for (var i=1; arguments.length>i; i++) { + static.drop(v, arguments[i]); + } } <ui:box> Modified: trunk/widgets/org.vexi.widgets/src_vunit/test/util/orderedlist_large.t =================================================================== --- trunk/widgets/org.vexi.widgets/src_vunit/test/util/orderedlist_large.t 2009-10-28 02:07:45 UTC (rev 3726) +++ trunk/widgets/org.vexi.widgets/src_vunit/test/util/orderedlist_large.t 2009-10-28 02:25:34 UTC (rev 3727) @@ -7,7 +7,7 @@ // TODO - move this. Too slow for and not relevant to // be a unit test. (Stress test? Speed test?) throw "TODO - move me"; - var list = .util.orderedlist({}); + var list = new .util.orderedlist(); var refs = {}; var assertlte = .test.vunit..assertLessThanEquals; // generates a random A-Z character Modified: trunk/widgets/org.vexi.widgets/src_vunit/test/util/orderedlist_simple.t =================================================================== --- trunk/widgets/org.vexi.widgets/src_vunit/test/util/orderedlist_simple.t 2009-10-28 02:07:45 UTC (rev 3726) +++ trunk/widgets/org.vexi.widgets/src_vunit/test/util/orderedlist_simple.t 2009-10-28 02:25:34 UTC (rev 3727) @@ -4,7 +4,7 @@ </meta:doc> <ui:box> - var list = .util.orderedlist({}); + var list = new .util.orderedlist(); var asserteq = .test.vunit..assertEquals; // create ordered list a,b,c This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn