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 = 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 lista = new LinkedList(); LinkedList temp = new LinkedList(); static int editando = -1; static boolean aberto = false; LinkedList inlist = new LinkedList(); LinkedList 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 = new LinkedList(); @SuppressWarnings("unchecked") // //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(); }// //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...\nFor this reason, you will not be able to use these channels in any composition rule. \nDo 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("\n\nin em contratos..."); for (int i = 0; i < contrato.getIn().size(); i++) { System.out.println(contrato.getIn().get(i).getChannel().getName()); } System.out.println("\n\nout em contratos..."); for (int i = 0; i < contrato.getOut().size(); i++) { System.out.println(contrato.getOut().get(i).getChannel().getName()); } System.out.println("\n\nChannel em contratos..."); for (int i = 0; i < contrato.getChannel().size(); i++) { System.out.println(contrato.getChannel().get(i).getName()); } System.out.println("\n\nevents em contratos..."); for (int i = 0; i < contrato.getEvents().size(); i++) { System.out.println(contrato.getEvents().get(i).getEvento()); } System.out.println("\n\nprotocolos 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 contrato.getIn().remove(inTable.getSelectedRow()); mostrarIn(); }//GEN-LAST:event_removerInActionPerformed private void removerOutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removerOutActionPerformed 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 { Barra b = new Barra(); b.criarBarra(2); Thread.sleep(2000); System.out.println("Primeira atualização:"); b.aumentar("teste"); Thread.sleep(2000); System.out.println("comecei fazer as coisa..."); ArrayList r = FDRResult(); System.out.println("acabei de fazer as coisa..."); System.out.println("Segunda atualização:"); b.aumentar("teste"); b.finalizar(); new ShowResultIOProcessGUI(inter, r, "FDR").setVisible(true); // 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() { CSPVerificationContract v = new CSPVerificationContract(contrato, listas); ArrayList r = new ArrayList(); 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 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 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 }