From: <mk...@us...> - 2007-09-03 17:30:31
|
Revision: 2116 http://vexi.svn.sourceforge.net/vexi/?rev=2116&view=rev Author: mkpg2 Date: 2007-09-03 10:27:32 -0700 (Mon, 03 Sep 2007) Log Message: ----------- Added argument checking to JSU to encourage consistent exception throwing and reduce code size (to be used by all methods not on potentially hot paths). Used in xml parsing code. Fix. function.apply() can pass in an arguments object as well now. Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Resources.java trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp trunk/core/org.vexi.core/src_junit/test/core/stream/TestStream.java Added Paths: ----------- trunk/core/org.vexi.core/src_junit/test/core/stream/badargs.t Modified: trunk/core/org.vexi.core/src/org/vexi/core/Resources.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2007-09-03 15:47:23 UTC (rev 2115) +++ trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2007-09-03 17:27:32 UTC (rev 2116) @@ -436,10 +436,10 @@ } }*/ - public static JS parseUTF8(JS arg0) throws JSExn { - if(arg0 == null) return null; + public static JS parseUTF8(JS[] args) throws JSExn { + if(args == null) return null; try { - InputStream is = JSU.getInputStream(arg0); + InputStream is = JSU.getInputStream(args[0]); if(is==null) return SC_; try{ return JSU.S(new String(InputStreamToByteArray.convert(is))); @@ -463,16 +463,20 @@ throw new JSExn(e.getMessage()); } } + + static final int[] ARGTYPES_parseXML = new int[]{JSU.FOUNTAIN, JSU.OBJ}; public static void parseXML(JS[] args) throws JSExn{ - if(args[0] == null) return; + JSU.checkArgs(args, ARGTYPES_parseXML); new XMLHelper(args[1]).doParse(args[0]); return; } - public static JS writeXML(JS f) throws JSExn { + static final int[] ARGTYPES_writeXML = new int[]{JSU.FOUNTAIN}; + public static JS writeXML(JS[] args) throws JSExn { + JSU.checkArgs(args, ARGTYPES_writeXML); try{ final BufferedWriter out = new BufferedWriter( - new OutputStreamWriter(Fountain.getOutputStream(f))); + new OutputStreamWriter(Fountain.getOutputStream(args[0]))); JS writer = new JS.Immutable(){ Stack stack = new Basket.Array(); Modified: trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-09-03 15:47:23 UTC (rev 2115) +++ trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-09-03 17:27:32 UTC (rev 2116) @@ -230,10 +230,10 @@ case "stream.cache": //try { return args[0] == null ? null : new Fountain.CachedStream((Stream)args[0], "resources", true); } //catch (Stream.NotCacheableException e) { throw new JSExn("this resource cannot be cached"); } - case "stream.write.xml": return Resources.writeXML(args[0]); + case "stream.write.xml": return Resources.writeXML(args); case "stream.parse.html": throw new JSExn("not implemented yet"); //return null; // FIXME backgrounding - case "stream.parse.utf8": return Resources.parseUTF8(args[0]); + case "stream.parse.utf8": return Resources.parseUTF8(args); case "thread.sleep": JSU.sleep(JSU.toInt(args[0])); return null; case "ui.browser": Platform.newBrowserWindow(JSU.toString(args[0])); return null; case "ui.insets": Modified: trunk/core/org.vexi.core/src_junit/test/core/stream/TestStream.java =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/stream/TestStream.java 2007-09-03 15:47:23 UTC (rev 2115) +++ trunk/core/org.vexi.core/src_junit/test/core/stream/TestStream.java 2007-09-03 17:27:32 UTC (rev 2116) @@ -28,7 +28,7 @@ public static void main(String[] args) throws Throwable { TestStream cts = new TestStream(); - TestCase t = cts.createTestCase(cts.getResourceDirs(), "accessresource.t"); + TestCase t = cts.createTestCase(cts.getResourceDirs(), "badargs.t"); t.runBare(); } Added: trunk/core/org.vexi.core/src_junit/test/core/stream/badargs.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/stream/badargs.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/stream/badargs.t 2007-09-03 17:27:32 UTC (rev 2116) @@ -0,0 +1,34 @@ +<vexi xmlns:ui="vexi://ui" xmlns=""> + + static.hasException = function(f /*...*/){ + var exn = false; + try{ + switch(arguments.length-1){ + case 1: f(arguments[1]); break; + case 2: f(arguments[1], arguments[2]); break; + } + }catch(e){ vexi.log.info(e);exn = true;} + return exn; + }; + + static.assertBadArgs = function(f /*...*/){ + assert(hasException.apply(arguments)); + }; + + static.assertGoodArgs = function(f /*...*/){ + assert(!hasException.apply(arguments)); + }; + + static.runtest = function(stream){ + assertBadArgs(vexi.stream.parse.xml,{}, {}); + assertBadArgs(vexi.stream.parse.xml,null, {}); + assertBadArgs(vexi.stream.parse.xml,stream); + assertBadArgs(vexi.stream.parse.xml,stream, null); + assertGoodArgs(vexi.stream.parse.xml,stream, {}); + assertBadArgs(vexi.stream.write.xml,{}); + assertGoodArgs(vexi.stream.write.xml,stream); + }; + + <ui:box/> + +</vexi> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mk...@us...> - 2007-09-12 21:06:28
|
Revision: 2168 http://vexi.svn.sourceforge.net/vexi/?rev=2168&view=rev Author: mkpg2 Date: 2007-09-12 14:06:31 -0700 (Wed, 12 Sep 2007) Log Message: ----------- Feature. Expose contentwidth/contentheight. Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp trunk/core/org.vexi.core/src/org/vexi/core/Constants.java Added Paths: ----------- trunk/core/org.vexi.core/src_junit/test/core/box/layout/ trunk/core/org.vexi.core/src_junit/test/core/box/layout/TestLayout.java trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentx.t Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-09-12 16:47:01 UTC (rev 2167) +++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-09-12 21:06:31 UTC (rev 2168) @@ -62,7 +62,7 @@ public final class Box extends JS.Obj implements Callable, Constants{ // Treat following always as tokens - x/y are perhaps to short to do the same - //#pragma tokens SC_ width Width + //#pragma tokens SC_ width Width WIDTH //#define PUT_BOX_FIELD(NAME,VAL,CODE,FLAG) \ // if (test(FLAG)) {\ @@ -202,8 +202,9 @@ private static final int Y_TRAP = 0x00800000; private static final int MINMAX_TRAPS = 0x01000000; - // unused - private static final int FLAG = 0x02000000; - // unused - private static final int FLAG = 0x04000000; + + private static final int CONTENTWIDTH_TRAP = 0x02000000; + private static final int CONTENTHEIGHT_TRAP = 0x04000000; // unused - private static final int FLAG = 0x08000000; private static final int MOVE_TRAP = 0x10000000; @@ -318,7 +319,7 @@ private void tryResize(int width, int height) { if (width == this.width && height == this.height) return; dirty(); - //#repeat width/height WIDTH_TRAP/HEIGHT_TRAP + //#repeat width/height WIDTH/HEIGHT if (width != this.width) { PUT_BOX_FIELD(SC_width,JSU.N(width),this.width = width,WIDTH_TRAP) // FEATURE: slightly more efficient? set(PLACE); if (parent != null) parent.set(PLACE_DESCENDENT); @@ -337,7 +338,7 @@ PUT_BOX_FIELD(SC_x,JSU.N(x),this.x = x,X_TRAP) } //#end - //#repeat width/height WIDTH_TRAP/HEIGHT_TRAP + //#repeat width/height WIDTH/HEIGHT if (width != this.width) { PUT_BOX_FIELD(SC_width,JSU.N(width),this.width = width,WIDTH_TRAP) // FEATURE: slightly more efficient? set(PLACE); if (parent != null) parent.set(PLACE_DESCENDENT); @@ -399,10 +400,8 @@ if (!test(CONSTRAIN)) return; // remember current size - int oldwidth = contentwidth, oldheight = contentheight; - contentwidth = 0; - contentheight = 0; - + int newwidth = 0, newheight = 0; + if (test(PACK)) { //#repeat width/height HORIZONTAL/VERTICAL // accumulate child contentwidth @@ -410,7 +409,7 @@ int i = 0; for (Box c = getChild(0); c != null; c = getChild(++i)) { if (!c.test(DISPLAY)) continue; - contentwidth += c.contentwidth; + newwidth += c.contentwidth; } // maximum child contentwidth @@ -418,7 +417,7 @@ int i = 0; for (Box c = getChild(0); c != null; c = getChild(++i)) { if (!c.test(DISPLAY)) continue; - contentwidth = max(contentwidth, c.contentwidth); + newwidth = max(newwidth, c.contentwidth); } } //#end @@ -427,20 +426,21 @@ int i = 0; for (Box c = getChild(0); c != null; c = getChild(++i)) { if (!c.test(DISPLAY)) continue; - contentwidth = max(contentwidth, c.contentwidth); - contentheight = max(contentheight, c.contentheight); + newwidth = max(newwidth, c.contentwidth); + newheight = max(newheight, c.contentheight); } } - - //#repeat width/height HAS_WIDTH_SLACK/HAS_HEIGHT_SLACK - if (contentwidth < minwidth || contentwidth < text.width) + + //#repeat width/height WIDTH/HEIGHT + if (newwidth < minwidth || newwidth < text.width) set(HAS_WIDTH_SLACK); else clear(HAS_WIDTH_SLACK); // constrain contentwidth - contentwidth = min(maxwidth, max(minwidth, max(contentwidth, text.width))); + newwidth = min(maxwidth, max(minwidth, max(newwidth, text.width))); // mark - if (oldwidth != contentwidth) { + if (newwidth != contentwidth) { + PUT_BOX_FIELD(SC_contentwidth,JSU.N(newwidth),contentwidth=newwidth,CONTENTWIDTH_TRAP) setPlace(); if (parent != null) { parent.set(PLACE); @@ -1149,10 +1149,12 @@ case "rowspan": throw new JSExn("Deprecated property read: "+JSU.toString(name)); case "width": return (minwidth==maxwidth) ? JSU.N(minwidth) : JSU.N(width); case "height": return (minheight==maxheight) ? JSU.N(minheight) : JSU.N(height); - case "minwidth": return JSU.N(contentwidth); + case "minwidth": return JSU.N(minwidth); case "maxwidth": return JSU.N(maxwidth); - case "minheight": return JSU.N(contentheight); + case "minheight": return JSU.N(minheight); case "maxheight": return JSU.N(maxheight); + case "contentwidth": return JSU.N(contentwidth); + case "contentheight": return JSU.N(contentheight); case "display": return JSU.B(test(DISPLAY)); case "visible": return isVisible() ? JSU.T : JSU.F; case "packed": throw new JSExn("Deprecated property read: "+JSU.toString(name)); @@ -1383,6 +1385,8 @@ case "maxwidth": set(MINMAX_TRAPS); case "minheight": set(MINMAX_TRAPS); case "maxheight": set(MINMAX_TRAPS); + case "contentwidth": set(CONTENTWIDTH_TRAP); + case "contentheight": set(CONTENTHEIGHT_TRAP); case "Enter": set(ENTER_TRAP); case "Leave": set(LEAVE_TRAP); case "_Move": set(MOVE_TRAP); @@ -1400,6 +1404,8 @@ case "y": if (getTrap(SC_y) == null) clear(Y_TRAP); case "width": if (getTrap(SC_width) == null) clear(WIDTH_TRAP); case "height": if (getTrap(SC_height) == null) clear(HEIGHT_TRAP); + case "contentwidth": if (getTrap(SC_contentwidth) == null) clear(CONTENTWIDTH_TRAP); + case "contentheight": if (getTrap(SC_contentheight) == null) clear(CONTENTHEIGHT_TRAP); case "Enter": if (getTrap(SC_Enter) == null) clear(ENTER_TRAP); case "Leave": if (getTrap(SC_Leave) == null) clear(LEAVE_TRAP); case "_Move": if (getTrap(SC__Move) == null) clear(MOVE_TRAP); Modified: trunk/core/org.vexi.core/src/org/vexi/core/Constants.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Constants.java 2007-09-12 16:47:01 UTC (rev 2167) +++ trunk/core/org.vexi.core/src/org/vexi/core/Constants.java 2007-09-12 21:06:31 UTC (rev 2168) @@ -8,6 +8,8 @@ static final JS SC_box = JSU.S("box",true); static final JS SC_characters = JSU.S("characters",true); static final JS SC_Children = JSU.S("Children",true); + static final JS SC_contentheight = JSU.S("contentheight",true); + static final JS SC_contentwidth = JSU.S("contentwidth",true); static final JS SC_cursor = JSU.S("cursor",true); static final JS SC_endElement = JSU.S("endElement",true); static final JS SC_Enter = JSU.S("Enter",true); Added: trunk/core/org.vexi.core/src_junit/test/core/box/layout/TestLayout.java =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/layout/TestLayout.java (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/box/layout/TestLayout.java 2007-09-12 21:06:31 UTC (rev 2168) @@ -0,0 +1,34 @@ +package test.core.box.layout; + +import junit.framework.Test; +import junit.framework.TestCase; +import test.core.CoreTestCase; +import test.core.CoreTestSuite; +import test.core.box.TestBox; +import testdeployment.NanoHTTPD; + +/** + * @author mike + */ +public class TestLayout extends TestBox{ + + public TestLayout() { + super(TestLayout.class); + } + + protected boolean filter(String name) { + return super.filter(name); + } + + public static Test suite() { + return CoreTestSuite.suite(new TestLayout()); + } + + + public static void main(String[] args) throws Throwable { + + CoreTestSuite cts = new TestLayout(); + TestCase t = cts.createTestCase(cts.getResourceDirs(), "contentx.t"); + t.runBare(); + } +} Property changes on: trunk/core/org.vexi.core/src_junit/test/core/box/layout/TestLayout.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentx.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentx.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentx.t 2007-09-12 21:06:31 UTC (rev 2168) @@ -0,0 +1,21 @@ +<vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib"> + + var testContentx = function(dim){ + var c1 = vexi.box; + c1["min"+dim]=10;c1.forcereflow(); + .util..assertEquals(10,c1["content"+dim]); + + var x = 0; + c1["content"+dim]++=function(v){ + x = v; + cascade = v; + }; + c1["min"+dim]=20;c1.forcereflow(); + .util..assertEquals(20,x); + }; + testContentx("width"); + testContentx("height"); + + + <ui:box/> +</vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mk...@us...> - 2007-09-13 10:27:02
|
Revision: 2180 http://vexi.svn.sourceforge.net/vexi/?rev=2180&view=rev Author: mkpg2 Date: 2007-09-13 03:27:03 -0700 (Thu, 13 Sep 2007) Log Message: ----------- Replace clip="false" with layout="layer" Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp trunk/core/org.vexi.core/src_junit/test/core/box/_lib.t Added Paths: ----------- trunk/core/org.vexi.core/src_junit/test/core/box/layout/layout.t Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-09-13 10:26:54 UTC (rev 2179) +++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-09-13 10:27:03 UTC (rev 2180) @@ -1142,7 +1142,7 @@ case "y": return JSU.N(y); case "orient": return test(ORIENT) ? SC_horizontal : SC_vertical; case "layout": return test(PACK) ? SC_pack : SC_place; - case "clip": return JSU.B(test(CLIP)); + //case "clip": return JSU.B(test(CLIP)); case "width": return (minwidth==maxwidth) ? JSU.N(minwidth) : JSU.N(width); case "height": return (minheight==maxheight) ? JSU.N(minheight) : JSU.N(height); case "minwidth": return JSU.N(minwidth); @@ -1298,15 +1298,22 @@ } case "layout": if (JSU.toString(value).equals("place")) { - if (test(PACK)) clear(PACK); + if (test(PACK) || !test(CLIP)) { + clear(PACK); set(CLIP); + } else return; - } else if (JSU.toString(value).equals("pack")) { + } else if (JSU.toString(value).equals("layer")) { + if (test(PACK) || test(CLIP)) { + clear(PACK); clear(CLIP); + } + else return; + } else if (JSU.toString(value).equals("pack")) { if (test(PACK)) return; else set(PACK); } else throw new JSExn("Attempt to set Box property 'layout' to unsupported value '"+JSU.toString(value)+"'"); setConstrain(); setPlace(); - case "clip": if (CHECKSET_FLAG(CLIP) && !test(PACK)) setConstrain(); + //case "clip": if (CHECKSET_FLAG(CLIP) && !test(PACK)) setConstrain(); case "orient": if (JSU.toString(value).equals("horizontal")) { if (test(ORIENT)) return; @@ -1319,6 +1326,8 @@ setConstrain(); setPlace(); } + case "rows": throw new JSExn("Deprecated property write to '"+JSU.toString(name)+"': "+JSU.toString(value)); + case "cols": throw new JSExn("Deprecated property write to '"+JSU.toString(name)+"': "+JSU.toString(value)); case "surface": for (int i=0; i<treeSize(); i++) getChild(i).putAndTriggerTraps(SC_surface, value); // FIXME: the call to setMinimized()/setMaximized() will trigger another call of this code in the course of triggering write traps case "Minimized": if (parent == null && getSurface() != null) getSurface().setMinimized(JSU.toBoolean(value)); Modified: trunk/core/org.vexi.core/src_junit/test/core/box/_lib.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/_lib.t 2007-09-13 10:26:54 UTC (rev 2179) +++ trunk/core/org.vexi.core/src_junit/test/core/box/_lib.t 2007-09-13 10:27:03 UTC (rev 2180) @@ -5,6 +5,11 @@ r.text = text; return r; }; + static.newBoxSize = function(w,h){ + var r = vexi.box; + r.width = w; r.height = h; + return r; + }; static.reorderWrite = function (b){ return function(v){ vexi.log.info(trapname); @@ -13,7 +18,10 @@ cascade = v; }; }; - + static.assertSize = function(w,h,b){ + .util..assertEquals(w,b.width); + .util..assertEquals(h,b.height); + }; <ui:box/> </vexi> Added: trunk/core/org.vexi.core/src_junit/test/core/box/layout/layout.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/layout/layout.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/box/layout/layout.t 2007-09-13 10:27:03 UTC (rev 2180) @@ -0,0 +1,25 @@ +<vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib"> + + + var p = vexi.box; + p.orient="horizontal"; + p.layout="pack"; + p.shrink="true"; + var c1 = lib..newBoxSize(20,20); + var c2 = lib..newBoxSize(30,20); + p[0] = c1; + p[1] = c2; + p.forcereflow(); + lib..assertSize(50,20,p); + + p.layout="place"; + p.forcereflow(); + lib..assertSize(0,0,p); + + p.layout="layer"; + p.forcereflow(); + lib..assertSize(30,20,p); + + + <ui:box/> +</vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mk...@us...> - 2007-09-15 16:52:21
|
Revision: 2207 http://vexi.svn.sourceforge.net/vexi/?rev=2207&view=rev Author: mkpg2 Date: 2007-09-15 09:52:24 -0700 (Sat, 15 Sep 2007) Log Message: ----------- Resources/id'd sub boxes in attributes now specified with a leading ':' Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Template.java trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java trunk/core/org.vexi.core/src_junit/test/core/general/typeof.t Added Paths: ----------- trunk/core/org.vexi.core/src_junit/test/core/general/attribute_newline.t trunk/core/org.vexi.core/src_junit/test/core/general/attribute_streams.t Removed Paths: ------------- trunk/core/org.vexi.core/src_junit/test/core/general/newlines_in_attributes.t Modified: trunk/core/org.vexi.core/src/org/vexi/core/Template.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Template.java 2007-09-15 16:44:11 UTC (rev 2206) +++ trunk/core/org.vexi.core/src/org/vexi/core/Template.java 2007-09-15 16:52:24 UTC (rev 2207) @@ -193,6 +193,24 @@ if ("null".equals(val)) val = null; + if(JSU.isString(val)){ + String valStr = JSU.toString(val); + if(valStr.length()>0 && valStr.charAt(0)==':'){ + String str=valStr.substring(1); + if(str.startsWith("$")){ + val = pis.get(val); + }else{ + String[] ab = str.split("\\.",2); + val = (JS) uriPrefixes.get(JSU.S(ab[0]), true); + while(ab.length==2 && val!=null){ + ab = ab[1].split("\\.",2); + val = val.get(JSU.S(ab[0])); + } + } + if(val==null) throw new JSExn(valStr + " evaluates to null"); + } + } + if (JSU.isString(val) && (JSU.toString(val).length() > 0)) { switch (JSU.toString(val).charAt(0)) { case '$': @@ -209,11 +227,11 @@ } - // UGLY - avoiding adding an init param if (script == null){ pisParserParam = TemplateBuilder.instance.createPIChecker(uriPrefixes, this); script = TemplateBuilder.parseScript(content, content_start, fileName(), pisParserParam); content = null; - if(script== null)script = JSU.F; + //UGLY - avoiding adding an init param + if(script== null)script = JSU.F; } if (script != JSU.F) JSU.cloneWithNewGlobalScope(script, pis).call(null, EMPTY_JS_ARRAY); @@ -412,7 +430,7 @@ // In org.vexi.devl we inspect the prefixes as part of the checking // for undeclared globals. We do not want to resolve as this will // change the order in which templates are resolved, giving a - // different behaviour to the non-devl code, which is very undesirable.hout + // different behaviour to the non-devl code, which is very undesirable. public Object get(JS key, boolean resolve) throws JSExn { Object r =map.get(key); if(r==NULL_PLACEHOLDER) Modified: trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java 2007-09-15 16:44:11 UTC (rev 2206) +++ trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java 2007-09-15 16:52:24 UTC (rev 2207) @@ -215,12 +215,8 @@ continue ATTR; } - // treat value starting with '.' as resource reference - String uri = a.getUri(i); - if(uri == null) uri = ""; - if (!uri.equals("")) uri = '.' + uri; keys.add(a.getKey(i)); - vals.add((a.getVal(i).startsWith(".") ? uri : "") + a.getVal(i)); + vals.add(a.getVal(i)); } if (keys.size() == 0) return; Copied: trunk/core/org.vexi.core/src_junit/test/core/general/attribute_newline.t (from rev 2069, trunk/core/org.vexi.core/src_junit/test/core/general/newlines_in_attributes.t) =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/general/attribute_newline.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/general/attribute_newline.t 2007-09-15 16:52:24 UTC (rev 2207) @@ -0,0 +1,13 @@ +<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns:li="lib" xmlns="lib2"> + + +/* At the moment choosing not to interpret \n as a new line. Would have + to check every attribute and perhaps only makes sense for text attributes. + Newline can be achieved, the xml way, as below if necessary.*/ + <ui:box a="@.a +a"> + //vexi.log.info(thisbox.a); + assert(a=="a\na"); + assert(a.charAt(1)=='\n'); + </ui:box> +</vexi> Added: trunk/core/org.vexi.core/src_junit/test/core/general/attribute_streams.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/general/attribute_streams.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/general/attribute_streams.t 2007-09-15 16:52:24 UTC (rev 2207) @@ -0,0 +1,10 @@ +<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="alpha" xmlns:b="beta"> + + +/* cannot interpret \n for all attributes as it doesn't necessarily make snes*/ + <ui:box u=":.pic" v=":b.pic2"/> + <ui:box> + assert(u==.pic); + assert(v==b.pic2); + </ui:box> +</vexi> Deleted: trunk/core/org.vexi.core/src_junit/test/core/general/newlines_in_attributes.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/general/newlines_in_attributes.t 2007-09-15 16:44:11 UTC (rev 2206) +++ trunk/core/org.vexi.core/src_junit/test/core/general/newlines_in_attributes.t 2007-09-15 16:52:24 UTC (rev 2207) @@ -1,7 +0,0 @@ -<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns:li="lib" xmlns="lib2"> - - <ui:box a="a\na"> - assert(a=="a\na"); - assert(a.charAt(1)=='\n'); - </ui:box> -</vexi> Modified: trunk/core/org.vexi.core/src_junit/test/core/general/typeof.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/general/typeof.t 2007-09-15 16:44:11 UTC (rev 2206) +++ trunk/core/org.vexi.core/src_junit/test/core/general/typeof.t 2007-09-15 16:52:24 UTC (rev 2207) @@ -2,7 +2,7 @@ <ui:box> //Traps on piscope globals -.util..assertEquals("template",typeof vexi[""]["typeof"]); +.util..assertEquals("stream",typeof vexi[""]["typeof"]); .util..assertEquals("box",typeof thisbox); </ui:box> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mk...@us...> - 2007-09-17 10:05:32
|
Revision: 2226 http://vexi.svn.sourceforge.net/vexi/?rev=2226&view=rev Author: mkpg2 Date: 2007-09-17 03:05:34 -0700 (Mon, 17 Sep 2007) Log Message: ----------- Small Fix. Get static on root dir returns null, doesn't throw exception. Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java Added Paths: ----------- trunk/core/org.vexi.core/src_junit/test/core/general/static_on_dir.t Modified: trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java 2007-09-17 01:05:57 UTC (rev 2225) +++ trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java 2007-09-17 10:05:34 UTC (rev 2226) @@ -34,7 +34,7 @@ public JS get(JS key) throws JSExn { // FEATURE - do we need to resolve here? We can resolve later perhaps, so // if you refer to a template but don't use it then it won't get resolved? - if (JSU.isString(key) && JSU.toString(key).equals("")) + if (SC_.equals(key)) return getStatic(); if (cache.get(key) != null) return (JS)cache.get(key); @@ -94,6 +94,7 @@ initializing = true; // FEATURE: Might want to handle the ".t" part better try{ + if(parent==null) return; JS res = parent.get(JSU.S(JSU.toString(parentkey) + ".t")); t = TemplateBuilder.build(unresolved, res); }finally{ @@ -144,14 +145,7 @@ /*public String toString(){ return coerceToString(); }*/ - /*public Keys keys() throws JSExn { - JS keys = clonee.keys(); - return new Keys(){ - protected JS contains(JS key) throws JSExn { - return super.contains(key); - } - - - }; - }*/ + public Keys keys() throws JSExn { + return clonee.keys(); + } } Added: trunk/core/org.vexi.core/src_junit/test/core/general/static_on_dir.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/general/static_on_dir.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/general/static_on_dir.t 2007-09-17 10:05:34 UTC (rev 2226) @@ -0,0 +1,12 @@ +<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns=""> + + <ui:box> + //vexi.log.info(vexi[""][""]); + + //assert(vexi[""]["static_on_dir.t"]!=null); + // static of a directory should be null + //assert(vexi[""]["b"][""]==null); + assert(vexi[""][""]==null); + + </ui:box> +</vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mk...@us...> - 2007-09-19 00:16:20
|
Revision: 2245 http://vexi.svn.sourceforge.net/vexi/?rev=2245&view=rev Author: mkpg2 Date: 2007-09-18 17:16:16 -0700 (Tue, 18 Sep 2007) Log Message: ----------- Fix. Stream dir["xxx.t"] fixed to be equivalent to dir["xxx"]/dir.xxx Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java trunk/core/org.vexi.core/src/org/vexi/core/Template.java trunk/core/org.vexi.core/src_junit/test/core/general/attribute_newline.t trunk/core/org.vexi.core/src_junit/test/core/general/static_on_dir.t Added Paths: ----------- trunk/core/org.vexi.core/src_junit/test/core/general/dot_t_key.t Modified: trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java 2007-09-18 23:58:08 UTC (rev 2244) +++ trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java 2007-09-19 00:16:16 UTC (rev 2245) @@ -32,12 +32,27 @@ } public JS get(JS key) throws JSExn { + if(key.equals(JSU.S("dot_t_key"))) + System.out.println("hi"); + // FEATURE - do we need to resolve here? We can resolve later perhaps, so // if you refer to a template but don't use it then it won't get resolved? if (SC_.equals(key)) return getStatic(); if (cache.get(key) != null) return (JS)cache.get(key); + String key_ = JSU.toString(key); + // x.t is equivalent to x + if(key_.endsWith(".t")){ + key_ = key_.substring(0,key_.length()-2); + JS origKey = key; + key = JSU.S(key_); + if (cache.get(key) != null){ + JS ret = (JS)cache.get(key); + cache.put(origKey, ret); + return ret; + } + } JS ret = new Blessing(super.getAndTriggerTraps(key), vexi, this, key); cache.put(key, ret); return ret; @@ -95,13 +110,19 @@ // FEATURE: Might want to handle the ".t" part better try{ if(parent==null) return; - JS res = parent.get(JSU.S(JSU.toString(parentkey) + ".t")); + JS res = parent.getTemplateRes(parentkey); t = TemplateBuilder.build(unresolved, res); }finally{ initializing = false; } } + private JS getTemplateRes(JS key) throws JSExn{ + String key_ = JSU.toString(key); + if(!key_.endsWith(".t")) key = JSU.S(key_ + ".t"); + return super.getAndTriggerTraps(key); + } + JS getStatic() throws JSExn { if (t == null) resolve(new Template(vexi, description())); return t != null ? t.getStatic(): null; @@ -138,14 +159,17 @@ return t; } - public String coerceToString(){ + public String coerceToString() { return description()+"$"+Integer.toHexString(hashCode()); } - public JS type() { return SC_stream;} - /*public String toString(){ - return coerceToString(); - }*/ + public JS type() { return SC_stream; } + public Keys keys() throws JSExn { return clonee.keys(); } + + // Useful when debugging + public String toString(){ + return coerceToString(); + } } Modified: trunk/core/org.vexi.core/src/org/vexi/core/Template.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Template.java 2007-09-18 23:58:08 UTC (rev 2244) +++ trunk/core/org.vexi.core/src/org/vexi/core/Template.java 2007-09-19 00:16:16 UTC (rev 2245) @@ -350,10 +350,9 @@ } - /*public String toString() { + public String toString() { return fileName(); - }*/ - + } } class CodeBlock{ Modified: trunk/core/org.vexi.core/src_junit/test/core/general/attribute_newline.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/general/attribute_newline.t 2007-09-18 23:58:08 UTC (rev 2244) +++ trunk/core/org.vexi.core/src_junit/test/core/general/attribute_newline.t 2007-09-19 00:16:16 UTC (rev 2245) @@ -4,7 +4,7 @@ /* At the moment choosing not to interpret \n as a new line. Would have to check every attribute and perhaps only makes sense for text attributes. Newline can be achieved, the xml way, as below if necessary.*/ - <ui:box a="@.a + <ui:box a="a a"> //vexi.log.info(thisbox.a); assert(a=="a\na"); Added: trunk/core/org.vexi.core/src_junit/test/core/general/dot_t_key.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/general/dot_t_key.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/general/dot_t_key.t 2007-09-19 00:16:16 UTC (rev 2245) @@ -0,0 +1,14 @@ +<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns=""> + + vexi.log.info("static!"); + <ui:box> + var template = vexi..dot_t_key; + var template_ = vexi[""]["dot_t_key.t"]; + vexi.log.warn("" + template); + vexi.log.warn("" + template_); + var static_ = template_[""]; + vexi.log.warn("" + static); + vexi.log.warn("" + static_); + + </ui:box> +</vexi> Modified: trunk/core/org.vexi.core/src_junit/test/core/general/static_on_dir.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/general/static_on_dir.t 2007-09-18 23:58:08 UTC (rev 2244) +++ trunk/core/org.vexi.core/src_junit/test/core/general/static_on_dir.t 2007-09-19 00:16:16 UTC (rev 2245) @@ -5,8 +5,9 @@ //assert(vexi[""]["static_on_dir.t"]!=null); // static of a directory should be null - //assert(vexi[""]["b"][""]==null); + assert(vexi[""]["b"][""]==null); assert(vexi[""][""]==null); + </ui:box> </vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mk...@us...> - 2007-09-20 15:19:39
|
Revision: 2274 http://vexi.svn.sourceforge.net/vexi/?rev=2274&view=rev Author: mkpg2 Date: 2007-09-20 08:19:28 -0700 (Thu, 20 Sep 2007) Log Message: ----------- Fix with Test. Removing trap no longer prevents 'after put' on box field traps. - cleaned up fireVisibleTraps Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp Added Paths: ----------- trunk/core/org.vexi.core/src_junit/test/core/box/layout/trapping.t Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-09-20 14:11:25 UTC (rev 2273) +++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-09-20 15:19:28 UTC (rev 2274) @@ -66,9 +66,10 @@ //#define PUT_BOX_FIELD(NAME,VAL,CODE,FLAG) \ // if (test(FLAG)) {\ - // boolean b = prePutTriggerTrapsAndCatchExceptions(NAME, VAL);\ + // Trap _t_ = wtrap(NAME);\ + // boolean _b_ = prePutTriggerTrapsAndCatchExceptions(_t_, NAME, VAL);\ // CODE;\ - // postPutTriggerTrapsAndCatchExceptions(NAME, b);\ + // postPutTriggerTrapsAndCatchExceptions(_t_, NAME, _b_);\ // } else {CODE;} @@ -735,9 +736,8 @@ /** execute trap JS up until the put, giving extra control over the put * it must ALWAYS be followed by a postPutTriggerTraps */ - private final boolean prePutTriggerTrapsAndCatchExceptions(JS name, JS val) { + private final boolean prePutTriggerTrapsAndCatchExceptions(Trap t, JS name, JS val) { try { - Trap t = wtrap(name); if (t != null) org.ibex.js.Thread.runBeforePut(t, val); } catch (JSExn e) { Log.uWarn(Box.class,"Caught JS Exception while putting to trap \""+name+"\""); @@ -754,9 +754,8 @@ } /** execute trap JS after a put */ - private final void postPutTriggerTrapsAndCatchExceptions(JS name, boolean b) { + private final void postPutTriggerTrapsAndCatchExceptions(Trap t, JS name, boolean b) { try { - Trap t = wtrap(name); if (t != null) org.ibex.js.Thread.runAfterPut(b); } catch (JSExn e) { Log.uWarn(Box.class,"Caught JS Exception while putting to trap \""+name+"\""); @@ -803,15 +802,21 @@ } /** fire traps on visible for this box and it's children */ - protected void fireVisibleTraps(boolean visibility, JS value) throws JSExn { - boolean b = false; - int i = 0; - if (test(VISIBLE_TRAP)) - b = prePutTriggerTrapsAndCatchExceptions(SC_visible, value); + protected void fireVisibleTraps(JS value) throws JSExn { + PUT_BOX_FIELD(SC_visible,value,fireVisibleTrapsOnChildren(value),VISIBLE_TRAP) + // important we use the same value before and after the cascade + /*Trap t = test(VISIBLE_TRAP)?wtrap(SC_visible):null; + if (t!=null) { + boolean b = prePutTriggerTrapsAndCatchExceptions(t, SC_visible, value); + ; + postPutTriggerTrapsAndCatchExceptions(t, SC_visible, b); + } else fireVisibleTrapsOnChildren(value);*/ + } + + final private void fireVisibleTrapsOnChildren(JS value) throws JSExn { + int i = 0; for (Box child = getChild(0); child != null; child = getChild(++i)) - if (child.test(DISPLAY)) child.fireVisibleTraps(visibility, value); - if (test(VISIBLE_TRAP)) - postPutTriggerTrapsAndCatchExceptions(SC_visible, b); + if (child.test(DISPLAY)) child.fireVisibleTraps(value); } /** get align value as a string from align flags */ @@ -1262,7 +1267,7 @@ if (test(DISPLAY) != display) { // fire visible traps - has to be done before set(DISPLAY) alters get("visible") for thisbox and descendents if (get(SC_visible) != value) { - fireVisibleTraps(display, value); + fireVisibleTraps(value); } if (display) { set(DISPLAY); Added: trunk/core/org.vexi.core/src_junit/test/core/box/layout/trapping.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/layout/trapping.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/box/layout/trapping.t 2007-09-20 15:19:28 UTC (rev 2274) @@ -0,0 +1,19 @@ +<vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib"> + var a = lib..newBoxSize(100,100); + var b = vexi.box; + a[0] = b; + var x = 1; + b.width ++= function(v){ + // remove trap to make sure this doesn't interfere with post put + // code - i.e that after the cascade + b.width --= callee; + x *= 2; + cascade = v; + x *= 3; + }; + assert(x==1); + b.forcereflow(); + assert(x==6); + + <ui:box/> +</vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mk...@us...> - 2007-09-27 15:52:44
|
Revision: 2344 http://vexi.svn.sourceforge.net/vexi/?rev=2344&view=rev Author: mkpg2 Date: 2007-09-27 08:46:56 -0700 (Thu, 27 Sep 2007) Log Message: ----------- Feature. Basic font repository. Install fonts. Test case. Changed download monitoring slightly. Fix. Testcase leaving stream open (write xml without xml/explicit close) Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Resources.java trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp trunk/core/org.vexi.core/src_junit/org/vexi/core/TestResources.java trunk/core/org.vexi.core/src_junit/test/core/download/TestDownload.java trunk/core/org.vexi.core/src_junit/test/core/stream/TestStream.java trunk/core/org.vexi.core/src_junit/test/core/stream/badargs.t trunk/core/org.vexi.core/src_junit/testdeployment/NanoHTTPD.java Added Paths: ----------- trunk/core/org.vexi.core/src_junit/testdeployment/VeraSans.vexi Modified: trunk/core/org.vexi.core/src/org/vexi/core/Resources.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2007-09-27 15:32:42 UTC (rev 2343) +++ trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2007-09-27 15:46:56 UTC (rev 2344) @@ -1,5 +1,6 @@ package org.vexi.core; +import java.awt.Font; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; @@ -21,10 +22,11 @@ import org.ibex.js.JS; import org.ibex.js.JSExn; import org.ibex.js.JSU; +import org.ibex.js.Thread; +import org.ibex.js.JS.Enumeration; +import org.ibex.js.JS.Keys; import org.ibex.js.JSU.Wrapper; -import org.ibex.js.Thread; import org.ibex.util.Basket; -import org.ibex.util.Callable; import org.ibex.util.Encode; import org.ibex.util.InputStreamToByteArray; import org.ibex.util.Log; @@ -61,13 +63,6 @@ //private static final boolean precache = false; //private static final boolean download = true; - private static final boolean zipfile = true; - private static final String[] datefmts = { - "EEE, dd MMM yyyy HH:mm:ss zzz", - "EEEE, dd-MMM-yy HH:mm:ss zzz", - "EEE MMM d HH:mm:ss yyyy" - }; - public static Fountain fountainForNames(final JS[] urls) throws JSExn{ if(urls.length==0) return null; if(urls.length==1){ @@ -127,7 +122,7 @@ newStream = new RemoteArchive(cacheableName); } else { - newStream = new Fountain.HTTP(cacheableName); + newStream = new RemoteFile(cacheableName); } } else { @@ -300,7 +295,7 @@ } /** convert a path (or URL) to a file name */ - private static String pathToFileName(String path) { + static String pathToFileName(String path) { return path.replace('/', '_').replace('\\', '_').replace(':', '_'); } @@ -316,126 +311,152 @@ } }; - public static class RemoteArchive extends Fountain{ - - String url; + public static class RemoteArchive extends RemoteFile{ Fountain.Zip cache; - public RemoteArchive(String url) { while (url.endsWith("/")) url = url.substring(0, url.length() - 1); this.url = url; } + public RemoteArchive(String url) { super(url);} public JS _get(JS key) throws JSExn { - try {if(cache == null)cache(this);} catch (IOException e) { - throw new JSExn(e.getMessage());} + cache_(this); return cache._get(key); } public InputStream getInputStream() throws IOException { // First download we check and potentially update the cache - if(cache == null){cache(this);} + cache(this); // FIXME - should take principal as argument? return cache.getInputStream(); } - /** pull the specified file from a URL and store it in a temporary local .vexi file - * @throws IOException */ + /** pull the specified file from a URL and store it in a temporary local .vexi file + * @param principal + * @throws IOException + * @throws JSExn */ public void cache(final JS principal) throws IOException { - int BUFFER_SIZE = 1024; - byte[] buffer = new byte[BUFFER_SIZE]; + if(cache!=null) return; + super.cache(principal); + cache = new Fountain.Zip(super.cache); + } + + private void cache_(final JS principal) throws JSExn { + try{cache(principal);}catch(IOException e){throw new JSExn(e.getMessage());} + } + + public Keys keys() throws JSExn { + cache_(this); // FIXME - should take principal as argument + return cache.keys(); + } + + } + + static public class RemoteFile extends Fountain{ - Log.uInfo(Main.class, "Downloading vexi file from " + url); - - Fountain httpStream = new Fountain.ProgressWatcher(new Fountain.HTTP(url), new Callable(){ - public Object run(Object o) throws Exception { - Trap t = principal.getTrap(SC_Progress); - //Log.uInfo("Blah", o); - // FEATURE - if not run yet, update previous - // scheduled JS arg. - if(t!=null && (t=t.write())!=null) - Thread.runInNew(t.function(), new JS[]{(JS)o}); - return null; - }}); - //HTTP.HTTPInputStream his = (HTTP.HTTPInputStream)HttpStream.getHeadStream(); - // get the timestamp on the remote file - long remoteModifiedDate = 0; - String remoteModified = null; - try { - JS info = httpStream.getInfo(); - remoteModified = JSU.toString(info.get(SC_lastModified)); - Trap t = principal.getTrap(SC_Downloading); - if(t!=null && (t=t.write())!=null) - Thread.runInNew(t.function(), new JS[]{info}); - } catch (JSExn e1) { - // Should not happen! - Log.error(Resources.class, e1); - } - - if (remoteModified!=null && !remoteModified.equals("")) { - // Try parsing the date using each of the date formats specified in RFC2616 - DateFormat dfmt; - Date dt = null; - for (int i=0; dt==null && i<datefmts.length; i++) { - dfmt = new SimpleDateFormat(datefmts[i]); - try { dt = dfmt.parse(remoteModified); } catch (ParseException e) { dt = null; } - } - if (dt==null) remoteModifiedDate = 0; // unable to parse remote date, so ignore it - else remoteModifiedDate = dt.getTime(); - } + String url; + String filename; + Fountain.File cache; + - String fname = getTempDir() + pathToFileName(url); - java.io.File localFile = new java.io.File(fname); + public RemoteFile(String url, String filename) { + while (url.endsWith("/")) url = url.substring(0, url.length() - 1); + this.url = url; + this.filename = filename; + } - // if the file exists, then compare the timestamps - if (localFile.exists()) { - long localModified = localFile.lastModified(); - if (remoteModifiedDate > 0) { - if (remoteModifiedDate <= localModified) { - // if the local file is newer or the same age, then just use it - Log.uInfo(Resources.class, "... using cached copy of vexi file"); - cache = new Zip(new File(localFile.getAbsolutePath())); - return; - } - } - } + public RemoteFile(String url) { + this(url, Resources.getTempDir() + Resources.pathToFileName(url)); + } - // download the file - FileOutputStream fos = new FileOutputStream(localFile); - int len; - InputStream is = httpStream.getInputStream(); - while ((len=is.read(buffer, 0, buffer.length)) >= 0) { - fos.write(buffer, 0, len); - } - fos.close(); - is.close(); + public InputStream getInputStream() throws IOException { + // First download we check and potentially update the cache + if(cache == null){cache(this);} + return cache.getInputStream(); + } - // set the local file's timestamp - if (remoteModifiedDate > 0) { - localFile.setLastModified(remoteModifiedDate); - } + /** pull the specified file from a URL and store it in a temporary local .vexi file + * @param principal + * @throws IOException + * @throws JSExn */ + public void cache(final JS principal) throws IOException { + Log.uInfo(Main.class, "Downloading vexi file from " + url); + try{ + Fountain.ProgressWatcher httpStream = new Fountain.ProgressWatcher(principal, new Fountain.HTTP(url)); + Trap finishTrap = principal.getTrap(SC_finish); + finishTrap=finishTrap==null?null:finishTrap.write(); + + // get the timestamp on the remote file + JS info = httpStream.getInfo(); + long remoteModifiedDate = parseDate(JSU.toString(info.get(SC_lastModified))); - Log.uInfo(Resources.class, "Done downloading to file " + localFile.getAbsolutePath()); - cache = new Zip(new File(localFile.getAbsolutePath())); - } - - public void addTrap(JS key, JS f) throws JSExn { - //TODO - worthwhile optimisation or not? - //String s = JSU.toString(key); - //if(s.equals("Downloading") || s.equals("Progress")) watch=true; - super.addTrap(key, f); - } - + java.io.File localFile = new java.io.File(filename); + + // if the file exists and we know the remote + // modification date - then compare the timestamps + if (localFile.exists() && remoteModifiedDate > 0) { + long localModified = localFile.lastModified(); + if (remoteModifiedDate <= localModified) { + // if the local file is newer or the same age, then just use it + Log.uInfo(Resources.class, "... using cached copy of file " + url); + cache = new File(localFile.getAbsolutePath()); + if(finishTrap!=null) Thread.runInNew(finishTrap.function(), new JS[]{JSU.F}); + return; + } + } + + Resources.streamToFile(localFile, httpStream.getInputStream()); + + // set the local file's timestamp + if (remoteModifiedDate > 0) { + localFile.setLastModified(remoteModifiedDate); + } + + Log.uInfo(Resources.class, "Done downloading to file " + localFile.getAbsolutePath()); + cache = new File(localFile.getAbsolutePath()); + if(finishTrap!=null) Thread.runInNew(finishTrap.function(), new JS[]{JSU.T}); + }catch(JSExn e){ + throw new IOException(e); + } + } + + public void addTrap(JS key, JS f) throws JSExn { + //FEATURE - worthwhile optimisation or not? + //String s = JSU.toString(key); + //if(s.equals("Downloading") || s.equals("Progress")) watch=true; + super.addTrap(key, f); + } + + private static final String[] datefmts = { + "EEE, dd MMM yyyy HH:mm:ss zzz", + "EEEE, dd-MMM-yy HH:mm:ss zzz", + "EEE MMM d HH:mm:ss yyyy" + }; + static private long parseDate(String remoteModified){ + if (remoteModified!=null && !remoteModified.equals("")) { + // Try parsing the date using each of the date formats specified in RFC2616 + DateFormat dfmt; + Date dt = null; + for (int i=0; dt==null && i<datefmts.length; i++) { + dfmt = new SimpleDateFormat(datefmts[i]); + try { dt = dfmt.parse(remoteModified); } catch (ParseException e) { dt = null; } + } + if (dt!=null) return dt.getTime(); + //unable to parse remote date, so it will be ignored + } + return 0; + } } + + final static int BUFFER_SIZE = 1024; + static void streamToFile(java.io.File localFile, InputStream is ) throws IOException{ + byte[] buffer = new byte[BUFFER_SIZE]; + FileOutputStream fos = new FileOutputStream(localFile); + int len; + while ((len=is.read(buffer, 0, buffer.length)) >= 0) { + fos.write(buffer, 0, len); + } + fos.close(); + is.close(); + } + - /* - public static class Stream extends JS.Immutable{ - - public JS get(JS key) throws JSExn { - String keyStr = JSU.toString(key); - // TODO preprocess... - if("".equals(keyStr)){ - - return super.get(key); - } - - }*/ public static JS parseUTF8(JS[] args) throws JSExn { if(args == null) return null; try { @@ -450,7 +471,6 @@ return null; } - public static void writeUTF8(JS[] args) throws JSExn { try{ OutputStream out = Fountain.getOutputStream(args[0]); @@ -484,7 +504,8 @@ String key = JSU.toString(arg); if(key.equals("startElement") || key.equals("endElement") || - key.equals("characters")) + key.equals("characters") || + key.equals("close")) return METHOD; return super.get(arg); } @@ -519,7 +540,10 @@ String chars = JSU.toString(args[0]); out.write(chars); return null; - } + }else if(key.equals("close")){ + out.close(); + return null; + } }catch(IOException e){ throw new JSExn(e.getMessage()); } @@ -530,9 +554,7 @@ }catch(IOException e){ throw new JSExn(e.getMessage()); } - } - static private class XMLHelper extends XML { @@ -620,6 +642,71 @@ } } } + + + static final File FONTDIR = new File(getTempDir() + "/fonts"); + static{ + FONTDIR.mkdirs(); + } + //////// + // FONT STUFF - + static public void installFont(JS stream) throws JSExn{ + try { + // FEATURE - verify (signed vexi files) + // FEATURE - version (install if a later version) + // FEATURE - don't cache remote archive somehow - + // though may not be possible if we want to do versioning + + Log.warn(Resources.class, "Installing fonts without verification"); + + Keys ks = stream.keys(); + + Enumeration E = ks.iterator(); + while(E.hasNext()){ + JS key = E.next(); + Fountain f = (Fountain) stream.get(key); + // Find out font name from .ttf + InputStream is = f.getInputStream(); + Font font = Font.createFont(Font.TRUETYPE_FONT, is); + String filename = font.getName(); + is.close(); + // Copy .ttf to font directory + is = f.getInputStream(); + streamToFile(new File(FONTDIR,filename+".ttf"), is); + Log.warn(Resources.class, "Installing font " + filename); + } + } catch (Exception e) { + Log.error(Resources.class, e); + throw new JSExn("Error installing font"); + } + } + + static JS installedFonts = new JS.Immutable() { + public JS get(JS key) throws JSExn { + String s = JSU.toString(key); + // FEATURE true type collections (.ttc) + File f = new File(FONTDIR, s + ".ttf"); + if(f.exists()){ + return new Fountain.File(f.getPath()); + } + return null; + } + public Keys keys() throws JSExn { + return new Keys(installedFonts){ + protected JS contains(JS key) throws JSExn { + return JSU.B(installedFonts.get(key)!=null); + } + public Enumeration iterator() throws JSExn { + return new Enumeration(null) { + String[] files = FONTDIR.list(); + private int n = 0; + public boolean _hasNext() { return n < files.length; } + public JS _next() { return JSU.S(files[n++]); } + }; + } + protected JS size() throws JSExn {return JSU.N((FONTDIR.listFiles().length));} + }; + } + }; } Modified: trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-09-27 15:32:42 UTC (rev 2343) +++ trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-09-27 15:46:56 UTC (rev 2344) @@ -113,7 +113,6 @@ case "stream": return getSub(name); case "stream.homedir": return Resources.fountainForName("file:" + System.getProperty("user.home")); case "stream.tempdir": return Resources.fountainForName("file:" + System.getProperty("java.io.tempdir")); - case "stream.watch": return METHOD; case "stream.unzip": return METHOD; case "stream.uncab": return METHOD; case "stream.cache": return METHOD; @@ -131,6 +130,8 @@ case "thread.sleep": return METHOD; case "ui": return getSub(name); case "ui.font": return getSub(name); + case "ui.font.install": return METHOD; + case "ui.font.installed": return Resources.installedFonts; case "ui.font.wait": return METHOD; case "ui.font.width": return METHOD; case "ui.font.height": return METHOD; @@ -236,7 +237,8 @@ case "stream.parse.utf8": return Resources.parseUTF8(args); case "thread.sleep": JSU.sleep(JSU.toInt(args[0])); return null; case "ui.browser": Platform.newBrowserWindow(JSU.toString(args[0])); return null; - case "ui.insets": + case "ui.font.install": Resources.installFont(args[0]); return null; + case "ui.insets": if(args[0] == null) throw new JSExn("can't discern insets for a null frame"); Box b = null; try{ b = (Box)args[0]; } @@ -256,15 +258,6 @@ //#switch(JSU.toString(method)) case "regexp": return new JSRegexp(args[0], args[1]); case "stream.parse.xml": Resources.parseXML(args); return null; - case "stream.watch": - final JS func = args[1]; - return new Fountain.ProgressWatcher((Fountain)args[0], - new Callable() { - public Object run(Object o) throws Exception { - JS[] args = (JS[])o; - return func.call(null, args); - } - }); case "stream.write.utf8": Resources.writeUTF8(args); return null; //#end case 3: Modified: trunk/core/org.vexi.core/src_junit/org/vexi/core/TestResources.java =================================================================== --- trunk/core/org.vexi.core/src_junit/org/vexi/core/TestResources.java 2007-09-27 15:32:42 UTC (rev 2343) +++ trunk/core/org.vexi.core/src_junit/org/vexi/core/TestResources.java 2007-09-27 15:46:56 UTC (rev 2344) @@ -1,7 +1,9 @@ package org.vexi.core; +import java.awt.Font; import java.io.BufferedReader; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -11,6 +13,7 @@ import junit.framework.TestSuite; import org.ibex.js.Fountain; +import org.ibex.js.JS; import org.ibex.js.JSU; import test.Util; @@ -22,7 +25,7 @@ public static void main(String[] args) throws Exception { //new Local().testLocalInJarB(); Remote r = new Remote(); - r.setUp(); r.testDownload(); r.tearDown(); + r.setUp(); r.testInstallFont(); r.tearDown(); } static public Test suite() { @@ -80,8 +83,11 @@ } static public class Remote extends TestCase{ + static final int PORT=7070; + static final int RATE=Integer.MAX_VALUE; // no throttling + static NanoHTTPD server = null; - static final String URL = "http://localhost:" + NanoHTTPD.PORT + "/"; + static final String URL = "http://localhost:" + PORT + "/"; static public boolean deleteDirectory(File path) { if( path.exists() ) { @@ -99,7 +105,7 @@ } protected void setUp() throws Exception { - NanoHTTPD.start(); + NanoHTTPD.start(PORT,RATE); // Set user.home and VEXIDIR_NAME to control // where the temp dir is put System.setProperty("user.home", "."); @@ -126,6 +132,19 @@ System.out.println("HI"); } + public void testInstallFont() throws Exception{ + // TODO delete cache + File installed = new File(Resources.FONTDIR,"Bitstream Vera Sans.ttf"); + if(installed.exists() && !installed.delete()) fail(); + Fountain f = Resources.cacheableForName(URL + "VeraSans.vexi"); + JS fontJS = Resources.installedFonts.get(JSU.S("Bitstream Vera Sans")); + assertNull(fontJS); + Resources.installFont(f); + assertTrue(installed.exists()); + fontJS = Resources.installedFonts.get(JSU.S("Bitstream Vera Sans")); + assertNotNull(fontJS); + } + } Modified: trunk/core/org.vexi.core/src_junit/test/core/download/TestDownload.java =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/download/TestDownload.java 2007-09-27 15:32:42 UTC (rev 2343) +++ trunk/core/org.vexi.core/src_junit/test/core/download/TestDownload.java 2007-09-27 15:46:56 UTC (rev 2344) @@ -39,7 +39,7 @@ return new CoreTestCase(resourceDirs, fileName){ protected void setUp() throws Exception { createDotVexi(new File(NanoHTTPD.class.getResource(".").getPath())); - NanoHTTPD.start(); + NanoHTTPD.start(7070,Integer.MAX_VALUE); } protected void tearDown() throws Exception { Modified: trunk/core/org.vexi.core/src_junit/test/core/stream/TestStream.java =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/stream/TestStream.java 2007-09-27 15:32:42 UTC (rev 2343) +++ trunk/core/org.vexi.core/src_junit/test/core/stream/TestStream.java 2007-09-27 15:46:56 UTC (rev 2344) @@ -74,6 +74,7 @@ File save_ = new File(tmpDir,"save.txt"); TestCase.assertTrue(!save_.exists() || save_.delete()); Fountain.File save = new Fountain.File(save_.getPath(),true); + //save.remove(); Thread.beforeNonJS(); try{ JS function = Util.getStatic(v, main, "runtest"); Modified: trunk/core/org.vexi.core/src_junit/test/core/stream/badargs.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/stream/badargs.t 2007-09-27 15:32:42 UTC (rev 2343) +++ trunk/core/org.vexi.core/src_junit/test/core/stream/badargs.t 2007-09-27 15:46:56 UTC (rev 2344) @@ -1,11 +1,12 @@ <vexi xmlns:ui="vexi://ui" xmlns=""> + static.ret = null; static.hasException = function(f /*...*/){ var exn = false; try{ switch(arguments.length-1){ - case 1: f(arguments[1]); break; - case 2: f(arguments[1], arguments[2]); break; + case 1: ret=f(arguments[1]); break; + case 2: ret=f(arguments[1], arguments[2]); break; } }catch(e){ vexi.log.info(e);exn = true;} return exn; @@ -24,9 +25,10 @@ assertBadArgs(vexi.stream.parse.xml,null, {}); assertBadArgs(vexi.stream.parse.xml,stream); assertBadArgs(vexi.stream.parse.xml,stream, null); + assertBadArgs(vexi.stream.write.xml,{}); assertGoodArgs(vexi.stream.parse.xml,stream, {}); - assertBadArgs(vexi.stream.write.xml,{}); assertGoodArgs(vexi.stream.write.xml,stream); + ret.close(); // as we opened a stream we need to make sure its closed }; <ui:box/> Modified: trunk/core/org.vexi.core/src_junit/testdeployment/NanoHTTPD.java =================================================================== --- trunk/core/org.vexi.core/src_junit/testdeployment/NanoHTTPD.java 2007-09-27 15:32:42 UTC (rev 2343) +++ trunk/core/org.vexi.core/src_junit/testdeployment/NanoHTTPD.java 2007-09-27 15:46:56 UTC (rev 2344) @@ -1,15 +1,34 @@ package testdeployment; -import java.io.*; -import java.util.*; -import java.net.*; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.net.BindException; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.SocketException; +import java.net.URLEncoder; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Locale; +import java.util.Properties; +import java.util.StringTokenizer; +import java.util.TimeZone; import org.ibex.util.Log; -import test.core.download.TestDownload; - /** - * MODIFIED - slightly, to suit test purposes (mikeg). + * MODIFIED - slightly + * 1) to suit test purposes (mikeg). + * 2) added basic bandwidth throttling. * * * A simple, tiny, nicely embeddable HTTP 1.0 server in Java @@ -50,14 +69,20 @@ */ public class NanoHTTPD { - //static int logLevel = Log.INFO; + public final int PORT; + private final int MAX_BYTES_PER_SECOND; - static public int PORT = 7070; + private static boolean log = true; private static NanoHTTPD singleton; + + static public void start() throws Exception{ - if(singleton==null) singleton = new NanoHTTPD(PORT); + start(7070,Integer.MAX_VALUE); } + static public void start(int port, int rate) throws Exception{ + if(singleton==null) singleton = new NanoHTTPD(port,rate); + } static public void stop() throws IOException{ if(singleton!=null){ @@ -109,7 +134,7 @@ if(myFileDir==null) myFileDir = new File("."); - return serveFile( uri, header, myFileDir, true ); + return serveFile( uri, method, header, myFileDir, true ); } /** @@ -207,8 +232,10 @@ * Throws an IOException if the socket is already in use * @throws InterruptedException */ - public NanoHTTPD( int port ) throws IOException, InterruptedException - { + public NanoHTTPD(int port, int rate) throws IOException, InterruptedException + { + PORT = port; + MAX_BYTES_PER_SECOND = rate; myFileDir = new File(NanoHTTPD.class.getResource(".").getPath());; myTcpPort = port; @@ -237,7 +264,7 @@ { ioe.printStackTrace(); } - System.out.println("NanoHTTPD, finished serving"); + Log.warn(NanoHTTPD.class, "finished serving"); } }); myThread.setDaemon( true ); @@ -262,7 +289,7 @@ } // Change port if requested - int port = 80; + int port = 7070; if ( args.length > 0 && lopt != 0 ) port = Integer.parseInt( args[0] ); @@ -273,7 +300,7 @@ NanoHTTPD nh = null; try { - nh = new NanoHTTPD( port ); + nh = new NanoHTTPD( port, 600); } catch( Exception ioe ) { @@ -553,7 +580,7 @@ * Serves file from homeDir and its' subdirectories (only). * Uses only URI, ignores all headers and HTTP parameters. */ - public Response serveFile( String uri, Properties header, File homeDir, + public Response serveFile( String uri, String method, Properties header, File homeDir, boolean allowDirectoryListing ) { // Make sure we won't die of an exception later @@ -677,13 +704,18 @@ catch ( NumberFormatException nfe ) {} } } - - FileInputStream fis = new FileInputStream( f ); - fis.skip( startFrom ); - Response r = new Response( HTTP_OK, mime, fis ); + InputStream is = null; + if("HEAD".equals(method)){ + is = new ByteArrayInputStream(new byte[]{}); + }else{ + is = new FileInputStream( f ); + is.skip( startFrom ); + } + Response r = new Response( HTTP_OK, mime, is ); r.addHeader( "Content-length", "" + (f.length() - startFrom)); r.addHeader( "Content-range", "" + startFrom + "-" + (f.length()-1) + "/" + f.length()); + r.addHeader( "last-modified", ""+formatDate(f.lastModified())); return r; } catch( IOException ioe ) @@ -692,6 +724,11 @@ } } + private static final SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz"); + private static String formatDate(long t){ + return sdf.format(new Date(t)); + } + /** * Hashtable mapping (String)FILENAME_EXTENSION -> (String)MIME_TYPE */ Added: trunk/core/org.vexi.core/src_junit/testdeployment/VeraSans.vexi =================================================================== (Binary files differ) Property changes on: trunk/core/org.vexi.core/src_junit/testdeployment/VeraSans.vexi ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mk...@us...> - 2007-09-28 16:55:43
|
Revision: 2350 http://vexi.svn.sourceforge.net/vexi/?rev=2350&view=rev Author: mkpg2 Date: 2007-09-28 09:55:46 -0700 (Fri, 28 Sep 2007) Log Message: ----------- Feature. Pass and access arguments when applying templates. pass: template(b, [...]) access: arguments[i] Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java trunk/core/org.vexi.core/src/org/vexi/core/Template.java trunk/core/org.vexi.core/src/org/vexi/net/HTTP.java Added Paths: ----------- trunk/core/org.vexi.core/src_junit/test/core/template/_apply_args.t trunk/core/org.vexi.core/src_junit/test/core/template/apply_args.t Modified: trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java 2007-09-28 16:27:48 UTC (rev 2349) +++ trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java 2007-09-28 16:55:46 UTC (rev 2350) @@ -4,6 +4,7 @@ import java.io.InputStream; import org.ibex.js.JS; +import org.ibex.js.JSArray; import org.ibex.js.JSExn; import org.ibex.js.JSU; import org.ibex.js.JS.Keys; @@ -140,13 +141,14 @@ public JS call(JS method, JS[] args) throws JSExn { if (method != null) return super.call(method, args); - if (args.length != 1) - throw new JSExn("Can only apply templates using a single-argument function"); + if ((args.length < 1 || !(args[0] instanceof Box)) + || (args.length == 2 && !(args[1] instanceof JSArray)) + || args.length > 2 ) + throw new JSExn("to apply a template us 'template(box [, array])'"); // Ensure template is created by creating the static part. getStatic(); - if (t == null) throw new JSExn("No such template " + description()); - if(!(args[0] instanceof Box)) throw new JSExn("can only apply templates to boxes"); - t.apply((Box)args[0]); + if (t == null) throw new JSExn("no such template " + description()); + t.apply((Box)args[0],args.length==2?((JSArray)args[1]).toArray():null); return args[0]; } Modified: trunk/core/org.vexi.core/src/org/vexi/core/Template.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Template.java 2007-09-28 16:27:48 UTC (rev 2349) +++ trunk/core/org.vexi.core/src/org/vexi/core/Template.java 2007-09-28 16:55:46 UTC (rev 2350) @@ -140,33 +140,35 @@ /** Applies the template to Box b - * @param pboxes a vector of all box parents on which to put $-references - * @param ptemplates a vector of the fileNames to recieve private references on the pboxes + * @param b - box applied to + * @param js[] - arguments object (typically empty) */ - public void apply(Box b) throws JSExn { - apply(b, null); + // @param pboxes a vector of all box parents on which to put $-references + // @param ptemplates a vector of the fileNames to recieve private references on the pboxes + public void apply(Box b, JS[] js) throws JSExn { + apply(b, js, null); } - private static Template preapply(Box b, Template t) throws JSExn{ + private static Template preapply(Box b, JS[] args, Template t) throws JSExn{ if (t != null){ // make sure we have resolved (if were top level) if(t.staticPart!=null && t.staticPart.staticObject==null){ t = ((Blessing)Vexi.resolveString(t.vexi,t.staticPart.sourceName, false)).initTemplate(t); } - t.apply(b, null); + t.apply(b, args, null); } return t; } - private void apply(Box b, PerInstantiationScope parentPis) throws JSExn { + private void apply(Box b, JS[] args, PerInstantiationScope parentPis) throws JSExn { Thread.getCurrentInterpreter().enterNonJSCall( this); try{ // REMARK - the preapplies may not have been resolved yet, // the resolved template is not necessarily the same object. // FOOTNOTE:2 - preapply = preapply(b, preapply); - principal = preapply(b, principal); + preapply = preapply(b, args, preapply); + principal = preapply(b, args, principal); // UNCOMMENT to DEBUG //b.put(JSU.S("_template_"), JSU.S(fileName()+":"+startLine)); @@ -182,7 +184,7 @@ // FIXME needs to obey the new application-ordering rules for (int i=0; children != null && i<children.size(); i++) { Box kid = new Box(); - ((Template)children.elementAt(i)).apply(kid, pis); + ((Template)children.elementAt(i)).apply(kid, null, pis); b.putAndTriggerTraps(b.get(SC_numchildren), kid); } @@ -220,7 +222,7 @@ //UGLY - avoiding adding an init param if(script== null)script = JSU.F; } - if (script != JSU.F) JSU.cloneWithNewGlobalScope(script, pis).call(null, EMPTY_JS_ARRAY); + if (script != JSU.F) JSU.cloneWithNewGlobalScope(script, pis).call(null, args!=null?args:EMPTY_JS_ARRAY); }finally{ Thread.getCurrentInterpreter().exitNonJSCall(); Modified: trunk/core/org.vexi.core/src/org/vexi/net/HTTP.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/net/HTTP.java 2007-09-28 16:27:48 UTC (rev 2349) +++ trunk/core/org.vexi.core/src/org/vexi/net/HTTP.java 2007-09-28 16:55:46 UTC (rev 2350) @@ -1515,7 +1515,7 @@ // Template.buildTemplate("org/ibex/builtin/proxy_authorization.ibex", // Stream.getInputStream((JS)Main.builtin.get("org/ibex/builtin/proxy_authorization.ibex")), // new Vexi(null)); - t.apply(b); + // t.apply(b,null); b.put("realm", realm); b.put("proxyIP", proxyIP); return null; Added: trunk/core/org.vexi.core/src_junit/test/core/template/_apply_args.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/template/_apply_args.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/template/_apply_args.t 2007-09-28 16:55:46 UTC (rev 2350) @@ -0,0 +1,12 @@ +<vexi xmlns:ui="vexi://ui" xmlns=""> + + + <ui:box> + assert(arguments!=null); + .util..assertEquals(2,arguments.length); + .util..assertEquals(4,arguments[0]); + .util..assertEquals("aces",arguments[1]); + + </ui:box> + +</vexi> Added: trunk/core/org.vexi.core/src_junit/test/core/template/apply_args.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/template/apply_args.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/template/apply_args.t 2007-09-28 16:55:46 UTC (rev 2350) @@ -0,0 +1,10 @@ +<vexi xmlns:ui="vexi://ui" xmlns=""> + + + <ui:box> + assert(arguments!=null); + vexi.log.info(arguments.length); + var _template = ._apply_args(vexi.box,[4,"aces"]); + </ui:box> + +</vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mk...@us...> - 2007-09-29 00:48:07
|
Revision: 2355 http://vexi.svn.sourceforge.net/vexi/?rev=2355&view=rev Author: mkpg2 Date: 2007-09-28 17:48:10 -0700 (Fri, 28 Sep 2007) Log Message: ----------- Fix. Resources in background threads. Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Resources.java trunk/core/org.vexi.core/src_junit/org/vexi/core/TestResources.java trunk/core/org.vexi.core/src_junit/testdeployment/NanoHTTPD.java Modified: trunk/core/org.vexi.core/src/org/vexi/core/Resources.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2007-09-29 00:04:27 UTC (rev 2354) +++ trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2007-09-29 00:48:10 UTC (rev 2355) @@ -1,6 +1,7 @@ package org.vexi.core; import java.awt.Font; +import java.awt.FontFormatException; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; @@ -30,6 +31,7 @@ import org.ibex.util.Encode; import org.ibex.util.InputStreamToByteArray; import org.ibex.util.Log; +import org.ibex.util.Pausable; import org.ibex.util.Tree; import org.ibex.util.XML; import org.ibex.util.Basket.Stack; @@ -47,7 +49,47 @@ // pseudo constant (want to change during testing) static String VEXIDIR_NAME = ".vexi"; + + + /** get the vexi file directory (currently [user home]/.vexi) and create it if it doesn't exist */ + static public final String DIR_VEXI; + static public final String DIR_FONTS; + + /////////// + /// INITIALISE RESOURCE DIRS + static { + // VEXIDIR + StringBuffer vexiDirPath = new StringBuffer(512); + // get the base dir; use the user's home dir if specified, otherwise use the temp dir + vexiDirPath.append(System.getProperty("user.home",System.getProperty("java.io.tmpdir",""))); + + // add a file separator on the end of the path if there isn't one already + if (!vexiDirPath.toString().endsWith(fileSep)) vexiDirPath.append(fileSep); + + + // append the vexi dir name, and create it if it doesn't exist + vexiDirPath.append(System.getProperty("vexi.vexidirname",".vexi")); + + + vexiDirPath.append(fileSep); + DIR_VEXI = vexiDirPath.toString(); + + // FONTDIR + DIR_FONTS = DIR_VEXI + "/fonts"; + + File vexiDir = new File(DIR_VEXI); + if (!vexiDir.exists()) vexiDir.mkdirs(); + File fontDir = new File(DIR_FONTS); + if (!fontDir.exists()) fontDir.mkdirs(); + + } + + + + + + /** * FEATURE: this should be implemented using self-emulation * Used for security checks. If this is null, it means that only @@ -266,34 +308,7 @@ } }*/ - /** get the vexi file directory (currently [user home]/.vexi) and create it if it doesn't exist */ - static String getTempDir() { - // get the base dir; use the user's home dir if specified, otherwise use the temp dir - StringBuffer vexiDirName = new StringBuffer(512); - String userHome = System.getProperty("user.home"); - if (userHome != null && !userHome.equals("")) { - vexiDirName.append(userHome); - } - else { - vexiDirName.append(System.getProperty("java.io.tmpdir")); - } - // add a file separator on the end of the path if there isn't one already - if (!vexiDirName.toString().endsWith(fileSep)) { - vexiDirName.append(fileSep); - } - - // append the vexi dir name, and create it if it doesn't exist - vexiDirName.append(VEXIDIR_NAME); - File tmpDir = new File(vexiDirName.toString()); - if (!tmpDir.exists()) { - tmpDir.mkdir(); - } - - vexiDirName.append(fileSep); - return vexiDirName.toString(); - } - /** convert a path (or URL) to a file name */ static String pathToFileName(String path) { return path.replace('/', '_').replace('\\', '_').replace(':', '_'); @@ -304,7 +319,7 @@ public JS get(JS key) throws JSExn { String biscuitid = System.getProperty("biscuitid","default"); String filename = biscuitid + "_" + JSU.toString(key); - File dotBiscuits = new File(getTempDir() + ".biscuits"); + File dotBiscuits = new File(DIR_VEXI + ".biscuits"); dotBiscuits.mkdirs(); Fountain f = new Fountain.File(dotBiscuits.getPath() + "/" + filename); return f; @@ -362,7 +377,7 @@ } public RemoteFile(String url) { - this(url, Resources.getTempDir() + Resources.pathToFileName(url)); + this(url, DIR_VEXI + Resources.pathToFileName(url)); } public InputStream getInputStream() throws IOException { @@ -377,16 +392,17 @@ * @throws JSExn */ public void cache(final JS principal) throws IOException { Log.uInfo(Main.class, "Downloading vexi file from " + url); - try{ - Fountain.ProgressWatcher httpStream = new Fountain.ProgressWatcher(principal, new Fountain.HTTP(url)); + try + { + final Fountain.ProgressWatcher httpStream = new Fountain.ProgressWatcher(principal, new Fountain.HTTP(url)); Trap finishTrap = principal.getTrap(SC_finish); finishTrap=finishTrap==null?null:finishTrap.write(); - + // get the timestamp on the remote file JS info = httpStream.getInfo(); long remoteModifiedDate = parseDate(JSU.toString(info.get(SC_lastModified))); - java.io.File localFile = new java.io.File(filename); + final java.io.File localFile = new java.io.File(filename); // if the file exists and we know the remote // modification date - then compare the timestamps @@ -399,23 +415,20 @@ if(finishTrap!=null) Thread.runInNew(finishTrap.function(), new JS[]{JSU.F}); return; } + } else{ + Resources.streamToFile(localFile, httpStream.getInputStream()); + // set the local file's timestamp + if (remoteModifiedDate > 0) { + localFile.setLastModified(remoteModifiedDate); + } + Log.uInfo(Resources.class, "Done downloading to file " + localFile.getAbsolutePath()); + cache = new File(localFile.getAbsolutePath()); + if(finishTrap!=null) Thread.runInNew(finishTrap.function(), new JS[]{JSU.T}); } - - Resources.streamToFile(localFile, httpStream.getInputStream()); - - // set the local file's timestamp - if (remoteModifiedDate > 0) { - localFile.setLastModified(remoteModifiedDate); - } - - Log.uInfo(Resources.class, "Done downloading to file " + localFile.getAbsolutePath()); - cache = new File(localFile.getAbsolutePath()); - if(finishTrap!=null) Thread.runInNew(finishTrap.function(), new JS[]{JSU.T}); }catch(JSExn e){ - // only supported by Java 6 - //throw new IOException(e); - throw new IOException(e.getMessage()); + throw new IOException(e); } + } public void addTrap(JS key, JS f) throws JSExn { @@ -644,51 +657,58 @@ } } } - - - static final File FONTDIR = new File(getTempDir() + "/fonts"); - static{ - FONTDIR.mkdirs(); - } + //////// // FONT STUFF - static public void installFont(JS stream) throws JSExn{ - try { - // FEATURE - verify (signed vexi files) - // FEATURE - version (install if a later version) - // FEATURE - don't cache remote archive somehow - - // though may not be possible if we want to do versioning + static public void installFont(final JS stream){ + final Pausable callback = Thread.pauseCurrent(); + new java.lang.Thread(new Runnable(){ + public void run() { + try{ + _installFont(stream); + JSU.schedule(callback, null); + } catch(JSExn e) { + JSU.schedule(callback, e); + } catch(Exception e) { + // IMPROVEMENT - JSU.schedule converts over exceptions for us + JSU.schedule(callback, new JSExn(e.getMessage())); + } + } + }).start(); - Log.warn(Resources.class, "Installing fonts without verification"); + } + static public void _installFont(JS stream) throws Exception{ + // FEATURE - verify (signed vexi files) + // FEATURE - version (install if a later version) + // FEATURE - don't cache remote archive somehow - + // though may not be possible if we want to do versioning - Keys ks = stream.keys(); - - Enumeration E = ks.iterator(); - while(E.hasNext()){ - JS key = E.next(); - Fountain f = (Fountain) stream.get(key); - // Find out font name from .ttf - InputStream is = f.getInputStream(); - Font font = Font.createFont(Font.TRUETYPE_FONT, is); - String filename = font.getName(); - is.close(); - // Copy .ttf to font directory - is = f.getInputStream(); - streamToFile(new File(FONTDIR,filename+".ttf"), is); - Log.warn(Resources.class, "Installing font " + filename); - } - } catch (Exception e) { - Log.error(Resources.class, e); - throw new JSExn("Error installing font"); - } + Log.warn(Resources.class, "Installing fonts without verification"); + + Keys ks = stream.keys(); + + Enumeration E = ks.iterator(); + while(E.hasNext()){ + JS key = E.next(); + Fountain f = (Fountain) stream.get(key); + // Find out font name from .ttf + InputStream is = f.getInputStream(); + Font font = Font.createFont(Font.TRUETYPE_FONT, is); + String filename = font.getName(); + is.close(); + // Copy .ttf to font directory + is = f.getInputStream(); + streamToFile(new File(DIR_FONTS,filename+".ttf"), is); + Log.warn(Resources.class, "Installing font " + filename); + } } - + static JS installedFonts = new JS.Immutable() { public JS get(JS key) throws JSExn { String s = JSU.toString(key); // FEATURE true type collections (.ttc) - File f = new File(FONTDIR, s + ".ttf"); + File f = new File(DIR_FONTS, s + ".ttf"); if(f.exists()){ return new Fountain.File(f.getPath()); } @@ -701,13 +721,13 @@ } public Enumeration iterator() throws JSExn { return new Enumeration(null) { - String[] files = FONTDIR.list(); + String[] files = new File(DIR_FONTS).list(); private int n = 0; public boolean _hasNext() { return n < files.length; } public JS _next() { return JSU.S(files[n++]); } }; } - protected JS size() throws JSExn {return JSU.N((FONTDIR.listFiles().length));} + protected JS size() throws JSExn {return JSU.N(( new File(DIR_FONTS).listFiles().length));} }; } }; Modified: trunk/core/org.vexi.core/src_junit/org/vexi/core/TestResources.java =================================================================== --- trunk/core/org.vexi.core/src_junit/org/vexi/core/TestResources.java 2007-09-29 00:04:27 UTC (rev 2354) +++ trunk/core/org.vexi.core/src_junit/org/vexi/core/TestResources.java 2007-09-29 00:48:10 UTC (rev 2355) @@ -1,9 +1,7 @@ package org.vexi.core; -import java.awt.Font; import java.io.BufferedReader; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -12,12 +10,13 @@ import junit.framework.TestCase; import junit.framework.TestSuite; +import org.ibex.js.DevUtil; import org.ibex.js.Fountain; import org.ibex.js.JS; import org.ibex.js.JSU; +import org.ibex.js.Thread; import test.Util; -import test.js.exec.JSTestSuite; import testdeployment.NanoHTTPD; public class TestResources { @@ -109,14 +108,13 @@ // Set user.home and VEXIDIR_NAME to control // where the temp dir is put System.setProperty("user.home", "."); - Resources.VEXIDIR_NAME = "_vexi_test"; - Resources.getTempDir(); + System.setProperty("vexi.vexidirname","_vexi_test"); } protected void tearDown() throws Exception { // Delete cache after each test - deleteDirectory(new File(Resources.getTempDir())); + deleteDirectory(new File(Resources.DIR_VEXI)); NanoHTTPD.stop(); } @@ -134,12 +132,13 @@ public void testInstallFont() throws Exception{ // TODO delete cache - File installed = new File(Resources.FONTDIR,"Bitstream Vera Sans.ttf"); + File installed = new File(Resources.DIR_FONTS,"Bitstream Vera Sans.ttf"); if(installed.exists() && !installed.delete()) fail(); Fountain f = Resources.cacheableForName(URL + "VeraSans.vexi"); JS fontJS = Resources.installedFonts.get(JSU.S("Bitstream Vera Sans")); assertNull(fontJS); - Resources.installFont(f); + Resources._installFont(f); + assertTrue(installed.exists()); fontJS = Resources.installedFonts.get(JSU.S("Bitstream Vera Sans")); assertNotNull(fontJS); Modified: trunk/core/org.vexi.core/src_junit/testdeployment/NanoHTTPD.java =================================================================== --- trunk/core/org.vexi.core/src_junit/testdeployment/NanoHTTPD.java 2007-09-29 00:04:27 UTC (rev 2354) +++ trunk/core/org.vexi.core/src_junit/testdeployment/NanoHTTPD.java 2007-09-29 00:48:10 UTC (rev 2355) @@ -72,7 +72,7 @@ public final int PORT; private final int MAX_BYTES_PER_SECOND; - private static boolean log = true; + public static boolean log = true; private static NanoHTTPD singleton; @@ -81,8 +81,11 @@ start(7070,Integer.MAX_VALUE); } static public void start(int port, int rate) throws Exception{ - if(singleton==null) singleton = new NanoHTTPD(port,rate); + start(port,rate,null); } + static public void start(int port, int rate, File rootDir) throws Exception{ + if(singleton==null) singleton = new NanoHTTPD(port,rate, rootDir); + } static public void stop() throws IOException{ if(singleton!=null){ @@ -132,8 +135,6 @@ parms.getProperty( value ) + "'" ); } - if(myFileDir==null) myFileDir = new File("."); - return serveFile( uri, method, header, myFileDir, true ); } @@ -232,11 +233,11 @@ * Throws an IOException if the socket is already in use * @throws InterruptedException */ - public NanoHTTPD(int port, int rate) throws IOException, InterruptedException + public NanoHTTPD(int port, int rate, File rootDir) throws IOException, InterruptedException { PORT = port; MAX_BYTES_PER_SECOND = rate; - myFileDir = new File(NanoHTTPD.class.getResource(".").getPath());; + myFileDir = rootDir==null?new File(NanoHTTPD.class.getResource(".").getPath()):rootDir; myTcpPort = port; // Retry, its possible the socket is still being released. @@ -269,52 +270,10 @@ }); myThread.setDaemon( true ); myThread.start(); + } - /** - * Starts as a standalone file server and waits for Enter. - */ - public static void main( String[] args ) - { - Log.info(NanoHTTPD.class, "NanoHTTPD 1.04 (C) 2001,2005 Jarno Elonen\n" + - "(Command line options: [port] [--licence])\n" ); - // Show licence if requested - int lopt = -1; - for ( int i=0; i<args.length; ++i ) - if ( args[i].toLowerCase().endsWith( "licence" )) - { - lopt = i; - Log.info(NanoHTTPD.class, LICENCE + "\n" ); - } - - // Change port if requested - int port = 7070; - if ( args.length > 0 && lopt != 0 ) - port = Integer.parseInt( args[0] ); - - if ( args.length > 1 && - args[1].toLowerCase().endsWith( "licence" )) - Log.info(NanoHTTPD.class, LICENCE + "\n" ); - - NanoHTTPD nh = null; - try - { - nh = new NanoHTTPD( port, 600); - } - catch( Exception ioe ) - { - System.err.println( "Couldn't start server:\n" + ioe ); - System.exit( -1 ); - } - - Log.info(NanoHTTPD.class, "Now serving files in port " + port + " from \"" + - nh.myFileDir.getAbsolutePath() + "\"" ); - Log.info(NanoHTTPD.class, "Hit Enter to stop.\n" ); - - try { System.in.read(); } catch( Throwable t ) {}; - } - /** * Handles one session, i.e. parses the HTTP request * and returns the response. @@ -523,13 +482,30 @@ if ( data != null ) { - byte[] buff = new byte[2048]; - while (true) - { - int read = data.read( buff, 0, 2048 ); - if (read <= 0) - break; - out.write( buff, 0, read ); + long start = System.currentTimeMillis(); + long total = 0; + Object mutex = new Object(); + synchronized(mutex){ + + byte[] buff = new byte[2048]; + while (true) + { + int read = data.read( buff, 0, 2048 ); + if (read <= 0) + break; + total += read; + if((total/2048)%40==0)Log.debug(NanoHTTPD.class, ""+total); + out.write( buff, 0, read ); + long elapsed = System.currentTimeMillis() - start; + if(elapsed<total/MAX_BYTES_PER_SECOND){ + try { + mutex.wait((total/MAX_BYTES_PER_SECOND)-elapsed); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + if((total/2048)%20!=0)Log.debug(NanoHTTPD.class, ""+total); } } out.flush(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mk...@us...> - 2007-09-29 23:56:13
|
Revision: 2363 http://vexi.svn.sourceforge.net/vexi/?rev=2363&view=rev Author: mkpg2 Date: 2007-09-29 16:52:47 -0700 (Sat, 29 Sep 2007) Log Message: ----------- Removed org.ibex.js.Pausable -was an unnecessary generalisation -its runtime exception types could escape int to JS and confuse things Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Main.java trunk/core/org.vexi.core/src/org/vexi/core/Resources.java trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp trunk/core/org.vexi.core/src/org/vexi/net/RPC.java trunk/core/org.vexi.core/src/org/vexi/net/SOAP.java trunk/core/org.vexi.core/src_unused/org/vexi/net/XMLRPC.java Modified: trunk/core/org.vexi.core/src/org/vexi/core/Main.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Main.java 2007-09-29 23:45:06 UTC (rev 2362) +++ trunk/core/org.vexi.core/src/org/vexi/core/Main.java 2007-09-29 23:52:47 UTC (rev 2363) @@ -4,10 +4,8 @@ package org.vexi.core; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.util.Vector; import org.ibex.js.Fountain; import org.ibex.js.JS; @@ -15,7 +13,6 @@ import org.ibex.js.JSU; import org.ibex.js.Scheduler; import org.ibex.js.Fountain.Multiple; -import org.ibex.util.Basket; import org.ibex.util.Callable; import org.ibex.util.Encode; import org.ibex.util.Log; Modified: trunk/core/org.vexi.core/src/org/vexi/core/Resources.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2007-09-29 23:45:06 UTC (rev 2362) +++ trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2007-09-29 23:52:47 UTC (rev 2363) @@ -1,7 +1,6 @@ package org.vexi.core; import java.awt.Font; -import java.awt.FontFormatException; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; @@ -28,10 +27,10 @@ import org.ibex.js.JS.Keys; import org.ibex.js.JSU.Wrapper; import org.ibex.util.Basket; +import org.ibex.util.Callable; import org.ibex.util.Encode; import org.ibex.util.InputStreamToByteArray; import org.ibex.util.Log; -import org.ibex.util.Pausable; import org.ibex.util.Tree; import org.ibex.util.XML; import org.ibex.util.Basket.Stack; @@ -661,8 +660,8 @@ //////// // FONT STUFF - static public void installFont(final JS stream){ - final Pausable callback = Thread.pauseCurrent(); + static public void installFont(final JS stream) throws JSExn{ + final Callable callback = Thread.pauseCurrent(); new java.lang.Thread(new Runnable(){ public void run() { try{ Modified: trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-09-29 23:45:06 UTC (rev 2362) +++ trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-09-29 23:52:47 UTC (rev 2363) @@ -18,8 +18,6 @@ import org.ibex.util.Callable; import org.ibex.util.Encode; import org.ibex.util.Log; -import org.ibex.util.Pausable; -import org.ibex.util.Pausable.NotPausableException; import org.vexi.graphics.Font; import org.vexi.net.HTTP; import org.vexi.net.SOAP; @@ -350,7 +348,7 @@ // From JS thread. static private Blessing bless_jsthread(final JS vexi, final JS fountain) throws JSExn { try { - final Pausable callback = Thread.pauseCurrent(); + final Callable callback = Thread.pauseCurrent(); new java.lang.Thread() { public void run() { try{ Fountain f = JSU.getFountain(fountain); @@ -362,7 +360,7 @@ } }}.start(); return null; // doesn't matter since we paused - } catch (NotPausableException npe) { + } catch (JSExn e) { throw new JSExn("cannot access a potentially remote resource in the foreground thread"); } } Modified: trunk/core/org.vexi.core/src/org/vexi/net/RPC.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/net/RPC.java 2007-09-29 23:45:06 UTC (rev 2362) +++ trunk/core/org.vexi.core/src/org/vexi/net/RPC.java 2007-09-29 23:52:47 UTC (rev 2363) @@ -7,6 +7,7 @@ import org.ibex.js.JSArray; import org.ibex.js.JSExn; import org.ibex.js.JSU; +import org.ibex.util.Callable; import org.ibex.util.Log; import org.ibex.util.Vec; import org.ksoap2.serialization.SoapObject; @@ -96,7 +97,7 @@ * The arguments that will be used to constuct the body of the * RPC request */ - void call(org.ibex.util.Pausable unpausecallback, JSArray args) { + void call(Callable unpausecallback, JSArray args) { if (Log.rpc) { Log.info(this, "call to " + url + " : " + method); } Modified: trunk/core/org.vexi.core/src/org/vexi/net/SOAP.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/net/SOAP.java 2007-09-29 23:45:06 UTC (rev 2362) +++ trunk/core/org.vexi.core/src/org/vexi/net/SOAP.java 2007-09-29 23:52:47 UTC (rev 2363) @@ -14,7 +14,6 @@ import org.ibex.js.Thread; import org.ibex.util.Callable; import org.ibex.util.Log; -import org.ibex.util.Pausable; import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; @@ -56,7 +55,7 @@ private Object call(final JSArray args) throws JSExn { try { - final org.ibex.util.Pausable callback = Thread.pauseCurrent(); + final Callable callback = Thread.pauseCurrent(); (new java.lang.Thread() { public void run() { @@ -71,7 +70,7 @@ } } - void call(final org.ibex.util.Pausable callback, JSArray jsarray) { + void call(final Callable callback, JSArray jsarray) { Object obj2; super.call(callback, jsarray); Log.info(this, "a"); @@ -139,17 +138,12 @@ }); } catch (final JSExn e) { final Exception e2 = e; - Scheduler.add(new Pausable() { - public Object run(Object o) throws Exception, AlreadyRunningException { + Scheduler.add(new Callable() { + public Object run(Object o) throws Exception { //callback.unpause(e2); Log.error(this, "FIXME: unpause e2:"+e2); return null; } - - public void pause() throws NotPausableException { - // TODO Auto-generated method stub - - } }); } catch (final IOException e) { final Exception e2 = e; Modified: trunk/core/org.vexi.core/src_unused/org/vexi/net/XMLRPC.java =================================================================== --- trunk/core/org.vexi.core/src_unused/org/vexi/net/XMLRPC.java 2007-09-29 23:45:06 UTC (rev 2362) +++ trunk/core/org.vexi.core/src_unused/org/vexi/net/XMLRPC.java 2007-09-29 23:52:47 UTC (rev 2363) @@ -15,7 +15,6 @@ import org.ibex.js.Thread; import org.ibex.util.Callable; import org.ibex.util.Log; -import org.ibex.util.Pausable; import org.ibex.util.Vec; import org.kobjects.xml.XmlReader; @@ -59,7 +58,7 @@ private final Object call(final JSArray args) throws JSExn { try { - final Pausable callback = Thread.pauseCurrent(); + final Callable callback = Thread.pauseCurrent(); new java.lang.Thread() { public void run() { call(callback, args); @@ -73,7 +72,7 @@ } - final void call(final org.ibex.util.Pausable callback, final JSArray args) { + final void call(final Callable callback, final JSArray args) { try { if (Log.rpc) Log.info(this, "call to " + url + " : " + method); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mk...@us...> - 2007-10-11 13:38:38
|
Revision: 2427 http://vexi.svn.sourceforge.net/vexi/?rev=2427&view=rev Author: mkpg2 Date: 2007-10-11 06:38:41 -0700 (Thu, 11 Oct 2007) Log Message: ----------- Commented out code for resolving absolute resources (probably not the way it will be done). Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Template.java trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp trunk/core/org.vexi.core/src_junit/test/core/CoreTestCase.java Modified: trunk/core/org.vexi.core/src/org/vexi/core/Template.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Template.java 2007-10-11 12:39:28 UTC (rev 2426) +++ trunk/core/org.vexi.core/src/org/vexi/core/Template.java 2007-10-11 13:38:41 UTC (rev 2427) @@ -154,7 +154,7 @@ if (t != null){ // make sure we have resolved (if were top level) if(t.staticPart!=null && t.staticPart.staticObject==null){ - t = ((Blessing)Vexi.resolveString(t.vexi,t.staticPart.sourceName, false)).initTemplate(t); + t = ((Blessing)Vexi.resolveString(t.vexi,t.staticPart.sourceName)).initTemplate(t); } t.apply(b, args, null); } @@ -426,7 +426,7 @@ // Resolve on demand (each prefix resolved once per template file) if(resolve && r instanceof String){ // TODO convert to Blessing - r = Vexi.resolveString(vexi,(String)r, true); + r = Vexi.resolveString(vexi,(String)r); map.put(key, r); } Modified: trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java 2007-10-11 12:39:28 UTC (rev 2426) +++ trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java 2007-10-11 13:38:41 UTC (rev 2427) @@ -90,6 +90,7 @@ InputStream is = JSU.getInputStream(s); if (is != null) { + // try { parse(new InputStreamReader(is)); if(Log.sLevel==Log.DEBUG)Log.uDebug(TemplateHelper.class, "Parsing template: " + sourceName()); JS staticScript = parseScript(staticCode.content, staticCode.content_start, sourceName(), createStaticChecker(staticCode.uriPrefixes)); @@ -105,6 +106,10 @@ }else{ Log.uWarn(LOG_TYPE, "'" + unresolved.staticPart.sourceName + ".t' does not declare a template"); } + // required? + //}finally{ + //is.close(); + //} } }catch(JSExn e){ throw e; Modified: trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-10-11 12:39:28 UTC (rev 2426) +++ trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-10-11 13:38:41 UTC (rev 2427) @@ -32,18 +32,19 @@ Log.uInfo(Main.class, "invoking initial template: "+ Main.initialTemplate); Thread.beforeNonJS(); try{ - resolveString(this, Main.initialTemplate, false).call(null, new JS[]{new Box()}); + resolveString(this, Main.initialTemplate).call(null, new JS[]{new Box()}); }finally{ Thread.afterNonJS(); } return null; } - static public JS resolveString(JS vexi, String str, boolean permitAbsolute) throws JSExn { - if (str.indexOf("://") != -1) { + static public JS resolveString(JS vexi, String str/*, boolean permitAbsolute*/) throws JSExn { + /* absolute - REMARK - unused, does it make anysense? + if (str.indexOf("://") != -1) { if (permitAbsolute) return Resources.fountainForName(str); throw new JSExn("absolute URL " + str + " not permitted here"); - } + }*/ // root-relative JS ret = (JS)vexi.getAndTriggerTraps(SC_); @@ -197,6 +198,11 @@ case "log.error": if(args.length<1) JSU.error(null); else JSU.error(args[0]); return null; case "net.rpc.soap": return new SOAP(JSU.toString(args[0]), JSU.toString(args[1]), JSU.toString(args[2])); case "stream.url": return Resources.fountainForNames(args); + case "stream.cache": return Resources.fountainForNames(args); + //try { return args[0] == null ? null : new Fountain.CachedStream((Stream)args[0], "resources", true); } + //catch (Stream.NotCacheableException e) { throw new JSExn("this resource cannot be cached"); } + + case "stream.url": return Resources.fountainForNames(args); //#end switch (args.length) { @@ -226,9 +232,6 @@ case "regexp": return new JSRegexp(args[0], null); case "stream.unzip": return args[0] == null ? null : new Fountain.Zip((Fountain)args[0]); //case "stream.uncab": return a == null ? null : new Stream.Cab(a); - case "stream.cache": - //try { return args[0] == null ? null : new Fountain.CachedStream((Stream)args[0], "resources", true); } - //catch (Stream.NotCacheableException e) { throw new JSExn("this resource cannot be cached"); } case "stream.write.xml": return Resources.writeXML(args); case "stream.parse.html": throw new JSExn("not implemented yet"); //return null; // FIXME backgrounding Modified: trunk/core/org.vexi.core/src_junit/test/core/CoreTestCase.java =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/CoreTestCase.java 2007-10-11 12:39:28 UTC (rev 2426) +++ trunk/core/org.vexi.core/src_junit/test/core/CoreTestCase.java 2007-10-11 13:38:41 UTC (rev 2427) @@ -7,7 +7,6 @@ import org.ibex.js.Thread; import org.ibex.util.Callable; import org.ibex.util.Log; -import org.ibex.util.Queue; import org.vexi.core.Box; import org.vexi.core.DevUtil; import org.vexi.core.Main; @@ -71,7 +70,7 @@ Log.uInfo(CoreTestCase.class, "invoking initial template: "+ main); Thread.beforeNonJS(); try{ - Vexi.resolveString(v, main, false).call(null, new JS[]{new Box()}); + Vexi.resolveString(v, main).call(null, new JS[]{new Box()}); }finally{ Thread.afterNonJS(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mk...@us...> - 2007-10-12 02:45:08
|
Revision: 2432 http://vexi.svn.sourceforge.net/vexi/?rev=2432&view=rev Author: mkpg2 Date: 2007-10-11 19:45:03 -0700 (Thu, 11 Oct 2007) Log Message: ----------- Development. - redone much of org.vexi.core.Resources.java - http post for org.ibexj.js.Fountain.HTTP - reorganised tests Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Main.java trunk/core/org.vexi.core/src/org/vexi/core/Resources.java trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp trunk/core/org.vexi.core/src/org/vexi/plat/Java2.java trunk/core/org.vexi.core/src_dev/org/vexi/core/DevUtil.java trunk/core/org.vexi.core/src_junit/org/vexi/core/TestResources.java trunk/core/org.vexi.core/src_junit/test/TestAll.java trunk/core/org.vexi.core/src_junit/test/core/TestCore.java trunk/core/org.vexi.core/src_junit/test/core/stream/TestStream.java Added Paths: ----------- trunk/core/org.vexi.core/src_junit/org/vexi/core/TestClasses.java trunk/core/org.vexi.core/src_junit/test/core/TestExec.java trunk/core/org.vexi.core/src_junit/test/core/stream/http/ trunk/core/org.vexi.core/src_junit/test/core/stream/http/TestStreamHTTP.java trunk/core/org.vexi.core/src_junit/test/core/stream/http/post.t Removed Paths: ------------- trunk/core/org.vexi.core/src_junit/org/vexi/core/TestCoreClasses.java Modified: trunk/core/org.vexi.core/src/org/vexi/core/Main.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Main.java 2007-10-12 02:44:39 UTC (rev 2431) +++ trunk/core/org.vexi.core/src/org/vexi/core/Main.java 2007-10-12 02:45:03 UTC (rev 2432) @@ -128,7 +128,7 @@ loadParam(args[i]); } else { - rr = Resources.cacheableForName(args[i]); + rr = Resources.fountainForArg(args[i]); if (rr!=null) { if (vexi_rr == null) vexi_rr = rr; else { Modified: trunk/core/org.vexi.core/src/org/vexi/core/Resources.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2007-10-12 02:44:39 UTC (rev 2431) +++ trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2007-10-12 02:45:03 UTC (rev 2432) @@ -10,8 +10,6 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; -import java.net.InetAddress; -import java.net.UnknownHostException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -34,7 +32,6 @@ import org.ibex.util.Tree; import org.ibex.util.XML; import org.ibex.util.Basket.Stack; -import org.vexi.plat.Platform; /** * Roughly encapsulates the vexi cache (.vexi directory) @@ -89,7 +86,7 @@ - /** + /* * * FEATURE: this should be implemented using self-emulation * Used for security checks. If this is null, it means that only * scripts originating from the local filesystem are loaded in @@ -99,23 +96,21 @@ */ public static Vector originAddresses = null; public static String originHost = null; - - // TODO - review/reimplement - //private static final boolean precache = false; - //private static final boolean download = true; - public static Fountain fountainForNames(final JS[] urls) throws JSExn{ - if(urls.length==0) return null; - if(urls.length==1){ - return fountainForName(JSU.toString(urls[0])); + + // TODO - move to constructor of Fountain.Multiple + public static JS combine(final JS[] streams) throws JSExn{ + if(streams.length==0) return null; + if(streams.length==1){ + return streams[0]; }else{ try{ // REMARK - ignoring non-cacheable (i.e. fountains which aren't some // sort of directory) when more than one arg given. final - Fountain.Multiple multiStream = new Fountain.Multiple(urls.length); - for(int i=0; i<urls.length; i++){ - Fountain cacheable = cacheableForName(JSU.toString(urls[i])); + Fountain.Multiple multiStream = new Fountain.Multiple(streams.length); + for(int i=0; i<streams.length; i++){ + Fountain cacheable = JSU.getFountain(streams[i]); multiStream.addOverrideStream(cacheable); } @@ -126,73 +121,42 @@ } } } - + - public static Fountain fountainForName(final String url) throws JSExn{ - if (url.startsWith("http://") || - url.startsWith("https://")){ - try{ - return cacheableForName(url); - }catch(Exception e){ - throw new JSExn(e.getMessage()); - } - } - else if (url.startsWith("data:")) return new Fountain.ByteArray(Encode.fromBase64(url.substring(5)), null); - else if (url.startsWith("utf8:")) return new Fountain.ByteArray(url.substring(5).getBytes(), null); - else if (url.startsWith("file:")) { - // FIXME - Platform.fileDialog(url.substring(5), false); - } - throw new JSExn("invalid resource specifier " + url); + public static Fountain fountainForURL(final String url) throws JSExn{ + Fountain r = _fountainForURL(url); + if(r==null) throw new JSExn("invalid resource specifier " + url); + return r; } - /** turn a widget stream name into a Stream object. Returns null when a local file does not exist */ - public static Fountain cacheableForName(String cacheableName) throws UnknownHostException, IOException { - Fountain newStream; - String streamHost; - - if (cacheableName.startsWith("http://") || cacheableName.startsWith("https://")) { - streamHost = cacheableName.substring(cacheableName.indexOf('/') + 2); - streamHost = streamHost.substring(0, streamHost.indexOf('/') == -1 ? streamHost.length() : streamHost.indexOf('/')); - if (streamHost.indexOf('@') != -1) streamHost = streamHost.substring(streamHost.indexOf('@') + 1); - if (streamHost.indexOf(':') != -1) streamHost = streamHost.substring(0,streamHost.indexOf(':')); - originHost = streamHost; - if (originAddresses==null) originAddresses = new Vector(); - originAddresses.addElement(InetAddress.getByName(streamHost)); - if (cacheableName.endsWith(".vexi")) { - newStream = new RemoteArchive(cacheableName); - } - else { - newStream = new RemoteFile(cacheableName); - } - } else { - - if(cacheableName.contains("!")){ - String archivePath = cacheableName.substring(0,cacheableName.indexOf("!")); - Fountain archive = new Fountain.Zip(new Fountain.File(archivePath)); - String afterAchive = cacheableName.substring(cacheableName.indexOf("!")+1); - return getZippedResource(archive, afterAchive) ; - - } - - File checkfile = new File(cacheableName); - if (checkfile.exists()) { - if (checkfile.isDirectory()) { - newStream = new Fountain.File(cacheableName); - } - else { - newStream = new Fountain.Zip(new Fountain.File(cacheableName)); - } - } - else { - newStream = null; - } - } - return newStream; + public static Fountain fountainForArg(final String arg){ + Fountain r = null; + try{ + r = _fountainForURL(arg); + if(r instanceof Fountain.HTTP) r = Resources.cache(r); + else if(r==null){ + if(arg.contains("!")){ + // FEATURE - make recursive (any depth of wrapping) + String archivePath = arg.substring(0,arg.indexOf("!")); + Fountain archive = new Fountain.Zip(new Fountain.File(archivePath)); + String afterAchive = arg.substring(arg.indexOf("!")+1); + return getZippedResource(archive, afterAchive) ; + } + File checkfile = new File(arg); + if (checkfile.exists()) { + r = new Fountain.File(arg); + if (!checkfile.isDirectory()) { + r = new Fountain.Zip(r); + } + } + } + }catch(JSExn e){ + Log.uWarn(Resources.class, e); + } + return r; } - + private static Fountain getZippedResource(Fountain zipFile, String path){ - // FEATURE - make recursive (any depth of wrapping) try{ Fountain insideArchive = (Fountain)zipFile.get(JSU.S(path)); return insideArchive; @@ -201,10 +165,27 @@ return null; } } + + static Fountain _fountainForURL(final String url) throws JSExn{ + if (url.startsWith("http://") || url.startsWith("https://")) return new Fountain.HTTP(url); + else if (url.startsWith("data:")) return new Fountain.ByteArray(Encode.fromBase64(url.substring(5)), null); + else if (url.startsWith("utf8:")) return new Fountain.ByteArray(url.substring(5).getBytes(), null); + else if (url.startsWith("file:")) { + // FIXME + //Platform.fileDialog(url.substring(5), false); + } + return null; + + } + + public static Fountain cache(final JS stream) throws JSExn{ + Fountain f = JSU.getFountain(stream); + String name = f.coerceToString(); + // HACK - using filename (ideally would use mimetype) + if (name.endsWith(".vexi")) return new CachedArchive(f); + return new CachedFile(f); + } - - - /* TODO review -> remove/reimplement * * unzip a .vexi file using ZipInputStream @@ -309,7 +290,8 @@ /** convert a path (or URL) to a file name */ - static String pathToFileName(String path) { + static String cacheName(Fountain f) { + String path = f.coerceToString(); return path.replace('/', '_').replace('\\', '_').replace(':', '_'); } @@ -325,10 +307,10 @@ } }; - public static class RemoteArchive extends RemoteFile{ + public static class CachedArchive extends CachedFile{ Fountain.Zip cache; - public RemoteArchive(String url) { super(url);} + public CachedArchive(Fountain f) { super(f);} public JS _get(JS key) throws JSExn { cache_(this); @@ -355,28 +337,28 @@ try{cache(principal);}catch(IOException e){throw new JSExn(e.getMessage());} } - public Keys keys() throws JSExn { - cache_(this); // FIXME - should take principal as argument + public Keys keys(JS principal) throws JSExn { + cache_(principal); return cache.keys(); } } - static public class RemoteFile extends Fountain{ + static public class CachedFile extends Fountain{ - String url; + //String url; String filename; + Fountain source; Fountain.File cache; - public RemoteFile(String url, String filename) { - while (url.endsWith("/")) url = url.substring(0, url.length() - 1); - this.url = url; + public CachedFile(Fountain source, String filename) { + this.source = source; this.filename = filename; } - public RemoteFile(String url) { - this(url, DIR_VEXI + Resources.pathToFileName(url)); + public CachedFile(Fountain source) { + this(source, DIR_VEXI + Resources.cacheName(source)); } public InputStream getInputStream() throws IOException { @@ -390,12 +372,10 @@ * @throws IOException * @throws JSExn */ public void cache(final JS principal) throws IOException { - Log.uInfo(Main.class, "Downloading vexi file from " + url); + Log.uInfo(Main.class, "Caching vexi file from " + source.coerceToString()); try { - final Fountain.ProgressWatcher httpStream = new Fountain.ProgressWatcher(principal, new Fountain.HTTP(url)); - Trap finishTrap = principal.getTrap(SC_finish); - finishTrap=finishTrap==null?null:finishTrap.write(); + final Fountain.ProgressWatcher httpStream = new Fountain.ProgressWatcher(principal, source); // get the timestamp on the remote file JS info = httpStream.getInfo(); @@ -409,9 +389,8 @@ long localModified = localFile.lastModified(); if (remoteModifiedDate <= localModified) { // if the local file is newer or the same age, then just use it - Log.uInfo(Resources.class, "... using cached copy of file " + url); + Log.uInfo(Resources.class, "... using cached copy of file " + localFile.getAbsolutePath()); cache = new File(localFile.getAbsolutePath()); - if(finishTrap!=null) Thread.runInNew(finishTrap.function(), new JS[]{JSU.F}); return; } } else{ @@ -422,7 +401,6 @@ } Log.uInfo(Resources.class, "Done downloading to file " + localFile.getAbsolutePath()); cache = new File(localFile.getAbsolutePath()); - if(finishTrap!=null) Thread.runInNew(finishTrap.function(), new JS[]{JSU.T}); } }catch(JSExn e){ throw new IOException(e); @@ -677,20 +655,24 @@ }).start(); } - static public void _installFont(JS stream) throws Exception{ + static public void _installFont(JS fontStream) throws Exception{ // FEATURE - verify (signed vexi files) // FEATURE - version (install if a later version) // FEATURE - don't cache remote archive somehow - // though may not be possible if we want to do versioning + // Cache stream so that we can look at it + + Log.warn(Resources.class, "Installing fonts without verification"); - Keys ks = stream.keys(); + Fountain cached = cache(fontStream); + Keys ks = cached.keys(fontStream); Enumeration E = ks.iterator(); while(E.hasNext()){ JS key = E.next(); - Fountain f = (Fountain) stream.get(key); + Fountain f = (Fountain) cached.get(key); // Find out font name from .ttf InputStream is = f.getInputStream(); Font font = Font.createFont(Font.TRUETYPE_FONT, is); Modified: trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-10-12 02:44:39 UTC (rev 2431) +++ trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-10-12 02:45:03 UTC (rev 2432) @@ -42,7 +42,7 @@ static public JS resolveString(JS vexi, String str/*, boolean permitAbsolute*/) throws JSExn { /* absolute - REMARK - unused, does it make anysense? if (str.indexOf("://") != -1) { - if (permitAbsolute) return Resources.fountainForName(str); + if (permitAbsolute) return Resources.fountainForURL(str); throw new JSExn("absolute URL " + str + " not permitted here"); }*/ // root-relative @@ -110,11 +110,12 @@ case "params": return Main.params; case "regexp": return METHOD; case "stream": return getSub(name); - case "stream.homedir": return Resources.fountainForName("file:" + System.getProperty("user.home")); - case "stream.tempdir": return Resources.fountainForName("file:" + System.getProperty("java.io.tempdir")); + case "stream.cache": return METHOD; + case "stream.multiple": return METHOD; + case "stream.homedir": return Resources.fountainForURL("file:" + System.getProperty("user.home")); + case "stream.tempdir": return Resources.fountainForURL("file:" + System.getProperty("java.io.tempdir")); case "stream.unzip": return METHOD; case "stream.uncab": return METHOD; - case "stream.cache": return METHOD; case "stream.url": return METHOD; case "stream.parse": return getSub(name); case "stream.parse.html": return METHOD; @@ -197,12 +198,7 @@ case "log.warn": if(args.length<1) JSU.warn(null); else JSU.warn(args[0]); return null; case "log.error": if(args.length<1) JSU.error(null); else JSU.error(args[0]); return null; case "net.rpc.soap": return new SOAP(JSU.toString(args[0]), JSU.toString(args[1]), JSU.toString(args[2])); - case "stream.url": return Resources.fountainForNames(args); - case "stream.cache": return Resources.fountainForNames(args); - //try { return args[0] == null ? null : new Fountain.CachedStream((Stream)args[0], "resources", true); } - //catch (Stream.NotCacheableException e) { throw new JSExn("this resource cannot be cached"); } - - case "stream.url": return Resources.fountainForNames(args); + case "stream.combine": return Resources.Multiple(args); //#end switch (args.length) { @@ -230,12 +226,14 @@ case "file.remove": ((Fountain.File)args[0]).remove(); return null; case "net.rpc.xml": return new XMLRPC(JSU.toString(args[0]), ""); case "regexp": return new JSRegexp(args[0], null); - case "stream.unzip": return args[0] == null ? null : new Fountain.Zip((Fountain)args[0]); - //case "stream.uncab": return a == null ? null : new Stream.Cab(a); - case "stream.write.xml": return Resources.writeXML(args); + case "stream.cache": return Resources.cache(args[0]); case "stream.parse.html": throw new JSExn("not implemented yet"); //return null; // FIXME backgrounding case "stream.parse.utf8": return Resources.parseUTF8(args); + case "stream.url": return Resources.fountainForURL(JSU.toString(args[0])); + case "stream.unzip": return args[0] == null ? null : new Fountain.Zip((Fountain)args[0]); + //case "stream.uncab": return a == null ? null : new Stream.Cab(a); + case "stream.write.xml": return Resources.writeXML(args); case "thread.sleep": JSU.sleep(JSU.toInt(args[0])); return null; case "ui.browser": Platform.newBrowserWindow(JSU.toString(args[0])); return null; case "ui.font.install": Resources.installFont(args[0]); return null; Modified: trunk/core/org.vexi.core/src/org/vexi/plat/Java2.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/plat/Java2.java 2007-10-12 02:44:39 UTC (rev 2431) +++ trunk/core/org.vexi.core/src/org/vexi/plat/Java2.java 2007-10-12 02:45:03 UTC (rev 2432) @@ -180,10 +180,14 @@ protected static class Java14Surface extends Java2Surface implements WindowStateListener, MouseWheelListener { public Java14Surface(Box root, boolean framed) { - super(root, true); + super(root, framed); // JDK1.4 doesn't like java.lang.Window's... - if (!framed) ((Frame)window).setUndecorated(true); - window.addWindowStateListener(this); + try{ + if (!framed) ((Frame)window).setUndecorated(true); + }catch(Exception e){ + e.printStackTrace(); + } + window.addWindowStateListener(this); window.addMouseWheelListener(this); window.setVisible(true); } Modified: trunk/core/org.vexi.core/src_dev/org/vexi/core/DevUtil.java =================================================================== --- trunk/core/org.vexi.core/src_dev/org/vexi/core/DevUtil.java 2007-10-12 02:44:39 UTC (rev 2431) +++ trunk/core/org.vexi.core/src_dev/org/vexi/core/DevUtil.java 2007-10-12 02:45:03 UTC (rev 2432) @@ -44,7 +44,7 @@ Multiple multiStream = null; for (int i=0; i<resources.length; i++) { - rr = Resources.cacheableForName(resources[i]); + rr = Resources.fountainForArg(resources[i]); if (rr!=null) { if (vexi_rr == null) vexi_rr = rr; else { Copied: trunk/core/org.vexi.core/src_junit/org/vexi/core/TestClasses.java (from rev 2150, trunk/core/org.vexi.core/src_junit/org/vexi/core/TestCoreClasses.java) =================================================================== --- trunk/core/org.vexi.core/src_junit/org/vexi/core/TestClasses.java (rev 0) +++ trunk/core/org.vexi.core/src_junit/org/vexi/core/TestClasses.java 2007-10-12 02:45:03 UTC (rev 2432) @@ -0,0 +1,14 @@ +package org.vexi.core; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; +import test.Util; + +public class TestClasses extends TestCase{ + static public Test suite() { + TestSuite suite = Util.newTestSuite(TestClasses.class); + suite.addTest(TestResources.suite()); + return suite; + } +} Deleted: trunk/core/org.vexi.core/src_junit/org/vexi/core/TestCoreClasses.java =================================================================== --- trunk/core/org.vexi.core/src_junit/org/vexi/core/TestCoreClasses.java 2007-10-12 02:44:39 UTC (rev 2431) +++ trunk/core/org.vexi.core/src_junit/org/vexi/core/TestCoreClasses.java 2007-10-12 02:45:03 UTC (rev 2432) @@ -1,17 +0,0 @@ -package org.vexi.core; - -import org.vexi.core.TestResources.Local; -import org.vexi.core.TestResources.Remote; - -import test.Util; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class TestCoreClasses extends TestCase{ - static public Test suite() { - TestSuite suite = Util.newTestSuite(TestCoreClasses.class); - suite.addTest(TestResources.suite()); - return suite; - } -} Modified: trunk/core/org.vexi.core/src_junit/org/vexi/core/TestResources.java =================================================================== --- trunk/core/org.vexi.core/src_junit/org/vexi/core/TestResources.java 2007-10-12 02:44:39 UTC (rev 2431) +++ trunk/core/org.vexi.core/src_junit/org/vexi/core/TestResources.java 2007-10-12 02:45:03 UTC (rev 2432) @@ -10,11 +10,9 @@ import junit.framework.TestCase; import junit.framework.TestSuite; -import org.ibex.js.DevUtil; import org.ibex.js.Fountain; import org.ibex.js.JS; import org.ibex.js.JSU; -import org.ibex.js.Thread; import test.Util; import testdeployment.NanoHTTPD; @@ -33,38 +31,28 @@ suite.addTest(Util.suiteJava(Remote.class)); return suite; } + - static public String inputStreamAsString(InputStream is) throws IOException{ - BufferedReader r = new BufferedReader(new InputStreamReader(is)); - StringBuffer output = new StringBuffer(); - String l; - while((l=r.readLine())!=null){ - output.append(l); - output.append('\n'); - } - return output.toString(); - } - - static public class Local extends TestCase{ + static public class Local extends ResourceTest{ public void testLocal() throws Exception{ String path = NanoHTTPD.class.getResource("").getPath(); - Fountain f = Resources.cacheableForName(path); + Fountain f = Resources.fountainForArg(path); Fountain a = (Fountain) f.get(JSU.S("a.txt")); InputStream is = Fountain.getInputStream(a); - assertEquals("z\n", inputStreamAsString(is)); + assertEquals("z\n", Util.inputStreamAsString(is)); } public void testLocalInZip() throws Exception{ String path = NanoHTTPD.class.getResource("test.vexi").getPath(); path +="!"; //System.out.println(path); - Fountain f = Resources.cacheableForName(path); + Fountain f = Resources.fountainForArg(path); Fountain b = (Fountain) f.get(JSU.S("b.txt")); - String contents = inputStreamAsString(Fountain.getInputStream(b)); + String contents = Util.inputStreamAsString(Fountain.getInputStream(b)); assertEquals("y\n", contents); Fountain c = (Fountain) f.get(JSU.S("foo")).get(JSU.S("c.txt")); - contents = inputStreamAsString(Fountain.getInputStream(c)); + contents = Util.inputStreamAsString(Fountain.getInputStream(c)); assertEquals("x\n", contents); } @@ -74,58 +62,41 @@ String path = NanoHTTPD.class.getResource("test.vexi").getPath(); path +="!foo"; //System.out.println(path); - Fountain f = Resources.cacheableForName(path); + Fountain f = Resources.fountainForArg(path); Fountain c = (Fountain) f.get(JSU.S("c.txt")); - String contents = inputStreamAsString(Fountain.getInputStream(c)); + String contents = Util.inputStreamAsString(Fountain.getInputStream(c)); assertEquals("x\n", contents); } } - static public class Remote extends TestCase{ + static public class Remote extends ResourceTest{ static final int PORT=7070; static final int RATE=Integer.MAX_VALUE; // no throttling static NanoHTTPD server = null; static final String URL = "http://localhost:" + PORT + "/"; - - static public boolean deleteDirectory(File path) { - if( path.exists() ) { - File[] files = path.listFiles(); - for(int i=0; i<files.length; i++) { - if(files[i].isDirectory()) { - deleteDirectory(files[i]); - } - else { - files[i].delete(); - } - } - } - return( path.delete() ); - } - + protected void setUp() throws Exception { NanoHTTPD.start(PORT,RATE); - // Set user.home and VEXIDIR_NAME to control - // where the temp dir is put - System.setProperty("user.home", "."); - System.setProperty("vexi.vexidirname","_vexi_test"); - + // as we delete in tear down, put them back here + new File(Resources.DIR_VEXI).mkdirs(); + new File(Resources.DIR_FONTS).mkdirs(); } protected void tearDown() throws Exception { // Delete cache after each test - deleteDirectory(new File(Resources.DIR_VEXI)); + Util.deleteDir(new File(Resources.DIR_VEXI)); NanoHTTPD.stop(); } public void testDownload() throws Exception{ - Fountain f = Resources.cacheableForName(URL + "test.vexi"); + Fountain f = Resources.cache(Resources.fountainForURL(URL + "test.vexi")); Fountain b = (Fountain) f.get(JSU.S("b.txt")); - String contents = inputStreamAsString(Fountain.getInputStream(b)); + String contents = Util.inputStreamAsString(Fountain.getInputStream(b)); assertEquals("y\n", contents); Fountain c = (Fountain) f.get(JSU.S("foo")).get(JSU.S("c.txt")); - contents = inputStreamAsString(Fountain.getInputStream(c)); + contents = Util.inputStreamAsString(Fountain.getInputStream(c)); assertEquals("x\n", contents); System.out.println("HI"); } @@ -134,7 +105,7 @@ // TODO delete cache File installed = new File(Resources.DIR_FONTS,"Bitstream Vera Sans.ttf"); if(installed.exists() && !installed.delete()) fail(); - Fountain f = Resources.cacheableForName(URL + "VeraSans.vexi"); + Fountain f = Resources.fountainForURL(URL + "VeraSans.vexi"); JS fontJS = Resources.installedFonts.get(JSU.S("Bitstream Vera Sans")); assertNull(fontJS); Resources._installFont(f); @@ -145,6 +116,17 @@ } } - +} +class ResourceTest extends TestCase{ + static{ + // Set user.home and VEXIDIR_NAME to control + // where the temp dir is put + System.setProperty("user.home", "."); + System.setProperty("vexi.vexidirname","_vexi_test"); + // REMARK if Resources is used before this is excuted + // they will initialise differently (consider putting + // this code somewhere it is sure to be executed before + // all tests). + } } Modified: trunk/core/org.vexi.core/src_junit/test/TestAll.java =================================================================== --- trunk/core/org.vexi.core/src_junit/test/TestAll.java 2007-10-12 02:44:39 UTC (rev 2431) +++ trunk/core/org.vexi.core/src_junit/test/TestAll.java 2007-10-12 02:45:03 UTC (rev 2432) @@ -4,10 +4,8 @@ import junit.framework.TestCase; import junit.framework.TestSuite; -import org.ibex.util.TestULog; +import org.ibex.net.TestNet; import org.ibex.util.TestUtil; -import org.vexi.core.TestCoreClasses; -import org.vexi.core.TestResources; import test.core.TestCore; import test.js.TestJS; @@ -17,10 +15,9 @@ static public Test suite() { TestSuite suite = Util.newTestSuite(TestAll.class); suite.addTest(TestUtil.suite()); + suite.addTest(TestNet.suite()); suite.addTest(TestJS.suite()); - suite.addTest(TestCore.suite()); // core tests in vexi - suite.addTest(TestCoreClasses.suite()); // core tests in java - + suite.addTest(TestCore.suite()); return suite; } } Modified: trunk/core/org.vexi.core/src_junit/test/core/TestCore.java =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/TestCore.java 2007-10-12 02:44:39 UTC (rev 2431) +++ trunk/core/org.vexi.core/src_junit/test/core/TestCore.java 2007-10-12 02:45:03 UTC (rev 2432) @@ -1,8 +1,11 @@ package test.core; +import junit.framework.Test; +import junit.framework.TestSuite; + import org.ibex.util.Log; +import org.vexi.core.TestClasses; -import junit.framework.Test; import test.Util; @@ -10,6 +13,9 @@ static public Test suite() { Util.changeLogLevel(Log.WARN); - return Util.buildScriptSuite(new TestCore()); + TestSuite suite = Util.newTestSuite(TestCore.class); + suite.addTest(TestExec.suite()); + suite.addTest(TestClasses.suite()); + return suite; } } Added: trunk/core/org.vexi.core/src_junit/test/core/TestExec.java =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/TestExec.java (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/TestExec.java 2007-10-12 02:45:03 UTC (rev 2432) @@ -0,0 +1,12 @@ +package test.core; + +import junit.framework.Test; +import test.Util; + + +public class TestExec { + + static public Test suite() { + return Util.buildScriptSuite(new TestExec()); + } +} Property changes on: trunk/core/org.vexi.core/src_junit/test/core/TestExec.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: trunk/core/org.vexi.core/src_junit/test/core/stream/TestStream.java =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/stream/TestStream.java 2007-10-12 02:44:39 UTC (rev 2431) +++ trunk/core/org.vexi.core/src_junit/test/core/stream/TestStream.java 2007-10-12 02:45:03 UTC (rev 2432) @@ -4,6 +4,7 @@ import junit.framework.Test; import junit.framework.TestCase; +import junit.framework.TestSuite; import org.ibex.js.Fountain; import org.ibex.js.JS; @@ -17,6 +18,7 @@ import test.core.CoreTestCase; import test.core.CoreTestSuite; import test.core.Util; +import test.core.stream.http.TestStreamHTTP; /** * @author mike @@ -41,7 +43,9 @@ } public static Test suite() { - return suite(new TestStream()); + TestSuite suite = (TestSuite) suite(new TestStream()); + suite.addTest(TestStreamHTTP.suite()); + return suite; } protected boolean filter(String name) { Added: trunk/core/org.vexi.core/src_junit/test/core/stream/http/TestStreamHTTP.java =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/stream/http/TestStreamHTTP.java (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/stream/http/TestStreamHTTP.java 2007-10-12 02:45:03 UTC (rev 2432) @@ -0,0 +1,53 @@ +package test.core.stream.http; + +import java.io.File; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestResult; + +import org.ibex.js.Fountain; +import org.ibex.js.JS; +import org.ibex.js.Scheduler; +import org.ibex.js.Thread; +import org.ibex.net.TestHTTP; +import org.ibex.util.Callable; +import org.vexi.core.Box; +import org.vexi.core.Main; +import org.vexi.core.Vexi; + +import test.core.CoreTestCase; +import test.core.CoreTestSuite; +import test.core.Util; +import test.core.namespace_vars.TestNamespaceVars; + +/** + * @author mike + */ +public class TestStreamHTTP extends CoreTestSuite{ + + public TestStreamHTTP() { + super(TestStreamHTTP.class); + } + + public void run(TestResult result) { + // start servlet + try { + TestHTTP.startServlet(); + } catch (Exception e) { + e.printStackTrace(); + } + super.run(result); + // end servlet + try { + TestHTTP.stopServlet(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + + public static Test suite() { + return CoreTestSuite.suite(new TestStreamHTTP()); + } +} Property changes on: trunk/core/org.vexi.core/src_junit/test/core/stream/http/TestStreamHTTP.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: trunk/core/org.vexi.core/src_junit/test/core/stream/http/post.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/stream/http/post.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/stream/http/post.t 2007-10-12 02:45:03 UTC (rev 2432) @@ -0,0 +1,14 @@ +<vexi xmlns:ui="vexi://ui" xmlns=""> + + var ss = vexi.stream.url("http://localhost:9999/foo"); + + vexi.stream.write.utf8(ss,"abc"); + + var r = vexi.stream.parse.utf8(ss); + + vexi.log.warn(r.length); + .util..assertEquals("ABC",r); + + <ui:box/> + +</vexi> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mk...@us...> - 2007-10-15 00:10:28
|
Revision: 2462 http://vexi.svn.sourceforge.net/vexi/?rev=2462&view=rev Author: mkpg2 Date: 2007-10-14 17:10:30 -0700 (Sun, 14 Oct 2007) Log Message: ----------- Medium part theory of some things. Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java trunk/core/org.vexi.core/src/org/vexi/core/Template.java trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp trunk/core/org.vexi.core/src_junit/test/core/gut/theming.t Modified: trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java 2007-10-14 23:54:04 UTC (rev 2461) +++ trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java 2007-10-15 00:10:30 UTC (rev 2462) @@ -8,6 +8,7 @@ import org.ibex.js.JSArrayLike; import org.ibex.js.JSExn; import org.ibex.js.JSU; +import org.ibex.js.Thread; import org.ibex.util.Basket; public class Blessing extends JS.Clone implements Cloneable, Constants { @@ -21,7 +22,8 @@ public JS parentkey = null; public Blessing parent = null; - private Basket.Map cache = new Basket.Hash(); + //OPTIMIZE - use our own hash map + private Basket.Map cache = new Basket.Hash(); boolean initializing = false; Blessing(JS clonee, JS vexi, Blessing parent, JS parentkey) throws JSExn { super(clonee); @@ -30,6 +32,14 @@ this.parent = parent; } + public JS getAndTriggerTraps(JS key) throws JSExn { + Trap t = (Trap)super.get(key, 1); + // REMARK - We're not like Clone here, we don't check the clonee's traps + // (since we do it in the get method) + if(t==null || (t = t.read())==null) return get(key); + return Thread.runInCurrent(t); + } + public JS get(JS key) throws JSExn { // FEATURE - do we need to resolve here? We can resolve later perhaps, so // if you refer to a template but don't use it then it won't get resolved? @@ -49,7 +59,8 @@ return ret; } } - JS ret = new Blessing(super.getAndTriggerTraps(key), vexi, this, key); + // REMARK - calling getAndTriggerTraps in a plain get? + JS ret = new Blessing(clonee.getAndTriggerTraps(key), vexi, this, key); cache.put(key, ret); return ret; } @@ -107,6 +118,7 @@ try{ if(parent==null) return; JS res = parent.getTemplateRes(parentkey); + unresolved.staticPart.sourceName = description(); t = TemplateBuilder.build(unresolved, res); }finally{ initializing = false; @@ -116,7 +128,7 @@ private JS getTemplateRes(JS key) throws JSExn{ String key_ = JSU.toString(key); if(!key_.endsWith(".t")) key = JSU.S(key_ + ".t"); - return super.getAndTriggerTraps(key); + return JSU.unclone(clonee).getAndTriggerTraps(key); } JS getStatic() throws JSExn { Modified: trunk/core/org.vexi.core/src/org/vexi/core/Template.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Template.java 2007-10-14 23:54:04 UTC (rev 2461) +++ trunk/core/org.vexi.core/src/org/vexi/core/Template.java 2007-10-15 00:10:30 UTC (rev 2462) @@ -206,7 +206,7 @@ val = (JS) uriPrefixes.get(JSU.S(ab[0]), true); while(ab.length==2 && val!=null){ ab = ab[1].split("\\.",2); - val = val.get(JSU.S(ab[0])); + val = val.getAndTriggerTraps(JSU.S(ab[0])); } } if(val==null) throw new JSExn(valStr + " evaluates to null"); Modified: trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java 2007-10-14 23:54:04 UTC (rev 2461) +++ trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java 2007-10-15 00:10:30 UTC (rev 2462) @@ -106,11 +106,10 @@ }else{ Log.uWarn(LOG_TYPE, "'" + unresolved.staticPart.sourceName + ".t' does not declare a template"); } - // required? - //}finally{ - //is.close(); - //} } + //else{ + // throw new JSExn("no template: " + JSU.getFountain(s).canonical()); + //} }catch(JSExn e){ throw e; }catch(Wrapper e){ Modified: trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-10-14 23:54:04 UTC (rev 2461) +++ trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-10-15 00:10:30 UTC (rev 2462) @@ -11,7 +11,6 @@ import org.ibex.js.JSExn; import org.ibex.js.JSRegexp; import org.ibex.js.JSU; -import org.ibex.js.Scheduler; import org.ibex.js.Thread; import org.ibex.js.XMLRPC; import org.ibex.util.Cache; @@ -51,10 +50,10 @@ while (str.indexOf('.') != -1) { String path = str.substring(0, str.indexOf('.')); str = str.substring(str.indexOf('.') + 1); - ret = ret.get(JSU.S(path)); + ret = ret.getAndTriggerTraps(JSU.S(path)); } try { - if (!"".equals(str)) ret = ret.get(JSU.S(str)); + if (!"".equals(str)) ret = ret.getAndTriggerTraps(JSU.S(str)); } catch (NullPointerException npe) { throw new JSExn("Invalid starting directory specified: "+str); } Modified: trunk/core/org.vexi.core/src_junit/test/core/gut/theming.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/gut/theming.t 2007-10-14 23:54:04 UTC (rev 2461) +++ trunk/core/org.vexi.core/src_junit/test/core/gut/theming.t 2007-10-15 00:10:30 UTC (rev 2462) @@ -11,19 +11,13 @@ <ui:box> <vexi.theme.a id="a"/> <vexi.theme.b id="b"/> - - .util..assertEquals("vexi.theme.a",$a.name); - .util..assertEquals("vexi.theme.a",.vexi.theme.a..name); + + .util..assertEquals("themeimpl.b",$b.name); + .util..assertEquals("themeimpl.b",.vexi.theme.b..name); - vexi.log.warn(.tempimpl.a..name); + .util..assertEquals("themeimpl.a",$a.name); + .util..assertEquals("themeimpl.a",.vexi.theme.a..name); - // TODO decide what should happen. Obviously - // b was accessed once, before being applied to vexi.theme - // should it be two seperate templates? - vexi.log.warn($b.name); - vexi.log.warn(.vexi.theme.b..name); - - </ui:box> </vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mk...@us...> - 2007-10-15 03:19:11
|
Revision: 2463 http://vexi.svn.sourceforge.net/vexi/?rev=2463&view=rev Author: mkpg2 Date: 2007-10-14 20:19:14 -0700 (Sun, 14 Oct 2007) Log Message: ----------- Feature. Create templates from strings (via blessing named,non-dir streams). Cleaned up Fountain. Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java trunk/core/org.vexi.core/src/org/vexi/core/Main.java trunk/core/org.vexi.core/src/org/vexi/core/Resources.java trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp Added Paths: ----------- trunk/core/org.vexi.core/src_junit/test/core/template/parse.t Modified: trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java 2007-10-15 00:10:30 UTC (rev 2462) +++ trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java 2007-10-15 03:19:14 UTC (rev 2463) @@ -20,6 +20,7 @@ private JS vexi; private Template t = null; public JS parentkey = null; + public JS name = null; public Blessing parent = null; //OPTIMIZE - use our own hash map @@ -31,6 +32,11 @@ this.parentkey = parentkey; this.parent = parent; } + Blessing(JS clonee, JS vexi, JS name) throws JSExn { + super(clonee); + this.vexi = vexi; + this.name = name; + } public JS getAndTriggerTraps(JS key) throws JSExn { Trap t = (Trap)super.get(key, 1); @@ -116,10 +122,10 @@ initializing = true; // FEATURE: Might want to handle the ".t" part better try{ - if(parent==null) return; - JS res = parent.getTemplateRes(parentkey); + JS res = (parent==null)? + this:parent.getTemplateRes(parentkey); unresolved.staticPart.sourceName = description(); - t = TemplateBuilder.build(unresolved, res); + t = TemplateBuilder.build(unresolved, res); }finally{ initializing = false; } @@ -137,13 +143,11 @@ } private String description() { - if(parent==null) return ""; + if(parent==null) return JSU.toString(name); String s = JSU.toString(parentkey); - for(Blessing b = parent; b.parentkey != null; b = b.parent) s = JSU.toString(b.parentkey) + "." + s; - return s;/* - String s = "";//JSU.toString(parentkey); - for(Blessing b = this; b != null; b = b.parent) s = JSU.toString(b.parentkey) + "." + s; - return s;*/ + for(Blessing b = parent; b!=null && b.parentkey != null; b = b.parent) + s = JSU.toString(b.parentkey) + "." + s; + return s; } public JS call(JS method, JS[] args) throws JSExn { Modified: trunk/core/org.vexi.core/src/org/vexi/core/Main.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Main.java 2007-10-15 00:10:30 UTC (rev 2462) +++ trunk/core/org.vexi.core/src/org/vexi/core/Main.java 2007-10-15 03:19:14 UTC (rev 2463) @@ -227,7 +227,6 @@ private final String data; private String name; public BuiltinFountain(String data, String name) { this.data = data; this.name = name; } - public String getCacheKey() throws NotCacheableException { throw new NotCacheableException(); } public InputStream getInputStream() throws IOException { return Encode.JavaSourceCode.decode(data); } public String coerceToString(){ return name!=null?name:super.coerceToString(); } } Modified: trunk/core/org.vexi.core/src/org/vexi/core/Resources.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2007-10-15 00:10:30 UTC (rev 2462) +++ trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2007-10-15 03:19:14 UTC (rev 2463) @@ -168,8 +168,8 @@ static Fountain _fountainForURL(final String url) throws JSExn{ if (url.startsWith("http://") || url.startsWith("https://")) return new Fountain.HTTP(url); - else if (url.startsWith("data:")) return new Fountain.ByteArray(Encode.fromBase64(url.substring(5)), null); - else if (url.startsWith("utf8:")) return new Fountain.ByteArray(url.substring(5).getBytes(), null); + else if (url.startsWith("data:")) return new Fountain.ByteArray(Encode.fromBase64(url.substring(5))); + else if (url.startsWith("utf8:")) return new Fountain.ByteArray(url.substring(5).getBytes()); else if (url.startsWith("file:")) { // FIXME //Platform.fileDialog(url.substring(5), false); Modified: trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-10-15 00:10:30 UTC (rev 2462) +++ trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-10-15 03:19:14 UTC (rev 2463) @@ -25,7 +25,7 @@ /** Singleton class that provides all functionality in the vexi.* namespace */ public final class Vexi extends JS.Obj implements JS.Cloneable, Constants, Callable { - public Vexi(Fountain rr) { try { super.addTrap(SC_,bless(this, rr));} catch(JSExn e) { throw new Error("should never happen: " + e); } } + public Vexi(Fountain rr) { try { super.addTrap(SC_,bless(this, rr, SC_));} catch(JSExn e) { throw new Error("should never happen: " + e); } } public Object run(Object o) throws JSExn { Log.uInfo(Main.class, "invoking initial template: "+ Main.initialTemplate); @@ -111,6 +111,7 @@ case "stream": return getSub(name); case "stream.cache": return METHOD; case "stream.combine": return METHOD; + case "stream.fromString": return METHOD; case "stream.homedir": return Resources.fountainForURL("file:" + System.getProperty("user.home")); case "stream.tempdir": return Resources.fountainForURL("file:" + System.getProperty("java.io.tempdir")); case "stream.unzip": return METHOD; @@ -188,6 +189,7 @@ public JS call(JS target, JS method, JS[] args) throws JSExn { try { //#switch(JSU.toString(method)) + case "bless": return bless_jsthread(target, args[0],(args.length<2)?null:args[1]); case "date": return new JSDate(args); case "file.load": return new Fountain.File(Platform.fileDialog("", false)); case "file.save": return new Fountain.File(Platform.fileDialog("", true)); @@ -208,7 +210,6 @@ break; case 1: //#switch(JSU.toString(method)) - case "bless": return bless_jsthread(target, args[0]); case "clone": if(args[0] == null) throw new JSExn("can't clone the null value"); return new JS.Clone(args[0]); @@ -226,6 +227,7 @@ case "net.rpc.xml": return new XMLRPC(JSU.toString(args[0]), ""); case "regexp": return new JSRegexp(args[0], null); case "stream.cache": return Resources.cache(args[0]); + case "stream.fromString": return new Fountain.ByteArray(JSU.toString(args[0]).getBytes()); case "stream.parse.html": throw new JSExn("not implemented yet"); //return null; // FIXME backgrounding case "stream.parse.utf8": return Resources.parseUTF8(args); @@ -346,14 +348,14 @@ // FEATURE: move this into builtin.vexi // From JS thread. - static private Blessing bless_jsthread(final JS vexi, final JS fountain) throws JSExn { + static private Blessing bless_jsthread(final JS vexi, final JS fountain, final JS name) throws JSExn { try { final Callable callback = Thread.pauseCurrent(); new java.lang.Thread() { public void run() { try{ Fountain f = JSU.getFountain(fountain); f.cache(f); - JSU.schedule(callback, bless(vexi,fountain)); + JSU.schedule(callback, bless(vexi,fountain,name)); }catch(Exception e){ JSExn jsexn = (e instanceof JSExn)?(JSExn)e: new JSExn(e.getMessage()); JSU.schedule(callback,jsexn); @@ -365,10 +367,10 @@ } } - static private Blessing bless(JS vexi, JS fountain) throws JSExn { + static private Blessing bless(JS vexi, JS fountain, JS name) throws JSExn { Fountain f = JSU.getFountain(fountain); if(f==null) throw new JSExn("cannot bless a non-stream JS"); - return new Blessing(fountain, vexi, null, null); + return new Blessing(fountain, vexi, name); } // JS:FIXME: This doesn't properly handle traps Added: trunk/core/org.vexi.core/src_junit/test/core/template/parse.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/template/parse.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/template/parse.t 2007-10-15 03:19:14 UTC (rev 2463) @@ -0,0 +1,28 @@ +<vexi xmlns:ui="vexi://ui" xmlns=""> + + + <ui:box> + + var tString = + ["<vexi xmlns:ui='vexi://ui'>", + "static.a=1; ", + "static.ex++=function(){try{throw \"\";}catch(e){return e;}}", + " <ui:box b='z'/></vexi>"].join("\n"); + + var tStream = vexi.stream.fromString(tString); + + + vexi.thread = function(){ + var t = vexi.bless(tStream,"mytemplate"); + .util..assertEquals(1,t..a); + var b = t(vexi.box); + .util..assertEquals("z",b.b); + var e = t..ex; + .util..assertEquals("mytemplate:3",e.backtrace[0]); + }; + + + + </ui:box> + +</vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mk...@us...> - 2007-10-15 12:36:54
|
Revision: 2466 http://vexi.svn.sourceforge.net/vexi/?rev=2466&view=rev Author: mkpg2 Date: 2007-10-15 05:36:53 -0700 (Mon, 15 Oct 2007) Log Message: ----------- Test. A slightly different way to create a template from a string. Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Resources.java trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp Added Paths: ----------- trunk/core/org.vexi.core/src_junit/test/core/template/parse2.t Modified: trunk/core/org.vexi.core/src/org/vexi/core/Resources.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2007-10-15 03:21:45 UTC (rev 2465) +++ trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2007-10-15 12:36:53 UTC (rev 2466) @@ -99,11 +99,11 @@ // TODO - move to constructor of Fountain.Multiple - public static JS combine(final JS[] streams) throws JSExn{ - if(streams.length==0) return null; + public static JS multiple(final JS[] streams) throws JSExn{ + /*if(streams.length==0) return null; if(streams.length==1){ return streams[0]; - }else{ + }else{*/ try{ // REMARK - ignoring non-cacheable (i.e. fountains which aren't some // sort of directory) when more than one arg given. @@ -119,7 +119,7 @@ }catch(Exception e){ throw new JSExn(e.getMessage()); } - } + //} } Modified: trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-10-15 03:21:45 UTC (rev 2465) +++ trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-10-15 12:36:53 UTC (rev 2466) @@ -110,7 +110,7 @@ case "regexp": return METHOD; case "stream": return getSub(name); case "stream.cache": return METHOD; - case "stream.combine": return METHOD; + case "stream.multiple": return METHOD; case "stream.fromString": return METHOD; case "stream.homedir": return Resources.fountainForURL("file:" + System.getProperty("user.home")); case "stream.tempdir": return Resources.fountainForURL("file:" + System.getProperty("java.io.tempdir")); @@ -199,7 +199,7 @@ case "log.warn": if(args.length<1) JSU.warn(null); else JSU.warn(args[0]); return null; case "log.error": if(args.length<1) JSU.error(null); else JSU.error(args[0]); return null; case "net.rpc.soap": return new SOAP(JSU.toString(args[0]), JSU.toString(args[1]), JSU.toString(args[2])); - case "stream.combine": return Resources.combine(args); + case "stream.multiple": return Resources.multiple(args); //#end switch (args.length) { Added: trunk/core/org.vexi.core/src_junit/test/core/template/parse2.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/template/parse2.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/template/parse2.t 2007-10-15 12:36:53 UTC (rev 2466) @@ -0,0 +1,33 @@ +<vexi xmlns:ui="vexi://ui" xmlns=""> + + + <ui:box> + + var tString = + ["<vexi xmlns:ui='vexi://ui'>", + "static.a=1; ", + "static.ex++=function(){try{throw \"\";}catch(e){return e;}}", + " <ui:box b='z'/></vexi>"].join("\n"); + + /* A second way to parse a template from a string. Instead of + giving it a name in the blessing, add it as a stream to a parent + stream, bless the parent and it will derive its name from the + trapname */ + + var tStream = vexi.stream.fromString(tString); + var pStream = vexi.stream.multiple(); + pStream["mytemplate.t"] ++= tStream; + + vexi.thread = function(){ + var pBlessing = vexi.bless(pStream); + var t = pBlessing.mytemplate; + .util..assertEquals(1,t..a); + var b = t(vexi.box); + .util..assertEquals("z",b.b); + var e = t..ex; + .util..assertEquals("mytemplate:3",e.backtrace[0]); + }; + + </ui:box> + +</vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-10-15 13:01:14
|
Revision: 2468 http://vexi.svn.sourceforge.net/vexi/?rev=2468&view=rev Author: clrg Date: 2007-10-15 06:01:18 -0700 (Mon, 15 Oct 2007) Log Message: ----------- Make isVisible() acknowledge visible read traps Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp trunk/core/org.vexi.core/src_junit/test/core/box/layout/visible.t Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-10-15 12:59:31 UTC (rev 2467) +++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-10-15 13:01:18 UTC (rev 2468) @@ -137,9 +137,11 @@ // unused - private static final int max(int a, int b, int c) { return (a>=b && a>=c) ? a : (b>=c && b>=a) ? b : c; } private final boolean inside(int x, int y) { return test(DISPLAY) && x >= 0 && y >= 0 && x < width && y < height; } - private final boolean isVisible() { + private final boolean isVisible() throws JSExn { Box b=this; while(true) { + if (b.test(VISIBLE_READ_TRAP)) + return JSU.toBoolean(b.getAndTriggerTraps(SC_visible)); if (!b.test(DISPLAY)) return false; if (b.parent == null) return Surface.fromBox(b) != null; b = b.parent; @@ -213,7 +215,7 @@ private static final int MINMAX_TRAPS = 0x01000000; private static final int CONTENTWIDTH_TRAP = 0x02000000; private static final int CONTENTHEIGHT_TRAP = 0x04000000; - // unused - private static final int FLAG = 0x08000000; + private static final int VISIBLE_READ_TRAP = 0x08000000; private static final int MOVE_TRAP = 0x10000000; private static final int ENTER_TRAP = 0x20000000; @@ -1184,7 +1186,7 @@ case "contentwidth": return JSU.N(contentwidth); case "contentheight": return JSU.N(contentheight); case "display": return JSU.B(test(DISPLAY)); - case "visible": /*System.err.println("??? "+JSU.T+", "+JSU.F);*/ return isVisible() ? JSU.T : JSU.F; + case "visible": return (test(DISPLAY) && ((parent!=null && parent.isVisible()) || getSurface()!=null)) ? JSU.T : JSU.F; case "cursor": return test(CURSOR) ? super.get(name) : null; case "mouse": if (getSurface() == null) return null; @@ -1426,8 +1428,10 @@ public void addTrap(JS key, JS f) throws JSExn { super.addTrap(key, f); // We are only interested in write traps - if (f.getFormalArgs().length !=1) + if (f.getFormalArgs().length != 1) { + if (JSU.toString(key).equals("visible")) set(VISIBLE_READ_TRAP); return; + } //#switch (JSU.toString(key)) case "x": set(X_TRAP); case "y": set(Y_TRAP); @@ -1457,7 +1461,7 @@ case "height": if (getTrap(SC_height) == null) clear(HEIGHT_TRAP); case "contentwidth": if (getTrap(SC_contentwidth) == null) clear(CONTENTWIDTH_TRAP); case "contentheight": if (getTrap(SC_contentheight) == null) clear(CONTENTHEIGHT_TRAP); - case "visible": if (getTrap(SC_visible) == null) clear(VISIBLE_TRAP); + case "visible": if (getTrap(SC_visible) == null) clear(VISIBLE_TRAP|VISIBLE_READ_TRAP); case "Enter": if (getTrap(SC_Enter) == null) clear(ENTER_TRAP); case "Leave": if (getTrap(SC_Leave) == null) clear(LEAVE_TRAP); case "_Move": if (getTrap(SC__Move) == null) clear(MOVE_TRAP); Modified: trunk/core/org.vexi.core/src_junit/test/core/box/layout/visible.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/layout/visible.t 2007-10-15 12:59:31 UTC (rev 2467) +++ trunk/core/org.vexi.core/src_junit/test/core/box/layout/visible.t 2007-10-15 13:01:18 UTC (rev 2468) @@ -2,25 +2,26 @@ var completed = false; var b = vexi.box; + var c = vexi.box; b.visible ++= function(v) { - .util..assertEquals(false, b.visible); + // this will always be true due to the read trap + //.util..assertEquals(false, b.visible); + .util..assertEquals(true, c.visible); .util..assertEquals(true, v); cascade = v; + // without the visible read trap on c, this will fail .util..assertEquals(true, b.visible); completed = true; } - var c = vexi.box; c[0] = b; c.display = false; c.visible ++= function() { return true; } - vexi.log.warn("here"); c.display = true; + .util..assertEquals(true, b.visible); // FEATURE - find a betterway to achieve this. Should the box // exceptions escape to the scheduler? assert(completed); - vexi.log.warn("here"); - - <ui:box/> + <ui:box /> </vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-10-16 16:30:35
|
Revision: 2475 http://vexi.svn.sourceforge.net/vexi/?rev=2475&view=rev Author: clrg Date: 2007-10-16 09:30:37 -0700 (Tue, 16 Oct 2007) Log Message: ----------- Fix glaring oversight - thisbox = null; was not firing Children traps (did it ever!?) Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp Added Paths: ----------- trunk/core/org.vexi.core/src_junit/test/core/box/childrentrap/writeAfterThisboxNull.t Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-10-15 16:07:18 UTC (rev 2474) +++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-10-16 16:30:37 UTC (rev 2475) @@ -140,8 +140,8 @@ private final boolean isVisible() throws JSExn { Box b=this; while(true) { - if (b.test(VISIBLE_READ_TRAP)) - return JSU.toBoolean(b.getAndTriggerTraps(SC_visible)); + if (b.test(VISIBLE_READ_TRAP)) + return JSU.toBoolean(b.getAndTriggerTraps(SC_visible)); if (!b.test(DISPLAY)) return false; if (b.parent == null) return Surface.fromBox(b) != null; b = b.parent; @@ -1216,7 +1216,11 @@ */ //#switch(JSU.toString(name)) - case "thisbox": if (value == null) removeFromParent(); + case "thisbox": + if (value == null) { + if (parent != null) parent.put(parent.indexNode(this), null); + else if (getSurface() != null) getSurface().dispose(true); + } case "font": setFont(value); case "fontsize": @@ -1429,7 +1433,7 @@ super.addTrap(key, f); // We are only interested in write traps if (f.getFormalArgs().length != 1) { - if (JSU.toString(key).equals("visible")) set(VISIBLE_READ_TRAP); + if (JSU.toString(key).equals("visible")) set(VISIBLE_READ_TRAP); return; } //#switch (JSU.toString(key)) Added: trunk/core/org.vexi.core/src_junit/test/core/box/childrentrap/writeAfterThisboxNull.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/childrentrap/writeAfterThisboxNull.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/box/childrentrap/writeAfterThisboxNull.t 2007-10-16 16:30:37 UTC (rev 2475) @@ -0,0 +1,27 @@ +<vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib"> + + var aGone = false; + var bGone = false; + var cGone = false; + var b = vexi.box; + b.Children ++= function(v) { + if (v == null) { + if (b[trapname].text == "a") aGone = true; + if (b[trapname].text == "b") bGone = true; + if (b[trapname].text == "c") cGone = true; + } + cascade = v; + } + + b[0] = lib..newBox("a"); + b[1] = lib..newBox("b"); + b[2] = lib..newBox("c"); + b[0].thisbox = null; + .util..assertEquals(true,aGone); + b[0].thisbox = null; + .util..assertEquals(true,bGone); + b[0].thisbox = null; + .util..assertEquals(true,cGone); + + <ui:box/> +</vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-10-18 23:41:57
|
Revision: 2494 http://vexi.svn.sourceforge.net/vexi/?rev=2494&view=rev Author: clrg Date: 2007-10-18 16:42:00 -0700 (Thu, 18 Oct 2007) Log Message: ----------- Make invalid color strings throw JSExn Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/graphics/Color.java trunk/core/org.vexi.core/src_junit/test/core/box/childrentrap/numchildrenWithRedirect.t Added Paths: ----------- trunk/core/org.vexi.core/src_junit/test/core/box/color.t Modified: trunk/core/org.vexi.core/src/org/vexi/graphics/Color.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/graphics/Color.java 2007-10-18 10:50:25 UTC (rev 2493) +++ trunk/core/org.vexi.core/src/org/vexi/graphics/Color.java 2007-10-18 23:42:00 UTC (rev 2494) @@ -6,12 +6,11 @@ import java.util.Hashtable; -import org.ibex.util.Log; +import org.ibex.js.JSExn; public class Color { - public static int stringToColor(String s) { - // FEATURE should throw JSExn for invalid colors + public static int stringToColor(String s) throws JSExn { if (s == null) return 0x00000000; Integer i = (Integer)standard.get(s); if (i != null) return 0xFF000000 | i.intValue(); @@ -56,17 +55,13 @@ g = Integer.parseInt(s.substring(7, 9), 16); break; default: - a = 0x00000000; - r = 0x00000000; - b = 0x00000000; - g = 0x00000000; + throw new JSExn("invalid color '"+s+"'"); } return a | r | b | g; } catch (NumberFormatException e) { - Log.info(Color.class, "invalid color " + s); - return 0; // FEATURE: error? + throw new JSExn("invalid color '"+s+"'"); } } Modified: trunk/core/org.vexi.core/src_junit/test/core/box/childrentrap/numchildrenWithRedirect.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/childrentrap/numchildrenWithRedirect.t 2007-10-18 10:50:25 UTC (rev 2493) +++ trunk/core/org.vexi.core/src_junit/test/core/box/childrentrap/numchildrenWithRedirect.t 2007-10-18 23:42:00 UTC (rev 2494) @@ -1,14 +1,14 @@ <vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib"> - - var b1 = vexi.box; - var b2 = vexi.box; - var b3 = vexi.box; - b1[0] = b2; - b1.redirect = b2; - b2.Children ++= function(v) { b3[trapname] = v; } - b2.Children ++= function() { return b3[trapname]; } - b2.numchildren ++= function() { return b3.numchildren; } - + + var b1 = vexi.box; + var b2 = vexi.box; + var b3 = vexi.box; + b1[0] = b2; + b1.redirect = b2; + b2.Children ++= function(v) { b3[trapname] = v; } + b2.Children ++= function() { return b3[trapname]; } + b2.numchildren ++= function() { return b3.numchildren; } + b1[0] = lib..newBox("a"); b1[1] = lib..newBox("b"); b1[2] = lib..newBox("c"); @@ -19,5 +19,5 @@ .util..assertEquals(3, b2.numchildren); .util..assertEquals(3, b1.numchildren); - <ui:box/> + <ui:box /> </vexi> Added: trunk/core/org.vexi.core/src_junit/test/core/box/color.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/color.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/box/color.t 2007-10-18 23:42:00 UTC (rev 2494) @@ -0,0 +1,28 @@ + +<vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib"> + + var b = vexi.box; + var error; + + error = false; + try { b.fill = ".red"; } + catch(e) { error = true; } + assert(error); + + error = false; + try { b.fill = "#123456789"; } + catch(e) { error = true; } + assert(error); + + error = false; + try { b.fill = "111"; } + catch(e) { error = true; } + assert(error); + + error = false; + try { b.fill = "foo"; } + catch(e) { error = true; } + assert(error); + + <ui:box/> +</vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-10-23 00:54:11
|
Revision: 2511 http://vexi.svn.sourceforge.net/vexi/?rev=2511&view=rev Author: clrg Date: 2007-10-22 17:54:12 -0700 (Mon, 22 Oct 2007) Log Message: ----------- Refined packed layout + more layout test cases Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp trunk/core/org.vexi.core/src_junit/test/core/box/_lib.t trunk/core/org.vexi.core/src_junit/test/core/box/layout/layout.t trunk/core/org.vexi.core/src_junit/test/core/box/layout/trapping.t Added Paths: ----------- trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentsize.t trunk/core/org.vexi.core/src_junit/test/core/box/layout/nestedpack.t trunk/core/org.vexi.core/src_junit/test/core/box/layout/unevenpack.t Removed Paths: ------------- trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentx.t Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-10-22 01:28:30 UTC (rev 2510) +++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-10-23 00:54:12 UTC (rev 2511) @@ -127,12 +127,12 @@ // unused - private final int depth() { int d=0; for (Box p = this.parent; p!=null; p = p.parent) d++; return d; } private static final int min(int a, int b) { return (a<b) ? a : b; } - // unused - private static final float min(float a, float b) { return (a<b) ? a : b; } + private static final float min(float a, float b) { return (a<b) ? a : b; } // unused - private static final short min(short a, short b) { return (a<b) ? a ? b; } // unused - private static final int min(int a, int b, int c) { return (a<=b && a<=c) ? a : (b<=c && b<=a) ? b : c; } private static final int max(int a, int b) { return (a>b) ? a : b; } - // unused - private static final float max(float a, float b) { return (a>b) ? a : b; } + private static final float max(float a, float b) { return (a>b) ? a : b; } // unused - private static final short max(short a, short b) { return (a>b) ? a : b; } // unused - private static final int max(int a, int b, int c) { return (a>=b && a>=c) ? a : (b>=c && b>=a) ? b : c; } @@ -483,6 +483,22 @@ /** place then invoke place() on a box's children */ private void place() { + if (treeSize()>0) { + placeChildren(); + if (test(PLACE_DESCENDENT)) { + clear(PLACE_DESCENDENT); + int i = 0; + for (Box child = getChild(0); child != null; child = getChild(++i)) { + if (!child.test(DISPLAY)) continue; + child.place(); + } + } + } else clear(PLACE|PLACE_DESCENDENT); + } + + private static final float variance = (float)0.05; + private static final boolean notNearZero(float n) { return ((n > variance) || (n < -variance)); } + private final void placeChildren() { if (test(PLACE)) { clear(PLACE); @@ -522,59 +538,52 @@ // take into account slack - slightly more processing // TODO: fold this into one loop somehow } else { - // first establish how many children will accept slack - int count = 0, consumed = 0; + // educated guess at the slack to hand out + float targetwidth = (float)width / treeSize(); + float total = (float)0.0; + int maxcount = 0; + int mincount = 0; int i = 0; - for (Box child = getChild(0); child != null; child = getChild(++i)) { - if (!child.test(DISPLAY)) continue; - if (!child.test(HSHRINK)) count++; - consumed += child.contentwidth; + while (notNearZero((float)width-total) && notNearZero(targetwidth)) { + i = 0; + total = (float)0.0; + mincount = 0; + maxcount = 0; + for (Box child = getChild(0); child != null; child = getChild(++i)) { + if (!child.test(DISPLAY)) continue; + if (child.test(HSHRINK)) { + total += (float)child.contentwidth; + } else { + if ((float)child.maxwidth > targetwidth) maxcount++; + if ((float)child.contentwidth < targetwidth) mincount++; + total += min(child.maxwidth, max(child.contentwidth, targetwidth)); + } + } + if ((float)width > total) { + if (maxcount == 0) break; + targetwidth += ((float)width-total) / (float)maxcount; + } + if (total > (float)width) { + if (mincount == 0) break; + targetwidth += ((float)width-total) / (float)mincount; + } } - // the slack to give to each non-shrunk child - float slack = count == 0 ? 0 : (float)max(0, width - consumed) / count; - // initiliasing to 0.01 prevents rounding down errors - float total = (float)0.01; - int shift, space; - // now we know how we are assigning slack, second pass handles layout i = 0; + total = (float)0.0; for (Box child = getChild(0); child != null; child = getChild(++i)) { if (!child.test(DISPLAY)) continue; // height, y child_height = child.test(VSHRINK) ? child.contentheight : min(child.maxheight, height); child_y = child.test(ALIGN_TOP) ? 0 : (child.test(ALIGN_BOTTOM) ? height - child_height : (height - child_height) / 2); - - // width, x - decline slack - if (child.test(HSHRINK)) { - child_x = (int)total; - child.tryMoveAndResize(child_x, child_y, child.contentwidth, child_height); - total += child.contentwidth; - - // width, x - assigning slack - } else { - // establish cominbed size of child contentwidth + slack [= space] but - // include total so that casting is relative to child position [total] - // to ensure we don't have leftover pixels due to flooring by casting - space = child.contentwidth + (int)(slack+total) - (int)total; - // fully absorb slack - if (child.maxwidth >= space) { - child_width = space; - shift = 0; - // position box relatively in available space - } else { - child_width = child.maxwidth; - if (child.test(ALIGN_LEFT)) - shift = 0; - else if (child.test(ALIGN_RIGHT)) - shift = space - child.maxwidth; - else shift = (space - child.maxwidth) / 2; - } - child_x = (int)total; - child.tryMoveAndResize(child_x + shift, child_y, child_width, child_height); - total += slack + (float)child.contentwidth; - } + // width, x + child_width = child.test(HSHRINK) ? child.contentwidth : + max(child.contentwidth, min(child.maxwidth, (int)(total+targetwidth+0.5)-(int)(total+0.5))); + child_x = (int)(total+0.5); + total += child_width; + child.tryMoveAndResize(child_x, child_y, child_width, child_height); } } @@ -596,19 +605,40 @@ // take into account slack - slightly more processing } else { - int count = 0, consumed = 0; + // educated guess at the slack to hand out + float targetheight = (float)height / treeSize(); + float total = (float)0.0; + int maxcount = 0; + int mincount = 0; int i = 0; - for (Box child = getChild(0); child != null; child = getChild(++i)) { - if (!child.test(DISPLAY)) continue; - if (!child.test(VSHRINK)) count++; - consumed += child.contentheight; + while (notNearZero((float)height-total) && notNearZero(targetheight)) { + i = 0; + total = (float)0.0; + mincount = 0; + maxcount = 0; + for (Box child = getChild(0); child != null; child = getChild(++i)) { + if (!child.test(DISPLAY)) continue; + if (child.test(VSHRINK)) { + total += (float)child.contentheight; + } else { + if ((float)child.maxheight > targetheight) maxcount++; + if ((float)child.contentheight < targetheight) mincount++; + total += min(child.maxheight, max(child.contentheight, targetheight)); + } + } + if ((float)height > total) { + if (maxcount == 0) break; + targetheight += ((float)height-total) / (float)maxcount; + } + if (total > (float)height) { + if (mincount == 0) break; + targetheight += ((float)height-total) / (float)mincount; + } } - float slack = count == 0 ? 0 : (float)max(0, height - consumed) / count; - float total = (float)0.01; - int shift, space; - + // now we know how we are assigning slack, second pass handles layout i = 0; + total = (float)0.0; for (Box child = getChild(0); child != null; child = getChild(++i)) { if (!child.test(DISPLAY)) continue; // width, x @@ -616,41 +646,16 @@ child_x = child.test(ALIGN_LEFT) ? 0 : (child.test(ALIGN_RIGHT) ? width - child_width : (width - child_width) / 2); // height, y - if (child.test(VSHRINK)) { - child_y = (int)total; - child.tryMoveAndResize(child_x, child_y, child_width, child.contentheight); - total += (float)child.contentheight; - } else { - space = child.contentheight + (int)(slack+total) - (int)total; - if (child.maxheight >= space) { - child_height = space; - shift = 0; - } else { - child_height = child.maxheight; - if (child.test(ALIGN_TOP)) - shift = 0; - else if (child.test(ALIGN_BOTTOM)) - shift = space - child.maxheight; - else shift = (space - child.maxheight) / 2; - } - child_y = (int)total; - child.tryMoveAndResize(child_x, child_y + shift, child_width, child_height); - total += slack + (float)child.contentheight; - } + child_height = child.test(VSHRINK) ? child.contentheight : + max(child.contentheight, min(child.maxheight, (int)(total+targetheight+0.5)-(int)(total+0.5))); + child_y = (int)(total+0.5); + total += child_height; + child.tryMoveAndResize(child_x, child_y, child_width, child_height); } } } } } - - if (test(PLACE_DESCENDENT)) { - clear(PLACE_DESCENDENT); - int i = 0; - for (Box child = getChild(0); child != null; child = getChild(++i)) { - if (!child.test(DISPLAY)) continue; - child.place(); - } - } } Modified: trunk/core/org.vexi.core/src_junit/test/core/box/_lib.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/_lib.t 2007-10-22 01:28:30 UTC (rev 2510) +++ trunk/core/org.vexi.core/src_junit/test/core/box/_lib.t 2007-10-23 00:54:12 UTC (rev 2511) @@ -1,27 +1,30 @@ <vexi xmlns:ui="vexi://ui" xmlns=""> - static.newBox = function(text){ + static.newBox = function(text) { var r = vexi.box; r.text = text; return r; - }; - static.newBoxSize = function(w,h){ + } + + static.newBoxSize = function(w, h) { var r = vexi.box; r.width = w; r.height = h; return r; - }; - static.reorderWrite = function (b){ - return function(v){ + } + + static.reorderWrite = function(b) { + return function(v) { vexi.log.info(trapname); var nc = b.numchildren; trapname = nc-trapname; cascade = v; }; - }; - static.assertSize = function(w,h,b){ - .util..assertEquals(w,b.width); - .util..assertEquals(h,b.height); - }; + } + + static.assertSize = function(w, h, b) { + .util..assertEquals(w, b.width); + .util..assertEquals(h, b.height); + } - <ui:box/> + <ui:box /> </vexi> Copied: trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentsize.t (from rev 2510, trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentx.t) =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentsize.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentsize.t 2007-10-23 00:54:12 UTC (rev 2511) @@ -0,0 +1,21 @@ +<vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib"> + + var testContentx = function(dim){ + var c1 = vexi.box; + c1["min"+dim]=10;c1.forcereflow(); + .util..assertEquals(10,c1["content"+dim]); + + var x = 0; + c1["content"+dim]++=function(v){ + x = v; + cascade = v; + }; + c1["min"+dim]=20;c1.forcereflow(); + .util..assertEquals(20,x); + }; + testContentx("width"); + testContentx("height"); + + + <ui:box/> +</vexi> Deleted: trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentx.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentx.t 2007-10-22 01:28:30 UTC (rev 2510) +++ trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentx.t 2007-10-23 00:54:12 UTC (rev 2511) @@ -1,21 +0,0 @@ -<vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib"> - - var testContentx = function(dim){ - var c1 = vexi.box; - c1["min"+dim]=10;c1.forcereflow(); - .util..assertEquals(10,c1["content"+dim]); - - var x = 0; - c1["content"+dim]++=function(v){ - x = v; - cascade = v; - }; - c1["min"+dim]=20;c1.forcereflow(); - .util..assertEquals(20,x); - }; - testContentx("width"); - testContentx("height"); - - - <ui:box/> -</vexi> Modified: trunk/core/org.vexi.core/src_junit/test/core/box/layout/layout.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/layout/layout.t 2007-10-22 01:28:30 UTC (rev 2510) +++ trunk/core/org.vexi.core/src_junit/test/core/box/layout/layout.t 2007-10-23 00:54:12 UTC (rev 2511) @@ -1,6 +1,5 @@ <vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib"> - var p = vexi.box; p.orient="horizontal"; p.layout="pack"; @@ -20,6 +19,5 @@ p.forcereflow(); lib..assertSize(30,20,p); - - <ui:box/> + <ui:box /> </vexi> Added: trunk/core/org.vexi.core/src_junit/test/core/box/layout/nestedpack.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/layout/nestedpack.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/box/layout/nestedpack.t 2007-10-23 00:54:12 UTC (rev 2511) @@ -0,0 +1,24 @@ +<vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib"> + + var a = vexi.box; + var b = vexi.box; + a[0] = b; + a.shrink=true; + b.width=15; + b.height=15; + var c = vexi.box; + b[0] = c; + + a.forcereflow(); + lib..assertSize(15,15,a); + lib..assertSize(15,15,b); + lib..assertSize(15,15,c); + + a.width=40; + a.forcereflow(); + lib..assertSize(40,15,a); + lib..assertSize(15,15,b); + lib..assertSize(15,15,c); + + <ui:box /> +</vexi> Modified: trunk/core/org.vexi.core/src_junit/test/core/box/layout/trapping.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/layout/trapping.t 2007-10-22 01:28:30 UTC (rev 2510) +++ trunk/core/org.vexi.core/src_junit/test/core/box/layout/trapping.t 2007-10-23 00:54:12 UTC (rev 2511) @@ -1,9 +1,11 @@ <vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib"> + var a = lib..newBoxSize(100,100); var b = vexi.box; a[0] = b; var x = 1; - b.width ++= function(v){ + + b.width ++= function(v) { // remove trap to make sure this doesn't interfere with post put // code - i.e that after the cascade b.width --= callee; @@ -11,9 +13,10 @@ cascade = v; x *= 3; }; + assert(x==1); a.forcereflow(); assert(x==6); - <ui:box/> + <ui:box /> </vexi> Added: trunk/core/org.vexi.core/src_junit/test/core/box/layout/unevenpack.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/layout/unevenpack.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/box/layout/unevenpack.t 2007-10-23 00:54:12 UTC (rev 2511) @@ -0,0 +1,54 @@ +<vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib" xmlns=""> + + var eq = .util..assertEquals; + + var testdim = function(dim) { + var a = vexi.box; + var b = vexi.box; + var c = vexi.box; + var p = vexi.box; + p.orient = (dim=="width"?"horizontal":"vertical"); + p[0] = a; + p[1] = b; + p[2] = c; + + a["min"+dim] = 50; + b["min"+dim] = 150; + c["min"+dim] = 250; + + p[dim] = 450; + p.forcereflow(); + eq(50, a[dim]); + eq(150, b[dim]); + eq(250, c[dim]); + + p[dim] = 500; + p.forcereflow(); + eq(100, a[dim]); + eq(150, b[dim]); + eq(250, c[dim]); + + p[dim] = 600; + p.forcereflow(); + eq(175, a[dim]); + eq(175, b[dim]); + eq(250, c[dim]); + + p[dim] = 750; + p.forcereflow(); + eq(250, a[dim]); + eq(250, b[dim]); + eq(250, c[dim]); + + p[dim] = 900; + p.forcereflow(); + eq(300, a[dim]); + eq(300, b[dim]); + eq(300, c[dim]); + } + + testdim("width"); + testdim("height"); + + <ui:box /> +</vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-11-20 22:51:39
|
Revision: 2601 http://vexi.svn.sourceforge.net/vexi/?rev=2601&view=rev Author: clrg Date: 2007-11-20 14:51:36 -0800 (Tue, 20 Nov 2007) Log Message: ----------- Rollback brown paper bag aka commit r2600 plus fix layout bug + add testcase Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentsize.t Added Paths: ----------- trunk/core/org.vexi.core/src_junit/test/core/box/layout/packbug.t Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-11-20 21:12:44 UTC (rev 2600) +++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-11-20 22:51:36 UTC (rev 2601) @@ -190,8 +190,8 @@ private static final int PACK = 0x00001000; private static final int CLIP = 0x00002000; - // private static final int FLAG = 0x00004000; - // private static final int FLAG = 0x00008000; + private static final int HAS_WIDTH_SLACK = 0x00004000; + private static final int HAS_HEIGHT_SLACK = 0x00008000; private static final int ALIGN_TOP = 0x00010000; private static final int ALIGN_BOTTOM = 0x00020000; @@ -442,7 +442,10 @@ } } - //#repeat width/height + //#repeat width/height WIDTH/HEIGHT + if (newwidth < minwidth || newwidth < text.width) + set(HAS_WIDTH_SLACK); + else clear(HAS_WIDTH_SLACK); // constrain contentwidth if (!test(HAS_EMPTY_STRING)) newwidth = max(newwidth, text.width); @@ -501,7 +504,7 @@ // horizontal stacking if (test(ORIENT) == HORIZONTAL) { // simple case - no slack, place children next to eachother - if (0 >= width - contentwidth) { + if (!test(HAS_WIDTH_SLACK) && 0 >= width - contentwidth) { for (Box child = getChild(i=0); child != null; child = getChild(++i)) { if (!child.test(DISPLAY)) continue; // height, y @@ -531,16 +534,16 @@ if (!child.test(DISPLAY)) continue; numactive++; // can't change size - if (child.test(HSHRINK)) { + if (child.test(HSHRINK) || (child.contentwidth==child.maxwidth)) { maxsizetotal += child.contentwidth; minsizetotal += child.contentwidth; total += child.contentwidth; - // can't grow bigger + // child minsize bigger than targetsize } else if (child.contentwidth > targetwidth) { minsizetotal += child.contentwidth; total += child.contentwidth; expandnum ++; - // can't get smaller + // child maxsize smaller than targetsize } else if (targetwidth > child.maxwidth) { maxsizetotal += child.maxwidth; total += child.maxwidth; @@ -599,7 +602,7 @@ // vertical stacking - mirrors horizontal stacking code [see for comments] } else { // simple case - no slack - if (0 >= height - contentheight) { + if (!test(HAS_HEIGHT_SLACK) && 0 >= height - contentheight) { for (Box child = getChild(i=0); child != null; child = getChild(++i)) { if (!child.test(DISPLAY)) continue; // width, x @@ -629,16 +632,16 @@ if (!child.test(DISPLAY)) continue; numactive++; // can't change size - if (child.test(VSHRINK)) { + if (child.test(VSHRINK) || (child.contentheight==child.maxheight)) { maxsizetotal += child.contentheight; minsizetotal += child.contentheight; total += child.contentheight; - // can't grow bigger + // child minsize bigger than targetsize } else if (child.contentheight > targetheight) { minsizetotal += child.contentheight; total += child.contentheight; expandnum ++; - // can't get smaller + // child maxsize smaller than targetsize } else if (targetheight > child.maxheight) { maxsizetotal += child.maxheight; total += child.maxheight; Modified: trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentsize.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentsize.t 2007-11-20 21:12:44 UTC (rev 2600) +++ trunk/core/org.vexi.core/src_junit/test/core/box/layout/contentsize.t 2007-11-20 22:51:36 UTC (rev 2601) @@ -2,7 +2,8 @@ var testContentx = function(dim){ var c1 = vexi.box; - c1["min"+dim]=10;c1.forcereflow(); + c1["min"+dim]=10; + c1.forcereflow(); .util..assertEquals(10,c1["content"+dim]); var x = 0; @@ -10,7 +11,8 @@ x = v; cascade = v; }; - c1["min"+dim]=20;c1.forcereflow(); + c1["min"+dim]=20; + c1.forcereflow(); .util..assertEquals(20,x); }; testContentx("width"); Added: trunk/core/org.vexi.core/src_junit/test/core/box/layout/packbug.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/layout/packbug.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/box/layout/packbug.t 2007-11-20 22:51:36 UTC (rev 2601) @@ -0,0 +1,20 @@ +<vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib" xmlns=""> + + var eq = .util..assertEquals; + + var a = vexi.box; + var b = vexi.box; + var c = vexi.box; + var d = vexi.box; + var p = vexi.box; + p[0] = a; a.width = 15; + p[1] = b; b.minwidth = 21; + p[2] = c; c.width = 15; + p[4] = d; d.width = 460; + p.width = 565; + p.forcereflow(); + + eq(75, b.width); + + <ui:box /> +</vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mk...@us...> - 2007-11-27 15:31:07
|
Revision: 2622 http://vexi.svn.sourceforge.net/vexi/?rev=2622&view=rev Author: mkpg2 Date: 2007-11-27 07:31:08 -0800 (Tue, 27 Nov 2007) Log Message: ----------- Feature. Making the JS multithreaded (again). Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp trunk/core/org.vexi.core/src/org/vexi/core/Main.java trunk/core/org.vexi.core/src/org/vexi/core/Resources.java trunk/core/org.vexi.core/src/org/vexi/core/Surface.java trunk/core/org.vexi.core/src/org/vexi/core/Template.java trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp trunk/core/org.vexi.core/src_junit/test/core/CoreTestCase.java trunk/core/org.vexi.core/src_junit/test/core/stream/TestStream.java trunk/core/org.vexi.core/src_unused/org/vexi/net/XMLRPC.java Modified: trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java 2007-11-27 15:30:49 UTC (rev 2621) +++ trunk/core/org.vexi.core/src/org/vexi/core/Blessing.java 2007-11-27 15:31:08 UTC (rev 2622) @@ -3,11 +3,7 @@ import java.io.IOException; import java.io.InputStream; -import org.ibex.js.JS; -import org.ibex.js.JSArray; -import org.ibex.js.JSArrayLike; -import org.ibex.js.JSExn; -import org.ibex.js.JSU; +import org.ibex.js.*; import org.ibex.js.Thread; import org.ibex.util.Basket; @@ -43,7 +39,7 @@ // REMARK - We're not like Clone here, we don't check the clonee's traps // (since we do it in the get method) if(t==null || (t = t.read())==null) return get(key); - return Thread.runInCurrent(t); + return Main.SCHEDULER.runInCurrent(t); } public JS get(JS key) throws JSExn { Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-11-27 15:30:49 UTC (rev 2621) +++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-11-27 15:31:08 UTC (rev 2622) @@ -835,7 +835,7 @@ * it must ALWAYS be followed by a postPutTriggerTraps */ private final boolean prePutTriggerTrapsAndCatchExceptions(Trap t, JS name, JS val) { try { - if (t != null) org.ibex.js.Thread.runBeforePut(t, val); + if (t != null) Main.SCHEDULER.runBeforePut(t, val); } catch (JSExn e) { Log.uWarn(Box.class,"Caught JS Exception while putting to trap \""+name+"\""); Log.uWarn(Box.class,e); @@ -848,7 +848,7 @@ /** execute trap JS after a put */ private final void postPutTriggerTrapsAndCatchExceptions(Trap t, JS name, boolean b) { try { - if (t != null) org.ibex.js.Thread.runAfterPut(b); + if (t != null) Main.SCHEDULER.runAfterPut(b); } catch (JSExn e) { Log.uWarn(Box.class,"Caught JS Exception while putting to trap \""+name+"\""); Log.uWarn(Box.class,e); @@ -1574,8 +1574,8 @@ boolean rangeTrapException = false; try { if (rangeTrap != null) { - value = Thread.runBeforePut(rangeTrap, value, JSU.N(i)); - JS jsi = Thread.cascadedTo; + value = Main.SCHEDULER.runBeforePut(rangeTrap, value, JSU.N(i)); + JS jsi = Main.SCHEDULER.cascadedTo; // returned from trap without cascading (cleaned up in finally clause) if (jsi==null) return; i = JSU.toInt(jsi); @@ -1626,7 +1626,7 @@ throw e; } finally { if (rangeTrap != null) { - Thread.runAfterPut(rangeTrapException); + Main.SCHEDULER.runAfterPut(rangeTrapException); } } } @@ -1639,8 +1639,8 @@ JS value = null; try { if (rangeTrap != null) { - value = Thread.runBeforeGet(rangeTrap, JSU.N(i)); - JS jsi = Thread.cascadedTo; + value = Main.SCHEDULER.runBeforeGet(rangeTrap, JSU.N(i)); + JS jsi = Main.SCHEDULER.cascadedTo; // if null value returned, avoiding innermost cascade if (jsi == null) return value; i = JSU.toInt(jsi); @@ -1657,7 +1657,7 @@ if (rangeTrap != null) { // value in: cascaded back to the lowermost read trap // value out: returned from the outer most read trap - value = Thread.runAfterGet(rangeTrapException, value); + value = Main.SCHEDULER.runAfterGet(rangeTrapException, value); } } return value; Modified: trunk/core/org.vexi.core/src/org/vexi/core/Main.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Main.java 2007-11-27 15:30:49 UTC (rev 2621) +++ trunk/core/org.vexi.core/src/org/vexi/core/Main.java 2007-11-27 15:31:08 UTC (rev 2622) @@ -22,7 +22,16 @@ /** Entry point for the Vexi Engine; handles splash screen, initial vexi app loading, and argument processing */ public class Main { - + // The SCHEDULER constant is the 'static entry point' for all + // js related operations. Since the JS is now multithreaded + // (Different org.ibex.js.Thread.Faction's can run in different + // java.lang.Thread's) we can no longer have static methods for + // accessing the interpreter. However Vexi only ever has a + // single Thread Faction org.vexi classes can come through here + // instead (alternative is org.ibex.js.Thread.getFaction() which + // uses ThreadLocals). + static public Scheduler SCHEDULER; + public static String origin = null; public static String initialTemplate = "main"; public static JS params = new JS.Obj(); @@ -171,7 +180,7 @@ public static void start(final Vexi vexi) { - + SCHEDULER = Platform.getScheduler(); Scheduler.forceActive ++; Scheduler.add(new Callable(){ public Object run(Object o) throws Exception { @@ -183,7 +192,7 @@ return null; } }); - Scheduler.init(Platform.getScheduler()); + Scheduler.init(SCHEDULER); } /*public static void tryExit(){ Modified: trunk/core/org.vexi.core/src/org/vexi/core/Resources.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2007-11-27 15:30:49 UTC (rev 2621) +++ trunk/core/org.vexi.core/src/org/vexi/core/Resources.java 2007-11-27 15:31:08 UTC (rev 2622) @@ -633,7 +633,7 @@ // FONT STUFF static public void installFont(final JS stream) throws JSExn{ - final Callable callback = Thread.pauseCurrent(); + final Callable callback = Main.SCHEDULER.pauseCurrent(); new java.lang.Thread(new Runnable(){ public void run() { try{ Modified: trunk/core/org.vexi.core/src/org/vexi/core/Surface.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Surface.java 2007-11-27 15:30:49 UTC (rev 2621) +++ trunk/core/org.vexi.core/src/org/vexi/core/Surface.java 2007-11-27 15:31:08 UTC (rev 2622) @@ -325,12 +325,12 @@ // After we finish the current thread that closed the last surface Scheduler.add(new Callable(){ public Object run(Object o) throws Exception { - if(Thread.alive.size()!=0){ + if(Main.SCHEDULER.alive.size()!=0){ // FEATURE - headless mode // vexi.thread.headless or function.headless Log.warn(Surface.class, "WARNING - threads are still alive: "); - for(int i=0; i<Thread.alive.size();i++){ - Thread t= (Thread) Thread.alive.elementAt(i); + for(int i=0; i<Main.SCHEDULER.alive.size();i++){ + Thread t= (Thread) Main.SCHEDULER.alive.elementAt(i); Log.warn(Surface.class, t); } } Modified: trunk/core/org.vexi.core/src/org/vexi/core/Template.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Template.java 2007-11-27 15:30:49 UTC (rev 2621) +++ trunk/core/org.vexi.core/src/org/vexi/core/Template.java 2007-11-27 15:31:08 UTC (rev 2622) @@ -162,7 +162,7 @@ } private void apply(Box b, JS[] args, PerInstantiationScope parentPis) throws JSExn { - Thread.getCurrentInterpreter().enterNonJSCall( this); + Main.SCHEDULER.getCurrentInterpreter().enterNonJSCall( this); try{ // REMARK - the preapplies may not have been resolved yet, // the resolved template is not necessarily the same object. @@ -226,7 +226,7 @@ if (script != JSU.F) JSU.cloneWithNewGlobalScope(script, pis).call(null, args!=null?args:EMPTY_JS_ARRAY); }finally{ - Thread.getCurrentInterpreter().exitNonJSCall(); + Main.SCHEDULER.getCurrentInterpreter().exitNonJSCall(); } } public String traceLine() { Modified: trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java 2007-11-27 15:30:49 UTC (rev 2621) +++ trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java 2007-11-27 15:31:08 UTC (rev 2622) @@ -97,11 +97,11 @@ if (t != null) { initStatic(); JS staticScope = t.new StaticScope(); - Thread.getCurrentInterpreter().enterNonJSCall( t.staticPart); + Main.SCHEDULER.getCurrentInterpreter().enterNonJSCall( t.staticPart); try{ if (staticScript != null) JSU.cloneWithNewGlobalScope(staticScript, staticScope).call(null, callempty); }finally{ - Thread.getCurrentInterpreter().exitNonJSCall(); + Main.SCHEDULER.getCurrentInterpreter().exitNonJSCall(); } }else{ Log.uWarn(LOG_TYPE, "'" + unresolved.staticPart.sourceName + ".t' does not declare a template"); Modified: trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-11-27 15:30:49 UTC (rev 2621) +++ trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-11-27 15:31:08 UTC (rev 2622) @@ -30,11 +30,11 @@ public Object run(Object o) throws JSExn { Log.uInfo(Main.class, "invoking initial template: "+ Main.initialTemplate); - Thread.beforeNonJS(); + Main.SCHEDULER.beforeNonJS(); try{ resolveString(this, Main.initialTemplate).call(null, new JS[]{new Box()}); }finally{ - Thread.afterNonJS(); + Main.SCHEDULER.afterNonJS(); } return null; } @@ -170,7 +170,7 @@ public void put(JS name, JS value) throws JSExn { //#switch(JSU.toString(name)) case "thread": - Thread.runInNew(value,null); + Main.SCHEDULER.runInNew(value,null); return; case "ui.clipboard": Platform.setClipBoard(JSU.toString(value)); return; case "ui.frame": Platform.createSurface((Box)value, true, true); return; @@ -355,7 +355,7 @@ // From JS thread. static private Blessing bless_jsthread(final JS vexi, final JS fountain, final JS name) throws JSExn { try { - final Callable callback = Thread.pauseCurrent(); + final Callable callback = Main.SCHEDULER.pauseCurrent(); new java.lang.Thread() { public void run() { try{ Fountain f = JSU.getFountain(fountain); Modified: trunk/core/org.vexi.core/src_junit/test/core/CoreTestCase.java =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/CoreTestCase.java 2007-11-27 15:30:49 UTC (rev 2621) +++ trunk/core/org.vexi.core/src_junit/test/core/CoreTestCase.java 2007-11-27 15:31:08 UTC (rev 2622) @@ -54,9 +54,9 @@ - + Main.SCHEDULER = new Platform.Scheduler(true); // Start scheduler - Exception e = (Exception)Scheduler.init(new Platform.Scheduler(true)); + Exception e = (Exception)Scheduler.init(Main.SCHEDULER); if(e != null){ if(e instanceof JSExn) throw new AssertJSExn((JSExn) e); throw e; @@ -68,11 +68,11 @@ Scheduler.add(new Callable(){ public Object run(Object o) throws Exception { Log.uInfo(CoreTestCase.class, "invoking initial template: "+ main); - Thread.beforeNonJS(); + Main.SCHEDULER.beforeNonJS(); try{ Vexi.resolveString(v, main).call(null, new JS[]{new Box()}); }finally{ - Thread.afterNonJS(); + Main.SCHEDULER.afterNonJS(); } return null; } Modified: trunk/core/org.vexi.core/src_junit/test/core/stream/TestStream.java =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/stream/TestStream.java 2007-11-27 15:30:49 UTC (rev 2621) +++ trunk/core/org.vexi.core/src_junit/test/core/stream/TestStream.java 2007-11-27 15:31:08 UTC (rev 2622) @@ -79,12 +79,12 @@ TestCase.assertTrue(!save_.exists() || save_.delete()); Fountain.File save = new Fountain.File(save_.getPath(),true); //save.remove(); - Thread.beforeNonJS(); + Main.SCHEDULER.beforeNonJS(); try{ JS function = Util.getStatic(v, main, "runtest"); - Thread.runInNew(function, new JS[]{save}); + Main.SCHEDULER.runInNew(function, new JS[]{save}); }finally{ - Thread.afterNonJS(); + Main.SCHEDULER.afterNonJS(); } return null; } Modified: trunk/core/org.vexi.core/src_unused/org/vexi/net/XMLRPC.java =================================================================== --- trunk/core/org.vexi.core/src_unused/org/vexi/net/XMLRPC.java 2007-11-27 15:30:49 UTC (rev 2621) +++ trunk/core/org.vexi.core/src_unused/org/vexi/net/XMLRPC.java 2007-11-27 15:31:08 UTC (rev 2622) @@ -17,6 +17,7 @@ import org.ibex.util.Log; import org.ibex.util.Vec; import org.kobjects.xml.XmlReader; +import org.vexi.core.Main; /** * An XML-RPC client implemented as a JavaScript Host Object. See the Vexi spec @@ -58,7 +59,7 @@ private final Object call(final JSArray args) throws JSExn { try { - final Callable callback = Thread.pauseCurrent(); + final Callable callback = Main.SCHEDULER.pauseCurrent(); new java.lang.Thread() { public void run() { call(callback, args); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-12-05 23:11:38
|
Revision: 2637 http://vexi.svn.sourceforge.net/vexi/?rev=2637&view=rev Author: clrg Date: 2007-12-05 15:11:42 -0800 (Wed, 05 Dec 2007) Log Message: ----------- Basic tidy up for 3.0 - rename fakeEvent->sendEvent - throw errors when putting to Box function properties Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp trunk/core/org.vexi.core/src_junit/test/core/box/events/layeredPress.t trunk/core/org.vexi.core/src_junit/test/core/box/events/layeredPressBlock.t trunk/core/org.vexi.core/src_junit/test/core/box/events/packedEnterLeave.t trunk/core/org.vexi.core/src_junit/test/core/box/events/simpleMove.t Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-12-05 22:04:09 UTC (rev 2636) +++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-12-05 23:11:42 UTC (rev 2637) @@ -1143,17 +1143,18 @@ ret.put(SC_x, JSU.N(b.localToGlobalX(0) - localToGlobalX(0))); ret.put(SC_y, JSU.N(b.localToGlobalY(0) - localToGlobalY(0))); return ret; - case "fakeEvent": + case "sendEvent": String event; - int fakemx, fakemy; - try { event = JSU.toString(args[0]); } - catch (Exception e) { throw new JSExn("Box.fakeEvent() takes a string as it's first argument"); } - try { fakemx = JSU.toInt(args[1]); } - catch (Exception e) { throw new JSExn("Box.fakeEvent() takes an integer as it's second argument"); } - try { fakemy = JSU.toInt(args[2]); } - catch (Exception e) { throw new JSExn("Box.fakeEvent() takes an integer as it's third argument"); } - if (event.equals("Move")) tryPropagateMove(fakemx, fakemy); - else propagateEvent(event, JSU.T, fakemx, fakemy); + int mx, my; + try { + event = JSU.toString(args[0]); + mx = JSU.toInt(args[1]); + my = JSU.toInt(args[2]); + } catch (Exception e) { + throw new JSExn("Illegal arguments for sendEvent; usage: sendEvent(<string>, <int>, <int>)"); + } + if (event.equals("Move")) tryPropagateMove(mx, my); + else propagateEvent(event, JSU.T, mx, my); return null; //#end } catch (NullPointerException npe) { @@ -1179,7 +1180,7 @@ //#switch (JSU.toString(name)) case "surface": return parent == null ? null : parent.getAndTriggerTraps(name); case "forcereflow": return METHOD; - case "fakeEvent": return METHOD; + case "sendEvent": return METHOD; case "indexof": return METHOD; case "distanceto": return METHOD; case "text": return JSU.S((text==null)? null:text.str); @@ -1355,6 +1356,10 @@ case "numchildren": throw new JSExn("Attempt to put to read-only '"+JSU.toString(name)+"'"); case "contentwidth": throw new JSExn("Attempt to put to read-only '"+JSU.toString(name)+"'"); case "contentheight": throw new JSExn("Attempt to put to read-only '"+JSU.toString(name)+"'"); + case "forcereflow": throw new JSExn("Attempt to put to read-only '"+JSU.toString(name)+"'"); + case "sendEvent": throw new JSExn("Attempt to put to read-only '"+JSU.toString(name)+"'"); + case "indexof": throw new JSExn("Attempt to put to read-only '"+JSU.toString(name)+"'"); + case "distanceto": throw new JSExn("Attempt to put to read-only '"+JSU.toString(name)+"'"); case "align": setAlign(value == null ? "topleft" : JSU.toString(value)); setParentPlace(); case "cursor": super.put(name, value); Modified: trunk/core/org.vexi.core/src_junit/test/core/box/events/layeredPress.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/events/layeredPress.t 2007-12-05 22:04:09 UTC (rev 2636) +++ trunk/core/org.vexi.core/src_junit/test/core/box/events/layeredPress.t 2007-12-05 23:11:42 UTC (rev 2637) @@ -46,7 +46,7 @@ a.forcereflow(); resetEvents(); - a.fakeEvent("Press1", 5, 5); + a.sendEvent("Press1", 5, 5); assert(events._Press1.a); assert(events._Press1.b); assert(events._Press1.c); Modified: trunk/core/org.vexi.core/src_junit/test/core/box/events/layeredPressBlock.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/events/layeredPressBlock.t 2007-12-05 22:04:09 UTC (rev 2636) +++ trunk/core/org.vexi.core/src_junit/test/core/box/events/layeredPressBlock.t 2007-12-05 23:11:42 UTC (rev 2637) @@ -47,7 +47,7 @@ resetEvents(); b.Press1_block = true; - a.fakeEvent("Press1", 5, 5); + a.sendEvent("Press1", 5, 5); assert(events._Press1.a); assert(events._Press1.b); assert(events._Press1.c); @@ -62,7 +62,7 @@ resetEvents(); b.Press1_block = null; b._Press1_block = true; - a.fakeEvent("Press1", 5, 5); + a.sendEvent("Press1", 5, 5); assert(events._Press1.a); assert(events._Press1.b); assert(events._Press1.c == null); @@ -77,7 +77,7 @@ resetEvents(); b._Press1_block = null; d.Press1_block = true; - a.fakeEvent("Press1", 5, 5); + a.sendEvent("Press1", 5, 5); assert(events._Press1.a); assert(events._Press1.b == null); assert(events._Press1.c == null); @@ -92,7 +92,7 @@ resetEvents(); d.Press1_block = null; d._Press1_block = true; - a.fakeEvent("Press1", 5, 5); + a.sendEvent("Press1", 5, 5); assert(events._Press1.a); assert(events._Press1.b == null); assert(events._Press1.c == null); Modified: trunk/core/org.vexi.core/src_junit/test/core/box/events/packedEnterLeave.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/events/packedEnterLeave.t 2007-12-05 22:04:09 UTC (rev 2636) +++ trunk/core/org.vexi.core/src_junit/test/core/box/events/packedEnterLeave.t 2007-12-05 23:11:42 UTC (rev 2637) @@ -27,21 +27,21 @@ a.forcereflow(); resetEvents(); - a.fakeEvent("Move", 5, 5); + a.sendEvent("Move", 5, 5); assert(events.Enter.b); assert(events.Leave.b == null); assert(events.Enter.c == null); assert(events.Leave.c == null); resetEvents(); - a.fakeEvent("Move", 15, 5); + a.sendEvent("Move", 15, 5); assert(events.Enter.b == null); assert(events.Leave.b); assert(events.Enter.c); assert(events.Leave.c == null); resetEvents(); - a.fakeEvent("Move", 5, 5); + a.sendEvent("Move", 5, 5); assert(events.Enter.b); assert(events.Leave.b == null); assert(events.Enter.c == null); Modified: trunk/core/org.vexi.core/src_junit/test/core/box/events/simpleMove.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/events/simpleMove.t 2007-12-05 22:04:09 UTC (rev 2636) +++ trunk/core/org.vexi.core/src_junit/test/core/box/events/simpleMove.t 2007-12-05 23:11:42 UTC (rev 2637) @@ -24,7 +24,7 @@ a.width = 10; a.height = 10; a.forcereflow(); - a.fakeEvent("Move", 5, 5); + a.sendEvent("Move", 5, 5); assert(events.Move.a); assert(events.Move.b); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cl...@us...> - 2007-12-21 18:09:27
|
Revision: 2692 http://vexi.svn.sourceforge.net/vexi/?rev=2692&view=rev Author: clrg Date: 2007-12-21 10:09:32 -0800 (Fri, 21 Dec 2007) Log Message: ----------- Reduce warnings and convert some tabs to spaces Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp trunk/core/org.vexi.core/src/org/vexi/graphics/Font.java trunk/core/org.vexi.core/src/org/vexi/plat/AWT.java trunk/core/org.vexi.core/src/org/vexi/plat/Java2.java trunk/core/org.vexi.core/src_dev/org/vexi/plat/Java2VolatileImage.java Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-12-21 02:50:06 UTC (rev 2691) +++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-12-21 18:09:32 UTC (rev 2692) @@ -21,7 +21,6 @@ import org.ibex.js.JSU; import org.ibex.js.JSExn; import org.ibex.js.Scheduler; -import org.ibex.js.Thread; import org.ibex.util.Callable; import org.ibex.util.Log; import org.vexi.graphics.Color; Modified: trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java 2007-12-21 02:50:06 UTC (rev 2691) +++ trunk/core/org.vexi.core/src/org/vexi/core/TemplateBuilder.java 2007-12-21 18:09:32 UTC (rev 2692) @@ -287,7 +287,7 @@ oldCb.apply: (Template)oldCb; t = (Template)cb; - t.children.addElement((Template)oldT); + t.children.addElement(oldT); state = STATE_IN_TEMPLATE_NODE; }else{ if (nodeStack.size() == 0) { Modified: trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-12-21 02:50:06 UTC (rev 2691) +++ trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2007-12-21 18:09:32 UTC (rev 2692) @@ -11,13 +11,11 @@ import org.ibex.js.JSExn; import org.ibex.js.JSRegexp; import org.ibex.js.JSU; -import org.ibex.js.Thread; import org.ibex.js.XMLRPC; import org.ibex.util.Cache; import org.ibex.util.Callable; import org.ibex.util.Encode; import org.ibex.util.Log; -import org.vexi.core.Text; import org.vexi.graphics.Font; import org.vexi.net.HTTP; import org.vexi.net.SOAP; @@ -46,7 +44,7 @@ throw new JSExn("absolute URL " + str + " not permitted here"); }*/ // root-relative - JS ret = (JS)vexi.getAndTriggerTraps(SC_); + JS ret = vexi.getAndTriggerTraps(SC_); while (str.indexOf('.') != -1) { String path = str.substring(0, str.indexOf('.')); Modified: trunk/core/org.vexi.core/src/org/vexi/graphics/Font.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/graphics/Font.java 2007-12-21 02:50:06 UTC (rev 2691) +++ trunk/core/org.vexi.core/src/org/vexi/graphics/Font.java 2007-12-21 18:09:32 UTC (rev 2692) @@ -98,7 +98,7 @@ width += g.advance; height = java.lang.Math.max(height, max_ascent + max_descent); } - return ((((long)width) << 32) | (long)(height & 0xffffffffL)); + return ((((long)width) << 32) | (height & 0xffffffffL)); } // FEATURE do we really need to be caching sizes? @@ -172,7 +172,7 @@ private synchronized void renderGlyph(Font.Glyph glyph) throws IOException { try { Log.debug(Font.class, "rasterizing glyph " + glyph.c + " of font " + glyph.font); - if (glyph.font.loadedStream != glyph.font.stream) loadFontByteStream(glyph.font.stream); + if (Font.loadedStream != glyph.font.stream) loadFontByteStream(glyph.font.stream); //long start = System.currentTimeMillis(); Modified: trunk/core/org.vexi.core/src/org/vexi/plat/AWT.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/plat/AWT.java 2007-12-21 02:50:06 UTC (rev 2691) +++ trunk/core/org.vexi.core/src/org/vexi/plat/AWT.java 2007-12-21 18:09:32 UTC (rev 2692) @@ -66,986 +66,985 @@ /** Platform subclass for all VM's providing AWT 1.1 functionality */ public class AWT extends JVM { - protected String getDescriptiveName() { - return "Generic JDK 1.1+ with AWT"; - } + protected String getDescriptiveName() { + return "Generic JDK 1.1+ with AWT"; + } - protected PixelBuffer _createPixelBuffer(int w, int h, Surface owner) { - return new AWTPixelBuffer(w, h); - } + protected PixelBuffer _createPixelBuffer(int w, int h, Surface owner) { + return new AWTPixelBuffer(w, h); + } - protected Picture _createPicture(JS r) { - return new AWTPicture(r); - } + protected Picture _createPicture(JS r) { + return new AWTPicture(r); + } - protected int _getScreenWidth() { - return Toolkit.getDefaultToolkit().getScreenSize().width; - } + protected int _getScreenWidth() { + return Toolkit.getDefaultToolkit().getScreenSize().width; + } - protected int _getScreenHeight() { - return Toolkit.getDefaultToolkit().getScreenSize().height; - } + protected int _getScreenHeight() { + return Toolkit.getDefaultToolkit().getScreenSize().height; + } - protected Surface _createSurface(Box b, boolean framed) { - return new AWTSurface(b, framed); - } + protected Surface _createSurface(Box b, boolean framed) { + return new AWTSurface(b, framed); + } - protected void postInit() { - Log.diag(Platform.class, " color depth = " - + Toolkit.getDefaultToolkit().getColorModel().getPixelSize() - + "bpp"); - } + protected void postInit() { + Log.diag(Platform.class, " color depth = " + + Toolkit.getDefaultToolkit().getColorModel().getPixelSize() + + "bpp"); + } - protected void _criticalAbort(String message) { - Log.error(this, message); - final Dialog d = new Dialog(new Frame(), "Vexi Cannot Continue"); - d.setLayout(new BorderLayout()); - TextArea ta = new TextArea("Vexi cannot continue because:\n\n" - + message, 10, 80); - ta.setEditable(false); - d.add(ta, "Center"); - Button b = new Button("OK"); - b.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - d.dispose(); - } - }); - d.add(b, "South"); - d.setModal(true); - d.pack(); - d.show(); - new Semaphore().block(); - } + protected void _criticalAbort(String message) { + Log.error(this, message); + final Dialog d = new Dialog(new Frame(), "Vexi Cannot Continue"); + d.setLayout(new BorderLayout()); + TextArea ta = new TextArea("Vexi cannot continue because:\n\n" + + message, 10, 80); + ta.setEditable(false); + d.add(ta, "Center"); + Button b = new Button("OK"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + d.dispose(); + } + }); + d.add(b, "South"); + d.setModal(true); + d.pack(); + d.setVisible(true); + new Semaphore().block(); + } - protected String _getClipBoard() { - Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); - if (cb == null) - return null; - Transferable clipdata = cb.getContents(null); - try { - return (String) clipdata.getTransferData(DataFlavor.stringFlavor); - } catch (Exception ex) { - return null; - } - } + protected String _getClipBoard() { + Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); + if (cb == null) + return null; + Transferable clipdata = cb.getContents(null); + try { + return (String) clipdata.getTransferData(DataFlavor.stringFlavor); + } catch (Exception ex) { + return null; + } + } - protected void _setClipBoard(String s) { - Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); - if (clipboard == null) - return; - StringSelection clipString = new StringSelection(s); - clipboard.setContents(clipString, clipString); - } + protected void _setClipBoard(String s) { + Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); + if (clipboard == null) + return; + StringSelection clipString = new StringSelection(s); + clipboard.setContents(clipString, clipString); + } - /** - * some platforms (cough, cough, NetscapeVM) have totally broken modifier - * masks; they will need to override this - */ - protected static int modifiersToButtonNumber(int modifiers) { - if ((modifiers & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK) - return 1; - if ((modifiers & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK) { - // ugh, MacOSX reports the right mouse button as BUTTON2_MASK... - if (System.getProperty("os.name", "").startsWith("Mac OS X")) - return 2; - return 3; - } - if ((modifiers & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) { - // ugh, MacOSX reports the right mouse button as BUTTON2_MASK... - if (System.getProperty("os.name", "").startsWith("Mac OS X")) - return 3; - return 2; - } - return 0; - } + /** + * some platforms (cough, cough, NetscapeVM) have totally broken modifier + * masks; they will need to override this + */ + protected static int modifiersToButtonNumber(int modifiers) { + if ((modifiers & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK) + return 1; + if ((modifiers & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK) { + // ugh, MacOSX reports the right mouse button as BUTTON2_MASK... + if (System.getProperty("os.name", "").startsWith("Mac OS X")) + return 2; + return 3; + } + if ((modifiers & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) { + // ugh, MacOSX reports the right mouse button as BUTTON2_MASK... + if (System.getProperty("os.name", "").startsWith("Mac OS X")) + return 3; + return 2; + } + return 0; + } - static class FileDialogHelper extends FileDialog implements WindowListener, - ComponentListener { - Semaphore s; + static class FileDialogHelper extends FileDialog implements WindowListener, ComponentListener { + Semaphore s; - public FileDialogHelper(String suggestedFileName, Semaphore s, - boolean write) { - super(new Frame(), write ? "Save" : "Open", write ? FileDialog.SAVE - : FileDialog.LOAD); - this.s = s; - addWindowListener(this); - addComponentListener(this); - if (suggestedFileName.indexOf(File.separatorChar) == -1) { - setFile(suggestedFileName); - } else { - setDirectory(suggestedFileName.substring(0, suggestedFileName - .lastIndexOf(File.separatorChar))); - setFile(suggestedFileName.substring(suggestedFileName - .lastIndexOf(File.separatorChar) + 1)); - } - show(); - } + public FileDialogHelper(String suggestedFileName, Semaphore s, + boolean write) { + super(new Frame(), write ? "Save" : "Open", write ? FileDialog.SAVE + : FileDialog.LOAD); + this.s = s; + addWindowListener(this); + addComponentListener(this); + if (suggestedFileName.indexOf(File.separatorChar) == -1) { + setFile(suggestedFileName); + } else { + setDirectory(suggestedFileName.substring(0, suggestedFileName + .lastIndexOf(File.separatorChar))); + setFile(suggestedFileName.substring(suggestedFileName + .lastIndexOf(File.separatorChar) + 1)); + } + setVisible(true); + } - public void windowActivated(WindowEvent e) { - } + public void windowActivated(WindowEvent e) { + } - public void windowClosed(WindowEvent e) { - s.release(); - } + public void windowClosed(WindowEvent e) { + s.release(); + } - public void windowClosing(WindowEvent e) { - } + public void windowClosing(WindowEvent e) { + } - public void windowDeactivated(WindowEvent e) { - } + public void windowDeactivated(WindowEvent e) { + } - public void windowDeiconified(WindowEvent e) { - } + public void windowDeiconified(WindowEvent e) { + } - public void windowIconified(WindowEvent e) { - } + public void windowIconified(WindowEvent e) { + } - public void windowOpened(WindowEvent e) { - } + public void windowOpened(WindowEvent e) { + } - public void componentHidden(ComponentEvent e) { - s.release(); - } + public void componentHidden(ComponentEvent e) { + s.release(); + } - public void componentMoved(ComponentEvent e) { - } + public void componentMoved(ComponentEvent e) { + } - public void componentResized(ComponentEvent e) { - } + public void componentResized(ComponentEvent e) { + } - public void componentShown(ComponentEvent e) { - } - }; + public void componentShown(ComponentEvent e) { + } + }; - protected String _fileDialog(String suggestedFileName, boolean write) { - final Semaphore s = new Semaphore(); - FileDialogHelper fd = new FileDialogHelper(suggestedFileName, s, write); - s.block(); - return fd.getDirectory() == null ? null : (fd.getDirectory() - + File.separatorChar + fd.getFile()); - } + protected String _fileDialog(String suggestedFileName, boolean write) { + final Semaphore s = new Semaphore(); + FileDialogHelper fd = new FileDialogHelper(suggestedFileName, s, write); + s.block(); + return fd.getDirectory() == null ? null : (fd.getDirectory() + + File.separatorChar + fd.getFile()); + } - // Inner Classes - // ///////////////////////////////////////////////////////////////////////////////////// + // Inner Classes + // ///////////////////////////////////////////////////////////////////////////////////// - protected Font.Glyph _createGlyph(Font f, char c) { - return new AWTGlyph(f, c); - } + protected Font.Glyph _createGlyph(Font f, char c) { + return new AWTGlyph(f, c); + } - protected static class AWTGlyph extends Font.Glyph { - private Image i = null; - private static ColorModel cmodel = new DirectColorModel(32, 0x00FF0000, - 0x0000FF00, 0x000000FF, 0xFF000000); + protected static class AWTGlyph extends Font.Glyph { + private Image i = null; + private static ColorModel cmodel = new DirectColorModel(32, 0x00FF0000, + 0x0000FF00, 0x000000FF, 0xFF000000); - // this doesn't work on Win32 because the JVM is broken - /* - * static final ColorModel cmodel = new ColorModel(8) { public int - * getRed(int p) { return 0; } public int getGreen(int p) { return 0; } - * public int getBlue(int p) { return 0; } public int getAlpha(int p) { - * return p & 0xFF; } }; - */ + // this doesn't work on Win32 because the JVM is broken + /* + * static final ColorModel cmodel = new ColorModel(8) { public int + * getRed(int p) { return 0; } public int getGreen(int p) { return 0; } + * public int getBlue(int p) { return 0; } public int getAlpha(int p) { + * return p & 0xFF; } }; + */ - public AWTGlyph(Font f, char c) { - super(f, c); - } + public AWTGlyph(Font f, char c) { + super(f, c); + } - Image getImage() { - if (i == null && isLoaded) { + Image getImage() { + if (i == null && isLoaded) { - int[] data2 = new int[data.length]; - for (int i = 0; i < data2.length; i++) - data2[i] = ((data[i]) & 0xff) << 24; + int[] data2 = new int[data.length]; + for (int i = 0; i < data2.length; i++) + data2[i] = ((data[i]) & 0xff) << 24; - MemoryImageSource mis = new MemoryImageSource(width, height, - cmodel, data2, 0, width); - mis.setAnimated(true); - i = Toolkit.getDefaultToolkit().createImage(mis); - MediaTracker mediatracker = new MediaTracker(new Canvas()); - mediatracker.addImage(i, 1); - try { - mediatracker.waitForAll(); - } catch (InterruptedException e) { - } - mediatracker.removeImage(i); - synchronized (AWTPixelBuffer.class) { - if (AWTPixelBuffer.component == null) { - AWTPixelBuffer.component = new Frame(); - AWTPixelBuffer.component.setVisible(false); - AWTPixelBuffer.component.addNotify(); - } - } - data = null; - } - return i; - } - } + MemoryImageSource mis = new MemoryImageSource(width, height, + cmodel, data2, 0, width); + mis.setAnimated(true); + i = Toolkit.getDefaultToolkit().createImage(mis); + MediaTracker mediatracker = new MediaTracker(new Canvas()); + mediatracker.addImage(i, 1); + try { + mediatracker.waitForAll(); + } catch (InterruptedException e) { + } + mediatracker.removeImage(i); + synchronized (AWTPixelBuffer.class) { + if (AWTPixelBuffer.component == null) { + AWTPixelBuffer.component = new Frame(); + AWTPixelBuffer.component.setVisible(false); + AWTPixelBuffer.component.addNotify(); + } + } + data = null; + } + return i; + } + } - protected static class AWTPicture extends Picture { - public Image i = null; - private static ColorModel cmodel = new DirectColorModel(32, 0x00FF0000, - 0x0000FF00, 0x000000FF, 0xFF000000); + protected static class AWTPicture extends Picture { + public Image i = null; + private static ColorModel cmodel = new DirectColorModel(32, 0x00FF0000, + 0x0000FF00, 0x000000FF, 0xFF000000); - boolean initialized = false; + boolean initialized = false; - public AWTPicture(JS r) { - super(r); - } + public AWTPicture(JS r) { + super(r); + } - public void init() { - if (initialized) - return; - initialized = true; - MemoryImageSource mis = new MemoryImageSource(width, height, - cmodel, data, 0, width); - mis.setAnimated(true); - i = Toolkit.getDefaultToolkit().createImage(mis); - MediaTracker mediatracker = new MediaTracker(new Canvas()); - mediatracker.addImage(i, 1); - try { - mediatracker.waitForAll(); - } catch (InterruptedException e) { - } - mediatracker.removeImage(i); - synchronized (AWTPixelBuffer.class) { - if (AWTPixelBuffer.component == null) { - AWTPixelBuffer.component = new Frame(); - AWTPixelBuffer.component.setVisible(false); - AWTPixelBuffer.component.addNotify(); - } - } - } - } + public void init() { + if (initialized) + return; + initialized = true; + MemoryImageSource mis = new MemoryImageSource(width, height, + cmodel, data, 0, width); + mis.setAnimated(true); + i = Toolkit.getDefaultToolkit().createImage(mis); + MediaTracker mediatracker = new MediaTracker(new Canvas()); + mediatracker.addImage(i, 1); + try { + mediatracker.waitForAll(); + } catch (InterruptedException e) { + } + mediatracker.removeImage(i); + synchronized (AWTPixelBuffer.class) { + if (AWTPixelBuffer.component == null) { + AWTPixelBuffer.component = new Frame(); + AWTPixelBuffer.component.setVisible(false); + AWTPixelBuffer.component.addNotify(); + } + } + } + } - protected static class AWTPixelBuffer implements PixelBuffer { + protected static class AWTPixelBuffer implements PixelBuffer { - protected Image i = null; - protected Graphics g = null; - protected AWTSurface surface = null; + protected Image i = null; + protected Graphics g = null; + protected AWTSurface surface = null; - /** - * JDK1.1 platforms require that a component be associated with each - * off-screen buffer - */ - static Component component = null; + /** + * JDK1.1 platforms require that a component be associated with each + * off-screen buffer + */ + static Component component = null; - public AWTPixelBuffer() { - } + public AWTPixelBuffer() { + } - public AWTPixelBuffer(Image i) { - this.i = i; - g = i.getGraphics(); - } + public AWTPixelBuffer(Image i) { + this.i = i; + g = i.getGraphics(); + } - public AWTPixelBuffer(AWTSurface s) { - this(Platform.getScreenWidth(), Platform.getScreenHeight()); - this.surface = s; - } + public AWTPixelBuffer(AWTSurface s) { + this(Platform.getScreenWidth(), Platform.getScreenHeight()); + this.surface = s; + } - public AWTPixelBuffer(int w, int h) { - synchronized (AWTPixelBuffer.class) { - if (component == null) { - component = new Frame(); - component.setVisible(false); - component.addNotify(); - } - } - i = component.createImage(w, h); - g = i.getGraphics(); - } + public AWTPixelBuffer(int w, int h) { + synchronized (AWTPixelBuffer.class) { + if (component == null) { + component = new Frame(); + component.setVisible(false); + component.addNotify(); + } + } + i = component.createImage(w, h); + g = i.getGraphics(); + } - public int getHeight() { - return i == null ? 0 : i.getHeight(null); - } + public int getHeight() { + return i == null ? 0 : i.getHeight(null); + } - public int getWidth() { - return i == null ? 0 : i.getWidth(null); - } + public int getWidth() { + return i == null ? 0 : i.getWidth(null); + } - /** draw an unscaled image */ - public void drawPicture(Picture source, int dx, int dy, int cx1, - int cy1, int cx2, int cy2) { - ((AWTPicture) source).init(); - g.setClip(cx1, cy1, cx2 - cx1, cy2 - cy1); - g.drawImage(((AWTPicture) source).i, dx, dy, null); - g.setClip(0, 0, i.getWidth(null), i.getHeight(null)); - } + /** draw an unscaled image */ + public void drawPicture(Picture source, int dx, int dy, int cx1, + int cy1, int cx2, int cy2) { + ((AWTPicture) source).init(); + g.setClip(cx1, cy1, cx2 - cx1, cy2 - cy1); + g.drawImage(((AWTPicture) source).i, dx, dy, null); + g.setClip(0, 0, i.getWidth(null), i.getHeight(null)); + } - /** draw an scaled image */ - public void drawPicture(Picture source, int dx1, int dy1, int dx2, - int dy2, int sx1, int sy1, int sx2, int sy2) { - ((AWTPicture) source).init(); - g.drawImage(((AWTPicture) source).i, dx1, dy1, dx2, dy2, sx1, sy1, - sx2, sy2, null); - } + /** draw an scaled image */ + public void drawPicture(Picture source, int dx1, int dy1, int dx2, + int dy2, int sx1, int sy1, int sx2, int sy2) { + ((AWTPicture) source).init(); + g.drawImage(((AWTPicture) source).i, dx1, dy1, dx2, dy2, sx1, sy1, + sx2, sy2, null); + } - /** implemented with java.awt 1.1's setXORMode() */ - public void drawGlyph(Font.Glyph source, int dx, int dy, int cx1, - int cy1, int cx2, int cy2, int rgb) { + /** implemented with java.awt 1.1's setXORMode() */ + public void drawGlyph(Font.Glyph source, int dx, int dy, int cx1, + int cy1, int cx2, int cy2, int rgb) { - // XOR the target region - g.setXORMode(new java.awt.Color((rgb & 0x00ff0000) >> 16, - (rgb & 0x0000ff00) >> 8, rgb & 0x000000ff)); - g.setColor(new java.awt.Color(0x0, 0x0, 0x0)); - g.fillRect(cx1, cy1, cx2 - cx1, cy2 - cy1); + // XOR the target region + g.setXORMode(new java.awt.Color((rgb & 0x00ff0000) >> 16, + (rgb & 0x0000ff00) >> 8, rgb & 0x000000ff)); + g.setColor(new java.awt.Color(0x0, 0x0, 0x0)); + g.fillRect(cx1, cy1, cx2 - cx1, cy2 - cy1); - // blacken the area we want the glyph to cover - g.setPaintMode(); - g.setClip(cx1, cy1, cx2 - cx1, cy2 - cy1); - g.drawImage(((AWTGlyph) source).getImage(), dx, dy, null); - g.setClip(0, 0, i.getWidth(null), i.getHeight(null)); + // blacken the area we want the glyph to cover + g.setPaintMode(); + g.setClip(cx1, cy1, cx2 - cx1, cy2 - cy1); + g.drawImage(((AWTGlyph) source).getImage(), dx, dy, null); + g.setClip(0, 0, i.getWidth(null), i.getHeight(null)); - // XOR back, turning black into the chosen rgb color - g.setXORMode(new java.awt.Color((rgb & 0x00ff0000) >> 16, - (rgb & 0x0000ff00) >> 8, rgb & 0x000000ff)); - g.setColor(new java.awt.Color(0x0, 0x0, 0x0)); - g.fillRect(cx1, cy1, cx2 - cx1, cy2 - cy1); + // XOR back, turning black into the chosen rgb color + g.setXORMode(new java.awt.Color((rgb & 0x00ff0000) >> 16, + (rgb & 0x0000ff00) >> 8, rgb & 0x000000ff)); + g.setColor(new java.awt.Color(0x0, 0x0, 0x0)); + g.fillRect(cx1, cy1, cx2 - cx1, cy2 - cy1); - // restore the graphics context - g.setPaintMode(); - } + // restore the graphics context + g.setPaintMode(); + } - // FIXME: try to use os acceleration - public void fillTrapezoid(int x1, int x2, int y1, int x3, int x4, - int y2, int argb) { - g.setColor(new java.awt.Color((argb & 0x00FF0000) >> 16, - (argb & 0x0000FF00) >> 8, (argb & 0x000000FF), - (argb & 0xFF000000) >>> 24)); - if (x1 == x3 && x2 == x4) { - g.fillRect(x1, y1, x4 - x1, y2 - y1); - } else - for (int y = y1; y < y2; y++) { - int _x1 = (int) Math.floor((y - y1) * (x3 - x1) / (y2 - y1) - + x1); - int _y1 = (int) Math.floor(y); - int _x2 = (int) Math.ceil((y - y1) * (x4 - x2) / (y2 - y1) - + x2); - int _y2 = (int) Math.floor(y) + 1; - if (_x1 > _x2) { - int _x0 = _x1; - _x1 = _x2; - _x2 = _x0; - } - g.fillRect(_x1, _y1, _x2 - _x1, _y2 - _y1); - } - } + // FIXME: try to use os acceleration + public void fillTrapezoid(int x1, int x2, int y1, int x3, int x4, + int y2, int argb) { + g.setColor(new java.awt.Color((argb & 0x00FF0000) >> 16, + (argb & 0x0000FF00) >> 8, (argb & 0x000000FF), + (argb & 0xFF000000) >>> 24)); + if (x1 == x3 && x2 == x4) { + g.fillRect(x1, y1, x4 - x1, y2 - y1); + } else + for (int y = y1; y < y2; y++) { + int _x1 = (int) Math.floor((y - y1) * (x3 - x1) / (y2 - y1) + + x1); + int _y1 = (int) Math.floor(y); + int _x2 = (int) Math.ceil((y - y1) * (x4 - x2) / (y2 - y1) + + x2); + int _y2 = (int) Math.floor(y) + 1; + if (_x1 > _x2) { + int _x0 = _x1; + _x1 = _x2; + _x2 = _x0; + } + g.fillRect(_x1, _y1, _x2 - _x1, _y2 - _y1); + } + } - public void drawLine(int x1, int y1, int x2, int y2, int color) { - // TODO Auto-generated method stub - throw new Error("FIXME: not yet implemented"); - } + public void drawLine(int x1, int y1, int x2, int y2, int color) { + // TODO Auto-generated method stub + throw new Error("FIXME: not yet implemented"); + } - public void fillTriangle(int x1, int y1, int x2, int y2, int x3, - int y3, int color) { - // TODO Auto-generated method stub - throw new Error("FIXME: not yet implemented"); - } - } + public void fillTriangle(int x1, int y1, int x2, int y2, int x3, + int y3, int color) { + // TODO Auto-generated method stub + throw new Error("FIXME: not yet implemented"); + } + } - protected static class AWTSurface extends Surface.DoubleBufferedSurface - implements MouseListener, MouseMotionListener, MouseWheelListener, - KeyListener, ComponentListener, WindowListener { + protected static class AWTSurface extends Surface.DoubleBufferedSurface + implements MouseListener, MouseMotionListener, MouseWheelListener, + KeyListener, ComponentListener, WindowListener { - public void blit(PixelBuffer s, int sx, int sy, int dx, int dy, - int dx2, int dy2) { - discoverInsets(); - try { - window.getGraphics().drawImage(((AWTPixelBuffer) s).i, - dx + leftInset, dy + topInset, dx2 + leftInset, - dy2 + topInset, sx, sy, sx + (dx2 - dx), - sy + (dy2 - dy), null); - } catch (NullPointerException npe) { /* - * FIXME: handle this - * gracefully - */ - } - } + public void blit(PixelBuffer s, int sx, int sy, int dx, int dy, + int dx2, int dy2) { + discoverInsets(); + try { + window.getGraphics().drawImage(((AWTPixelBuffer) s).i, + dx + leftInset, dy + topInset, dx2 + leftInset, + dy2 + topInset, sx, sy, sx + (dx2 - dx), + sy + (dy2 - dy), null); + } catch (NullPointerException npe) { /* + * FIXME: handle this + * gracefully + */ + } + } - /** - * if (component instanceof Frame) then frame == window else frame == - * null - */ - Frame frame = null; - Window window = null; + /** + * if (component instanceof Frame) then frame == window else frame == + * null + */ + Frame frame = null; + Window window = null; - /** our component's insets */ - // protected Insets insets = new Insets(0, 0, 0, 0); - /** - * some JDKs let us recycle a single Dimension object when calling - * getSize() - */ - Dimension singleSize = new Dimension(); + /** our component's insets */ + // protected Insets insets = new Insets(0, 0, 0, 0); + /** + * some JDKs let us recycle a single Dimension object when calling + * getSize() + */ + Dimension singleSize = new Dimension(); - public void toBack() { - if (window != null) - window.toBack(); - } + public void toBack() { + if (window != null) + window.toBack(); + } - public void toFront() { - if (window != null) - window.toFront(); - } + public void toFront() { + if (window != null) + window.toFront(); + } - public void setLocation() { - if (window != null) - window.setLocation(x, y); - } + public void setLocation() { + if (window != null) + window.setLocation(x, y); + } - public void setTitleBarText(String s) { - if (frame != null) - frame.setTitle(s); - } + public void setTitleBarText(String s) { + if (frame != null) + frame.setTitle(s); + } - public void setInvisible(boolean b) { - window.setVisible(!b); - } + public void setInvisible(boolean b) { + window.setVisible(!b); + } - public void setIcon(Picture i) { - if (frame == null) - return; - // frame.setIconImage(image); - // BROKEN - setting the icon - // ... problem setting icon causes java to hang if from AWTPicture's - // image - // ImageIcon(..).getImage() seems to work however. - // frame.setIconImage(((AWTPicture)i).i); - } + public void setIcon(Picture i) { + if (frame == null) + return; + // frame.setIconImage(image); + // BROKEN - setting the icon + // ... problem setting icon causes java to hang if from AWTPicture's + // image + // ImageIcon(..).getImage() seems to work however. + // frame.setIconImage(((AWTPicture)i).i); + } - public void _setSize(int width, int height) { - discoverInsets(); - // System.err.println("_setSize: "+width+", "+height - // +" ("+leftInset+", "+rightInset+", "+topInset+", - // "+bottomInset+")"); - window.setSize(width + (leftInset + rightInset), height - + (topInset + bottomInset)); - } + public void _setSize(int width, int height) { + discoverInsets(); + // System.err.println("_setSize: "+width+", "+height + // +" ("+leftInset+", "+rightInset+", "+topInset+", + // "+bottomInset+")"); + window.setSize(width + (leftInset + rightInset), height + + (topInset + bottomInset)); + } - protected void _setMinimized(boolean b) { - Log.warn(this, - "JDK 1.1 platforms cannot minimize or unminimize windows"); - } + protected void _setMinimized(boolean b) { + Log.warn(this, + "JDK 1.1 platforms cannot minimize or unminimize windows"); + } - protected void _setMaximized(boolean b) { - if (!b) { - Log.warn(this, "JDK 1.1 platforms cannot unmaximize windows"); - return; - } - window.setLocation(new Point(0, 0)); - window.setSize(Toolkit.getDefaultToolkit().getScreenSize()); - } + protected void _setMaximized(boolean b) { + if (!b) { + Log.warn(this, "JDK 1.1 platforms cannot unmaximize windows"); + return; + } + window.setLocation(new Point(0, 0)); + window.setSize(Toolkit.getDefaultToolkit().getScreenSize()); + } - class InnerFrame extends Frame { - public InnerFrame() throws java.lang.UnsupportedOperationException { - } + class InnerFrame extends Frame { + public InnerFrame() throws java.lang.UnsupportedOperationException { + } - /** - * overrides the native Frame method to supposedly enforce a minimum - * size - */ - public Dimension getMinimumSize() { - // FEATURE: cache dimension - return new Dimension(root == null ? 0 : root.minwidth, - root == null ? 0 : root.minheight); - } + /** + * overrides the native Frame method to supposedly enforce a minimum + * size + */ + public Dimension getMinimumSize() { + // FEATURE: cache dimension + return new Dimension(root == null ? 0 : root.minwidth, + root == null ? 0 : root.minheight); + } - public void update(Graphics gr) { - paint(gr); - } + public void update(Graphics gr) { + paint(gr); + } - public void paint(Graphics gr) { - Rectangle r = gr.getClipBounds(); + public void paint(Graphics gr) { + Rectangle r = gr.getClipBounds(); - // ugly hack for Java1.4 dynamicLayout on Win32 -- this catches - // expansions during smooth resize - int newwidth = Math.max(r.x - leftInset + r.width, root.width); - int newheight = Math - .max(r.y - topInset + r.height, root.height); - if (newwidth > root.width || newheight > root.height) - componentResized( - window.getWidth() - leftInset - rightInset, window - .getHeight() - - topInset - bottomInset); + // ugly hack for Java1.4 dynamicLayout on Win32 -- this catches + // expansions during smooth resize + int newwidth = Math.max(r.x - leftInset + r.width, root.width); + int newheight = Math + .max(r.y - topInset + r.height, root.height); + if (newwidth > root.width || newheight > root.height) + componentResized( + window.getWidth() - leftInset - rightInset, window + .getHeight() + - topInset - bottomInset); - refreshFromBackbuffer(r.x - leftInset, r.y - topInset, r.width, - r.height); - } + refreshFromBackbuffer(r.x - leftInset, r.y - topInset, r.width, + r.height); + } - public InputMethodRequests getInputMethodRequests() { - // REMARK - makes us a passive client FOOTNOTE1 - return null; - } - } + public InputMethodRequests getInputMethodRequests() { + // REMARK - makes us a passive client FOOTNOTE1 + return null; + } + } - class InnerWindow extends Window { - public InnerWindow() throws java.lang.UnsupportedOperationException { - super(new Frame()); - } + class InnerWindow extends Window { + public InnerWindow() throws java.lang.UnsupportedOperationException { + super(new Frame()); + } - /** - * overrides the native Window method to supposedly enforce a - * minimum size - */ - public Dimension getMinimumSize() { - // FEATURE: cache dimension - return new Dimension(root == null ? 0 : root.minwidth, - root == null ? 0 : root.minheight); - } + /** + * overrides the native Window method to supposedly enforce a + * minimum size + */ + public Dimension getMinimumSize() { + // FEATURE: cache dimension + return new Dimension(root == null ? 0 : root.minwidth, + root == null ? 0 : root.minheight); + } - public void update(Graphics gr) { - paint(gr); - } + public void update(Graphics gr) { + paint(gr); + } - public void paint(Graphics gr) { - Rectangle r = gr.getClipBounds(); - refreshFromBackbuffer(r.x - leftInset, r.y - topInset, r.width, - r.height); - } + public void paint(Graphics gr) { + Rectangle r = gr.getClipBounds(); + refreshFromBackbuffer(r.x - leftInset, r.y - topInset, r.width, + r.height); + } - public InputMethodRequests getInputMethodRequests() { - // REMARK - makes us a passive client FOOTNOTE1 - return null; - } - } + public InputMethodRequests getInputMethodRequests() { + // REMARK - makes us a passive client FOOTNOTE1 + return null; + } + } - /** establish the size of the frame decorations */ - private void discoverInsets() { - Insets i = window.getInsets(); - if (leftInset == i.left && topInset == i.top - && bottomInset == i.bottom && rightInset == i.right) - return; - leftInset = i.left; - topInset = i.top; - bottomInset = i.bottom; - rightInset = i.right; - // respect the size of the root box - window.setSize(pendingWidth + (leftInset + rightInset), - pendingHeight + (topInset + bottomInset)); - } + /** establish the size of the frame decorations */ + private void discoverInsets() { + Insets i = window.getInsets(); + if (leftInset == i.left && topInset == i.top + && bottomInset == i.bottom && rightInset == i.right) + return; + leftInset = i.left; + topInset = i.top; + bottomInset = i.bottom; + rightInset = i.right; + // respect the size of the root box + window.setSize(pendingWidth + (leftInset + rightInset), + pendingHeight + (topInset + bottomInset)); + } - /** sets the maximum size of the frame */ - public void setMaximumSize(int maxw, int maxh) { + /** sets the maximum size of the frame */ + public void setMaximumSize(int maxw, int maxh) { - } + } - /** - * note that the minimum size is handled by getMinimumSize in - * InnerFrame/InnerWindow - */ - public void setMinimumSize(int minx, int miny, boolean resizable) { - if (frame != null) - frame.setResizable(resizable); - // FEATURE: Java 1.5 - // window.setMinimumSize(new - // Dimension(root.minwidth+leftInset+rightInset, - // root.minheight+topInset+bottomInset)); - } + /** + * note that the minimum size is handled by getMinimumSize in + * InnerFrame/InnerWindow + */ + public void setMinimumSize(int minx, int miny, boolean resizable) { + if (frame != null) + frame.setResizable(resizable); + // FEATURE: Java 1.5 + // window.setMinimumSize(new + // Dimension(root.minwidth+leftInset+rightInset, + // root.minheight+topInset+bottomInset)); + } - private int rootfill = 0x0; - private Color rootcolor = null; + private int rootfill = 0x0; + private Color rootcolor = null; - private final void setBackgroundColor() { - rootfill = root.fillcolor; - rootcolor = (rootfill & 0xFF000000) == 0 ? Color.white : new Color( - (rootfill >> 16) & 0xff, (rootfill >> 8) & 0xff, - (rootfill) & 0xff); - window.setBackground(rootcolor); - } + private final void setBackgroundColor() { + rootfill = root.fillcolor; + rootcolor = (rootfill & 0xFF000000) == 0 ? Color.white : new Color( + (rootfill >> 16) & 0xff, (rootfill >> 8) & 0xff, + (rootfill) & 0xff); + window.setBackground(rootcolor); + } - public void render() { - // useful optimisation; - if (rootfill != root.fillcolor) - setBackgroundColor(); - super.render(); - } + public void render() { + // useful optimisation; + if (rootfill != root.fillcolor) + setBackgroundColor(); + super.render(); + } - AWTSurface(Box root, boolean framed) { - super(root); + AWTSurface(Box root, boolean framed) { + super(root); - try { - if (framed) - window = frame = new InnerFrame(); - else - window = new InnerWindow(); - // this is here to catch HeadlessException on jdk1.4 - } catch (java.lang.UnsupportedOperationException e) { - Log - .error(this, - "Exception thrown in AWTSurface$InnerFrame() -- this should never happen"); - Log.error(this, e); - } + try { + if (framed) + window = frame = new InnerFrame(); + else + window = new InnerWindow(); + // this is here to catch HeadlessException on jdk1.4 + } catch (java.lang.UnsupportedOperationException e) { + Log + .error(this, + "Exception thrown in AWTSurface$InnerFrame() -- this should never happen"); + Log.error(this, e); + } - // set the default icon image to the vexi logo - if (frame != null) - frame.setIconImage(new ImageIcon(Main.class - .getResource("builtin/vexi-icon.png")).getImage()); + // set the default icon image to the vexi logo + if (frame != null) + frame.setIconImage(new ImageIcon(Main.class + .getResource("builtin/vexi-icon.png")).getImage()); - // Theoretically pack causes the insets to be calculated. - // - // AWT Bug - (Linux X11 at least) - // The insets calculated are not always exact. It seems - // that only a guess is returned. - window.pack(); - setLocation(); - setSize(pendingWidth, pendingHeight); // setSize handles the - // insets + // Theoretically pack causes the insets to be calculated. + // + // AWT Bug - (Linux X11 at least) + // The insets calculated are not always exact. It seems + // that only a guess is returned. + window.pack(); + setLocation(); + setSize(pendingWidth, pendingHeight); // setSize handles the + // insets - // initialise the backbuffer and window with the root colour - // REMARK - this is for nicer initial rendering - setBackgroundColor(); - AWTPixelBuffer buf = (AWTPixelBuffer) backbuffer; - buf.g.setColor(rootcolor); - buf.g.fillRect(0, 0, pendingWidth, pendingHeight); + // initialise the backbuffer and window with the root colour + // REMARK - this is for nicer initial rendering + setBackgroundColor(); + AWTPixelBuffer buf = (AWTPixelBuffer) backbuffer; + buf.g.setColor(rootcolor); + buf.g.fillRect(0, 0, pendingWidth, pendingHeight); - window.addMouseListener(this); - window.addKeyListener(this); - window.addComponentListener(this); - window.addMouseMotionListener(this); - window.addMouseWheelListener(this); - window.addWindowListener(this); - //workaround for an OS X limitation - try { - window.getInputContext().setCompositionEnabled(false); - } catch (UnsupportedOperationException e) { - Log.warn(this, "setCompositionEnabled() failed. Are you running OS X?"); - } - // window.add + window.addMouseListener(this); + window.addKeyListener(this); + window.addComponentListener(this); + window.addMouseMotionListener(this); + window.addMouseWheelListener(this); + window.addWindowListener(this); + //workaround for an OS X limitation + try { + window.getInputContext().setCompositionEnabled(false); + } catch (UnsupportedOperationException e) { + Log.warn(this, "setCompositionEnabled() failed. Are you running OS X?"); + } + // window.add - // IMPORTANT: this must be called before render() to ensure - // that our peer has been created - makeVisible(); - } + // IMPORTANT: this must be called before render() to ensure + // that our peer has been created + makeVisible(); + } - protected void makeVisible() { - window.setVisible(true); - } + protected void makeVisible() { + window.setVisible(true); + } - public void _dispose() { - window.removeMouseListener(this); - window.removeMouseWheelListener(this); + public void _dispose() { + window.removeMouseListener(this); + window.removeMouseWheelListener(this); - // removed to work around a jdk1.3 bug - /* window.removeKeyListener(this); */ + // removed to work around a jdk1.3 bug + /* window.removeKeyListener(this); */ - window.removeComponentListener(this); - window.removeMouseMotionListener(this); - window.removeWindowListener(this); - window.dispose(); - } + window.removeComponentListener(this); + window.removeMouseMotionListener(this); + window.removeWindowListener(this); + window.dispose(); + } - public void syncCursor() { - if (cursor.equals("crosshair")) - window.setCursor(Cursor - .getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); - else if (cursor.equals("east")) - window.setCursor(Cursor - .getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); - else if (cursor.equals("move")) - window - .setCursor(Cursor - .getPredefinedCursor(Cursor.MOVE_CURSOR)); - else if (cursor.equals("north")) - window.setCursor(Cursor - .getPredefinedCursor(Cursor.N_RESIZE_CURSOR)); - else if (cursor.equals("northeast")) - window.setCursor(Cursor - .getPredefinedCursor(Cursor.NE_RESIZE_CURSOR)); - else if (cursor.equals("northwest")) - window.setCursor(Cursor - .getPredefinedCursor(Cursor.NW_RESIZE_CURSOR)); - else if (cursor.equals("south")) - window.setCursor(Cursor - .getPredefinedCursor(Cursor.S_RESIZE_CURSOR)); - else if (cursor.equals("southeast")) - window.setCursor(Cursor - .getPredefinedCursor(Cursor.SE_RESIZE_CURSOR)); - else if (cursor.equals("southwest")) - window.setCursor(Cursor - .getPredefinedCursor(Cursor.SW_RESIZE_CURSOR)); - else if (cursor.equals("text")) - window - .setCursor(Cursor - .getPredefinedCursor(Cursor.TEXT_CURSOR)); - else if (cursor.equals("west")) - window.setCursor(Cursor - .getPredefinedCursor(Cursor.W_RESIZE_CURSOR)); - else if (cursor.equals("wait")) - window - .setCursor(Cursor - .getPredefinedCursor(Cursor.WAIT_CURSOR)); - else if (cursor.equals("hand")) - window - .setCursor(Cursor - .getPredefinedCursor(Cursor.HAND_CURSOR)); - else - window.setCursor(Cursor - .getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } + public void syncCursor() { + if (cursor.equals("crosshair")) + window.setCursor(Cursor + .getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); + else if (cursor.equals("east")) + window.setCursor(Cursor + .getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); + else if (cursor.equals("move")) + window + .setCursor(Cursor + .getPredefinedCursor(Cursor.MOVE_CURSOR)); + else if (cursor.equals("north")) + window.setCursor(Cursor + .getPredefinedCursor(Cursor.N_RESIZE_CURSOR)); + else if (cursor.equals("northeast")) + window.setCursor(Cursor + .getPredefinedCursor(Cursor.NE_RESIZE_CURSOR)); + else if (cursor.equals("northwest")) + window.setCursor(Cursor + .getPredefinedCursor(Cursor.NW_RESIZE_CURSOR)); + else if (cursor.equals("south")) + window.setCursor(Cursor + .getPredefinedCursor(Cursor.S_RESIZE_CURSOR)); + else if (cursor.equals("southeast")) + window.setCursor(Cursor + .getPredefinedCursor(Cursor.SE_RESIZE_CURSOR)); + else if (cursor.equals("southwest")) + window.setCursor(Cursor + .getPredefinedCursor(Cursor.SW_RESIZE_CURSOR)); + else if (cursor.equals("text")) + window + .setCursor(Cursor + .getPredefinedCursor(Cursor.TEXT_CURSOR)); + else if (cursor.equals("west")) + window.setCursor(Cursor + .getPredefinedCursor(Cursor.W_RESIZE_CURSOR)); + else if (cursor.equals("wait")) + window + .setCursor(Cursor + .getPredefinedCursor(Cursor.WAIT_CURSOR)); + else if (cursor.equals("hand")) + window + .setCursor(Cursor + .getPredefinedCursor(Cursor.HAND_CURSOR)); + else + window.setCursor(Cursor + .getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } - // AWT Message translation - // //////////////////////////////////////////////////////////////// + // AWT Message translation + // //////////////////////////////////////////////////////////////// - // these functions are all executed in the AWT thread, not the - // MessageQueue thread. As a result, they must be *extremely* - // careful about invoking methods on instances of Box. Currently, - // they should only enqueue messages, use Box.whoIs() - // (unsynchronised but thought to be safe), and modify members of - // Surface. + // these functions are all executed in the AWT thread, not the + // MessageQueue thread. As a result, they must be *extremely* + // careful about invoking methods on instances of Box. Currently, + // they should only enqueue messages, use Box.whoIs() + // (unsynchronised but thought to be safe), and modify members of + // Surface. - public void componentHidden(ComponentEvent e) { - } + public void componentHidden(ComponentEvent e) { + } - public void componentShown(ComponentEvent e) { - } + public void componentShown(ComponentEvent e) { + } - public void windowOpened(WindowEvent e) { - } + public void windowOpened(WindowEvent e) { + } - public void windowClosed(WindowEvent e) { - } + public void windowClosed(WindowEvent e) { + } - public void windowClosing(WindowEvent e) { - Close(); - } + public void windowClosing(WindowEvent e) { + Close(); + } - public void windowIconified(WindowEvent e) { - Minimized(true); - } + public void windowIconified(WindowEvent e) { + Minimized(true); + } - public void windowDeiconified(WindowEvent e) { - dirty(0, 0, root.width, root.height); - Minimized(false); - } + public void windowDeiconified(WindowEvent e) { + dirty(0, 0, root.width, root.height); + Minimized(false); + } - public void windowActivated(WindowEvent e) { - Focused(true); - } + public void windowActivated(WindowEvent e) { + Focused(true); + } - public void windowDeactivated(WindowEvent e) { - Focused(false); - } + public void windowDeactivated(WindowEvent e) { + Focused(false); + } - public void componentMoved(ComponentEvent e) { - PosChange(window.getLocation().x, window.getLocation().y); - } + public void componentMoved(ComponentEvent e) { + PosChange(window.getLocation().x, window.getLocation().y); + } - public void componentResized(ComponentEvent e) { - // Insets first known exactly on first componentResized event - // Before being set visible (AWT on top of XWindows at least) - // after pack it seems AWT guesses what the insets will be - // Take every time in case they change(?!) - discoverInsets(); - // System.err.println("componentResized: "+window.getWidth()+", - // "+window.getHeight() - // +" ("+leftInset+", "+rightInset+", "+topInset+", - // "+bottomInset+")"); - componentResized(window.getWidth() - leftInset - rightInset, window - .getHeight() - - topInset - bottomInset); - } + public void componentResized(ComponentEvent e) { + // Insets first known exactly on first componentResized event + // Before being set visible (AWT on top of XWindows at least) + // after pack it seems AWT guesses what the insets will be + // Take every time in case they change(?!) + discoverInsets(); + // System.err.println("componentResized: "+window.getWidth()+", + // "+window.getHeight() + // +" ("+leftInset+", "+rightInset+", "+topInset+", + // "+bottomInset+")"); + componentResized(window.getWidth() - leftInset - rightInset, window + .getHeight() + - topInset - bottomInset); + } - public void componentResized(int newwidth, int newheight) { - // First we fill the expanded part of the buffer before - // an old (dirty) copy of that buffer part gets painted - // REMARK - synchronized so we won't fill during render - synchronized (this) { - AWTPixelBuffer buf = (AWTPixelBuffer) backbuffer; - buf.g.setColor(new java.awt.Color( - (root.fillcolor >> 16) & 0xff, - (root.fillcolor >> 8) & 0xff, (root.fillcolor) & 0xff)); - if (pendingWidth < newwidth) { - buf.g.fillRect(pendingWidth, 0, newwidth, newheight); - dirty(pendingWidth, 0, newwidth - pendingWidth, newheight); - } - if (pendingHeight < newheight) { - buf.g.fillRect(0, pendingHeight, newwidth, newheight); - dirty(0, pendingHeight, newwidth, newheight - pendingHeight); - } - SizeChange(newwidth, newheight); - } - } + public void componentResized(int newwidth, int newheight) { + // First we fill the expanded part of the buffer before + // an old (dirty) copy of that buffer part gets painted + // REMARK - synchronized so we won't fill during render + synchronized (this) { + AWTPixelBuffer buf = (AWTPixelBuffer) backbuffer; + buf.g.setColor(new java.awt.Color( + (root.fillcolor >> 16) & 0xff, + (root.fillcolor >> 8) & 0xff, (root.fillcolor) & 0xff)); + if (pendingWidth < newwidth) { + buf.g.fillRect(pendingWidth, 0, newwidth, newheight); + dirty(pendingWidth, 0, newwidth - pendingWidth, newheight); + } + if (pendingHeight < newheight) { + buf.g.fillRect(0, pendingHeight, newwidth, newheight); + dirty(0, pendingHeight, newwidth, newheight - pendingHeight); + } + SizeChange(newwidth, newheight); + } + } - public void keyTyped(KeyEvent k) { - // REMARK - we are a so called 'passive Input Method' client. - // We receive composed text (e.g. asian characters) as key events - // where we want to convert them into a keypressed/keyreleased - // Vexi event. Unfortunately we need a way to distinguish between - // events due to inputMethods (which we want) and those from the - // keyboard which are already handled via keyPressed/keyReleased. - // HACK Simplest is to just except non-ascii chars. - int unicode = (int) k.getKeyChar(); - if (255 >= unicode) - return; - KeyPressed("" + k.getKeyChar()); - KeyReleased("" + k.getKeyChar()); - } + public void keyTyped(KeyEvent k) { + // REMARK - we are a so called 'passive Input Method' client. + // We receive composed text (e.g. asian characters) as key events + // where we want to convert them into a keypressed/keyreleased + // Vexi event. Unfortunately we need a way to distinguish between + // events due to inputMethods (which we want) and those from the + // keyboard which are already handled via keyPressed/keyReleased. + // HACK Simplest is to just except non-ascii chars. + int unicode = (int) k.getKeyChar(); + if (255 >= unicode) + return; + KeyPressed("" + k.getKeyChar()); + KeyReleased("" + k.getKeyChar()); + } - public void keyPressed(KeyEvent k) { - KeyPressed(translateKey(k)); - } + public void keyPressed(KeyEvent k) { + KeyPressed(translateKey(k)); + } - public void keyReleased(KeyEvent k) { - KeyReleased(translateKey(k)); - } + public void keyReleased(KeyEvent k) { + KeyReleased(translateKey(k)); + } - public void mouseExited(MouseEvent m) { - mouseMoved(m); - } + public void mouseExited(MouseEvent m) { + mouseMoved(m); + } - public void mouseEntered(MouseEvent m) { - mouseMoved(m); - } + public void mouseEntered(MouseEvent m) { + mouseMoved(m); + } - public void mouseDragged(MouseEvent m) { - mouseMoved(m); - } + public void mouseDragged(MouseEvent m) { + mouseMoved(m); + } - public void mouseMoved(MouseEvent m) { + public void mouseMoved(MouseEvent m) { - // ugly hack for Java1.4 dynamicLayout on Win32 -- this catches - // contractions during smooth resize - int newwidth = window.getWidth() - leftInset - rightInset; - int newheight = window.getHeight() - topInset - bottomInset; - if (newwidth != root.width || newheight != root.height) - componentResized(newwidth, newheight); + // ugly hack for Java1.4 dynamicLayout o... [truncated message content] |
From: <cl...@us...> - 2008-01-15 12:55:36
|
Revision: 2729 http://vexi.svn.sourceforge.net/vexi/?rev=2729&view=rev Author: clrg Date: 2008-01-15 04:55:14 -0800 (Tue, 15 Jan 2008) Log Message: ----------- Correct/update license headers - Apache Public Source License -> Apache Software License - Update copyright statements to 2008 - Add proper GPL notices (note: some files probably still missing this) Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp trunk/core/org.vexi.core/src/org/vexi/core/LocalStorage.java trunk/core/org.vexi.core/src/org/vexi/core/Main.java trunk/core/org.vexi.core/src/org/vexi/core/Surface.java trunk/core/org.vexi.core/src/org/vexi/core/Template.java trunk/core/org.vexi.core/src/org/vexi/core/Text.java trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp trunk/core/org.vexi.core/src/org/vexi/graphics/Color.java trunk/core/org.vexi.core/src/org/vexi/graphics/Font.java trunk/core/org.vexi.core/src/org/vexi/graphics/HTML.java trunk/core/org.vexi.core/src/org/vexi/graphics/Paint.java trunk/core/org.vexi.core/src/org/vexi/graphics/Picture.java trunk/core/org.vexi.core/src/org/vexi/graphics/PixelBuffer.java trunk/core/org.vexi.core/src/org/vexi/net/HTTP.java trunk/core/org.vexi.core/src/org/vexi/plat/AWT.java trunk/core/org.vexi.core/src/org/vexi/plat/Darwin.java trunk/core/org.vexi.core/src/org/vexi/plat/GCJ.java trunk/core/org.vexi.core/src/org/vexi/plat/JVM.java trunk/core/org.vexi.core/src/org/vexi/plat/Java2.java trunk/core/org.vexi.core/src/org/vexi/plat/Linux.java trunk/core/org.vexi.core/src/org/vexi/plat/OpenGL.java trunk/core/org.vexi.core/src/org/vexi/plat/POSIX.java trunk/core/org.vexi.core/src/org/vexi/plat/PalmOS.java trunk/core/org.vexi.core/src/org/vexi/plat/Platform.java trunk/core/org.vexi.core/src/org/vexi/plat/Solaris.java trunk/core/org.vexi.core/src/org/vexi/plat/Win32.java trunk/core/org.vexi.core/src/org/vexi/plat/X11.java trunk/core/org.vexi.core/src/org/vexi/util/BasicTree.java trunk/core/org.vexi.core/src/org/vexi/util/DirtyList.java trunk/core/org.vexi.core/src_dev/org/vexi/plat/Java2VolatileImage.java trunk/core/org.vexi.core/src_unused/org/vexi/net/XMLRPC.java trunk/core/org.vexi.core/src_unused/org/vexi/net/XmlRpcMarshaller.java Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/core/LocalStorage.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/LocalStorage.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/core/LocalStorage.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/core/Main.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Main.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/core/Main.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/core/Surface.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Surface.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/core/Surface.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/core/Template.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Template.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/core/Template.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/core/Text.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Text.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/core/Text.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/core/Vexi.jpp 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/graphics/Color.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/graphics/Color.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/graphics/Color.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/graphics/Font.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/graphics/Font.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/graphics/Font.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/graphics/HTML.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/graphics/HTML.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/graphics/HTML.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/graphics/Paint.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/graphics/Paint.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/graphics/Paint.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/graphics/Picture.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/graphics/Picture.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/graphics/Picture.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/graphics/PixelBuffer.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/graphics/PixelBuffer.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/graphics/PixelBuffer.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/net/HTTP.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/net/HTTP.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/net/HTTP.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,7 @@ -// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL] +// Copyright 2000-2008 the Contributors, as shown in the revision logs. +// Licensed under the GNU General Public License version 2 ("the License"). +// You may not use this file except in compliance with the License. + package org.vexi.net; import java.io.BufferedInputStream; Modified: trunk/core/org.vexi.core/src/org/vexi/plat/AWT.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/plat/AWT.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/plat/AWT.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/plat/Darwin.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/plat/Darwin.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/plat/Darwin.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. package org.vexi.plat; Modified: trunk/core/org.vexi.core/src/org/vexi/plat/GCJ.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/plat/GCJ.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/plat/GCJ.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/plat/JVM.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/plat/JVM.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/plat/JVM.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/plat/Java2.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/plat/Java2.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/plat/Java2.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/plat/Linux.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/plat/Linux.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/plat/Linux.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/plat/OpenGL.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/plat/OpenGL.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/plat/OpenGL.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/plat/POSIX.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/plat/POSIX.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/plat/POSIX.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/plat/PalmOS.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/plat/PalmOS.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/plat/PalmOS.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/plat/Platform.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/plat/Platform.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/plat/Platform.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/plat/Solaris.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/plat/Solaris.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/plat/Solaris.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/plat/Win32.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/plat/Win32.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/plat/Win32.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/plat/X11.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/plat/X11.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/plat/X11.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,4 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Copyright 2000-2008 the Contributors, as shown in the revision logs. // Licensed under the GNU General Public License version 2 ("the License"). // You may not use this file except in compliance with the License. Modified: trunk/core/org.vexi.core/src/org/vexi/util/BasicTree.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/util/BasicTree.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/util/BasicTree.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,11 +1,11 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. -// Licensed under the Apache Public Source License 2.0 ("the License"). +// Copyright 2000-2008 the Contributors, as shown in the revision logs. +// Licensed under the Apache Software License 2.0 ("the License"). // You may not use this file except in compliance with the License. package org.vexi.util; -/*** +/** * Derived from the Ibex class Hash.Array, this is a very simple * implementation of the key 'tree' functions to replace the way * too complex (and as such notoriously problematic and notably Modified: trunk/core/org.vexi.core/src/org/vexi/util/DirtyList.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/util/DirtyList.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src/org/vexi/util/DirtyList.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,5 +1,5 @@ -// Copyright 2000-2005 the Contributors, as shown in the revision logs. -// Licensed under the Apache Public Source License 2.0 ("the License"). +// Copyright 2000-2008 the Contributors, as shown in the revision logs. +// Licensed under the Apache Software License 2.0 ("the License"). // You may not use this file except in compliance with the License. package org.vexi.util; @@ -12,6 +12,8 @@ * enclosing both A and B occupies no more than epsilon + Area_A + * Area_B. Failing this, if two corners of A fall within B, A will be * shrunk to exclude the union of A and B. + * + * @author Charles Goodwin */ public class DirtyList { Modified: trunk/core/org.vexi.core/src_dev/org/vexi/plat/Java2VolatileImage.java =================================================================== --- trunk/core/org.vexi.core/src_dev/org/vexi/plat/Java2VolatileImage.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src_dev/org/vexi/plat/Java2VolatileImage.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,7 @@ -// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL] +// Copyright 2000-2008 the Contributors, as shown in the revision logs. +// Licensed under the GNU General Public License version 2 ("the License"). +// You may not use this file except in compliance with the License. + package org.vexi.plat; import java.awt.AlphaComposite; Modified: trunk/core/org.vexi.core/src_unused/org/vexi/net/XMLRPC.java =================================================================== --- trunk/core/org.vexi.core/src_unused/org/vexi/net/XMLRPC.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src_unused/org/vexi/net/XMLRPC.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,7 @@ -// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL] +// Copyright 2000-2008 the Contributors, as shown in the revision logs. +// Licensed under the GNU General Public License version 2 ("the License"). +// You may not use this file except in compliance with the License. + package org.vexi.net; import java.io.BufferedReader; Modified: trunk/core/org.vexi.core/src_unused/org/vexi/net/XmlRpcMarshaller.java =================================================================== --- trunk/core/org.vexi.core/src_unused/org/vexi/net/XmlRpcMarshaller.java 2008-01-15 12:54:08 UTC (rev 2728) +++ trunk/core/org.vexi.core/src_unused/org/vexi/net/XmlRpcMarshaller.java 2008-01-15 12:55:14 UTC (rev 2729) @@ -1,4 +1,7 @@ -//Copyright 2004 Tupshin Harper, see the COPYING file for licensing [GPL] +// Copyright 2000-2008 the Contributors, as shown in the revision logs. +// Licensed under the GNU General Public License version 2 ("the License"). +// You may not use this file except in compliance with the License. + package org.vexi.net; import java.io.IOException; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |