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

/*
 * jfrmAnadirParticipante.java
 *
 * Created on 07-feb-2012, 17:39:09
 */

package vista;

import java.util.ArrayList;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import modelo.DocumentoReq;
import modelo.Participante;
import vista.jfrmOrganizacion;

/**
 *
 * @author Carmen
 */
public class jfrmAnadirParticipante extends javax.swing.JFrame {

    DocumentoReq auxDocPpal;
    JFrame auxformulario;
    jfrmPrincipal jfaux;
    /** Creates new form jfrmAnadirParticipante */
    public jfrmAnadirParticipante(DocumentoReq DocPpal,JFrame formulario) {

        initComponents();
        auxDocPpal=DocPpal;
       
        auxformulario=formulario;


        DefaultListModel listModel=new DefaultListModel();

        for ( int  i = 0  ; i < auxDocPpal.getParticipante().size();i++) {
            listModel.addElement ( auxDocPpal.getParticipante().get(i));
        }
        listModel.addElement ( "nuevo" );
        //auxDocPpal.getParticipante().set(listModel);
        //jfrmParticipantes jfp=new Participantes(auxDocPpal, this);//si se accede desde autor es 0
        this.setEnabled(false);
        //jfp.setVisible(true);
    }

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

        jScrollPane1 = new javax.swing.JScrollPane();
        jtxtaParticipantes = new javax.swing.JTextArea();
        jLabel1 = new javax.swing.JLabel();
        jbtnAceptar = new javax.swing.JButton();
        jbtnCancelar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

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

        jLabel1.setText("Participantes:");

        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)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jbtnAceptar)
                        .addGap(18, 18, 18)
                        .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))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbtnAceptar)
                    .addComponent(jbtnCancelar))
                .addContainerGap(33, Short.MAX_VALUE))
        );

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

    private void jbtnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnAceptarActionPerformed
        
         if(auxformulario instanceof jfrmOrganizacion){
            jfrmOrganizacion jor= (jfrmOrganizacion) auxformulario;
            //jor.getJlstautor().setListData(this.jlstParticipantes.getSelectedValues());

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


    /**
    * @param args the command line arguments
    */
//    public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                new jfrmAnadirParticipante().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.JTextArea jtxtaParticipantes;
    // End of variables declaration//GEN-END:variables

}
