/*
 * JFileOptions.java
 *
 * Created on 24 Ιούνιος 2005, 1:11 μμ
 *
 * 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;

import com.panayotis.jubler.JIDialog;
import static com.panayotis.jubler.i18n.I18N._;

import com.panayotis.jubler.media.MediaFile;
import com.panayotis.jubler.subs.Subtitles;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

/**
 *
 * @author  teras
 */
public abstract class JFileOptions extends JPanel implements OptionsHolder  {
    
    public JFileOptions() {
        initComponents();
    }
    
    protected void setCombo(JComboBox enc, String t, String deflt) {
        if ( enc.getSelectedItem().equals(t)) return;
        
        int i = enc.getSelectedIndex();
        enc.setSelectedItem(t);
        if ( enc.getSelectedIndex() == i) {
            enc.setSelectedItem(deflt);
        }
    }
    
    protected String getItemName(JComboBox box) {
        return box.getSelectedItem().toString();
    }
    
    public abstract void updateVisuals(MediaFile mfile, Subtitles subs);
    
    public JPanel getTabPanel() {
        return this;
    }
    
    /* This method is called when a load/save action is performed
     * To grasp when a JPreferences dialog is displayed, see
     * Options.loadSystemPreferences(JPreferences);
     */
    public void showDialog(JFrame parent, MediaFile mfile, Subtitles subs) {
        if ( !DialogVisible.isSelected() ) return;
        
        updateVisuals(mfile, subs);
        DialogVisible.setVisible(false);
        JIDialog.message(parent, this, _("File preferences"), JIDialog.QUESTION_MESSAGE);
        DialogVisible.setVisible(true);
    }
    
    /* We simply ignore this message */
    public void tabChanged() {}
    
    /** 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() {
        DialogVisible = new javax.swing.JCheckBox();

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

        add(DialogVisible, java.awt.BorderLayout.SOUTH);

    }// </editor-fold>//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    protected javax.swing.JCheckBox DialogVisible;
    // End of variables declaration//GEN-END:variables
    
//   protected abstract String getDialogVisible
}
