Ignore:
Timestamp:
05/09/08 09:31:42 (16 years ago)
Author:
ra33
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/actions/Simple.java

    r21 r22  
    44import java.awt.Point;
    55import java.awt.event.InputEvent;
     6import java.io.BufferedReader;
     7import java.io.InputStreamReader;
    68import java.util.ArrayList;
    79import java.util.LinkedList;
    810import java.util.List;
    911
     12import org.expeditee.agents.WriteTree;
    1013import org.expeditee.gui.AttributeUtils;
    1114import org.expeditee.gui.DisplayIO;
     
    880883                                        String log = SessionStats.getFrameEventList();
    881884                                        Text t;
    882                                         try {
    883                                                 t = (Text) context.getPointers().getVariable(tokens[1])
    884                                                                 .getValue();
    885                                                 t.setText(log);
    886                                         } catch (Exception e) {
    887                                                 t = new Text(-1, log);
    888                                                 context.getPointers().setObject(tokens[1], t);
    889                                         }
     885                                        // try {
     886                                        t = (Text) context.getPointers().getVariable(tokens[1])
     887                                                        .getValue();
     888                                        t.setText(log);
     889                                        // } catch (Exception e) {
     890                                        // t = new Text(-1, log);
     891                                        // context.getPointers().setObject(tokens[1], t);
     892                                        // }
    890893
    891894                                        return Status.OK;
     
    10281031                                String stats = SessionStats.getCurrentStats();
    10291032                                Text t;
    1030                                 try {
    1031                                         t = (Text) context.getPointers().getVariable(tokens[1])
    1032                                                         .getValue();
    1033                                         t.setText(stats);
    1034                                 } catch (Exception e) {
    1035                                         t = new Text(-1, stats);
    1036                                         context.getPointers().setObject(tokens[1], t);
    1037                                 }
     1033                                // try {
     1034                                t = (Text) context.getPointers().getVariable(tokens[1])
     1035                                                .getValue();
     1036                                t.setText(stats);
     1037                                // } catch (Exception e) {
     1038                                // t = new Text(-1, stats);
     1039                                // context.getPointers().setObject(tokens[1], t);
     1040                                // }
    10381041
    10391042                                return Status.OK;
     
    11231126                        Text dynamicCode = new Text(1, codeText);
    11241127                        RunItem(dynamicCode, context, Status.OK);
     1128                        return Status.OK;
     1129                } else if (tokens[0].equals("runoscommand")) {
     1130                        String command = getMessage(tokens, context, code.toString(), " ",
     1131                                        1);
     1132                        Runtime.getRuntime().exec(command);
     1133                        return Status.OK;
     1134                } else if (tokens[0].equals("executeoscommand")) {
     1135                        String command = getMessage(tokens, context, code.toString(), " ",
     1136                                        1);
     1137                        Process p = Runtime.getRuntime().exec(command);
     1138                        FrameGraphics.DisplayMessage(command, Color.darkGray);
     1139                       
     1140                        BufferedReader stdInput = new BufferedReader(new InputStreamReader(
     1141                                        p.getInputStream()));
     1142                        BufferedReader stdError = new BufferedReader(new InputStreamReader(
     1143                                        p.getErrorStream()));
     1144                        String message = "";
     1145                        while ((message = stdInput.readLine()) != null) {
     1146                                FrameGraphics.DisplayMessage(message);
     1147                        }
     1148                        while ((message = stdError.readLine()) != null) {
     1149                                FrameGraphics.ErrorMessage(message);
     1150                        }
    11251151                        return Status.OK;
    11261152                } else if (tokens[0].startsWith("else")) {
     
    12791305                        Item item = (Item) context.getPointers().getVariable(itemVar)
    12801306                                        .getValue();
     1307                        item
     1308                                        .setPosition(FrameMouseActions.MouseX,
     1309                                                        FrameMouseActions.MouseY);
    12811310                        FrameMouseActions.pickup(item);
    12821311                        return Status.OK;
     
    12911320                        Frame frame = DisplayIO.getCurrentFrame();
    12921321                        Text item = frame.createNewText(s);
     1322                        item
     1323                                        .setPosition(FrameMouseActions.MouseX,
     1324                                                        FrameMouseActions.MouseY);
    12931325                        FrameMouseActions.pickup(item);
    12941326                        // DisplayIO.repaint();
     
    13331365                        frame.addItem(new Line(dot1, dot2, frame.getNextItemID()));
    13341366                        return Status.OK;
    1335                 } else if (tokens[0].equals("createitem")) {
     1367                } else if (tokens[0].equals("createitem")
     1368                                || tokens[0].equals("createtext")) {
    13361369                        assertMinParametreCount(tokens, 4);
    13371370                        assertVariableType(tokens[1], 1, SPointer.framePrefix);
     
    13521385                                }
    13531386                                newItem = frame.addText(x, y, newText, newAction);
    1354                         } else
    1355                                 // create a point if the optional params are not provided
    1356                                 newItem = frame.addDot(x, y);
     1387                        } else {
     1388                                if (tokens[0].equals("createtext")) {
     1389                                        newItem = frame.createNewText();
     1390                                        newItem.setPosition(x, y);
     1391                                } else {
     1392                                        // create a point if the optional params are not provided
     1393                                        newItem = frame.addDot(x, y);
     1394                                }
     1395                        }
    13571396                        context.getPointers().setObject(tokens[4], newItem);
    13581397
     
    16391678                        }
    16401679                        context.createFrameset(framesetName, successVar);
     1680                        return Status.OK;
     1681                } else if (tokens[0].equals("writetree")) {
     1682                        assertMinParametreCount(tokens, 3);
     1683                        assertVariableType(tokens[1], 1, SPointer.framePrefix);
     1684                        Frame source = (Frame) context.getPointers().getVariable(tokens[1])
     1685                                        .getValue();
     1686                        String format = context.getPrimitives().getStringValue(tokens[2]);
     1687                        String fileName = context.getPrimitives().getStringValue(tokens[3]);
     1688                        WriteTree wt = new WriteTree(format, fileName);
     1689                        if (wt.initialise(source)){
     1690                                wt.setStartFrame(source);
     1691                                wt.run();
     1692                        }
    16411693                        return Status.OK;
    16421694                } else if (tokens[0].equals("concatstr")) {
Note: See TracChangeset for help on using the changeset viewer.