Blame view

circus/src/circusRefine/gui/TelaTatica.java 18 KB
8d0dc533f   Madiel de Souza Conserva Filho   first
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
  package circusRefine.gui;
  
  import circusRefine.core.ExternalManager;
  
  
  import circusRefine.Tactic.Excecao.LawNotFound;
  import circusRefine.Tactic.Excecao.TacticNotFound;
  import circusRefine.Tactic.Excecao.Unification;
  import circusRefine.Tactic.Parser.Parser2;
  
  import java.awt.BorderLayout;
  import javax.swing.JButton;
  import java.awt.Color;
  import java.awt.Dimension;
  import java.awt.FlowLayout;
  import java.awt.Font;
  import java.awt.GridBagConstraints;
  import java.awt.GridBagLayout;
  import java.awt.GridLayout;
  import java.awt.SystemColor;
  import java.awt.TextArea;
  
  import javax.swing.AbstractButton;
  import javax.swing.ImageIcon;
  import javax.swing.JFileChooser;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.JMenu;
  import javax.swing.JMenuBar;
  import javax.swing.JMenuItem;
  import javax.swing.JPanel;
  import javax.swing.JTextArea;
  import javax.swing.JScrollPane;
  import javax.swing.JOptionPane;
  import javax.swing.JTextPane;
  import javax.swing.JToolBar;
  import javax.swing.event.CaretEvent;
  import javax.swing.event.CaretListener;
  
  import circusRefine.Tactic.Parser.ParseException;
  import circusRefine.Tactic.Principal.*;
  import circusRefine.Tactic.Util.GerenciadorTaticas;
  
  import java.awt.event.ActionEvent;
  import java.io.*;
  
  
  
  public class TelaTatica extends JFrame{
  
  
  	public TelaTatica(){
  
  	}
  
  	/**
  	 * 
  	 */
  	private static final long serialVersionUID = 1L;
  	static int opened = 0; 
  	GridBagLayout gridBagLayout = new GridBagLayout(); 
  
  	private GridBagConstraints cons = new GridBagConstraints();
  	JButton image_save  = new JButton();
  	ExternalManager gerInterface;
  	static File file = null;
  	Tatica tatica = new Tatica();
  	Parser2 parser = new Parser2();
  	TecladoArcAngelC tecArcAngelC;
  
  	JMenuBar Menu1 = new JMenuBar();
  
  	JMenu Arquivo         = new JMenu();
  	//JMenu Help = new JMenu();
  
  	JMenuItem Salvar   = new JMenuItem();
  	JMenuItem Compilar   = new JMenuItem();
  	JMenuItem Sair 	 = new JMenuItem();
  
  
  	JPanel panel1 = new JPanel();
  	JButton btnCompilar = new JButton();
  	JButton btnCancel = new JButton();
  	JButton btnSave = new JButton();
  	JButton btnGerar = new JButton();
  	JTextArea jTactic = new JTextArea();
  	JScrollPane rolagem;
  	JLabel labelEntrada = new JLabel();
  	JTextPane text = new JTextPane();
  	JTextArea ta = new JTextArea();
  	int row, coluna;
  	//JButton btnDigitacao = new JButton();
  	JButton btnTecladoVirtual = new JButton();
  	JButton btnLimpar = new JButton();
  	JPanel panel2 = new JPanel();
  	BorderLayout borderLayout1 = new BorderLayout();
  	BorderLayout borderLayout2 = new BorderLayout();
  	JPanel panel3 = new JPanel();
  	GridLayout gridLayout1 = new GridLayout();
  	JPanel panel4 = new JPanel();
  	BorderLayout borderLayout3 = new BorderLayout();
  	BorderLayout borderLayout4 = new BorderLayout();
  	FlowLayout flowLayout1 = new FlowLayout();
  
  	JPanel panel5 = new JPanel();
  	JPanel panel6 = new JPanel();
  	JPanel panel7 = new JPanel();
  	JPanel panel8 = new JPanel();
  	JPanel panel9 = new JPanel();
  
  	FileWriter writer = null;
  	JFileChooser fileChooser = new JFileChooser();
  
  	public TelaTatica(ExternalManager gerExterno) {
  		gerInterface = gerExterno;
  		jbInit();
  		tecArcAngelC = new TecladoArcAngelC(this, this.gerInterface);
  	}
  
  
  	private Tatica compilar_Action() {
  
  		try{
  			tatica = gerInterface.parseTatica(file);
  
  			if (!gerInterface.verificarErroParser()){
  				if(opened==0){
  					JOptionPane.showMessageDialog
  					(null,gerInterface.getMessage("AddTactic"));
  					gerInterface.updateTacticList(tatica);	
  				}
  				else
  					JOptionPane.showMessageDialog
  					(null,gerInterface.getMessage("EditTactic"));
  
  
  				
  				limpar_Action();
  
  				gerInterface.retornarTelaTatica().setVisible(false);
  			}
  		}catch(TacticNotFound e2){
  			//linha = gerInterface.setarLinha();
  			gerInterface.telaErro("TacticNotFound", "", "Tactic: " + e2.getNomeTactic() + "at line: " + gerInterface.setarLinha());
  			System.out.println("TacticNotFound");
  		}
  		catch(LawNotFound e3){
  			gerInterface.telaErro("LawNotFound", "", "Law: " + e3.getLei() + "at line: " + gerInterface.setarLinha());
  			System.out.println("LawNotFound");
  		}
  
  
  		return tatica;
  
  
  	}
  	
  	
  /*	private void jbInit2(){
  		
  		this.setTitle( "Tactic´s Editor");
  		this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  		this.setResizable(true);
  		this.setLocation(300,80);
  		this.setSize(700, 600);
  		
  		
  		Arquivo.setText("Arquivo");
  		Arquivo.setMnemonic(gerInterface.getMessage("COD0001").charAt(0));
  		//Abrir.setText(gerInterface.getMessage("COD0003"));
  		//Abrir.setMnemonic(gerInterface.getMessage("COD0003").charAt(0));
  		Salvar.setText("Save");
  		Salvar.setMnemonic(gerInterface.getMessage("COD0005").charAt(0));
  		Compilar.setText("Compile");
  		Sair.setText("Exit");
  		Sair.setMnemonic(gerInterface.getMessage("COD0008").charAt(0));
  		
  		Arquivo.add(Salvar);
  		Arquivo.add(Compilar);
  		Arquivo.add(Sair);
  		Menu1.add(Arquivo);
  		
  
  		
  		btnCompilar.setForeground(Color.RED);
  		btnCompilar.setFont(new Font("Dialog", 1, 12));
  		btnCompilar.setText(gerInterface.getMessage("Compile"));
  		btnCompilar.addActionListener(new java.awt.event.ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  
  
  				//try {
  
  				try {
  					compilarActionPerformed();
  
  				} catch (TacticNotFound e1) {
  					// TODO Auto-generated catch block
  					e1.printStackTrace();
  
  				} catch (LawNotFound e2) {
  					// TODO Auto-generated catch block
  					e2.printStackTrace();
  				}
  
  				limpar_Action();
  				gerInterface.retornarTelaTatica().setVisible(false);
  
  
  			}
  
  		}
  
  		);
  
  		btnLimpar.setForeground(Color.RED);
  		btnLimpar.setFont(new Font("Dialog", 1, 12));
  		btnLimpar.setText("Limpar");
  		btnLimpar.addActionListener(new java.awt.event.ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				limpar_Action();
  			}
  		}
  		);
  
  		btnCancel.setForeground(Color.red);
  		btnCancel.setFont(new Font("Dialog", 1, 12));
  		btnCancel.setText("Cancelar");
  		btnCancel.addActionListener(new java.awt.event.ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				btnCancel_actionPerformed(e);
  				limpar_Action();
  			}
  		});
  		
  		btnSave.setForeground(Color.red);
  		btnSave.setFont(new Font("Dialog", 1, 12));
  		btnSave.setText("Save Tactic");
  		btnSave.addActionListener(new java.awt.event.ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				btnCancel_actionPerformed(e);
  				limpar_Action();
  			}
  		});
  
  		btnTecladoVirtual.setForeground(Color.black);
  		btnTecladoVirtual.setFont(new Font("Dialog", 1, 12));
  		btnTecladoVirtual.setText(gerInterface.getMessage("Keybord"));
  		btnTecladoVirtual.addActionListener(new java.awt.event.ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				tecladoVirtual_Action(e);
  
  			}
  		});
  		
  		this.setLayout( new BorderLayout() );
  		
  		JLabel texto1 =  new JLabel("Enter ArcAngelC Code: " );
  		JPanel pNorte, pCentro, pSul;
  		
  		pNorte = new JPanel();
  		pNorte.setBackground(Color.green);
  		pNorte.add(texto1);
  		this.add(pNorte, BorderLayout.NORTH);
  		
  
  		 
  		
  		jTactic.setFont(new Font ("CZT", Font.PLAIN, 14));
  		jTactic.setText("");
  		rolagem = new JScrollPane(jTactic);
  		jTactic.setToolTipText("Parser");
  		
  		pCentro = new JPanel();
  		
  		this.add(pCentro,BorderLayout.CENTER);
  		
  		pCentro.setLayout(new FlowLayout(FlowLayout.CENTER)); //define o layout
  		pCentro.add(jTactic);
  		this.add(pCentro,BorderLayout.CENTER);
  		
  		
  		pSul = new JPanel();
  		pSul.add(btnSave);
  		pSul.add(btnCompilar);
  		pSul.add(btnTecladoVirtual);
  		this.add(pSul, BorderLayout.SOUTH);
  		
  		this.setJMenuBar(Menu1);
  		
  	}*/
  	
  	
  	void image_save_actionPerformed(ActionEvent e) {
  		this.salvarTatica();
  	}
  	
  	private void jbInit(){
  
  		this.setLocation(300,80);
  		this.setSize(700, 600);
  		this.setResizable(true);
  		this.setTitle("Parser ArcAngelC");
  
  		this.setJMenuBar(Menu1);
  		Arquivo.setText(gerInterface.getMessage("COD0511"));
  		Arquivo.setMnemonic(gerInterface.getMessage("COD0001").charAt(0));
  		//Abrir.setText(gerInterface.getMessage("COD0003"));
  		//Abrir.setMnemonic(gerInterface.getMessage("COD0003").charAt(0));*/
  		Salvar.setText("Save");
  		Salvar.setMnemonic(gerInterface.getMessage("COD0005").charAt(0));
  		Compilar.setText(gerInterface.getMessage("Generate"));
  		Sair.setText("Exit");
  		Sair.setMnemonic(gerInterface.getMessage("COD0008").charAt(0));
  		
  		Arquivo.add(Salvar);
  		Arquivo.add(Compilar);
  		Arquivo.add(Sair);
  		Menu1.add(Arquivo);
  
  		jTactic.setFont(new Font ("CZT", Font.PLAIN, 14));
  		jTactic.setText("");
  		rolagem = new JScrollPane(jTactic);
  		jTactic.setToolTipText("Parser");
  		ta.setText("Linha: " + (1) + ", Coluna:" + (1));
  		
  		
  		
  		jTactic.addCaretListener(
  					 
  					/*
  					 
  					Neste caso, criei uma nova instância de CaretListener para que um componente do tipo JLabel seja atualizado sempre que o usuário movimentar o cursor dentro do componente
  					 
  					*/
  					 
  					new CaretListener() {
  					 
  					public void caretUpdate(CaretEvent e) {
  					 
  					 row = jTactic.getDocument().getRootElements()[0].getElementIndex(jTactic.getCaretPosition());
  					 
  					coluna =  jTactic.getCaretPosition() -  jTactic.getDocument().getRootElements()[0].getElement(row).getStartOffset();
  					 
  					
  					ta.setText("Line: " + (row + 1) + ", Col:" + (coluna + 1));
  					//ta.setBackground(Color.GRAY);
  					 
  					}
  					 
  					}
  					 
  					);
  		
  		
  		/*jTactic.setFont(new Font ("CZT", Font.PLAIN, 14));
  		jTactic.setText("");
  		rolagem = new JScrollPane(jTactic);
  		jTactic.setToolTipText("Parser");*/
  
  
  		btnCompilar.setForeground(Color.RED);
  		btnCompilar.setFont(new Font("Dialog", 1, 12));
  		btnCompilar.setText(gerInterface.getMessage("Generate"));
  		//btnCompilar.setText("Generate");
  		btnCompilar.addActionListener(new java.awt.event.ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  
  
  				//try {
  
  				try {
  					compilarActionPerformed();
  
  				} catch (TacticNotFound e1) {
  					// TODO Auto-generated catch block
  					e1.printStackTrace();
  
  				} catch (LawNotFound e2) {
  					// TODO Auto-generated catch block
  					e2.printStackTrace();
  				}
  
  				limpar_Action();
  				gerInterface.retornarTelaTatica().setVisible(false);
  
  
  			}
  
  		}
  
  		);
  		
  		btnSave.setForeground(Color.BLUE);
  		btnSave.setFont(new Font("Dialog", 1, 12));
  		btnSave.setText("Save Tactic");
  		btnSave.addActionListener(new java.awt.event.ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				salvarTatica();
  			}
  		});
  		
  		btnGerar.setForeground(Color.BLUE);
  		btnGerar.setFont(new Font("Dialog", 1, 12));
  		btnGerar.setText("Save Tactic");
  		btnGerar.addActionListener(new java.awt.event.ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				salvarTatica();
  			}
  		});
  
  		btnLimpar.setForeground(Color.RED);
  		btnLimpar.setFont(new Font("Dialog", 1, 12));
  		btnLimpar.setText("Limpar");
  		btnLimpar.addActionListener(new java.awt.event.ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				limpar_Action();
  			}
  		}
  		);
  
  		btnCancel.setForeground(Color.red);
  		btnCancel.setFont(new Font("Dialog", 1, 12));
  		btnCancel.setText("Save");
  		btnCancel.addActionListener(new java.awt.event.ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				btnCancel_actionPerformed(e);
  				limpar_Action();
  			}
  		});
  
  		btnTecladoVirtual.setForeground(Color.black);
  		btnTecladoVirtual.setFont(new Font("Dialog", 1, 14));
  		btnTecladoVirtual.setText(gerInterface.getMessage("Keybord"));
  		btnTecladoVirtual.addActionListener(new java.awt.event.ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				tecladoVirtual_Action(e);
  
  			}
  		});
  
  
  		labelEntrada.setText(gerInterface.getMessage("EnterCode"));
  		panel1.setLayout(borderLayout1);
  		panel2.setLayout(borderLayout2);
  		panel3.setLayout(gridLayout1);
  		panel4.setLayout(borderLayout3);
  		panel9.setLayout(flowLayout1);
  
  		this.getContentPane().add(panel1, BorderLayout.CENTER);
  		//panel1.add(Menu1);
  		panel1.add(panel2, BorderLayout.CENTER);
          //panel5.add(Menu1);
  		panel2.add(rolagem,  BorderLayout.CENTER);
  		panel2.add(panel5, BorderLayout.WEST);
  		panel2.add(panel6,  BorderLayout.SOUTH);
  		panel2.add(panel7,  BorderLayout.EAST);
  		panel2.add(panel8, BorderLayout.NORTH);
  
  		panel1.add(panel3,  BorderLayout.SOUTH);
  
  		panel3.add(ta);
  		panel3.add(btnSave,null);
  		panel3.add(btnCompilar, null);
  		
  		panel3.add(btnTecladoVirtual, null);
  		//panel3.add(btnCancel, null);
  
  
  		panel1.add(panel4, BorderLayout.NORTH);
  		//panel1.add(panel5, BorderLayout.NORTH);
  
  		/*Menu1.add(Arquivo);
  		Arquivo.add(Salvar);
  		Arquivo.add(Compilar);
  		Arquivo.addSeparator();
  		Arquivo.add(Sair);*/
  
  		Compilar.addActionListener(new java.awt.event.ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  
  				try {
  					compilarActionPerformed();
  
  				} catch (TacticNotFound e1) {
  					// TODO Auto-generated catch block
  					System.out.println(e1.getNomeTactic());
  
  				} catch (LawNotFound e2) {
  					// TODO Auto-generated catch block
  					e2.printStackTrace();
  
  				}
  				limpar_Action();
  				gerInterface.retornarTelaTatica().setVisible(false);
  			}
  		}
  		);
  
  
  		Salvar.addActionListener(new java.awt.event.ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				salvarTatica();
  			}
  		}
  		);
  
  		Sair.addActionListener(new java.awt.event.ActionListener() {
  			public void actionPerformed(ActionEvent e) {
  				btnCancel_actionPerformed(e);
  				limpar_Action();
  			}
  		}
  		);
  
  		//panel5.add(Menu1,  BorderLayout.CENTER);
  		panel4.add(labelEntrada,  BorderLayout.CENTER);
  
  		// A parte do arquivo
  		panel4.add(panel9,  BorderLayout.EAST);
  
  	}
  
  
  	protected void btnCancel_actionPerformed(ActionEvent e) {
  		this.setVisible(false);
  
  
  	}
  
  	public void limparTexto() {
  		jTactic.setText("");
  	}
  
  	private void limpar_Action() {
  		this.limparTexto();
  
  	}
  
  
  	private void tecladoVirtual_Action(ActionEvent e){
  		tecArcAngelC.pack();
  		tecArcAngelC.setLocation(490, 200);
  		tecArcAngelC.setVisible(true);
  	}
  
  	public static void sairTela(){
  		Object[] botoes = {"Sim", "Não"};
  		int opcao = 
  			JOptionPane.showOptionDialog(
  					null, "Deseja sair? [S/N]",
  					"Fechar Tela Parser ArcAngelC",
  					JOptionPane.DEFAULT_OPTION,
  					JOptionPane.INFORMATION_MESSAGE,
  					null, botoes, botoes[1] );
  		if (opcao == 0) {
  			System.exit(0);
  
  
  		}
  	}
  
  
  	/**
  	 * Método responsavel por retornar o código do arquivo para
  	 * setar na telaTatica
  	 * @param file
  	 * @return
  	 * @throws IOException
  	 */
  	public void setarArquivo(File file) throws IOException{
  		gerInterface.retornarEspecificacao(file);
  	}
  
  	public void setarTelaTatica(String codigo){
  		jTactic.setText(codigo);
  	}
  
  
  	public int getLine() {
  		String texto = this.jTactic.getText();
  		int posicaoCursor = this.jTactic.getCaretPosition();
  		int linha = 1;
  		int coluna = 1;
  
  		char[] arrayCaracteres = texto.toCharArray();
  
  		for (int i = 0; i < posicaoCursor; i++){
  			if (arrayCaracteres[i]=='
  ') {
  				linha++;
  				coluna = 1;
  			} else {
  				coluna++;
  			}	
  		}
  
  		//this.getStatusMsg1().setText("Lin: "+linha+" Col: "+coluna);
  
  		return linha;
  	}
  
  	public void showErrorWindow(String mensagem, String details, String infoExtra){
  
  		boolean retorno = false;
  		String options[] = {"Close","Details"};
  		int resposta = JOptionPane.showOptionDialog(this,
  				infoExtra,
  				//gerInterface.getMessage("TacticError"),
  				gerInterface.getMessage(mensagem),
  				JOptionPane.YES_NO_OPTION,
  				JOptionPane.ERROR_MESSAGE,
  				null,
  				options,
  				options[0]);
  
  		switch (resposta) {
  		case 0: 
  			retorno = false;
  			break;
  		case 1:
  			retorno = true;
  			break;
  		default:
  			retorno = false;
  		}
  		if (retorno) {
  			if (details == null || details.equals("")) {
  				details = gerInterface.getMessage("NoDetails");
  			}    
  			JOptionPane.showMessageDialog(this, details, this.gerInterface.getMessage("ErrorDetails"), JOptionPane.ERROR_MESSAGE);
  		}
  	}
  
  	/**
  	 * Método que salva uma tática 
  	 */
  	private void salvarTatica(){
  
  
  		JFileChooser fChooser = new JFileChooser();
  		fChooser.setCurrentDirectory(new File("."));
  
  		int result = fChooser.showDialog(null,gerInterface.getMessage("SaveT"));
  		if(result == JFileChooser.APPROVE_OPTION)
  		{
  			file = fChooser.getSelectedFile();
  		}
  	}
  
  	/**
  	 * Método responsavel por pegar o texto que foi digitado na tela
  	 * @return codigo O código digitado
  	 */ 
  	public String getText(){
  		String codigo = jTactic.getText();
  		return codigo;
  	}
  
  	/**
  	 * Método que realiza o processo de compilar 
  	 */
  	private void compilarActionPerformed() throws TacticNotFound, LawNotFound{
  		boolean overwrite = true;
  		if (!jTactic.getText().equals("")){
  			if (opened == 0 ){
  				overwrite = false;
  				JOptionPane.showMessageDialog(this,this.gerInterface.getMessage("SaveTactic"), 
  						this.gerInterface.getMessage("SaveT"), JOptionPane.INFORMATION_MESSAGE);
  				salvarTatica();
  			}
  
  			gerInterface.escreveArquivo(file, getText());
  			tatica = compilar_Action();
  
  
  			/**
  			 * Serializar nova tatica
  			 */
  			if (tatica!=null)
  			gerInterface.escreveTaticaSerializada(tatica);
  			opened = 0;
  		}
  		else 
  			JOptionPane.showMessageDialog(this,this.gerInterface.getMessage("EmptyFile"), 
  					this.gerInterface.getMessage("EmptyFile"), JOptionPane.INFORMATION_MESSAGE);
  	}
  
  
  	/**
  	 * M�todo utilizado para digitar com o auxilio do Teclado Virtual.
  	 *
  	 * @param carac      ........
  	 *
  	 */
  	public void escrever(String carac) {
  
  		/* captura posicao do cursor na tela */
  		int position = jTactic.getCaret().getDot();
  
  		this.jTactic.insert(carac, position);
  		
  		
  		/*this.text.insert(carac,position);
  		 
  		String[] array = carac.split(" ");
  		
  		for (int i = 0; i <array.length; i++) {
  			String e = array[i];
  			if (e.equalsIgnoreCase("\\tbegin"));
  			System.out.println(e);
  			
  		}
  		
  		text.setText(carac);
  
  		
  		this.jTactic.setText(t);*/
  
  	}
  }