/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jfrmNuevaExcepcion.java
 *
 * Created on 02-dic-2011, 13:24:09
 */

package vista;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.MutableTreeNode;
import modelo.*;

/**
 *
 * @author Carmen
 */
public class jfrmNuevaExcepcion extends javax.swing.JFrame {
    DocumentoReq auxDocPpal;
    jfrmPrincipal jaux;
    PasoCU nuevoPasoCU;
    MutableTreeNode auxinsertNode;
    int auxinsertIndex;

    /** Creates new form jfrmNuevaExcepcion */
    public jfrmNuevaExcepcion(jfrmPrincipal jf, DocumentoReq docPpal, MutableTreeNode insertNode, int insertIndex, PasoCU pasoUso ) {
        auxinsertNode=insertNode;
        auxinsertIndex=insertIndex;
        jaux=jf;
        auxDocPpal=docPpal;
        nuevoPasoCU = pasoUso;
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanelCondicionExcepcion = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtxaCondicionExcepcion = new javax.swing.JTextArea();
        jLabel2 = new javax.swing.JLabel();
        jcboxTerminacionExcepcion = new javax.swing.JComboBox();
        jPanelAccionExcepcion = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jradAccionActorExcepcion = new javax.swing.JRadioButton();
        jradAccionInclusionExtensionExcepcion = new javax.swing.JRadioButton();
        jcboxActorExcepcion = new javax.swing.JComboBox();
        jcboxCUExcepcion = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtxaAccionRealizadaSistemaExcepcion = new javax.swing.JTextArea();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jtxtValorExcepcion = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jtxtUnidad = new javax.swing.JTextField();
        jtxttipoAccion = new javax.swing.JTextField();
        jbtnaceptar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Condición de la excepción");

        jtxaCondicionExcepcion.setColumns(20);
        jtxaCondicionExcepcion.setRows(5);
        jScrollPane1.setViewportView(jtxaCondicionExcepcion);

        jLabel2.setText("Terminación de la excepción");

        jcboxTerminacionExcepcion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        javax.swing.GroupLayout jPanelCondicionExcepcionLayout = new javax.swing.GroupLayout(jPanelCondicionExcepcion);
        jPanelCondicionExcepcion.setLayout(jPanelCondicionExcepcionLayout);
        jPanelCondicionExcepcionLayout.setHorizontalGroup(
            jPanelCondicionExcepcionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelCondicionExcepcionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelCondicionExcepcionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanelCondicionExcepcionLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 335, Short.MAX_VALUE))
                    .addComponent(jLabel1)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanelCondicionExcepcionLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jcboxTerminacionExcepcion, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap(57, Short.MAX_VALUE))
        );
        jPanelCondicionExcepcionLayout.setVerticalGroup(
            jPanelCondicionExcepcionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelCondicionExcepcionLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 152, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jcboxTerminacionExcepcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(38, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Condición/Terminación", jPanelCondicionExcepcion);

        jLabel3.setText("Tipo de acción");

        jradAccionActorExcepcion.setText("Acción de un actor");
        jradAccionActorExcepcion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jradAccionActorExcepcionActionPerformed(evt);
            }
        });

        jradAccionInclusionExtensionExcepcion.setText("Inclusión/extensión");

        jcboxActorExcepcion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jcboxCUExcepcion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel4.setText("Acción(es) es realizada(s) por el sistema/ un actor ");

        jtxaAccionRealizadaSistemaExcepcion.setColumns(20);
        jtxaAccionRealizadaSistemaExcepcion.setRows(5);
        jScrollPane2.setViewportView(jtxaAccionRealizadaSistemaExcepcion);

        jLabel5.setText("Frecuencia");

        jLabel6.setText("Valor");

        jtxtValorExcepcion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtValorExcepcionActionPerformed(evt);
            }
        });

        jLabel7.setText("Unidad");

        javax.swing.GroupLayout jPanelAccionExcepcionLayout = new javax.swing.GroupLayout(jPanelAccionExcepcion);
        jPanelAccionExcepcion.setLayout(jPanelAccionExcepcionLayout);
        jPanelAccionExcepcionLayout.setHorizontalGroup(
            jPanelAccionExcepcionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAccionExcepcionLayout.createSequentialGroup()
                .addGroup(jPanelAccionExcepcionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelAccionExcepcionLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanelAccionExcepcionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 392, Short.MAX_VALUE)
                            .addComponent(jLabel3)
                            .addGroup(jPanelAccionExcepcionLayout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addGroup(jPanelAccionExcepcionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jradAccionActorExcepcion)
                                    .addComponent(jradAccionInclusionExtensionExcepcion))
                                .addGap(29, 29, 29)
                                .addGroup(jPanelAccionExcepcionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jcboxCUExcepcion, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jcboxActorExcepcion, 0, 181, Short.MAX_VALUE)))
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addGroup(jPanelAccionExcepcionLayout.createSequentialGroup()
                                .addGap(16, 16, 16)
                                .addComponent(jLabel6)
                                .addGap(18, 18, 18)
                                .addComponent(jtxtValorExcepcion, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(72, 72, 72)
                                .addComponent(jLabel7)
                                .addGap(18, 18, 18)
                                .addComponent(jtxtUnidad, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanelAccionExcepcionLayout.createSequentialGroup()
                        .addGap(53, 53, 53)
                        .addComponent(jtxttipoAccion, javax.swing.GroupLayout.PREFERRED_SIZE, 226, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanelAccionExcepcionLayout.setVerticalGroup(
            jPanelAccionExcepcionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAccionExcepcionLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtxttipoAccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelAccionExcepcionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jradAccionActorExcepcion)
                    .addComponent(jcboxActorExcepcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelAccionExcepcionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jradAccionInclusionExtensionExcepcion)
                    .addComponent(jcboxCUExcepcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 17, Short.MAX_VALUE)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelAccionExcepcionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtValorExcepcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7)
                    .addComponent(jtxtUnidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15))
        );

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

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

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 417, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(181, 181, 181)
                        .addComponent(jbtnaceptar)))
                .addContainerGap(21, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
                .addComponent(jbtnaceptar)
                .addGap(20, 20, 20))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 448, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 381, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );

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

    private void jradAccionActorExcepcionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jradAccionActorExcepcionActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jradAccionActorExcepcionActionPerformed

    private void jbtnaceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnaceptarActionPerformed
        //Hay que añadir actor y caso de uso
        ExcepcionCU anadirExcepcion= nuevoPasoCU.anadirExcepcion(jtxaCondicionExcepcion.getText(),jcboxTerminacionExcepcion.getName(),jtxttipoAccion.getText(),jtxaAccionRealizadaSistemaExcepcion.getText(),Integer.parseInt(jtxtValorExcepcion.getText()),jtxtUnidad.getText());
        MutableTreeNode node=new DefaultMutableTreeNode("Nueva_Excepcion " + jtxaCondicionExcepcion.getText());
        DefaultTreeModel model =(DefaultTreeModel) jaux.getJtreDocumento().getModel();
        model.insertNodeInto(node, auxinsertNode, auxinsertIndex);
        this.setEnabled(false);
        jaux.setEnabled(true);
        this.dispose();
    
}//GEN-LAST:event_jbtnaceptarActionPerformed

    private void jtxtValorExcepcionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtxtValorExcepcionActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtxtValorExcepcionActionPerformed

    /**
    * @param args the command line arguments
    */
   /* public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new jfrmNuevaExcepcion().setVisible(true);
            }
        });
    }
*/
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanelAccionExcepcion;
    private javax.swing.JPanel jPanelCondicionExcepcion;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JButton jbtnaceptar;
    private javax.swing.JComboBox jcboxActorExcepcion;
    private javax.swing.JComboBox jcboxCUExcepcion;
    private javax.swing.JComboBox jcboxTerminacionExcepcion;
    private javax.swing.JRadioButton jradAccionActorExcepcion;
    private javax.swing.JRadioButton jradAccionInclusionExtensionExcepcion;
    private javax.swing.JTextArea jtxaAccionRealizadaSistemaExcepcion;
    private javax.swing.JTextArea jtxaCondicionExcepcion;
    private javax.swing.JTextField jtxtUnidad;
    private javax.swing.JTextField jtxtValorExcepcion;
    private javax.swing.JTextField jtxttipoAccion;
    // End of variables declaration//GEN-END:variables

}
