/*
 * SelectionPanel.java
 *
 * Created on 16. August 2005, 12:40
 */

package org.rosuda.JClaR;

/**
 * Panel with three buttons to invert the selection, select all and deselect all.
 * @author tobias
 */
public class SelectionPanel extends javax.swing.JPanel {
    
    /**
     * The Object to be notified when a button is clicked.
     */
    private SelectionModIF selm;
    
    /**
     * Creates new form SelectionPanel
     * @param selm The Object to be notified when a button is clicked.
     */
    SelectionPanel(SelectionModIF selm) {
        this.selm=selm;
        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.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        butAll = new javax.swing.JButton();
        butNothing = new javax.swing.JButton();
        butInvert = new javax.swing.JButton();

        setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.X_AXIS));

        butAll.setText("Select all");
        butAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butAllActionPerformed(evt);
            }
        });

        add(butAll);

        butNothing.setText("Select nothing");
        butNothing.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butNothingActionPerformed(evt);
            }
        });

        add(butNothing);

        butInvert.setText("Invert selection");
        butInvert.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                butInvertActionPerformed(evt);
            }
        });

        add(butInvert);

    }
    // </editor-fold>//GEN-END:initComponents
    
    private void butInvertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butInvertActionPerformed
        selm.invertSelection();
    }//GEN-LAST:event_butInvertActionPerformed
    
    private void butNothingActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butNothingActionPerformed
        selm.selectNothing();
    }//GEN-LAST:event_butNothingActionPerformed
    
    private void butAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_butAllActionPerformed
        selm.selectAll();
    }//GEN-LAST:event_butAllActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton butAll;
    private javax.swing.JButton butInvert;
    private javax.swing.JButton butNothing;
    // End of variables declaration//GEN-END:variables
    
}
