Blame view

BRIC/src/GUI/ContractGUI.java 42.1 KB
eeb5cac08   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
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
  package GUI;
  
  import CSP_ANALYSE.CSPVerificationContract;
  import LOGIC.Channel;
  import CSP_ANALYSE.CheckerResult;
  import LOGIC.Contract;
  import LOGIC.EventChannel;
  import CSP_ANALYSE.FDRResult;
  import LOGIC.Barra;
  import LOGIC.Internacional;
  import LOGIC.ObjectList;
  import LOGIC.Protocols;
  import java.awt.Cursor;
  import java.io.File;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.util.ArrayList;
  import java.util.LinkedList;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  import javax.swing.ImageIcon;
  import javax.swing.JOptionPane;
  import javax.swing.table.DefaultTableModel;
  
  public class ContractGUI extends javax.swing.JFrame {
  
      public ContractGUI(Internacional inter, ObjectList listas, boolean edicao, int local) { //inicialização da tela...
          this.listas = listas;
          this.edicao = edicao;
          this.local = local;
          this.inter = inter;
  
  
          this.setTitle("BRIC");  //seta título...
          //FileWriter Wcsp = null;
          contrato.setType(listas.getTypeList());
  
  
          ver = "!";
  
          //colunas da tabela...
          tmTipo1 = new DefaultTableModel(null, new String[]{"Canal"}) {
              public boolean isCellEditable(int rowIndex, int mColIndex) {
                  return false;
              }
          };
          tmTipo2 = new DefaultTableModel(null, new String[]{"Canal de comunicação", "Protocol", "Dual-protocol"}) {
              public boolean isCellEditable(int rowIndex, int mColIndex) {
                  return false;
              }
          };
          initComponents();
  
          ticFDR.setIcon(iconl);
          ticFDR.setVisible(true);
  
          if (edicao == false) {
              contrato.setBehavior("");
          } else {
              if (listas.getContractList().get(local).getFlag()) {
                  ticFDR.setIcon(iconv);
              }
          }
  
          //ícones da tela...
          ImageIcon seta = new ImageIcon("images/s.png");
          OutImage.setIcon(seta);
          inImage.setIcon(seta);
          addCC.setIcon(seta);
          //jButton1.setIcon(seta);
  
  
  
          //botões...
          bundleButtons();
  
          resultado = "";
          verificaEdicao();
          mostrarCanais();
          mostrarTabelas();
  
  
          /*if (contrato.getFlag()) {
           ticFDR.setIcon(iconv);
           } else {
           ticFDR.setIcon(iconl);
           }*/
      }
      //inicialização dos ícones, tabelas e variáveis...
      static ImageIcon iconl = new ImageIcon("images/exc.jpg");
      static ImageIcon iconx = new ImageIcon("images/xx.jpg");
      static ImageIcon iconv = new ImageIcon("images/v.jpg");
      String resultado = "";
      static String ver = "!";
      String canal;
      String tipo;
      Contract contrato = new Contract();
      ObjectList listas = new ObjectList();
      public static LinkedList<Channel> channel = new LinkedList();
      DefaultTableModel tmTipo1;
      DefaultTableModel tmTipo2;
      DefaultTableModel tcTipo = new DefaultTableModel(null, new String[]{"Portas"}) {
          public boolean isCellEditable(int rowIndex, int mColIndex) {
              return false;
          }
      };
      DefaultTableModel tiTipo = new DefaultTableModel(null, new String[]{"Interface"}) {
          public boolean isCellEditable(int rowIndex, int mColIndex) {
              return false;
          }
      };
      DefaultTableModel tinTipo = new DefaultTableModel(null, new String[]{"In"}) {
          public boolean isCellEditable(int rowIndex, int mColIndex) {
              return false;
          }
      };
      DefaultTableModel toutTipo = new DefaultTableModel(null, new String[]{"Out"}) {
          public boolean isCellEditable(int rowIndex, int mColIndex) {
              return false;
          }
      };
      //static String b = "";
      //Interface i = new Interface();
      LinkedList<Channel> lista = new LinkedList();
      LinkedList<String> temp = new LinkedList();
      static int editando = -1;
      static boolean aberto = false;
      LinkedList<EventChannel> inlist = new LinkedList();
      LinkedList<EventChannel> outlist = new LinkedList();
      private String b;
      CheckerResult cr = new CheckerResult();
      //CSPVerification cspv = new CSPVerificationContract(contrato);
      //CSP_Creator CSP = new CSP_Creator();
      boolean edicao;
      int local;
      Internacional inter;
      LinkedList<Protocols> protocols = new LinkedList();
  
      @SuppressWarnings("unchecked")
      // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
      private void initComponents() {
  
          nameContract = new javax.swing.JLabel();
          nome = new javax.swing.JTextField();
          behavior = new javax.swing.JLabel();
          channels = new javax.swing.JLabel();
          concluir = new javax.swing.JButton();
          write = new javax.swing.JButton();
          jScrollPane6 = new javax.swing.JScrollPane();
          R = new javax.swing.JTable();
          jScrollPane2 = new javax.swing.JScrollPane();
          C = new javax.swing.JTable();
          jScrollPane3 = new javax.swing.JScrollPane();
          I = new javax.swing.JTable();
          cancelar = new javax.swing.JButton();
          jScrollPane5 = new javax.swing.JScrollPane();
          outTable = new javax.swing.JTable();
          jScrollPane7 = new javax.swing.JScrollPane();
          inTable = new javax.swing.JTable();
          inImage = new javax.swing.JButton();
          OutImage = new javax.swing.JButton();
          removerIn = new javax.swing.JButton();
          removerOut = new javax.swing.JButton();
          jScrollPane1 = new javax.swing.JScrollPane();
          canais = new javax.swing.JTable();
          imagem = new javax.swing.JLabel();
          verification = new javax.swing.JButton();
          ticFDR = new javax.swing.JLabel();
          addCC = new javax.swing.JButton();
          removerCC = new javax.swing.JButton();
  
          setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
          setMinimumSize(new java.awt.Dimension(760, 695));
          addWindowListener(new java.awt.event.WindowAdapter() {
              public void windowActivated(java.awt.event.WindowEvent evt) {
                  formWindowActivated(evt);
              }
              public void windowClosed(java.awt.event.WindowEvent evt) {
                  formWindowClosed(evt);
              }
          });
  
          nameContract.setText("Nome:");
  
          nome.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  nomeActionPerformed(evt);
              }
          });
  
          behavior.setText("Comportamento:");
  
          channels.setText("Canais:");
  
          concluir.setText("Concluir");
          concluir.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  concluirActionPerformed(evt);
              }
          });
  
          write.setText("Escrever Comportamento");
          write.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  writeActionPerformed(evt);
              }
          });
  
          R.setModel(tmTipo2);
          R.addMouseListener(new java.awt.event.MouseAdapter() {
              public void mouseClicked(java.awt.event.MouseEvent evt) {
                  RMouseClicked(evt);
              }
          });
          jScrollPane6.setViewportView(R);
  
          C.setModel(tcTipo);
          jScrollPane2.setViewportView(C);
  
          I.setModel(tiTipo);
          jScrollPane3.setViewportView(I);
  
          cancelar.setText("Cancelar");
          cancelar.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  cancelarActionPerformed(evt);
              }
          });
  
          outTable.setModel(toutTipo);
          jScrollPane5.setViewportView(outTable);
  
          inTable.setModel(tinTipo);
          jScrollPane7.setViewportView(inTable);
  
          inImage.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  inImageActionPerformed(evt);
              }
          });
  
          OutImage.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  OutImageActionPerformed(evt);
              }
          });
  
          removerIn.setText("remover");
          removerIn.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  removerInActionPerformed(evt);
              }
          });
  
          removerOut.setText("remover");
          removerOut.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  removerOutActionPerformed(evt);
              }
          });
  
          canais.setModel(tmTipo1);
          canais.addMouseListener(new java.awt.event.MouseAdapter() {
              public void mouseClicked(java.awt.event.MouseEvent evt) {
                  canaisMouseClicked(evt);
              }
          });
          jScrollPane1.setViewportView(canais);
  
          imagem.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
          imagem.addMouseListener(new java.awt.event.MouseAdapter() {
              public void mouseClicked(java.awt.event.MouseEvent evt) {
                  imagemMouseClicked(evt);
              }
          });
  
          verification.setText("verificação I/O Process");
          verification.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  verificationActionPerformed(evt);
              }
          });
  
          addCC.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  addCCActionPerformed(evt);
              }
          });
  
          removerCC.setText("remover");
          removerCC.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent evt) {
                  removerCCActionPerformed(evt);
              }
          });
  
          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
          getContentPane().setLayout(layout);
          layout.setHorizontalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(layout.createSequentialGroup()
                  .addContainerGap()
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                      .addGroup(layout.createSequentialGroup()
                          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                              .addGroup(layout.createSequentialGroup()
                                  .addComponent(nameContract)
                                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                  .addComponent(nome, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
                              .addGroup(layout.createSequentialGroup()
                                  .addComponent(behavior)
                                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                  .addComponent(write)
                                  .addGap(18, 18, 18)
                                  .addComponent(imagem)
                                  .addGap(135, 135, 135)
                                  .addComponent(verification)
                                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                  .addComponent(ticFDR, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)))
                          .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                      .addGroup(layout.createSequentialGroup()
                          .addComponent(channels)
                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                              .addGroup(layout.createSequentialGroup()
                                  .addGap(0, 0, Short.MAX_VALUE)
                                  .addComponent(cancelar)
                                  .addGap(18, 18, 18)
                                  .addComponent(concluir)
                                  .addGap(28, 28, 28))
                              .addGroup(layout.createSequentialGroup()
                                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                      .addGroup(layout.createSequentialGroup()
                                          .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 256, javax.swing.GroupLayout.PREFERRED_SIZE)
                                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                          .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 288, javax.swing.GroupLayout.PREFERRED_SIZE))
                                      .addGroup(layout.createSequentialGroup()
                                          .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)
                                          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                              .addGroup(layout.createSequentialGroup()
                                                  .addGap(37, 37, 37)
                                                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                      .addComponent(removerIn, javax.swing.GroupLayout.Alignment.TRAILING)
                                                      .addComponent(removerOut, javax.swing.GroupLayout.Alignment.TRAILING)))
                                              .addGroup(layout.createSequentialGroup()
                                                  .addGap(18, 18, 18)
                                                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                      .addComponent(OutImage, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                      .addComponent(inImage, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                      .addGroup(layout.createSequentialGroup()
                                                          .addGap(19, 19, 19)
                                                          .addComponent(removerCC))
                                                      .addComponent(addCC, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                              .addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.TRAILING)
                                              .addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 473, Short.MAX_VALUE)
                                              .addComponent(jScrollPane7))))
                                  .addContainerGap())))))
          );
          layout.setVerticalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(layout.createSequentialGroup()
                  .addContainerGap()
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                      .addComponent(nameContract)
                      .addComponent(nome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                      .addGroup(layout.createSequentialGroup()
                          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                              .addComponent(ticFDR, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                              .addComponent(verification)
                              .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                  .addComponent(behavior)
                                  .addComponent(write)
                                  .addComponent(imagem)))
                          .addGap(18, 18, 18)
                          .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                              .addGroup(layout.createSequentialGroup()
                                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                      .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
                                      .addGroup(layout.createSequentialGroup()
                                          .addGap(31, 31, 31)
                                          .addComponent(addCC, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                          .addComponent(removerCC)))
                                  .addGap(34, 34, 34)
                                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                      .addGroup(layout.createSequentialGroup()
                                          .addComponent(inImage, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                          .addComponent(removerIn))
                                      .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE))
                                  .addGap(36, 36, 36)
                                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                      .addGroup(layout.createSequentialGroup()
                                          .addGap(6, 6, 6)
                                          .addComponent(OutImage, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                                          .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                          .addComponent(removerOut))
                                      .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 108, javax.swing.GroupLayout.PREFERRED_SIZE)))
                              .addComponent(channels)
                              .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                          .addGap(18, 18, 18)
                          .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))
                      .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))
                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                      .addComponent(cancelar)
                      .addComponent(concluir))
                  .addContainerGap())
          );
  
          pack();
      }// </editor-fold>//GEN-END:initComponents
  
      private void concluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_concluirActionPerformed
          if (/*!b.equals("")&&*/!nome.getText().equals("")/*&&!channel.isEmpty()*/) {
              if (isNameFree()) {
                  if (isAllProtocolsImplemented()) {
                      int local;
                      if (edicao == false) {
                          listas.getContractList().add(new Contract());
                          local = listas.getContractList().size() - 1;
                      } else {
                          local = this.local;
                      }
                      listas.getContractList().get(local).setName(nome.getText());
                      listas.getContractList().get(local).setBehavior(contrato.getBehavior());
  
  
                      editando = -1;
  
                      TelaInicial.aberto = false;
  
                      listas.getContractList().get(local).setChannel(contrato.getChannel());
                      listas.getContractList().get(local).setIn(contrato.getIn());
                      listas.getContractList().get(local).setOut(contrato.getOut());
                      listas.getContractList().get(local).setEvents(contrato.getEvents());
                      listas.getContractList().get(local).setFlag(contrato.getFlag());
                      listas.getContractList().get(local).setProtocolos(protocols);
                      System.out.println("contratos   " + protocols);
                  } else {
                      int retorno = JOptionPane.showConfirmDialog(null, "This contract is missing some protocols and dual-protocols for some channels...
  For this reason, you will not be able to use these channels in any composition rule. 
  Do you want to continue?");
                      if (retorno == 0) {
                          int local;
                          if (edicao == false) {
                              listas.getContractList().add(new Contract());
                              local = listas.getContractList().size() - 1;
                          } else {
                              local = this.local;
                          }
                          listas.getContractList().get(local).setName(nome.getText());
                          listas.getContractList().get(local).setBehavior(contrato.getBehavior());
  
  
                          editando = -1;
  
                          TelaInicial.aberto = false;
  
                          listas.getContractList().get(local).setChannel(contrato.getChannel());
                          listas.getContractList().get(local).setIn(contrato.getIn());
                          listas.getContractList().get(local).setOut(contrato.getOut());
                          listas.getContractList().get(local).setEvents(contrato.getEvents());
                          listas.getContractList().get(local).setFlag(contrato.getFlag());
                          listas.getContractList().get(local).setProtocolos(contrato.getProtocolos());
                          System.out.println("contratos   " + protocols);
  
  
  
                      }
  
                  }
                  System.out.println("
  
  in em contratos...");
                  for (int i = 0; i < contrato.getIn().size(); i++) {
                      System.out.println(contrato.getIn().get(i).getChannel().getName());
                  }
  
                  System.out.println("
  
  out em contratos...");
                  for (int i = 0; i < contrato.getOut().size(); i++) {
                      System.out.println(contrato.getOut().get(i).getChannel().getName());
                  }
  
                  System.out.println("
  
  Channel em contratos...");
                  for (int i = 0; i < contrato.getChannel().size(); i++) {
                      System.out.println(contrato.getChannel().get(i).getName());
                  }
  
                  System.out.println("
  
  events em contratos...");
                  for (int i = 0; i < contrato.getEvents().size(); i++) {
                      System.out.println(contrato.getEvents().get(i).getEvento());
                  }
  
                  System.out.println("
  
  protocolos em contratos...");
                  for (int i = 0; i < contrato.getProtocolos().size(); i++) {
                      System.out.println(contrato.getProtocolos().get(i).getCanal());
                  }
  
                  this.dispose();
  
              } else {
                  JOptionPane.showMessageDialog(null, "nome de contrato já existe...");
              }
          } else {
              JOptionPane.showMessageDialog(null, "informações faltando, complete antes de concluir");
          }
      }//GEN-LAST:event_concluirActionPerformed
  
      private void nomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nomeActionPerformed
      }//GEN-LAST:event_nomeActionPerformed
  
      private void writeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_writeActionPerformed
  
          if (aberto == false) {
              if (!nome.getText().equals("") && !nome.getText().equals(null)) {
                  if (contrato.getBehavior().equals("")) {
                      contrato.setBehavior(nome.getText() + " = ");
                      System.out.println("setando contrato...");
                  }
                  ContractGUI.aberto = true;
                  new BehaviorGUI(inter, b, contrato).setVisible(true);
                  ticFDR.setIcon(iconl);
  
              } else {
                  ContractGUI.aberto = false;
                  JOptionPane.showMessageDialog(null, "Você precisa de um nome antes de escrever o comportamento...");
              }
          } else {
              ContractGUI.aberto = false;
              JOptionPane.showMessageDialog(null, "já existe uma janela aberta...");
          }
  
          mostrarCanaisR();
  
      }//GEN-LAST:event_writeActionPerformed
  
      private void cancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarActionPerformed
          editando = -1;
          TelaInicial.aberto = false;
  
          contrato.setBehavior("");
          this.dispose();
      }//GEN-LAST:event_cancelarActionPerformed
  
      private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
          //listaContratos.editando = false;
  
          TelaInicial.aberto = false;
      }//GEN-LAST:event_formWindowClosed
  
      private void inImageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_inImageActionPerformed
  
          if (this.canais.getSelectedRow() > -1) {
              ticFDR.setIcon(iconl);
              new InsertEventGUI(inter, listas.getChannelList().get(this.canais.getSelectedRow()), contrato, listas, "in").setVisible(true);
              if (verifica(listas.getChannelList().get(this.canais.getSelectedRow()).getName(), inlist) && verifica(listas.getChannelList().get(this.canais.getSelectedRow()).getName(), outlist)) {
  
                  //channel.add(new Channel());
                  //channel.get(channel.size() - 1).setName(listas.getChannelList().get(this.canais.getSelectedRow()).getName());
                  //channel.get(channel.size() - 1).setType(listas.getChannelList().get(this.canais.getSelectedRow()).getType());
                  //channel.get(channel.size() - 1).setFlag("in");
                  // fazer os mostrar...
                  mostrarTabelas();
              } else {
                  JOptionPane.showMessageDialog(null, "Esse canal ja esta sendo utilizado...");
              }
              if (contrato.getBehavior() != "") {
                  //contrato.setBehavior(b);
                  //contrato.setIn(inlist);
                  //contrato.setOut(outlist);
                  //contrato.setChannel(listas.getChannelList());
                  teste();
              }
          }
      }//GEN-LAST:event_inImageActionPerformed
  
      private void OutImageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OutImageActionPerformed
  
          if (this.canais.getSelectedRow() > -1) {
              ticFDR.setIcon(iconl);
              new InsertEventGUI(inter, listas.getChannelList().get(this.canais.getSelectedRow()), contrato, listas, "out").setVisible(true);
              if (verifica(listas.getChannelList().get(this.canais.getSelectedRow()).getName(), outlist) && verifica(listas.getChannelList().get(this.canais.getSelectedRow()).getName(), inlist)) {
  
                  //channel.add(new Channel());
                  //channel.get(channel.size() - 1).setName(listas.getChannelList().get(this.canais.getSelectedRow()).getName());
                  //channel.get(channel.size() - 1).setType(listas.getChannelList().get(this.canais.getSelectedRow()).getType());
                  //channel.get(channel.size() - 1).setFlag("out");
                  // fazer os mostrar...
                  mostrarTabelas();
  
              } else {
  
                  JOptionPane.showMessageDialog(null, "Esse canal ja esta sendo utilizado...");
              }
              if (contrato.getBehavior() != "") {
                  //contrato.setBehavior(b);
                  //contrato.setIn(inlist);
                  //contrato.setOut(outlist);
                  //contrato.setChannel(listas.getChannelList());
                  teste();
              }
          }
  
      }//GEN-LAST:event_OutImageActionPerformed
  
      private void removerInActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removerInActionPerformed
          if (inTable.getSelectedRow() > -1) {
              contrato.getIn().remove(inTable.getSelectedRow());
              mostrarIn();
          }
      }//GEN-LAST:event_removerInActionPerformed
  
      private void removerOutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removerOutActionPerformed
          if (outTable.getSelectedRow() > -1) {
              contrato.getOut().remove(outTable.getSelectedRow());
              mostrarOut();
          }
      }//GEN-LAST:event_removerOutActionPerformed
  
      private void imagemMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_imagemMouseClicked
          teste();
          //mudarIcone();
          JOptionPane.showMessageDialog(null, resultado);
  
  
      }//GEN-LAST:event_imagemMouseClicked
  
      private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
  
          contrato.setName(nome.getText());
          //contrato.setBehavior(b);
  
          if (contrato.getBehavior() != "") {
  
  
              //contrato.setBehavior(b);
              //contrato.setChannel(listas.getChannelList());
              teste();
          }
          mostrarTabelas();
          //System.out.println(inlist);
  
      }//GEN-LAST:event_formWindowActivated
  
      private void verificationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_verificationActionPerformed
          //try {
              
              new Thread (){
                  public void run(){
                      Barra b;
                      try {
                          b = new Barra();
                      
  
  
                      b.criarBarra(2);
  
  
                      
  
                      b.aumentar("carregando");
  
                      ArrayList<FDRResult> r = FDRResult();
                      b.aumentar("carregando");
                      b.finalizar();
                      new ShowResultIOProcessGUI(inter, r, "FDR").setVisible(true);
                      } catch (InterruptedException ex) {
                          Logger.getLogger(ContractGUI.class.getName()).log(Level.SEVERE, null, ex);
                      }
                  }
              }.start();
  
  
              
              // TODO add your handling code here:
  //        } catch (InterruptedException ex) {
  //            Logger.getLogger(ContractGUI.class.getName()).log(Level.SEVERE, null, ex);
  //        }
      }//GEN-LAST:event_verificationActionPerformed
  
      private void canaisMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_canaisMouseClicked
          // TODO add your handling code here:
      }//GEN-LAST:event_canaisMouseClicked
  
      private void RMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_RMouseClicked
          if (evt.getClickCount() == 2) {
              new ProtocolsGUI(contrato.getProtocolos(), listas, R.getSelectedRow()).setVisible(true);
          } else {
          }// TODO add your handling code here:
      }//GEN-LAST:event_RMouseClicked
  
      private void addCCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addCCActionPerformed
          if (this.canais.getSelectedRow() > -1) {
              new InsertEventGUI(inter, listas.getChannelList().get(this.canais.getSelectedRow()), contrato, listas, "cc").setVisible(true);
              mostrarTabelas();
  
          }
          // TODO add your handling code here:
      }//GEN-LAST:event_addCCActionPerformed
  
      private void removerCCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removerCCActionPerformed
          if (R.getSelectedRow() > -1) {
              contrato.getProtocolos().remove(R.getSelectedRow());
              mostrarTabelas();
          }
          // TODO add your handling code here:
      }//GEN-LAST:event_removerCCActionPerformed
  
      public ArrayList<FDRResult> FDRResult() {
          CSPVerificationContract v = new CSPVerificationContract(contrato, listas);
          ArrayList<FDRResult> r = new ArrayList<FDRResult>();
          r = v.verificaContractIsIOprocess();
  
          if (isResultTrue(r)) {
              // System.out.println("entrou aqui...");
              ticFDR.setIcon(iconv);
              contrato.setFlag(true);
              //ticFDR.setText("tic");
          } else {
              ticFDR.setIcon(iconx);
              contrato.setFlag(false);
              //ticFDR.setText("x");
          }
  
          return r;
      }
  
      public boolean isAllProtocolsImplemented() {
          if (contrato.getChannel().size() == protocols.size()) {
              return true;
          }
          return false;
      }
  
      public boolean isResultTrue(ArrayList<FDRResult> r) {
          for (int i = 0; i < r.size(); i++) {
              if ((!r.get(i).getResultado())) {
                  return false;
              }
          }
  
  
          return true;
      }
  
      public void instanciarProtocolos(int i) {
          for (int j = 0; j < i; j++) {
          }
      }
  
      public void teste() {
  
          //contrato.setBehavior(b);
          CSPVerificationContract cspv = new CSPVerificationContract(contrato, listas);
          cr = cspv.verificaBehaviorChecker();
          //System.out.println("o/ "+cr.getResultado());
          if (cr.getResultado()) {
              imagem.setIcon(iconv);
              imagem.setText("okay");
              resultado = cr.getMensagem();
          }
          if (!cr.getResultado()) {
              imagem.setIcon(iconx);
              imagem.setText("errado");
              resultado = cr.getMensagem();
          }
  
      }
  
      public boolean verifica(String s, LinkedList<EventChannel> m) {
          for (int j = 0; j < m.size(); j++) {
              if (m.get(j).getEvento().equals(s)) {
                  return false;
              }
  
          }
          return true;
  
      }
  
      public boolean VerificaI(String t) {
          for (int j = 0; j < temp.size(); j++) {
              if (temp.get(j) == t) {
                  return false;
              }
          }
          return true;
      }
  
      public void mudarIcone() {
  
          if (b.equals(null)) {
              ver = "!";
          }
  
          if (ver.equals("!")) {
  
              // System.out.println("!");
              imagem.setIcon(iconl);
  
          } else {
              if (ver.equals("v")) {
                  //   System.out.println("v");
                  imagem.setIcon(iconv);
              } else {
                  if (ver.equals("x")) {
  
                      //     System.out.println("x");
                      imagem.setIcon(iconx);
                  }
              }
          }
          imagem.setVisible(true);
      }
  
      public void mostrarIn() {
          while (inTable.getRowCount() > 0) {
              tinTipo.removeRow(0);
          }
  
          if (contrato.getIn().isEmpty()) {
          } else {
  
              String[] linha = new String[]{null};
              for (int j = 0; j < contrato.getIn().size(); j++) {
                  if (VerificaI(contrato.getIn().get(j).getEvento())) {
                      tinTipo.addRow(linha);
                      tinTipo.setValueAt(contrato.getIn().get(j).getEvento(), j, 0);
                  }
              }
          }
      }
  
      public void mostrarOut() {
          while (outTable.getRowCount() > 0) {
              toutTipo.removeRow(0);
          }
  
          if (contrato.getOut().isEmpty()) {
          } else {
  
              String[] linha = new String[]{null};
              for (int j = 0; j < contrato.getOut().size(); j++) {
                  if (VerificaI(contrato.getOut().get(j).getEvento())) {
                      toutTipo.addRow(linha);
                      toutTipo.setValueAt(contrato.getOut().get(j).getEvento(), j, 0);
  
                  }
              }
          }
      }
  
      public void mostrarInterface() {
          while (I.getRowCount() > 0) {
              tiTipo.removeRow(0);
          }
          temp.clear();
          if (contrato.getChannel().isEmpty()) {
          } else {
  
              String[] linha = new String[]{null, null};
              for (int j = 0; j < contrato.getChannel().size(); j++) {
                  for (int i = 0; i < contrato.getChannel().get(j).getType().size(); i++) {
                      if (VerificaI(contrato.getChannel().get(j).getType().get(i).getNome())) {
  
                          temp.add(contrato.getChannel().get(j).getType().get(i).getNome());
                      }
                  }
              }
              for (int j = 0; j < temp.size(); j++) {
                  tiTipo.addRow(linha);
                  tiTipo.setValueAt(temp.get(j), j, 0);
              }
          }
      }
  
      public void mostrarConjuntoCanais() {
          mostrarInterface();
          while (C.getRowCount() > 0) {
              tcTipo.removeRow(0);
          }
          if (contrato.getChannel().isEmpty()) {
          } else {
  
              String[] linha = new String[]{null, null};
              for (int j = 0; j < contrato.getChannel().size(); j++) {
                  tcTipo.addRow(linha);
                  tcTipo.setValueAt(contrato.getChannel().get(j).getName(), j, 0);
  
              }
          }
      }
  
      public void mostrarCanaisR() {
          while (R.getRowCount() > 0) {
              tmTipo2.removeRow(0);
          }
  
          if (contrato.getProtocolos().isEmpty()) {
          } else {
  
              String[] linha = new String[]{null, null, null};
              for (int j = 0; j < contrato.getProtocolos().size(); j++) {
                  tmTipo2.addRow(linha);
                  tmTipo2.setValueAt(contrato.getProtocolos().get(j).getCc(), j, 0);
                  tmTipo2.setValueAt(takeProtocol(contrato.getProtocolos().get(j)), j, 1);
                  tmTipo2.setValueAt(takeDualProtocol(contrato.getProtocolos().get(j)), j, 2);
  
              }
          }
      }
  
      public void mostrarCanais() {
          while (canais.getRowCount() > 0) {
              tmTipo1.removeRow(0);
          }
          if (listas.getChannelList().isEmpty()) {
          } else {
  
              String[] linha = new String[]{null};
              for (int j = 0; j < listas.getChannelList().size(); j++) {
                  tmTipo1.addRow(linha);
                  tmTipo1.setValueAt(listas.getChannelList().get(j).getName(), j, 0);
  
              }
          }
      }
  
      public void mostrarTabelas() {
          mostrarIn();
          mostrarOut();
          mostrarInterface();
          mostrarConjuntoCanais();
          mostrarCanaisR();
          mostrarCanais();
      }
  
      private void verificaEdicao() {
          if (edicao == true) {
              nome.setText(listas.getContractList().get(local).getName());
              contrato.setChannel(listas.getContractList().get(local).getChannel());
              contrato.setIn(listas.getContractList().get(local).getIn());
              contrato.setOut(listas.getContractList().get(local).getOut());
              contrato.setBehavior(listas.getContractList().get(local).getBehavior());
              contrato.setFlag(false);
              contrato.setProtocolos(listas.getContractList().get(local).getProtocolos());
          }
  
      }
  
      public boolean isNameFree() {
          for (int i = 0; i < listas.getContractList().size(); i++) {
              if (nome.equals(listas.getContractList().get(i).getName()) && i != local) {
                  return false;
              }
          }
          return true;
  
  
      }
  
      public String takeProtocol(Protocols c) {
  
          if (!c.getProtocol().equals("")) {
              return "ok";
          }
  
  
          return "?";
      }
  
      public String takeDualProtocol(Protocols c) {
          if (!c.getDualProtocol().equals("")) {
              return "ok";
          }
  
  
          return "?";
      }
  
      public void bundleButtons() {
          nameContract.setText(inter.retornarMensagem("COD0032"));
          channels.setText(inter.retornarMensagem("COD0006"));
          write.setText(inter.retornarMensagem("COD0040"));
          removerIn.setText(inter.retornarMensagem("COD0021"));
          removerOut.setText(inter.retornarMensagem("COD0021"));
          cancelar.setText(inter.retornarMensagem("COD0026"));
          concluir.setText(inter.retornarMensagem("COD0025"));
          behavior.setText(inter.retornarMensagem("COD0027"));
          verification.setText(inter.retornarMensagem("COD0041"));
      }
      // Variables declaration - do not modify//GEN-BEGIN:variables
      private javax.swing.JTable C;
      private javax.swing.JTable I;
      private javax.swing.JButton OutImage;
      private javax.swing.JTable R;
      private javax.swing.JButton addCC;
      private javax.swing.JLabel behavior;
      private javax.swing.JTable canais;
      private javax.swing.JButton cancelar;
      private javax.swing.JLabel channels;
      private javax.swing.JButton concluir;
      private javax.swing.JLabel imagem;
      private javax.swing.JButton inImage;
      private javax.swing.JTable inTable;
      private javax.swing.JScrollPane jScrollPane1;
      private javax.swing.JScrollPane jScrollPane2;
      private javax.swing.JScrollPane jScrollPane3;
      private javax.swing.JScrollPane jScrollPane5;
      private javax.swing.JScrollPane jScrollPane6;
      private javax.swing.JScrollPane jScrollPane7;
      private javax.swing.JLabel nameContract;
      private javax.swing.JTextField nome;
      private javax.swing.JTable outTable;
      private javax.swing.JButton removerCC;
      private javax.swing.JButton removerIn;
      private javax.swing.JButton removerOut;
      private javax.swing.JLabel ticFDR;
      private javax.swing.JButton verification;
      private javax.swing.JButton write;
      // End of variables declaration//GEN-END:variables
  }