/*
 * JOptionTabs.java
 *
 * Created on June 1, 2007, 2:29 PM
 *
 * This file is part of Jubler.
 *
 * Jubler is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 2.
 *
 *
 * Jubler is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Jubler; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

package com.panayotis.jubler.options.gui;

import java.awt.BorderLayout;
import java.awt.Insets;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JToggleButton;

/**
 *
 * @author  teras
 */
public class JOptionTabs extends JPanel {
    
    private ArrayList<TabPage> tabs;
    private Window parent;
    
    /**
     * Creates new form JOptionTabs
     */
    public JOptionTabs(Window parent) {
        initComponents();
        tabs = new ArrayList<TabPage>();
        this.parent = parent;
    }
    
    public void addTab(TabPage page) {
        tabs.add(page);
        TabP.addTab(page.getTabName(), page.getTabIcon(), page.getTabPanel(), page.getTabTooltip());
    }

    public void setVisibleTab(int index) {
        if (index<0 || index >= tabs.size()) return;
        
        TabPage page = tabs.get(index);
        TabP.insertTab(page.getTabName(), page.getTabIcon(), page.getTabPanel(), page.getTabTooltip(), index);
    }
    
    public ArrayList<TabPage> getTabArray() {
        return tabs;
    }
    
    public void initTabs() {
        TabP.setSelectedIndex(0);
    }
    
    /** 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() {
        TabsBG = new javax.swing.ButtonGroup();
        TabP = new javax.swing.JTabbedPane();

        setLayout(new java.awt.BorderLayout());

        setBorder(javax.swing.BorderFactory.createEmptyBorder(4, 8, 4, 8));
        TabP.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                TabPStateChanged(evt);
            }
        });

        add(TabP, java.awt.BorderLayout.CENTER);

    }// </editor-fold>//GEN-END:initComponents

    private void TabPStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_TabPStateChanged
        tabs.get(TabP.getSelectedIndex()).tabChanged();
    }//GEN-LAST:event_TabPStateChanged
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTabbedPane TabP;
    private javax.swing.ButtonGroup TabsBG;
    // End of variables declaration//GEN-END:variables
    
}
