package be.ephec.nsjc.jws.view;

import be.ephec.nsjc.jws.controller.JWSController;
import be.ephec.nsjc.jws.model.HTTPTrace;

import java.util.Observable;
import java.util.Scanner;

public class ConsoleView extends AbstractView{

    private boolean running = true;

    public ConsoleView(HTTPTrace trace, JWSController controller) {
        super(trace, controller);
    }

    @Override
    public void update(Observable o, Object arg) {
        int count = (Integer) arg;
        if (this.trace.hasMadeResponse()) {
            System.out.println(this.trace.getResponseList().get(count));
        } else {
            System.out.println(this.trace.getRequestList().get(count));
        }
    }

    @Override
    public void log(String log) {
        System.out.println(log);
    }

    private class InputReader implements Runnable {
        private Scanner sc;

        @Override
        public void run() {
            this.sc = new Scanner(System.in);
            while (running) {
                try {
                    ConsoleView.this.controller.handleInput(this.sc.nextLine().trim());
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

@@ -224,16 +224,40 @@
 tView%7B%0A%0A
+    private Scanner sc;%0A
     priv
@@ -387,16 +387,58 @@
 oller);%0A
+        this.sc = new Scanner(System.in);%0A
     %7D%0A%0A 
@@ -902,36 +902,8 @@
 le %7B
-%0A        private Scanner sc;
 %0A%0A  
@@ -950,54 +950,8 @@
 ) %7B%0A
-            this.sc = new Scanner(System.in);%0A
     
@@ -998,16 +998,16 @@
   try %7B%0A
+
         
@@ -1058,21 +1058,16 @@
 leInput(
-this.
 sc.nextL

move scanner to main thread