/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package GUI;
import CSP_ANALYSE.CSPVerificationContract;
import CSP_ANALYSE.CheckerResult;
import LOGIC.AuxiliarProcess;
import LOGIC.Contract;
import LOGIC.ObjectList;
import javax.swing.JOptionPane;
/**
*
* @author sarah
*/
public class AuxiliarProcessGUI extends javax.swing.JFrame {
/**
* Creates new form AuxiliarProcessGUI
*/
public AuxiliarProcessGUI(ObjectList listas, String comp) {
initComponents();
this.listas = listas;
csp.setText(comp);
}
String comportamento = "";
ObjectList listas;
CheckerResult cr = new CheckerResult();
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
csp = new javax.swing.JTextArea();
concluir = new javax.swing.JButton();
cancelar = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
csp.setColumns(20);
csp.setRows(5);
jScrollPane1.setViewportView(csp);
concluir.setText("concluir");
concluir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
concluirActionPerformed(evt);
}
});
cancelar.setText("cancelar");
cancelar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelarActionPerformed(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)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(cancelar)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(concluir)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(concluir)
.addComponent(cancelar))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void concluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_concluirActionPerformed
comportamento = csp.getText();
if(!comportamento.equals("")){
Contract contrato = new Contract();
contrato.setChannel(listas.getChannelList());
contrato.setType(listas.getTypeList());
contrato.setBehavior(comportamento);
CSPVerificationContract cspv = new CSPVerificationContract(contrato, listas);
cr = cspv.verificaBehaviorChecker();
if(cr.getResultado()){
listas.setProcessosAuxiliares(comportamento);
this.dispose();
}
else{
JOptionPane.showMessageDialog(null, "Não é possível concluir enquanto houver erros... \nErro: \n"+cr.getMensagem());
}
}
}//GEN-LAST:event_concluirActionPerformed
private void cancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarActionPerformed
this.dispose(); // TODO add your handling code here:
}//GEN-LAST:event_cancelarActionPerformed
/**
* @param args the command line arguments
*/
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelar;
private javax.swing.JButton concluir;
private javax.swing.JTextArea csp;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration//GEN-END:variables
}