/** ********************* CONSTRUCTOR **************************** */ public RyanairInspector2GUI() { bufferNavegadores = new Buffer(new CircularQueue(SIZE)); for (Navegador n : navegadores) { bufferNavegadores.Put(n); } bufferVuelos = new Buffer(new CircularQueue(SIZE)); System.out.println(rutaActual); System.out.println("-- Empieza lectura fichero --"); vuelos = UtilsIO.leerFicheroDatosConsultaVuelos(rutaActual + nomFichConsultas); for (Vuelo v : vuelos) { bufferVuelos.Put(v); System.out.println(v.toString()); } System.out.println("-- Termina lectura fichero --"); /*__ CREAMOS UNA INSTANCIA PARA CAPTURAR UN VUELO */ unvueloRyanair = new RyanairInspector2(); creaContenidos(); // Iniciamos la carga de la pagina iniciaCaptura(table); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); // System.out.println("despues de dispose"); }
// Gestiona el evento Fin de la carga de la pagina del BROWSER private boolean iniciaCaptura(Table table) { for (Vuelo v : vuelos) { if (v .isSinEmpezar()) { // Interpretemos la marca de si se ha empezado o no a capturar este // vuelo boolean encontrado = false; for (Iterator<Navegador> it = navegadores.iterator(); it.hasNext() && !encontrado; ) { Navegador n = (Navegador) it.next(); if (!n.isOcupado()) { // Si el navegador está libre // unvueloRyanair. // encontrado= true; } } } } /* Vuelo v= (Vuelo)bufferVuelos.Get(); if(v != null){ //Si hay algun vuelo sin capturar Navegador n= (Navegador)bufferNavegadores.Get(); if(n != null){ //Si hay algun navegador while(v.isSinEmpezar()){ } }*/ /* if( hiloConsultas < vuelos.size() ){ Iterator<Vuelo> it = vuelos.iterator(); Vuelo v = null; int i=-1; while (it.hasNext() && i<hiloConsultas) { v = (Vuelo) it.next(); i++; System.out.print(i); } System.out.println("\nCONSULTA SOBRE VUELO: "+v); boolean respCapturaVuelo= unvueloRyanair.capturaVuelo(brw, table, v.getOrigen(), v.getDestino(), v.getFecha()); System.out.println("respCapturaVuelo="+respCapturaVuelo); if(respCapturaVuelo) { Browser.clearSessions(); //Borra todas las cookies de la sesion hiloConsultas++; if(hiloConsultas<vuelos.size()){ it = vuelos.iterator(); i=-1; while (it.hasNext() && i<hiloConsultas) { v = (Vuelo) it.next(); i++; System.out.print(i); } System.out.println("\nCONSULTA SOBRE VUELO: "+v); }else { brw.stop(); System.out.println("brw stop 1"); } inicializaCaptura(brw, table); //numPantalla=0; //gestionaBrowserFin(brw); //brw.setUrl("http://www.bookryanair.com/SkySales/FRSearch.aspx?culture=ES-ES&pos=HEAD"); } }else { brw.stop(); System.out.println("brw stop 2"); } */ return true; }