/*
 *      Luis Israel Diéguez Arjona
 *      Sonia Cejas Soria
 *      Sergio Cabello García
 *      María José González Cordero
 *
 *      Ingeniería del Software de Gestión II
 *      Ingeniería Técnica Informática de Gestión
 *      Universidad de Huelva
 */

package vista;

import java.util.Observable;
import java.util.Observer;
import modelo.Paso;





public class jfCasoUso_Paso extends javax.swing.JFrame implements Observer {
    // Formulario padre
    jfHome home;
    // Control del identificador
    String identCasoUsoPadre;
    String identPaso;
    // Control del Update de Observers
    int contadorEjecuciones = 0;





    public jfCasoUso_Paso() {
        initComponents();
        this.buttonGroup.add(jRadioButton_accionSistema);
        this.buttonGroup.add(jRadioButton_accionActor);
        this.buttonGroup.add(jRadioButton_inclusionExtension);
        jRadioButton_accionSistema.setSelected(true);
    }
    public jfCasoUso_Paso(jfHome home, String identCasoUsoPadre) {
        // Inicializo
        initComponents();
        this.buttonGroup.add(jRadioButton_accionSistema);
        this.buttonGroup.add(jRadioButton_accionActor);
        this.buttonGroup.add(jRadioButton_inclusionExtension);
        jRadioButton_accionSistema.setSelected(true);
        this.home = home;
        this.identCasoUsoPadre = identCasoUsoPadre;

        // Configura el identificador
        String ident = this.home.documentoRequisitos.getNuevoIdentificadorPaso (this.identCasoUsoPadre);
        identPaso = "UCP-" + ident;
    }




    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup = new javax.swing.ButtonGroup();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jCheckBox_esCondicional = new javax.swing.JCheckBox();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea_condicion = new javax.swing.JTextArea();
        jPanel2 = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        jRadioButton_accionSistema = new javax.swing.JRadioButton();
        jRadioButton_accionActor = new javax.swing.JRadioButton();
        jRadioButton_inclusionExtension = new javax.swing.JRadioButton();
        jComboBox_accionActor = new javax.swing.JComboBox();
        jComboBox_inclusionExtension = new javax.swing.JComboBox();
        jPanel8 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTextArea_acciones = new javax.swing.JTextArea();
        jPanel9 = new javax.swing.JPanel();
        jTextField_frecuencia = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jComboBox_frecuencia = new javax.swing.JComboBox();
        jPanel3 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea_comentarios = new javax.swing.JTextArea();
        jButton_aceptar = new javax.swing.JButton();
        jButton_cancelar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Tipo de paso"));
        jPanel4.setPreferredSize(new java.awt.Dimension(207, 54));

        jCheckBox_esCondicional.setText("Paso condicional");
        jCheckBox_esCondicional.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jCheckBox_esCondicionalItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jCheckBox_esCondicional)
                .addContainerGap(267, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jCheckBox_esCondicional)
                .addContainerGap(8, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Condición"));

        jTextArea_condicion.setColumns(20);
        jTextArea_condicion.setLineWrap(true);
        jTextArea_condicion.setRows(5);
        jTextArea_condicion.setEnabled(false);
        jScrollPane1.setViewportView(jTextArea_condicion);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Condición", jPanel1);

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("Tipo de acción"));

        jRadioButton_accionSistema.setText("Acción del sistema");
        jRadioButton_accionSistema.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jRadioButton_accionSistemaItemStateChanged(evt);
            }
        });

        jRadioButton_accionActor.setText("Acción de un actor");
        jRadioButton_accionActor.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jRadioButton_accionActorItemStateChanged(evt);
            }
        });

        jRadioButton_inclusionExtension.setText("Inclusión / extensión");
        jRadioButton_inclusionExtension.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jRadioButton_inclusionExtensionItemStateChanged(evt);
            }
        });

        jComboBox_accionActor.setEnabled(false);
        jComboBox_accionActor.setPreferredSize(new java.awt.Dimension(215, 20));

        jComboBox_inclusionExtension.setEnabled(false);
        jComboBox_inclusionExtension.setPreferredSize(new java.awt.Dimension(215, 20));

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jRadioButton_accionSistema)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jRadioButton_accionActor, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jRadioButton_inclusionExtension, javax.swing.GroupLayout.Alignment.LEADING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jComboBox_accionActor, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboBox_inclusionExtension, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(89, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jComboBox_accionActor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBox_inclusionExtension, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jRadioButton_accionSistema, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jRadioButton_accionActor)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRadioButton_inclusionExtension)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder("Acciones realizadas por el sistema / un actor"));

        jTextArea_acciones.setColumns(20);
        jTextArea_acciones.setLineWrap(true);
        jScrollPane3.setViewportView(jTextArea_acciones);

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder("Rendimiento"));
        jPanel9.setPreferredSize(new java.awt.Dimension(209, 54));

        jTextField_frecuencia.setPreferredSize(new java.awt.Dimension(30, 20));

        jLabel6.setText("veces al");

        jComboBox_frecuencia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "año", "mes", "semana", "día", "hora", "minuto", "segundo" }));
        jComboBox_frecuencia.setPreferredSize(new java.awt.Dimension(100, 20));

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTextField_frecuencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBox_frecuencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField_frecuencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jComboBox_frecuencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel9, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Acción", jPanel2);

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Comentarios"));

        jTextArea_comentarios.setColumns(20);
        jTextArea_comentarios.setLineWrap(true);
        jTextArea_comentarios.setRows(5);
        jScrollPane2.setViewportView(jTextArea_comentarios);

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 255, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Comentarios", jPanel3);

        jButton_aceptar.setText("Aceptar");
        jButton_aceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_aceptarActionPerformed(evt);
            }
        });

        jButton_cancelar.setText("Cancelar");
        jButton_cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_cancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(247, Short.MAX_VALUE)
                .addComponent(jButton_aceptar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton_cancelar)
                .addContainerGap())
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 413, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton_cancelar)
                    .addComponent(jButton_aceptar))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton_cancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_cancelarActionPerformed
        home.setEnabled(true);
        this.dispose();
}//GEN-LAST:event_jButton_cancelarActionPerformed
    private void jButton_aceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_aceptarActionPerformed
        Paso nuevoPaso = new Paso();
        boolean puedoCerrar = true;

        // Creo el paso
        nuevoPaso.setIdentificacion(identPaso);
        nuevoPaso.setEsCondicional(jCheckBox_esCondicional.isEnabled());
        nuevoPaso.setCondicion(jTextArea_condicion.getText());
        nuevoPaso.setAccionSistema(jRadioButton_accionSistema.isEnabled());
        nuevoPaso.setAccionActor(jRadioButton_accionActor.isEnabled());
        nuevoPaso.setInclusionExtension(jRadioButton_inclusionExtension.isEnabled());
        nuevoPaso.setDescripcionAccion(jTextArea_acciones.getText());
        if (!this.jTextField_frecuencia.getText().equals(""))
            nuevoPaso.setValorRendimiento(Integer.parseInt(this.jTextField_frecuencia.getText()));
        nuevoPaso.setUnidadRendimiento((String) jComboBox_frecuencia.getSelectedItem());    //Duda de que se haga asi.
        nuevoPaso.setComentario(jTextArea_comentarios.getText());

        // Nombre
        nuevoPaso.setNombre("");
        if (jCheckBox_esCondicional.isSelected()) {
            nuevoPaso.setNombre("Si " + this.jTextArea_condicion.getText() +", ");
        }
        if (jRadioButton_accionSistema.isEnabled() == true){
            nuevoPaso.setNombre(nuevoPaso.getNombre() + "el Sistema "
                    + this.jTextArea_acciones.getText()
                    + " " + this.jTextField_frecuencia.getText()
                    + " " + this.jComboBox_frecuencia.getSelectedItem().toString() + " ");
        }
        else if (jRadioButton_accionActor.isEnabled() == true){
            nuevoPaso.setNombre(nuevoPaso.getNombre() + "el actor "
                        + this.jComboBox_accionActor.getSelectedItem().toString()
                        + this.jTextArea_acciones.getText() + " " );
        }
        else if (jRadioButton_inclusionExtension.isEnabled() == true){
            nuevoPaso.setNombre(nuevoPaso.getNombre() + "se realiza el caso de uso "
                        + this.jComboBox_inclusionExtension.getSelectedItem().toString());
        }

        // Lo guardo y cierro
        if (puedoCerrar) {
            home.documentoRequisitos.addCasoUso_Paso(identCasoUsoPadre, nuevoPaso);
            // Cierro la ventana
            home.setEnabled(true);
            this.dispose();
        }
    }//GEN-LAST:event_jButton_aceptarActionPerformed
    private void jCheckBox_esCondicionalItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jCheckBox_esCondicionalItemStateChanged
        if (jCheckBox_esCondicional.isSelected()) {
            jTextArea_condicion.setEnabled(true);
            jTextArea_condicion.grabFocus();
        } else {
            jTextArea_condicion.setText("");
            jTextArea_condicion.setEnabled(false);
        }
    }//GEN-LAST:event_jCheckBox_esCondicionalItemStateChanged
    private void jRadioButton_accionSistemaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jRadioButton_accionSistemaItemStateChanged
        jComboBox_accionActor.setEnabled(false);
        jComboBox_inclusionExtension.setEnabled(false);
        jTextArea_acciones.setEnabled(true);
        jTextField_frecuencia.setEnabled(true);
        jComboBox_frecuencia.setEnabled(true);
    }//GEN-LAST:event_jRadioButton_accionSistemaItemStateChanged
    private void jRadioButton_accionActorItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jRadioButton_accionActorItemStateChanged
        jComboBox_accionActor.setEnabled(true);
        jComboBox_inclusionExtension.setEnabled(false);
        jTextArea_acciones.setEnabled(true);
        jTextField_frecuencia.setEnabled(false);
        jComboBox_frecuencia.setEnabled(false);
    }//GEN-LAST:event_jRadioButton_accionActorItemStateChanged
    private void jRadioButton_inclusionExtensionItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jRadioButton_inclusionExtensionItemStateChanged
        jComboBox_accionActor.setEnabled(false);
        jComboBox_inclusionExtension.setEnabled(true);
        jTextArea_acciones.setEnabled(false);
        jTextField_frecuencia.setEnabled(false);
        jComboBox_frecuencia.setEnabled(false);
    }//GEN-LAST:event_jRadioButton_inclusionExtensionItemStateChanged
    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
        home.setEnabled(true);
        this.dispose();
    }//GEN-LAST:event_formWindowClosed





    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new jfCasoUso_Paso().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup;
    private javax.swing.JButton jButton_aceptar;
    private javax.swing.JButton jButton_cancelar;
    private javax.swing.JCheckBox jCheckBox_esCondicional;
    private javax.swing.JComboBox jComboBox_accionActor;
    private javax.swing.JComboBox jComboBox_frecuencia;
    private javax.swing.JComboBox jComboBox_inclusionExtension;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JRadioButton jRadioButton_accionActor;
    private javax.swing.JRadioButton jRadioButton_accionSistema;
    private javax.swing.JRadioButton jRadioButton_inclusionExtension;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextArea jTextArea_acciones;
    private javax.swing.JTextArea jTextArea_comentarios;
    private javax.swing.JTextArea jTextArea_condicion;
    private javax.swing.JTextField jTextField_frecuencia;
    // End of variables declaration//GEN-END:variables



    

    public void update(Observable o, Object arg) {
            home.actualizarJTree();
            home.actualizarTextPane();
    }


}
