Re: (try again) PATCH: Bug 98: loadTemplate(ByteStream, String
Adam Megacz <[email protected]> 08 Apr 2003 02:51:08 -0700
| Newsgroups | gmane.comp.java.xwt.general |
|---|---|
| Organization | XWT |
| Message-ID | <[email protected]> |
It's still linewrapping. Please use 'make propose-patch' - a Matt Mullens <[email protected]> writes: > (My apologies, I believe it was messed up by the > wraps, lets try this one instead) > > Index: Resources.java > =================================================================== > RCS file: /cvs/xwt/src/org/xwt/Resources.java,v > retrieving revision 1.10 > diff -u -r1.10 Resources.java > --- Resources.java12 Feb 2003 06:40:22 -00001.10 > +++ Resources.java6 Apr 2003 02:27:14 -0000 > @@ -131,6 +131,29 @@ > if (Log.verbose) Log.log(Resources.class, > "done loading archive"); > } > + > + /** Load a bytestream */ > + public static synchronized void > loadTemplate(InputStream is, String name) throws > IOException { > + > + String templateName = new String(name); > + > + if (templateName.endsWith(".xwt")){ > + templateName = templateName.substring(0, > templateName.length() - 4); > + } > + String packageName = > JSObject.nodeNameToPackageName(templateName); > + String shortName = > templateName.substring(templateName.lastIndexOf(".")+1); > + if (!validResourceName(shortName)) return; > + > + Object user = usedPackages.get(packageName); > + if (user != null){ > + if (Log.on) Log.log(Resources.class, > "templates have already been loaded into " + > packageName + "; refusing to load " + templateName); > + }else{ > + Static.createStatic(templateName, false); > + usedPackages.put(packageName, new > Object()); > + bytes.put(templateName + ".xwt", > isToByteArray(is)); > + } > + } > + > /** holds the current theme mappings */ > static Vector mapFrom = new Vector(); > Index: XWT.java > =================================================================== > RCS file: /cvs/xwt/src/org/xwt/XWT.java,v > retrieving revision 1.18 > diff -u -r1.18 XWT.java > --- XWT.java3 Oct 2002 22:45:58 -00001.18 > +++ XWT.java6 Apr 2003 02:27:15 -0000 > @@ -64,6 +64,7 @@ > else if (name.equals("println")) return > println; > else if (name.equals("math")) return > org.xwt.util.JSObject.defaultObjects.get("Math", > null); > else if (name.equals("loadArchive")) return > loadArchive; > + else if (name.equals("loadTemplate")) return > loadTemplate; > else if (name.equals("prefetchImage")) return > prefetchImage; > else if (name.equals("prefs")) return prefs; > else if (name.equals("encodeURI")) return > JSObject.defaultObjects.get("encodeURI", null); > @@ -508,6 +509,30 @@ > return null; > } > }; > + > + private static final JSObject.JSFunction > loadTemplate = new JSObject.JSFunction() { > + public Object call(Context cx, Scriptable > thisObj, Scriptable ctorObj, Object[] args) throws > JavaScriptException { > + if (!ThreadMessage.suspendThread()) > return null; > + > + try { > + if (args == null || args.length < > 2 || args[0] == null || args[1] == null) return null; > + InputStream is = > ((ByteStream)(args[0])).getInputStream(); > + String name = (String)args[1]; > + Resources.loadTemplate(is, name); > + } catch (IOException ioe) { > + if (Log.on) Log.log(this, > "IOException while loading Template:"); > + if (Log.on) Log.log(this, ioe); > + throw new > JavaScriptException(ioe.toString()); > + > + } finally { > + ThreadMessage.resumeThread(); > + > + } > + return null; > + } > + }; > + > + > private static final JSObject.JSFunction > prefetchImage = new JSObject.JSFunction() { > public Object call(Context cx, Scriptable > thisObj, Scriptable ctorObj, Object[] args) throws > JavaScriptException { > > __________________________________________________ > Do you Yahoo!? > Yahoo! Tax Center - File online, calculators, forms, and more > http://tax.yahoo.com > > _______________________________________________ > http://lists.xwt.org/listinfo/dev > -- _______________________________________________ http://lists.xwt.org/listinfo/dev