Ignore:
Timestamp:
07/25/08 16:37:58 (16 years ago)
Author:
ra33
Message:

Adding calculation stuff...

File:
1 edited

Legend:

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

    r156 r161  
    4444import org.expeditee.simple.BelowMinParametreCountException;
    4545import org.expeditee.simple.Context;
     46import org.expeditee.simple.ExpediteeJEP;
    4647import org.expeditee.simple.IncorrectParametreCountException;
    4748import org.expeditee.simple.IncorrectTypeException;
     
    5960import org.expeditee.stats.AgentStats;
    6061import org.expeditee.stats.SessionStats;
     62import org.nfunk.jep.Node;
    6163
    6264public class Simple implements Runnable {
     
    313315                        t.start();
    314316                } else {
    315                         if (!testSuite.runSuite()){
     317                        if (!testSuite.runSuite()) {
    316318                                throw new RuntimeException(frameset + " failed");
    317319                        }
     
    780782                        // Check if the user wants to display a message
    781783                        // Check for set statements
    782                 } else if (tokens[0].startsWith("issearchpatternvalid")) {
     784                } else if (tokens[0].startsWith("calculatestring")) {
     785                        assertMinParametreCount(tokens, 2);
     786                        String toCalculate = context.getPrimitives().getStringValue(tokens[1]);
     787                        boolean result = true;
     788                        ExpediteeJEP myParser = new ExpediteeJEP();
     789                        //Add the variables in the system
     790                        context.getPrimitives().addToParser(myParser);
     791                        Node equation = myParser.parseExpression(toCalculate);
     792                        //TODO get the answer
     793                       
     794                } else if (tokens[0].startsWith("calculateitem")) {
     795                        assertMinParametreCount(tokens, 1);
     796                        assertVariableType(tokens[1], 1, SPointer.itemPrefix);
     797                        Item item = (Item)context.getPointers().getVariable(tokens[1]).getValue();
     798                        Frame frame = null;
     799                        if(tokens.length > 2){
     800                                assertVariableType(tokens[2], 2, SPointer.framePrefix);
     801                                frame = (Frame)context.getPointers().getVariable(tokens[2]).getValue();
     802                        }
     803                        Misc.calculate(frame, item);
     804                }else if (tokens[0].startsWith("issearchpatternvalid")) {
    783805                        assertExactParametreCount(tokens, 2);
    784806                        boolean result = true;
     
    901923                                SearchAgent searchAgent = new SearchTree();
    902924                                _agent = searchAgent;
    903                                 searchAgent.initialise(null, null, topFrameName, resultsFrameset,
    904                                                 replacementString, pattern);
     925                                searchAgent.initialise(null, null, topFrameName,
     926                                                resultsFrameset, replacementString, pattern);
    905927                                searchAgent.run();
    906928                                _agent = null;
     
    964986                                Item valueItem = null;
    965987                                // Begin the search
    966                                 for (Text text : targetFrame.getTextItems()){
     988                                for (Text text : targetFrame.getTextItems()) {
    967989                                        String s = text.getText().toLowerCase();
    968990
     
    12711293                                        context.getPointers().setObject(frameTitleVar,
    12721294                                                        frame.getTitleItem());
    1273                                 }else if (tokens[0].startsWith("getframefilepath")) {
     1295                                } else if (tokens[0].startsWith("getframefilepath")) {
    12741296                                        assertExactParametreCount(tokens, 2);
    12751297                                        String frameName = context.getPrimitives().getStringValue(
     
    19992021                        } else
    20002022                                context.readFrame(frameName, frameVar, null);
    2001                 }else if (tokens[0].equals("exitexpeditee")) {
     2023                } else if (tokens[0].equals("exitexpeditee")) {
    20022024                        Browser._theBrowser.exit();
    2003                 }else if (tokens[0].equals("readkbdcond")) {
     2025                } else if (tokens[0].equals("readkbdcond")) {
    20042026
    20052027                        String nextCharVarName = DEFAULT_CHAR;
     
    24832505                        assertExactParametreCount(tokens, 0);
    24842506                        FrameMouseActions.leftButton();
    2485                         //DisplayIO.clickMouse(InputEvent.BUTTON1_MASK);
     2507                        // DisplayIO.clickMouse(InputEvent.BUTTON1_MASK);
    24862508                } else if (tokens[0].equals("clickmiddlebutton")) {
    24872509                        assertExactParametreCount(tokens, 0);
    24882510                        FrameMouseActions.middleButton();
    2489                         //DisplayIO.clickMouse(InputEvent.BUTTON2_MASK);
     2511                        // DisplayIO.clickMouse(InputEvent.BUTTON2_MASK);
    24902512                } else if (tokens[0].equals("clickrightbutton")) {
    24912513                        assertExactParametreCount(tokens, 0);
    24922514                        FrameMouseActions.rightButton();
    2493                         //DisplayIO.clickMouse(InputEvent.BUTTON3_MASK);
     2515                        // DisplayIO.clickMouse(InputEvent.BUTTON3_MASK);
    24942516                } else if (tokens[0].equals("repaint")) {
    24952517                        assertExactParametreCount(tokens, 0);
Note: See TracChangeset for help on using the changeset viewer.