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

/*
 * jfrmCasodeUso.java
 *
 * Created on 22-nov-2011, 17:05:03
 */

package vista;

import java.awt.Component;
import java.util.ArrayList;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import javax.swing.ListModel;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.MutableTreeNode;
import modelo.CasodeUso;
import modelo.DocumentoReq;
import modelo.ReqFuncional;
import modelo.ReqInformacion;
import modelo.ReqNoFuncional;
import modelo.ReqRestriccion;

/**
 *
 * @author acc_local
 */
public class jfrmRequisito extends javax.swing.JFrame {
    DocumentoReq auxDocPpal;
    jfrmPrincipal jfaux;
    MutableTreeNode auxinsertNode;
    jfrmElementoCreado jElemento;
    int auxinsertIndex;
    private String tipo;
    DefaultListModel lista= new DefaultListModel();

    /** Creates new form jfrmCasodeUso */
    public jfrmRequisito(jfrmPrincipal jf, DocumentoReq docPpal,jfrmElementoCreado jeleme, MutableTreeNode insertNode, int insertIndex, String tipo) {
        auxinsertNode=insertNode;
        auxinsertIndex=insertIndex;
        jElemento=jeleme;
        jfaux=jf;
        auxDocPpal=docPpal;
        
        initComponents();
        jtxpComentarios.setText("PD");
        this.tipo=tipo;
        if(tipo.equals("Informacion"))
        {
            jTabReq.setEnabledAt(1, false);
            jTabReq.remove(1);
            this.setTitle("Nuevo requisito de información");
        }
        else
        {
            jTabReq.setEnabledAt(2, false);
            jTabReq.remove(2);
            if(tipo.equals("funcional"))
            {
                this.setTitle("Nuevo requisito funcional");
            }
            if(tipo.equals("noFuncional"))
            {
                this.setTitle("Nuevo requisito No funcional");
            }
            if(tipo.equals("Restriccion"))
            {
                this.setTitle("Nuevo requisito de restricción");
            }
        }
    }

    /** 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() {

        jTabReq = new javax.swing.JTabbedPane();
        jpanGeneral = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jtxtNombreReq = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jtxtAutores = new javax.swing.JTextField();
        jtxtFuentes = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jpanDescripcion = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtxaDescripcion = new javax.swing.JTextArea();
        jpanDetalles = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jtxtConceptoRelevante = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jtxtValorMaxVida = new javax.swing.JTextField();
        jtxtUnidadMaxVida = new javax.swing.JTextField();
        jtxtUnidadMedioVida = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jtxtValorMedioVida = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jtxtNumMedOcurrencias = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jtxtNumOcurrencias = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jpanPrioridad = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jtxtimportancia = new javax.swing.JTextField();
        jtxturgencia = new javax.swing.JTextField();
        jtxtestadoDesarrollo = new javax.swing.JTextField();
        jtxtestabilidad = new javax.swing.JTextField();
        jpanComentarios = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtxpComentarios = new javax.swing.JTextPane();
        jpanRastreabilidad = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        jlstRastreable = new javax.swing.JList();
        jbtnAceptar = 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);
            }
        });

        jLabel1.setText("Nombre:");

        jtxtNombreReq.setText("Prueba requisito");

        jLabel2.setText("Autores:");

        jtxtAutores.setText("PD");

        jtxtFuentes.setText("PD");

        jLabel3.setText("Fuentes:");

        javax.swing.GroupLayout jpanGeneralLayout = new javax.swing.GroupLayout(jpanGeneral);
        jpanGeneral.setLayout(jpanGeneralLayout);
        jpanGeneralLayout.setHorizontalGroup(
            jpanGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanGeneralLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpanGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpanGeneralLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(12, 12, 12)
                        .addComponent(jtxtNombreReq, javax.swing.GroupLayout.DEFAULT_SIZE, 336, Short.MAX_VALUE))
                    .addGroup(jpanGeneralLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtxtAutores, javax.swing.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE))
                    .addGroup(jpanGeneralLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtxtFuentes, javax.swing.GroupLayout.DEFAULT_SIZE, 342, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jpanGeneralLayout.setVerticalGroup(
            jpanGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanGeneralLayout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addGroup(jpanGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jtxtNombreReq, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jpanGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jtxtAutores, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jpanGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jtxtFuentes, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(74, Short.MAX_VALUE))
        );

        jTabReq.addTab("General", jpanGeneral);

        jLabel5.setText("El sistema debera...");

        jtxaDescripcion.setColumns(20);
        jtxaDescripcion.setRows(5);
        jtxaDescripcion.setText("PD");
        jScrollPane2.setViewportView(jtxaDescripcion);

        javax.swing.GroupLayout jpanDescripcionLayout = new javax.swing.GroupLayout(jpanDescripcion);
        jpanDescripcion.setLayout(jpanDescripcionLayout);
        jpanDescripcionLayout.setHorizontalGroup(
            jpanDescripcionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanDescripcionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpanDescripcionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE)
                    .addComponent(jLabel5))
                .addContainerGap())
        );
        jpanDescripcionLayout.setVerticalGroup(
            jpanDescripcionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanDescripcionLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabReq.addTab("Descripción", jpanDescripcion);

        jLabel4.setText("Concepto Relevante: ");

        jtxtConceptoRelevante.setText("PD");

        jLabel11.setText("Tiempo máximo de vida");

        jLabel12.setText("Valor:");

        jLabel13.setText("Unidad tiempo:");

        jtxtValorMaxVida.setText("1");

        jtxtUnidadMaxVida.setText("PD");

        jtxtUnidadMedioVida.setText("PD");
        jtxtUnidadMedioVida.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtUnidadMedioVidaActionPerformed(evt);
            }
        });

        jLabel14.setText("Unidad tiempo:");

        jtxtValorMedioVida.setText("1");

        jLabel15.setText("Valor:");

        jLabel16.setText("Tiempo medio de vida");

        jtxtNumMedOcurrencias.setText("1");

        jLabel17.setText("Nº medio:");

        jtxtNumOcurrencias.setText("1");

        jLabel18.setText("Nº:");

        jLabel19.setText("Ocurrencias Simultaneas");

        javax.swing.GroupLayout jpanDetallesLayout = new javax.swing.GroupLayout(jpanDetalles);
        jpanDetalles.setLayout(jpanDetallesLayout);
        jpanDetallesLayout.setHorizontalGroup(
            jpanDetallesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanDetallesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpanDetallesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpanDetallesLayout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtxtConceptoRelevante, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE))
                    .addGroup(jpanDetallesLayout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(163, 163, 163))
                    .addGroup(jpanDetallesLayout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtxtValorMaxVida, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jtxtUnidadMaxVida, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpanDetallesLayout.createSequentialGroup()
                        .addComponent(jLabel16)
                        .addGap(151, 151, 151))
                    .addGroup(jpanDetallesLayout.createSequentialGroup()
                        .addComponent(jLabel19)
                        .addGap(151, 151, 151))
                    .addGroup(jpanDetallesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jpanDetallesLayout.createSequentialGroup()
                            .addGap(17, 17, 17)
                            .addComponent(jLabel18)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jtxtNumOcurrencias, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel17)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jtxtNumMedOcurrencias, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jpanDetallesLayout.createSequentialGroup()
                            .addComponent(jLabel15)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jtxtValorMedioVida, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(jLabel14)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jtxtUnidadMedioVida, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );
        jpanDetallesLayout.setVerticalGroup(
            jpanDetallesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanDetallesLayout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(jpanDetallesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jtxtConceptoRelevante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jpanDetallesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jtxtValorMaxVida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13)
                    .addComponent(jtxtUnidadMaxVida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jLabel16)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jpanDetallesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(jtxtValorMedioVida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14)
                    .addComponent(jtxtUnidadMedioVida, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel19)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jpanDetallesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtNumMedOcurrencias, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17)
                    .addComponent(jtxtNumOcurrencias, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18))
                .addContainerGap(97, Short.MAX_VALUE))
        );

        jTabReq.addTab("Detalles", jpanDetalles);

        jLabel7.setText("Importancia:");

        jLabel8.setText("Urgencia:");

        jLabel9.setText("Estado de desarrollo:");

        jLabel10.setText("Estabilidad:");

        jtxtimportancia.setText("PD");

        jtxturgencia.setText("PD");

        jtxtestadoDesarrollo.setText("PD");

        jtxtestabilidad.setText("PD");
        jtxtestabilidad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtxtestabilidadActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jpanPrioridadLayout = new javax.swing.GroupLayout(jpanPrioridad);
        jpanPrioridad.setLayout(jpanPrioridadLayout);
        jpanPrioridadLayout.setHorizontalGroup(
            jpanPrioridadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanPrioridadLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpanPrioridadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8)
                    .addComponent(jLabel9)
                    .addComponent(jLabel10))
                .addGap(22, 22, 22)
                .addGroup(jpanPrioridadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jtxtestabilidad)
                    .addComponent(jtxtestadoDesarrollo)
                    .addComponent(jtxturgencia)
                    .addComponent(jtxtimportancia, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE))
                .addContainerGap(75, Short.MAX_VALUE))
        );
        jpanPrioridadLayout.setVerticalGroup(
            jpanPrioridadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanPrioridadLayout.createSequentialGroup()
                .addGap(49, 49, 49)
                .addGroup(jpanPrioridadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jtxtimportancia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpanPrioridadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jtxturgencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpanPrioridadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jtxtestadoDesarrollo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpanPrioridadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jtxtestabilidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(175, Short.MAX_VALUE))
        );

        jTabReq.addTab("Prioridad", jpanPrioridad);

        jLabel6.setText("Comentarios: ");

        jScrollPane1.setViewportView(jtxpComentarios);

        javax.swing.GroupLayout jpanComentariosLayout = new javax.swing.GroupLayout(jpanComentarios);
        jpanComentarios.setLayout(jpanComentariosLayout);
        jpanComentariosLayout.setHorizontalGroup(
            jpanComentariosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanComentariosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpanComentariosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE)
                    .addComponent(jLabel6))
                .addContainerGap())
        );
        jpanComentariosLayout.setVerticalGroup(
            jpanComentariosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanComentariosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabReq.addTab("Comentarios", jpanComentarios);

        jButton1.setText("Añadir");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jScrollPane3.setViewportView(jlstRastreable);

        javax.swing.GroupLayout jpanRastreabilidadLayout = new javax.swing.GroupLayout(jpanRastreabilidad);
        jpanRastreabilidad.setLayout(jpanRastreabilidadLayout);
        jpanRastreabilidadLayout.setHorizontalGroup(
            jpanRastreabilidadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanRastreabilidadLayout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton1)
                .addContainerGap(57, Short.MAX_VALUE))
        );
        jpanRastreabilidadLayout.setVerticalGroup(
            jpanRastreabilidadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanRastreabilidadLayout.createSequentialGroup()
                .addGroup(jpanRastreabilidadLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpanRastreabilidadLayout.createSequentialGroup()
                        .addGap(46, 46, 46)
                        .addComponent(jButton1))
                    .addGroup(jpanRastreabilidadLayout.createSequentialGroup()
                        .addGap(28, 28, 28)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(211, Short.MAX_VALUE))
        );

        jTabReq.addTab("Rastreabilidad", jpanRastreabilidad);

        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(getContentPane());
        getContentPane().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(jTabReq, javax.swing.GroupLayout.DEFAULT_SIZE, 414, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(169, 169, 169)
                        .addComponent(jbtnAceptar)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabReq, javax.swing.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jbtnAceptar)
                .addContainerGap())
        );

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

    private void jbtnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnAceptarActionPerformed
        if(comprobarTexto() || comprobarTextoinfo())
        {
            boolean todosnumeros=true;

            String nomb = new String();

            if(tipo.equals("funcional"))
            {
                ArrayList<String> listaAux = new ArrayList();
                for(int i=0; i<jlstRastreable.getModel().getSize(); i++)
                {
                    listaAux.add(jlstRastreable.getModel().getElementAt(i).toString());
                }
                ReqFuncional newRF= auxDocPpal.nuevoReqFunc("RF "+jtxtNombreReq.getText(),
                                                            jtxtAutores.getText(),
                                                            jtxtFuentes.getText(),
                                                            jtxpComentarios.getText(),
                                                            jtxtimportancia.getText(),
                                                            jtxturgencia.getText(),
                                                            jtxtestadoDesarrollo.getText(),
                                                            jtxtestabilidad.getText(),
                                                            jtxaDescripcion.getText(),
                                                            listaAux);
                nomb = newRF.getNombre();
            }
            if(tipo.equals("NoFuncional"))
            {
                ArrayList<String> listaAux = new ArrayList();
                for(int i=0; i<jlstRastreable.getModel().getSize(); i++)
                {
                    listaAux.add(jlstRastreable.getModel().getElementAt(i).toString());
                }
                ReqNoFuncional newRNF = auxDocPpal.nuevoReqNoFunc("RNF "+jtxtNombreReq.getText(),
                                                                  jtxtAutores.getText(),
                                                                  jtxtFuentes.getText(),
                                                                  jtxpComentarios.getText(),
                   /* Insertamos todos los datos */               jtxtimportancia.getText(),
                   /* Necesarios del constructor */               jtxturgencia.getText(),
                                                                  jtxtestadoDesarrollo.getText(),
                                                                  jtxtestabilidad.getText(),
                                                                  jtxaDescripcion.getText(),
                                                                  listaAux);
                nomb = newRNF.getNombre();
            }
            if(tipo.equals("Restriccion"))
            {
                ArrayList<String> listaAux = new ArrayList();
                for(int i=0; i<jlstRastreable.getModel().getSize(); i++)
                {
                    listaAux.add(jlstRastreable.getModel().getElementAt(i).toString());
                }
                ReqRestriccion newRRes = auxDocPpal.nuevoReqRest("RRes "+jtxtNombreReq.getText(),
                                                                  jtxtAutores.getText(),
                                                                  jtxtFuentes.getText(),
                                                                  jtxpComentarios.getText(),
                   /* Insertamos todos los datos */               jtxtimportancia.getText(),
                   /* Necesarios del constructor */               jtxturgencia.getText(),
                                                                  jtxtestadoDesarrollo.getText(),
                                                                  jtxtestabilidad.getText(),
                                                                  jtxaDescripcion.getText(),
                                                                  listaAux);
                nomb = newRRes.getNombre();
            }
            if(tipo.equals("Informacion"))
            {
                

                if(!isNumeric(jtxtValorMaxVida.getText()) ||
                                   !isNumeric(jtxtValorMedioVida.getText()) ||
                                   !isNumeric(jtxtNumOcurrencias.getText()) ||
                                   !isNumeric(jtxtNumMedOcurrencias.getText()))
                {
                    String cadena="";
                    if(!isNumeric(jtxtValorMaxVida.getText()))
                    {
                        cadena="El campo VALOR MÁXIMO DE VIDA debe ser numérico\n";
                    }
                    if(!isNumeric(jtxtValorMedioVida.getText()))
                    {
                        cadena+="El campo VALOR MEDIO DE VIDA debe ser numérico\n";
                    }
                    if(!isNumeric(jtxtNumOcurrencias.getText()))
                    {
                        cadena+="El campo NÚMERO DE OCURRENCIAS debe ser numérico\n";
                    }
                    if(!isNumeric(jtxtNumMedOcurrencias.getText()))
                    {
                        cadena+="El campo NÚMERO MEDIO DE OCURRENCIAS debe ser numérico\n";
                    }

                    mostrarmensaje(cadena);
                    todosnumeros=false;
                }
                else
                {
                    ArrayList<String> listaAux = new ArrayList();
                    for(int i=0; i<jlstRastreable.getModel().getSize(); i++)
                    {
                        listaAux.add(jlstRastreable.getModel().getElementAt(i).toString());
                    }
                    ReqInformacion newRInf = auxDocPpal.nuevoReqInfo("RInf "+jtxtNombreReq.getText(),
                                                                     jtxtAutores.getText(),
                                                                     jtxtFuentes.getText(),
                                                                     jtxtimportancia.getText(),
                                                                     jtxturgencia.getText(),
                                                                     jtxtestadoDesarrollo.getText(),
                                                                     jtxtestabilidad.getText(),
                                                                     jtxpComentarios.getText(),
                                                                     jtxtConceptoRelevante.getText(),
                                                                     Integer.parseInt(jtxtValorMaxVida.getText()),
                                                                     Integer.parseInt(jtxtValorMedioVida.getText()),
                                                                     jtxtUnidadMaxVida.getText(),
                                                                     jtxtUnidadMedioVida.getText(),
                                                                     Integer.parseInt(jtxtNumOcurrencias.getText()),
                                                                     Integer.parseInt(jtxtNumMedOcurrencias.getText()),
                                                                     listaAux);
                    nomb = newRInf.getNombre();
                }
            }

            if(!tipo.equals("Informacion") || (tipo.equals("Informacion") && todosnumeros==true))
            {
                MutableTreeNode node=new DefaultMutableTreeNode(nomb);
                DefaultTreeModel model =(DefaultTreeModel) jfaux.getJtreDocumento().getModel();
                model.insertNodeInto(node, auxinsertNode, auxinsertIndex);
                mostrarmensaje("Insertado nuevo " + nomb);
                jfaux.setEnabled(true);
                jfaux.update(null, evt);
                this.dispose();
            }
        }
        else
        {
            mostrarmensaje("Debes rellenar todos los campos!!");
        }

    }//GEN-LAST:event_jbtnAceptarActionPerformed

    private boolean comprobarTexto()
    {
        if(jtxtNombreReq.getText().equals("") ||
                jtxtAutores.getText().equals("") ||
                jtxtFuentes.getText().equals("") ||
                jtxaDescripcion.getText().equals("") ||
                jtxtimportancia.getText().equals("") ||
                jtxturgencia.getText().equals("") ||
                jtxtestadoDesarrollo.getText().equals("") ||
                jtxtestabilidad.getText().equals("") ||
                jtxpComentarios.getText().equals(""))
        {
            return false;
        }
        return true;
    }
    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
        jfaux.setEnabled(true);
        this.dispose();
    }//GEN-LAST:event_formWindowClosed

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

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

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
       jElemento.setVisible(true);
       jElemento.setDestino(this);
       jElemento.setNombre_tipo("REQUISITO");
    }//GEN-LAST:event_jButton1ActionPerformed

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    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.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTabbedPane jTabReq;
    private javax.swing.JButton jbtnAceptar;
    private javax.swing.JList jlstRastreable;
    private javax.swing.JPanel jpanComentarios;
    private javax.swing.JPanel jpanDescripcion;
    private javax.swing.JPanel jpanDetalles;
    private javax.swing.JPanel jpanGeneral;
    private javax.swing.JPanel jpanPrioridad;
    private javax.swing.JPanel jpanRastreabilidad;
    private javax.swing.JTextArea jtxaDescripcion;
    private javax.swing.JTextPane jtxpComentarios;
    private javax.swing.JTextField jtxtAutores;
    private javax.swing.JTextField jtxtConceptoRelevante;
    private javax.swing.JTextField jtxtFuentes;
    private javax.swing.JTextField jtxtNombreReq;
    private javax.swing.JTextField jtxtNumMedOcurrencias;
    private javax.swing.JTextField jtxtNumOcurrencias;
    private javax.swing.JTextField jtxtUnidadMaxVida;
    private javax.swing.JTextField jtxtUnidadMedioVida;
    private javax.swing.JTextField jtxtValorMaxVida;
    private javax.swing.JTextField jtxtValorMedioVida;
    private javax.swing.JTextField jtxtestabilidad;
    private javax.swing.JTextField jtxtestadoDesarrollo;
    private javax.swing.JTextField jtxtimportancia;
    private javax.swing.JTextField jtxturgencia;
    // End of variables declaration//GEN-END:variables


    private void mostrarmensaje(String mensaje) {
         JOptionPane.showMessageDialog(this, mensaje, "Advertencia",
                                JOptionPane.WARNING_MESSAGE);
    }

    private boolean comprobarTextoinfo()
    {
        if(jtxtNombreReq.getText().equals("") ||
           jtxtAutores.getText().equals("") ||
           jtxtFuentes.getText().equals("") ||
           jtxtimportancia.getText().equals("") ||
           jtxturgencia.getText().equals("") ||
           jtxtestadoDesarrollo.getText().equals("") ||
           jtxtestabilidad.getText().equals("") ||
           jtxpComentarios.getText().equals("") ||
           jtxtConceptoRelevante.getText().equals("") ||
           jtxtValorMaxVida.getText().equals("") ||
           jtxtUnidadMaxVida.getText().equals("") ||
           jtxtValorMedioVida.getText().equals("") ||
           jtxtUnidadMedioVida.getText().equals("") ||
           jtxtNumOcurrencias.getText().equals("") ||
           jtxtNumMedOcurrencias.getText().equals(""))
        {
            return false;
        }
        return true;
    }

    private static boolean isNumeric(String  cadena){
	try {
		Integer .parseInt(cadena);
		return true;
	} catch (NumberFormatException  nfe){
		return false;
	}
    }


    public void setRastre(Object t)
    {
        lista.addElement(t);
        jlstRastreable.setModel((ListModel) lista);
        jlstRastreable.validate();
    }
}
