package test;

import javax.swing.JFrame;

import graph.LayeredGraphNode;
import processor.PseudoCodeNode;
import processor.PseudoCodeProcessor;

public class StepInProcessor extends PseudoCodeProcessor{

    public StepInProcessor(PseudoCodeNode start, LayeredGraphNode graph, JFrame view) {
        super(start, graph, view);
    }
    
    @Override
    public void run()
    {
        while( true )
        {
            CodeStatus status = null;
            try {
                status = forwardStep();
                forwardStep();
                if( status == CodeStatus.FINISHED )
                {
                    System.out.println( "Step Into works in forward direction.");
                    break;
                }
                backwardStep();
            } catch (Exception e) {
                e.printStackTrace();
                return;
            }
            if( status == CodeStatus.FINISHED )
            {
                System.out.println( "Step Into works in forward direction.");
                break;
            }
        }
        while( true )
        {
            CodeStatus status = null;
            try {
                status = backwardStep();
                if( status == CodeStatus.FINISHED )
                {
                    System.out.println( "Step Into works in backward direction.");
                    break;
                }
                backwardStep();
                forwardStep();
            } catch (Exception e) {
                e.printStackTrace();
                return;
            }
            if( status == CodeStatus.FINISHED )
            {
                System.out.println( "Step Into works in backward direction.");
                break;
            }
        }
    }
}
