1 | import java.applet.Applet; |
---|
2 | |
---|
3 | import netscape.javascript.JSObject; |
---|
4 | |
---|
5 | import br.gov.serpro.cert.DigitalCertificate; |
---|
6 | import br.gov.serpro.setup.Setup; |
---|
7 | |
---|
8 | |
---|
9 | public class Main extends Applet{ |
---|
10 | |
---|
11 | //private DigitalCertificate teste; |
---|
12 | private Thread executaTeste; |
---|
13 | private DataReader dataReader; |
---|
14 | private JSObject page; |
---|
15 | private Setup setup; |
---|
16 | |
---|
17 | /** |
---|
18 | * |
---|
19 | */ |
---|
20 | private static final long serialVersionUID = 1726731542858100340L; |
---|
21 | |
---|
22 | /** |
---|
23 | * |
---|
24 | */ |
---|
25 | public void start() { |
---|
26 | this.setup = new Setup(this); |
---|
27 | //this.teste = new DigitalCertificate(); |
---|
28 | this.dataReader = new DataReader(); |
---|
29 | //this.data.setResultado(this.teste.init()); |
---|
30 | this.executaTeste = new Leitor(dataReader, JSObject.getWindow(this), setup); |
---|
31 | this.executaTeste.start(); |
---|
32 | |
---|
33 | //this.page = JSObject.getWindow(this); |
---|
34 | /*try{ |
---|
35 | SwingUtilities.invokeAndWait(new Runnable(){ |
---|
36 | |
---|
37 | public void run() { |
---|
38 | // TODO Auto-generated method stub |
---|
39 | int resultado = teste.init(); |
---|
40 | System.out.println("Event Dispatching Thread: Resultado após leitura do token" + resultado); |
---|
41 | dataReader.setResultado(resultado); |
---|
42 | } |
---|
43 | |
---|
44 | }); |
---|
45 | } |
---|
46 | catch (InterruptedException e){ |
---|
47 | e.printStackTrace(); |
---|
48 | } |
---|
49 | catch (InvocationTargetException e) { |
---|
50 | // TODO Auto-generated catch block |
---|
51 | e.printStackTrace(); |
---|
52 | } |
---|
53 | */ |
---|
54 | } |
---|
55 | |
---|
56 | //TODO: Testar a passagem de parâmetros do javascript para a applet |
---|
57 | /** |
---|
58 | * @param args |
---|
59 | */ |
---|
60 | public void doButtonClickAction(String resultado){ |
---|
61 | dataReader.setResultado(resultado); |
---|
62 | dataReader.unlock(); |
---|
63 | //return "cert"; |
---|
64 | } |
---|
65 | |
---|
66 | //public class Executor extends Thread { |
---|
67 | // |
---|
68 | // @Override |
---|
69 | // public void run() { |
---|
70 | // // TODO Auto-generated method stub |
---|
71 | // super.run(); |
---|
72 | // |
---|
73 | // // chamar função no javascript |
---|
74 | // System.out.println("Classe executor: pegando resultado."); |
---|
75 | // int resultado = dataReader.getResultado(); |
---|
76 | // page.call("mostraResultado", new String[] {Integer.toString(resultado)}); |
---|
77 | |
---|
78 | // } |
---|
79 | |
---|
80 | //} |
---|
81 | |
---|
82 | } |
---|