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

/*
 * jfrmRastreabilidad.java
 *
 * Created on 22-ene-2012, 20:44:12
 */
package vista;

import java.awt.Component;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import modelo.DocumentoReq;

/**
 *
 * @author UHU
 */
public class jfrmRastreabilidad extends javax.swing.JFrame {
    DocumentoReq auxDocPpal;
    JFrame auxFormulario;
    String auxTipo;
    /** Creates new form jfrmRastreabilidad */
    public jfrmRastreabilidad(DocumentoReq docPpal, JFrame formulario, String tipo) {
        initComponents();
        auxDocPpal=docPpal;
        auxTipo=tipo;
        auxFormulario=formulario;
        
        DefaultListModel lstmodel=new DefaultListModel();
        jlstNodos.setModel(lstmodel);
        for(int i=0; i<auxDocPpal.getmObjetivo().size(); i++){
            lstmodel.addElement(auxDocPpal.getmObjetivo().get(i).toString());
        }
        for(int i=0; i<auxDocPpal.getmRequisito().size(); i++){
            lstmodel.addElement(auxDocPpal.getmRequisito().get(i).toString());
        }
        for(int i=0; i<auxDocPpal.getmActor().size(); i++){
            lstmodel.addElement(auxDocPpal.getmActor().get(i).toString());
        }
        for(int i=0; i<auxDocPpal.getmCasodeUso().size(); i++){
            lstmodel.addElement(auxDocPpal.getmCasodeUso().get(i).toString());
        }
        for(int i=0; i<auxDocPpal.getmImagen().size(); i++){
            lstmodel.addElement(auxDocPpal.getmImagen().get(i).toString());
        }
        for(int i=0; i<auxDocPpal.getmParrafo().size(); i++){
            lstmodel.addElement(auxDocPpal.getmParrafo().get(i).toString());
        }
        
    }

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

        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jlstNodos = new javax.swing.JList();
        jbtnAceptar = new javax.swing.JButton();
        jbtnCancelar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setResizable(false);

        jLabel1.setText("Elija un objeto:");

        jScrollPane1.setViewportView(jlstNodos);

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

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

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jbtnAceptar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jbtnCancelar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addComponent(jLabel1))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jbtnAceptar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jbtnCancelar))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

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

    private void jbtnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnAceptarActionPerformed
        if(auxFormulario instanceof jfrmObjetivo){
            jfrmObjetivo jfObjetivo= (jfrmObjetivo) auxFormulario;
            if(auxTipo.equals("destino")) {
                jfObjetivo.getModelo_destino().addElement(jlstNodos.getSelectedValue().toString());
            }
            else if(auxTipo.equals("origen")) {
                jfObjetivo.getModelo_origen().addElement(jlstNodos.getSelectedValue().toString()); 
            }
            jfObjetivo.setEnabled(true);
            this.dispose();
        }
        else if(auxFormulario instanceof jfrmReqFuncional){
            jfrmReqFuncional jfReqFuncional= (jfrmReqFuncional) auxFormulario;
            if(auxTipo.equals("destino")) {
                jfReqFuncional.getModelo_destino().addElement(jlstNodos.getSelectedValue().toString());
            }
            else if(auxTipo.equals("origen")) {
                jfReqFuncional.getModelo_origen().addElement(jlstNodos.getSelectedValue().toString()); 
            }
            jfReqFuncional.setEnabled(true);
            this.dispose();
        }
        else if(auxFormulario instanceof jfrmReqNoFuncional){
            jfrmReqNoFuncional jfReqNoFuncional= (jfrmReqNoFuncional) auxFormulario;
            if(auxTipo.equals("destino")) {
                jfReqNoFuncional.getModelo_destino().addElement(jlstNodos.getSelectedValue().toString());
            }
            else if(auxTipo.equals("origen")) {
                jfReqNoFuncional.getModelo_origen().addElement(jlstNodos.getSelectedValue().toString()); 
            }
            jfReqNoFuncional.setEnabled(true);
            this.dispose();
        }
        else if(auxFormulario instanceof jfrmReqRestriccion){
            jfrmReqRestriccion jfReqRestriccion= (jfrmReqRestriccion) auxFormulario;
            if(auxTipo.equals("destino")) {
                jfReqRestriccion.getModelo_destino().addElement(jlstNodos.getSelectedValue().toString());
            }
            else if(auxTipo.equals("origen")) {
                jfReqRestriccion.getModelo_origen().addElement(jlstNodos.getSelectedValue().toString()); 
            }
            jfReqRestriccion.setEnabled(true);
            this.dispose();
        }
        else if(auxFormulario instanceof jfrmReqInformacion){
            jfrmReqInformacion jfReqInformacion= (jfrmReqInformacion) auxFormulario;
            if(auxTipo.equals("destino")) {
                jfReqInformacion.getModelo_destino().addElement(jlstNodos.getSelectedValue().toString());
            }
            else if(auxTipo.equals("origen")) {
                jfReqInformacion.getModelo_origen().addElement(jlstNodos.getSelectedValue().toString()); 
            }
            jfReqInformacion.setEnabled(true);
            this.dispose();
        }
//        else if(auxFormulario instanceof jfrmCasodeUso){
//            jfrmCasodeUso jfCasodeUso= (jfrmCasodeUso) auxFormulario;
//            if(auxTipo.equals("destino")) {
//                jfCasodeUso.getModelo_destino().addElement(jlstNodos.getSelectedValue().toString());
//            }
//            else if(auxTipo.equals("origen")) {
//                jfCasodeUso.getModelo_origen().addElement(jlstNodos.getSelectedValue().toString()); 
//            }
//            jfCasodeUso.setEnabled(true);
//            this.dispose();
//        }
        else if(auxFormulario instanceof jfrmActor){
            jfrmActor jfActor= (jfrmActor) auxFormulario;
            if(auxTipo.equals("destino")) {
                jfActor.getModelo_destino().addElement(jlstNodos.getSelectedValue().toString());
            }
            else if(auxTipo.equals("origen")) {
                jfActor.getModelo_origen().addElement(jlstNodos.getSelectedValue().toString()); 
            }
            jfActor.setEnabled(true);
            this.dispose();
        }
        else if(auxFormulario instanceof jfrmImagen){
            jfrmImagen jfImagen= (jfrmImagen) auxFormulario;
            if(auxTipo.equals("destino")) {
                jfImagen.getModelo_destino().addElement(jlstNodos.getSelectedValue().toString());
            }
            else if(auxTipo.equals("origen")) {
                jfImagen.getModelo_origen().addElement(jlstNodos.getSelectedValue().toString()); 
            }
            jfImagen.setEnabled(true);
            this.dispose();
        }
        else if(auxFormulario instanceof jfrmParrafo){
            jfrmParrafo jfParrafo= (jfrmParrafo) auxFormulario;
            if(auxTipo.equals("destino")) {
                jfParrafo.getModelo_destino().addElement(jlstNodos.getSelectedValue().toString());
            }
            else if(auxTipo.equals("origen")) {
                jfParrafo.getModelo_origen().addElement(jlstNodos.getSelectedValue().toString()); 
            }
            jfParrafo.setEnabled(true);
            this.dispose();
        }
    }//GEN-LAST:event_jbtnAceptarActionPerformed

    private void jbtnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnCancelarActionPerformed
        auxFormulario.setEnabled(true);
        this.dispose();
    }//GEN-LAST:event_jbtnCancelarActionPerformed

    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        /* Set the Nimbus look and feel */
//        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
//         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
//         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(jfrmRastreabilidad.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(jfrmRastreabilidad.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(jfrmRastreabilidad.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(jfrmRastreabilidad.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//        //</editor-fold>
//
//        /* Create and display the form */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//
//            public void run() {
//                new jfrmRastreabilidad().setVisible(true);
//            }
//        });
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbtnAceptar;
    private javax.swing.JButton jbtnCancelar;
    private javax.swing.JList jlstNodos;
    // End of variables declaration//GEN-END:variables
}
