Changeset 784


Ignore:
Timestamp:
01/29/14 15:53:51 (10 years ago)
Author:
jts21
Message:

Add JSItem class, which like JSWidget is an item controlled by javascript, but with an Expeditee item rather than Swing.
TODO: Add the ability to set input and click handlers for the item.

Location:
trunk/src/org/expeditee
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/FrameUtils.java

    r781 r784  
    3434import org.expeditee.items.Item.HighlightMode;
    3535import org.expeditee.items.ItemUtils;
     36import org.expeditee.items.JSItem;
    3637import org.expeditee.items.Line;
    3738import org.expeditee.items.PermissionPair;
     
    10121013                                        toParse.addItem(new Circle((Text) i));
    10131014                                    }
     1015                                    // Check for JSItem
     1016                                } else if(ItemUtils.startsWithTag(i, "@js")) {
     1017                                        toParse.addItem(new JSItem((Text) i));
    10141018                                    // Check for interactive widgets
    10151019                                } else if (ItemUtils.startsWithTag(i,
  • trunk/src/org/expeditee/items/widgets/InteractiveWidget.java

    r774 r784  
    292292         * @return An array of args. null if none provided
    293293         */
    294         static String[] parseArgs(String args) {
     294        public static String[] parseArgs(String args) {
    295295
    296296                if (args == null)
  • trunk/src/org/expeditee/items/widgets/JSWidget.java

    r765 r784  
    55import java.util.List;
    66
    7 import javax.script.Bindings;
    87import javax.script.Invocable;
    9 import javax.script.ScriptContext;
    108import javax.script.ScriptEngine;
    119import javax.swing.JComponent;
     
    6361        this.container.add(component);
    6462        this.scriptEngine.put("component", this.component);
     63        this.scriptEngine.eval("save = " + this.save);
     64        this.scriptEngine.eval("load = " + this.load);
    6565        }
    6666       
     
    6969                                source.getData().get(1).replaceAll("\\\\n", "\n"),
    7070                                source.getData().get(2).replaceAll("\\\\n", "\n"));
    71                 this.scriptEngine.eval("load = " + this.load);
    7271                this.invocable.invokeFunction("load", (Object) args);
    7372        }
     
    9089                try {
    9190                        List<String> args = new LinkedList<String>();
    92                         this.scriptEngine.eval("save = " + this.save);
    9391                        this.invocable.invokeFunction("save", (Object)args);
    9492                        return args.toArray(new String[0]);
    95                 } catch(NullPointerException e) {
    96                         // caused when a null list is returned
    97                         return null;
    9893        } catch (Exception e) {
    9994                e.printStackTrace();
Note: See TracChangeset for help on using the changeset viewer.