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

Legend:

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

    r19 r21  
    3838import org.expeditee.simple.UnitTestFailedException;
    3939import org.expeditee.stats.AgentStats;
     40import org.expeditee.stats.SessionStats;
    4041
    4142public class Simple {
     
    236237                // item.setColor(Color.CYAN);
    237238                FrameUtils.DisplayFrame(item.getParent().getFrameName(), true);
    238                 item.showHighlight(true, Color.CYAN);
     239                item.setSelectionColor(Color.CYAN);
    239240                FrameIO.SaveFrame(item.getParent());
    240241        }
     
    312313                Frame frame = i.getParent();
    313314
    314                 if (i == frame.getTitle() || i == frame.getFrameNameItem() || i.isAnnotation()) {
     315                if (i == frame.getTitle() || i == frame.getFrameNameItem()
     316                                || i.isAnnotation()) {
    315317                        return false;
    316318                }
     
    576578                                for (Text text : targetFrame.getBodyTextItems(true)) {
    577579                                        String s = text.getTextNoList().toLowerCase();
    578                                        
     580
    579581                                        if (s.startsWith(targetAttribute)) {
    580582                                                attributeItem = text;
     
    847849                                                }
    848850                                        }
    849 
    850851                                        return Status.OK;
    851852                                } else if (tokens[0].startsWith("getframename")) {
     
    872873                                                        frameName);
    873874                                        context.getPrimitives().setValue(tokens[2], filePath);
     875                                        return Status.OK;
     876                                } else if (tokens[0].equals("getframelog")) {
     877                                        assertExactParametreCount(tokens, 1);
     878                                        assertVariableType(tokens[1], 1, SPointer.itemPrefix);
     879
     880                                        String log = SessionStats.getFrameEventList();
     881                                        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                                        }
     890
    874891                                        return Status.OK;
    875892                                }
     
    10051022                                                FrameIO.getFramesetList());
    10061023                                return Status.OK;
     1024                        } else if (tokens[0].equals("getsessionstats")) {
     1025                                assertExactParametreCount(tokens, 1);
     1026                                assertVariableType(tokens[1], 1, SPointer.itemPrefix);
     1027
     1028                                String stats = SessionStats.getCurrentStats();
     1029                                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                                }
     1038
     1039                                return Status.OK;
    10071040                        }
    10081041                } else if (tokens[0].equals("or")) {
     
    10601093                                || tokens[0].equals("errorln") || tokens[0].equals("errorline")) {
    10611094                        String message = getMessage(tokens, context, code.toString(),
    1062                                         tokens[0].endsWith("nospaces") ? "" : " ");
     1095                                        tokens[0].endsWith("nospaces") ? "" : " ", 1);
    10631096
    10641097                        if (tokens[0].equals("errorln") || tokens[0].equals("errorline"))
     
    10671100                                FrameGraphics.DisplayMessageAlways(message);
    10681101                        return Status.OK;
    1069                 } else if (tokens[0].equals("typein")
    1070                                 || tokens[0].equals("typeinnospaces")) {
     1102                } else if (tokens[0].equals("typeatrate")) {
     1103                        assertMinParametreCount(tokens, 1);
     1104                        double delay = context.getPrimitives().getDoubleValue(tokens[1]);
     1105                        String s = getMessage(tokens, context, code.toString(), " ", 2);
     1106                        for (int i = 0; i < s.length(); i++) {
     1107                                FrameKeyboardActions.processChar(s.charAt(i));
     1108                                Thread.sleep((int) (delay * 1000));
     1109                        }
     1110                        return Status.OK;
     1111                } else if (tokens[0].equals("type") || tokens[0].equals("typenospaces")) {
    10711112
    10721113                        String s = getMessage(tokens, context, code.toString(), tokens[0]
    1073                                         .equals("typein") ? " " : "");
     1114                                        .equals("type") ? " " : "", 1);
    10741115                        for (int i = 0; i < s.length(); i++) {
    10751116                                FrameKeyboardActions.processChar(s.charAt(i));
    10761117                                Thread.sleep(25);
    10771118                        }
     1119                        return Status.OK;
     1120                } else if (tokens[0].equals("runstring")) {
     1121                        String codeText = getMessage(tokens, context, code.toString(), " ",
     1122                                        1);
     1123                        Text dynamicCode = new Text(1, codeText);
     1124                        RunItem(dynamicCode, context, Status.OK);
    10781125                        return Status.OK;
    10791126                } else if (tokens[0].startsWith("else")) {
     
    13451392                } else if (tokens[0].equals("copyitem")) {
    13461393                        assertMinParametreCount(tokens, 2);
    1347                         assertVariableType(tokens[1],1,SPointer.itemPrefix);
    1348                         assertVariableType(tokens[2],2,SPointer.itemPrefix);
    1349                         Item item = (Item)context.getPointers().getVariable(tokens[1]).getValue();
     1394                        assertVariableType(tokens[1], 1, SPointer.itemPrefix);
     1395                        assertVariableType(tokens[2], 2, SPointer.itemPrefix);
     1396                        Item item = (Item) context.getPointers().getVariable(tokens[1])
     1397                                        .getValue();
    13501398                        Item copy = item.copy();
    13511399                        context.getPointers().setObject(tokens[2], copy);
    13521400
    13531401                        return Status.OK;
    1354                 }else if (tokens[0].equals("copyframeset")) {
     1402                } else if (tokens[0].equals("copyframeset")) {
    13551403                        assertMinParametreCount(tokens, 2);
    13561404                        String framesetToCopy = context.getPrimitives().getStringValue(
     
    13691417                } else if (tokens[0].equals("copyframe")) {
    13701418                        assertMinParametreCount(tokens, 2);
    1371                         assertVariableType(tokens[1],1,SPointer.framePrefix);
    1372                         assertVariableType(tokens[2],2,SPointer.framePrefix);
     1419                        assertVariableType(tokens[1], 1, SPointer.framePrefix);
     1420                        assertVariableType(tokens[2], 2, SPointer.framePrefix);
    13731421                        Frame frameToCopy = (Frame) context.getPointers().getVariable(
    13741422                                        tokens[1]).getValue();
     
    20632111
    20642112        private static String getMessage(String[] tokens, Context context,
    2065                         String code, String separator) throws Exception {
     2113                        String code, String separator, int firstStringIndex)
     2114                        throws Exception {
    20662115                StringBuilder message = new StringBuilder();
    2067                 if (tokens.length == 1) {
     2116                if (tokens.length == firstStringIndex) {
    20682117                        message.append(context.getPrimitives().getVariable(DEFAULT_STRING)
    20692118                                        .stringValue());
    20702119                } else {
    2071                         for (int i = 1; i < tokens.length; i++) {
     2120                        for (int i = firstStringIndex; i < tokens.length; i++) {
    20722121                                if (Primitives.isPrimitive(tokens[i])) {
    20732122                                        message.append(context.getPrimitives().getVariable(
Note: See TracChangeset for help on using the changeset viewer.