2003/10/03 03:59:31
[org.ibex.core.git] / src / org / xwt / Trap.java
index c6c6a47..df51b53 100644 (file)
@@ -19,16 +19,14 @@ public class Trap {
     private static final Hash PROHIBITED = new Hash(120, 3);
 
     static {
-        // FIXME: review
         String[] p = new String[] {
-            "sizetoimage", "shrink", "hshrink", "vshrink", "x", "y",
-            "width", "height", "flex", "hflex", "vflex", "cols",
+            "shrink", "hshrink", "vshrink", "x", "y",
+            "width", "height", "flex", "colspan", "rowspan", "cols",
             "rows", "align", "invisible", "absolute", "globalx",
             "globaly", "minwidth", "minheight", "height", "width",
             "maxwidth", "maxheight", "numchildren", "hpad", "vpad",
-            "doublebuffered", "cursor", "mousex", "mousey", "xwt",
-            "static", "mouseinside", "root", "thisbox", "indexof",
-            "path"
+            "buffered", "cursor", "mousex", "mousey",
+            "mouseinside", "thisbox", "indexof", "path", "font", "fontsize"
         };
         for(int i=0; i<p.length; i++) PROHIBITED.put(p[i], Boolean.TRUE);
     };
@@ -99,13 +97,24 @@ public class Trap {
     private Trap() { }
 
     public Object perform() throws JS.Exn {
-        if (f.getNumFormalArgs() > 0) return cascade();
-        return f.call(new TrapArgs(this));
+        try {
+            if (f.getNumFormalArgs() > 0) return cascade();
+            return f.call(new TrapArgs(this));
+        } catch (Exception e) {
+            Log.log(this, "Exception thrown from within trap: " + e);
+            return null;
+        }
     }
     
     public void perform(Object val) throws JS.Exn {
-        if (f.getNumFormalArgs()== 0) cascade(val);
-        f.call(new TrapArgs(this, val));
+        try {
+            if (f.getNumFormalArgs() == 0) cascade(val);
+            TrapArgs ta = new TrapArgs(this, val);
+            Object ret = f.call(ta);
+            if (ret != Boolean.FALSE && !ta.cascadeHappened) cascade(val);
+        } catch (Exception e) {
+            Log.log(this, "Exception thrown from within trap: " + e);
+        }
     }
     
     public Object cascade() {
@@ -120,11 +129,12 @@ public class Trap {
 
     private static class TrapArgs extends JS.Array {
         private Trap t;
+        public boolean cascadeHappened = false;
         public TrapArgs(Trap t) { this.t = t; }
         public TrapArgs(Trap t, Object value) { this.t = t; addElement(value); }
         
         public void put(Object key, Object val) {
-            if (key.equals("cascade")) t.cascade(val);
+            if (key.equals("cascade")) { cascadeHappened = true; t.cascade(val); }
             else super.put(key, val);
         }
 
@@ -134,6 +144,7 @@ public class Trap {
             if (key.equals("trapee")) return t.trapee;
             if (key.equals("trapname")) return t.name;
             if (key.equals("cascade")) return t.cascade();
+            if (key.equals("callee")) return t.f;
             return super.get(key);
         }
     }