class AvailableColumnsPanel extends javax.swing.JPanel {

    private final Table table;
    private final AvailableColumnsModel availableColumnsModel;
    private final Column[] columns;
    private JCheckBox[] columnsCheckBoxes;
    private AvailableColumnsValidator validator;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel contentPanel;
    private javax.swing.JLabel descriptionLabel;
    private javax.swing.JScrollPane scroll;
    // End of variables declaration//GEN-END:variables

    /**
     * Creates new form AvailableColumnsPanel
     */
    public AvailableColumnsPanel(Table table, AvailableColumnsModel availableColumnsModel) {
        initComponents();
        this.table = table;
        this.availableColumnsModel = availableColumnsModel;
        columns = table.toArray();
        refreshColumns();
        refreshAvailableColumnsControls();
    }

    public ValidationPanel getValidationPanel() {
        ValidationPanel validationPanel = new ValidationPanel();
        validationPanel.setInnerComponent(this);

        ValidationGroup group = validationPanel.getValidationGroup();
//        group.add(validator = new AvailableColumnsValidator());
        refreshAvailableColumnsControls();
        return validationPanel;
    }

    private void refreshColumns() {
        columnsCheckBoxes = new JCheckBox[columns.length];
        contentPanel.removeAll();
        contentPanel.setLayout(new MigLayout("", "[pref!]"));
        for (int i = 0; i < columns.length; i++) {
            columnsCheckBoxes[i] =
                new JCheckBox(columns[i].getTitle(), availableColumnsModel.isColumnAvailable(columns[i]));
            columnsCheckBoxes[i].addActionListener(new ColumnCheckBoxListener(i));
            contentPanel.add(columnsCheckBoxes[i], "wrap");
        }
        contentPanel.revalidate();
        contentPanel.repaint();
    }

    private void refreshAvailableColumnsControls() {
        boolean enabled = availableColumnsModel.canAddAvailableColumn();
        for (JCheckBox cb : columnsCheckBoxes) {
            if (!cb.isSelected()) {
                cb.setEnabled(enabled);
            }
        }
        if (validator != null) {
//            validator.event();
        }
    }

    /**
     * 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() {<FILL_FUNCTION_BODY>}// </editor-fold>//GEN-END:initComponents

    class ColumnCheckBoxListener implements ActionListener {

        private final int index;

        public ColumnCheckBoxListener(int index) {
            this.index = index;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            if (columnsCheckBoxes[index].isSelected()) {
                availableColumnsModel.addAvailableColumn(columns[index]);
            } else {
                availableColumnsModel.removeAvailableColumn(columns[index]);
            }
            refreshAvailableColumnsControls();
        }
    }

    class AvailableColumnsValidator extends ValidationListener {

        protected AvailableColumnsValidator(Class targetType, ValidationUI ui,
                                            Object component) {
            super(targetType, ui, component);
        }

        @Override
        protected void performValidation(Problems prblms) {
            if (!availableColumnsModel.canAddAvailableColumn()) {
                prblms.add(NbBundle
                        .getMessage(AvailableColumnsPanel.class, "AvailableColumnsPanel.maximum-available-columns.info"),
                    Severity.INFO);
            }
        }
    }
}


        scroll = new javax.swing.JScrollPane();
        contentPanel = new javax.swing.JPanel();
        descriptionLabel = new javax.swing.JLabel();

        contentPanel.setLayout(new java.awt.GridLayout());
        scroll.setViewportView(contentPanel);

        descriptionLabel.setText(org.openide.util.NbBundle
            .getMessage(AvailableColumnsPanel.class, "AvailableColumnsPanel.descriptionLabel.text")); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(descriptionLabel, javax.swing.GroupLayout.Alignment.LEADING,
                            javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
                        .addComponent(scroll, javax.swing.GroupLayout.Alignment.LEADING,
                            javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE))
                    .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(descriptionLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 29, Short.MAX_VALUE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(scroll, javax.swing.GroupLayout.PREFERRED_SIZE, 238,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap())
        );
    
<methods>public void <init>() ,public void <init>(java.awt.LayoutManager) ,public void <init>(boolean) ,public void <init>(java.awt.LayoutManager, boolean) ,public javax.accessibility.AccessibleContext getAccessibleContext() ,public javax.swing.plaf.PanelUI getUI() ,public java.lang.String getUIClassID() ,public void setUI(javax.swing.plaf.PanelUI) ,public void updateUI() <variables>private static final java.lang.String uiClassID