/*
 * JReparent.java
 *
 * Created on 25 ΈôΈΩœçΈΫΈΙΈΩœ² 2005, 3:31 ΈΦΈΦ
 * 
 * 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.tools;
import static com.panayotis.jubler.i18n.I18N._;

import com.panayotis.jubler.Jubler;
import java.util.Vector;

import static com.panayotis.jubler.i18n.I18N._;
import java.util.ArrayList;

/**
 *
 * @author  teras
 */
public class JReparent extends javax.swing.JPanel {
    private ArrayList<Jubler> jublerlist;
    
    /** Creates new form JSplit */
    public JReparent(Jubler current, Jubler parent) {
        initComponents();
        jublerlist = new ArrayList<Jubler>();
        
        int selection = 0;
        Jubler cjubler;
        
        JubSelector.addItem(_("-No parent available-"));
        for ( int i = 0 ; i <Jubler.windows.size() ; i++) {
            cjubler = Jubler.windows.elementAt(i);
            if ( cjubler != current ) {
                jublerlist.add(cjubler);
                if (cjubler==parent) selection = jublerlist.size();
                JubSelector.addItem(cjubler.getSubtitles().getCurrentFileName());
            }
        }
        JubSelector.setSelectedIndex(selection);
    }
    
    public Jubler getDesiredParent() {
        if (JubSelector.getSelectedIndex()<1) return null;
        return jublerlist.get(JubSelector.getSelectedIndex()-1);
    }
    /** 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() {
        Position = new javax.swing.ButtonGroup();
        JubSelector = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();

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

        JubSelector.setToolTipText(_("The new parent subtitles file"));
        add(JubSelector, java.awt.BorderLayout.CENTER);

        jLabel1.setText(_("Provide the desired parent for this subtitles file"));
        add(jLabel1, java.awt.BorderLayout.NORTH);

    }
    // </editor-fold>//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox JubSelector;
    private javax.swing.ButtonGroup Position;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables
    
}
