2003/11/18 10:47:26
[org.ibex.core.git] / src / org / xwt / Template.java
index d633f48..56ca4d9 100644 (file)
@@ -98,7 +98,7 @@ public class Template {
         if (staticscript == null) return staticJSScope;
         JSFunction temp = staticscript;
         staticscript = null;
-        temp.cloneWithNewParentJSScope(staticJSScope).call(null, null, null, null, 0);
+        temp.cloneWithNewParentScope(staticJSScope).call(null, null, null, null, 0);
         return staticJSScope;
     }
     
@@ -122,15 +122,15 @@ public class Template {
         for (int i=0; children != null && i<children.size(); i++) {
             Box kid = new Box();
             ((Template)children.elementAt(i)).apply(kid, xwt, pis);
-            b.putAndTriggerJSTraps(JS.N(b.numchildren), kid);
+            b.putAndTriggerTraps(JS.N(b.numchildren), kid);
         }
 
-        if (script != null) script.cloneWithNewParentJSScope(pis).call(null, null, null, null, 0);
+        if (script != null) script.cloneWithNewParentScope(pis).call(null, null, null, null, 0);
 
         for(int i=0; keys != null && i<keys.length; i++)
-            if (vals[i] instanceof String && ((String)vals[i]).charAt(0) == '$') b.putAndTriggerJSTraps(keys[i], pis.get(vals[i]));
-            else if ("image".equals(keys[i])) b.putAndTriggerJSTraps("image", resolveStringToResource((String)vals[i], xwt, true));
-            else if (keys[i] != null) b.putAndTriggerJSTraps(keys[i], vals[i]);
+            if (vals[i] instanceof String && ((String)vals[i]).charAt(0) == '$') b.putAndTriggerTraps(keys[i], pis.get(vals[i]));
+            else if ("image".equals(keys[i])) b.putAndTriggerTraps("image", resolveStringToResource((String)vals[i], xwt, true));
+            else if (keys[i] != null) b.putAndTriggerTraps(keys[i], vals[i]);
     }
 
 
@@ -211,17 +211,9 @@ public class Template {
             Hash h = new Hash(c.len * 2, 3);
             for(int i=0; i<c.len; i++) {
                 if (c.keys[i] == null) continue;
-                if (c.keys[i].endsWith(":image")) {
-                    String uri = (String)c.urimap.get(c.keys[i].substring(0, c.keys[i].indexOf(':')));
-                    c.keys[i] = c.keys[i].substring(c.keys[i].lastIndexOf(':') + 1);
-                    c.vals[i] = uri + "." + c.vals[i];
-                }                    
-                if ((c.keys[i].equals("preapply") || c.keys[i].endsWith(":preapply")) && c.localName.equals("template")) {
-                    String uri = "";
-                    if (c.keys[i].endsWith(":preapply")) {
-                        uri = "." + c.urimap.get(c.keys[i].substring(0, c.keys[i].indexOf(':')));
-                        c.keys[i] = c.keys[i].substring(c.keys[i].lastIndexOf(':') + 1);
-                    }
+                if (c.keys[i].equals("fill") || c.keys[i].equals("font")) c.vals[i] = c.uris[i] + "." + c.vals[i];
+                if (c.keys[i].equals("preapply")) {
+                    String uri = c.uris[i];
                     StringTokenizer tok = new StringTokenizer(c.vals[i].toString(), " ");
                     while(tok.hasMoreTokens()) t.preapply.addElement(uri + tok.nextToken());
                     c.keys[i] = c.keys[c.keys.length - 1];
@@ -283,7 +275,9 @@ public class Template {
             try {
                 String contentString = t.content.toString();
                 if (contentString.trim().length() > 0)
-                    thisscript = JS.parse(t.fileName + (isstatic ? "._" : ""), t.content_start, new StringReader(contentString));
+                    thisscript = JSFunction.fromReader(t.fileName + (isstatic ? "._" : ""),
+                                                       t.content_start,
+                                                       new StringReader(contentString));
             } catch (IOException ioe) {
                 if (Log.on) Log.log(this, "  ERROR: " + ioe.getMessage());
                 thisscript = null;
@@ -347,8 +341,8 @@ public class Template {
             declare("$" + key);
             put("$" + key, target);
         }
-        public PerInstantiationJSScope(JSScope parentJSScope, XWT xwt, PerInstantiationJSScope parentBoxPis, JSScope myStatic) {
-            super(parentJSScope);
+        public PerInstantiationJSScope(JSScope parentScope, XWT xwt, PerInstantiationJSScope parentBoxPis, JSScope myStatic) {
+            super(parentScope);
             this.parentBoxPis = parentBoxPis;
             this.xwt = xwt;
             this.myStatic = myStatic;