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

/*
 * jfrmexcepcion.java
 *
 * Created on 26-nov-2011, 11:19:11
 */

package vista;

import javax.swing.JOptionPane;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.MutableTreeNode;
import modelo.ExcepcionCU;

/**
 *
 * @author jmnieves
 */
public class jfrmexcepcion extends javax.swing.JPanel {
    jfrmPrincipal jaux;
    MutableTreeNode auxinsertNode;
    int auxinsertIndex;

    /** Creates new form jfrmexcepcion */
    public jfrmexcepcion(jfrmPrincipal jvolver, MutableTreeNode insertNode, int insertIndex) {
        auxinsertNode=insertNode;
        auxinsertIndex=insertIndex;
        jaux=jvolver;
        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() {

        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();
        jradAccionSistemaExcepcion = new javax.swing.JRadioButton();
        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();
        jcboxUnidadExcepcion = new javax.swing.JComboBox();
        jtxtValorExcepcion = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jbtnaceptar = new javax.swing.JButton();

        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");

        jradAccionSistemaExcepcion.setText("Acción del sistema");

        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");

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

        jtxtValorExcepcion.setText("jTextField1");

        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()
                .addContainerGap()
                .addGroup(jPanelAccionExcepcionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelAccionExcepcionLayout.createSequentialGroup()
                        .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(jradAccionSistemaExcepcion)
                                    .addGroup(jPanelAccionExcepcionLayout.createSequentialGroup()
                                        .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))
                        .addContainerGap())
                    .addGroup(jPanelAccionExcepcionLayout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addComponent(jLabel6)
                        .addGap(18, 18, 18)
                        .addComponent(jtxtValorExcepcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 137, Short.MAX_VALUE)
                        .addComponent(jLabel7)
                        .addGap(18, 18, 18)
                        .addComponent(jcboxUnidadExcepcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(41, 41, 41))))
        );
        jPanelAccionExcepcionLayout.setVerticalGroup(
            jPanelAccionExcepcionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAccionExcepcionLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jradAccionSistemaExcepcion)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .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, 12, 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(jcboxUnidadExcepcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(jtxtValorExcepcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .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 layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 417, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(181, 181, 181)
                        .addComponent(jbtnaceptar)))
                .addContainerGap(21, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.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))
        );
    }// </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 newexcepcion= auxDocPpal.getCasodeUso.getpaso.nuevaexcepcion(jtxaCondicionExcepcion.getText(),jcboxTerminacionExcepcion.getText(),jradAccionSistemaExcepcion.isSelected(),jradAccionActorExcepcion.isSelected(),jradAccionInclusionExtensionExcepcion.isSelected(),jtxaAccionRealizadaSistemaExcepcion.getText(),Integer.parseInt(jtxtValorExcepcion.getText(),Integer.parseInt(jcboxUnidadExcepcion.getText());
        MutableTreeNode node=new DefaultMutableTreeNode("Nueva_Excepcion " + newexcepcion.newpaso());
        DefaultTreeModel model =(DefaultTreeModel) jfaux.getJtreDocumento().getModel();
        model.insertNodeInto(node, auxinsertNode, auxinsertIndex);
        mostrarmensaje("Insertada la Excepcion"+newexcepcion.getNombreCU());
        jfaux.setEnabled(true);
       // this.dispose();*/
        // TODO add your handling code here:
    }//GEN-LAST:event_jbtnaceptarActionPerformed


    // 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 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.JComboBox jcboxUnidadExcepcion;
    private javax.swing.JRadioButton jradAccionActorExcepcion;
    private javax.swing.JRadioButton jradAccionInclusionExtensionExcepcion;
    private javax.swing.JRadioButton jradAccionSistemaExcepcion;
    private javax.swing.JTextArea jtxaAccionRealizadaSistemaExcepcion;
    private javax.swing.JTextArea jtxaCondicionExcepcion;
    private javax.swing.JTextField jtxtValorExcepcion;
    // End of variables declaration//GEN-END:variables

    private void mostrarmensaje(String mensaje) {
         JOptionPane.showMessageDialog(this, mensaje, "Excepcion añadida",
                                JOptionPane.WARNING_MESSAGE);
     }
}
