package event.editor;

import java.awt.event.*;
import javax.swing.*;
import java.util.*;

/**
 *
 * @author nathaniellehrer
 */
public class CHPRadioPanel extends javax.swing.JPanel {

    private ActionListener removeListener;


    /** Creates new form CHPRadioPanel */
    public CHPRadioPanel() {
        initComponents();
        HashMap<JButton, String> buttonMap = new HashMap<JButton, String>();
        buttonMap.put(addDispatchButton, "Dispatch");
        buttonMap.put(addFieldButton, "Field");
        GenericTable.genericizeTable(jScrollPane1, buttonMap, deleteSelectedButton);
    }

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

        jLabel4 = new javax.swing.JLabel();
        audioText = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        addDispatchButton = new javax.swing.JButton();
        deleteSelectedButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        addFieldButton = new javax.swing.JButton();

        jLabel4.setText("Radio File");

        audioText.setToolTipText("The radio audio file");

        jButton2.setText("Browse");
        jButton2.setToolTipText("Browse for the radio audio file");
        jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                browse(evt);
            }
        });

        addDispatchButton.setText("Add Dispatch");
        addDispatchButton.setToolTipText("Adds a row for dialog by the dispatch operator in the table");

        deleteSelectedButton.setText("Delete Selected");
        deleteSelectedButton.setToolTipText("Deletes the selected row from the table");

        addFieldButton.setText("Add Field");
        addFieldButton.setToolTipText("Adds a row for dialog by the field operator in the table");
        addFieldButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addFieldButtonActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 730, Short.MAX_VALUE)
                    .add(layout.createSequentialGroup()
                        .add(addDispatchButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 130, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(3, 3, 3)
                        .add(addFieldButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 130, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(deleteSelectedButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 131, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
                    .add(layout.createSequentialGroup()
                        .add(jLabel4)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(audioText, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 511, Short.MAX_VALUE)
                        .add(18, 18, 18)
                        .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 130, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(audioText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel4)
                    .add(jButton2))
                .add(18, 18, 18)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(addDispatchButton)
                    .add(addFieldButton)
                    .add(deleteSelectedButton))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void browse(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_browse
        JFileChooser browser = new JFileChooser();
        int returnVal = browser.showOpenDialog(this);
        if(returnVal == JFileChooser.APPROVE_OPTION) {
           audioText.setText(browser.getSelectedFile().getPath());
        }
    }//GEN-LAST:event_browse

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

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addDispatchButton;
    private javax.swing.JButton addFieldButton;
    private javax.swing.JTextField audioText;
    private javax.swing.JButton deleteSelectedButton;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables

}
