- // Theming Logic ////////////////////////////////////////////////////////////
-
- /** helper method to recursively gather up the list of keys to be preserved */
- private void gatherPreserves(Vec v) {
- for(int i=0; preserve != null && i<preserve.length; i++) v.addElement(preserve[i]);
- for(int i=0; _preapply != null && i<_preapply.length; i++) if (_preapply[i] != null) _preapply[i].gatherPreserves(v);
- for(int i=0; _postapply != null && i<_postapply.length; i++) if (_postapply[i] != null) _postapply[i].gatherPreserves(v);
- }
-
- /** runs statics, resolves string references to other templates into actual Template instance references, and sets <tt>change</tt> as needed */
- void link() { link(false); }
-
- /** same as link(), except that with a true value, it will force a re-link */
- private void link(boolean force) {
-
- if (staticscript != null) try {
- JS.Scope s = Static.createStatic(nodeName, false);
- if (staticscript != null) {
- JS.CompiledFunction temp = staticscript;
- staticscript = null;
-
- // we layer a transparent scope over the Static so that we can catch requests for the xwt object
- // yet not screw up paths that include a package called xwt (ie xwt.static.org.xwt.foo)
- JS.Scope varScope = new JS.Scope(s) {
- public boolean isTransparent() { return true; }
- public Object get(Object key) {
- if ("xwt".equals(key)) return XWT.singleton; else return super.get(key);
- } };
-
- temp.call(new JS.Array(), varScope);
- }
- } catch (JS.Exn e) {
- if (Log.on) Log.log(this, "WARNING: uncaught ecmascript exception: " + e.getMessage());
- }
-
- if (!(force || (preapply != null && _preapply == null) || (postapply != null && _postapply == null))) return;
-
- if (preapply != null) {
- if (_preapply == null) _preapply = new Template[preapply.length];
- for(int i=0; i<_preapply.length; i++) {
- Template t = getTemplate(preapply[i], importlist);
- if (t != _preapply[i]) changed = true;
- _preapply[i] = t;
- }
- }
- if (postapply != null) {
- if (_postapply == null) _postapply = new Template[postapply.length];
- for(int i=0; i<_postapply.length; i++) {
- Template t = getTemplate(postapply[i], importlist);
- if (t != _postapply[i]) changed = true;
- _postapply[i] = t;
- }
- }
-
- for(int i=0; children != null && i<children.length; i++) children[i].link(force);
- }
-