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

/*
 * jfrmElementosRas.java
 *
 * Created on 18-ene-2012, 12:01:22
 */

package vista;

import java.util.Iterator;
import java.util.Observable;
import java.util.Observer;
import javax.swing.DefaultListModel;
import modelo.CasodeUso;
import modelo.DocumentoReq;
/**
 *
 * @author Ruben
 */
public class jfrmElementosRas extends javax.swing.JFrame {
    DocumentoReq auxDocPpal;
    jfrmPrincipal jfaux;
    jfrmRastreabilidad jraux;
    int FilasOColumnas;
    /** Creates new form jfrmElementosRas */
    public jfrmElementosRas(jfrmRastreabilidad jr,DocumentoReq docPpal,jfrmPrincipal jf, int FoC) {
        auxDocPpal=docPpal;
        jraux=jr;
        jfaux=jf;
        FilasOColumnas=FoC;

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

        jbtnAnadir = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jlstElemento = new javax.swing.JList();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });

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

        jlstElemento.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Casos de Uso", "Fichero Grafico", "Objetivo", "Parrafo", "Requisito de Informacion", "Requisito Funcional", "Requisito no Funcional", "Requisito Restriccion" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane1.setViewportView(jlstElemento);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(22, 22, 22)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 48, Short.MAX_VALUE)
                .addComponent(jbtnAnadir)
                .addGap(39, 39, 39))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(jbtnAnadir))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(35, Short.MAX_VALUE))
        );

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

    private void jbtnAnadirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnAnadirActionPerformed
        switch(FilasOColumnas)
        {
            case 0: jraux.setTxtFila(jlstElemento.getModel().getElementAt(jlstElemento.getSelectedIndex()));
                    break;
            case 1: jraux.setTxtColumna(jlstElemento.getModel().getElementAt(jlstElemento.getSelectedIndex()));
                    break;
        }
    }//GEN-LAST:event_jbtnAnadirActionPerformed

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
        jraux.setEnabled(true);
        this.dispose();
    }//GEN-LAST:event_formWindowClosed

    /**
    * @param args the command line arguments
    */
    /*public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new jfrmElementosRas().setVisible(true);
            }
        });
    }*/

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbtnAnadir;
    private javax.swing.JList jlstElemento;
    // End of variables declaration//GEN-END:variables


}
