/*
 The MIT License (MIT)

 Copyright (c) 2015 Aleksandar Cvetković

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in all
 copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 */
package htsquirrel.gui.pages.settings;

import static htsquirrel.HTSquirrel.applyTheme;
import static htsquirrel.HTSquirrel.getTheme;
import static htsquirrel.HTSquirrel.setTheme;

/**
 *
 * @author Aleksandar Cvetković <arcvetkovic@gmail.com>
 */
public class SettingsBase extends javax.swing.JPanel {

    /**
     * Creates new form SettingsBase
     */
    public SettingsBase() {
        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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        labelTitle = new javax.swing.JLabel();
        labelLanguage = new javax.swing.JLabel();
        comboBoxLanguage = new javax.swing.JComboBox();
        labelTheme = new javax.swing.JLabel();
        comboBoxTheme = new javax.swing.JComboBox();
        buttonOk = new javax.swing.JButton();

        labelTitle.setFont(new java.awt.Font("DejaVu Sans", 0, 18)); // NOI18N
        labelTitle.setForeground(new java.awt.Color(255, 102, 0));
        labelTitle.setText("Settings");

        labelLanguage.setText("Language:");

        comboBoxLanguage.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "English", "Srpski" }));

        labelTheme.setText("Theme:");

        comboBoxTheme.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Dark", "Light" }));

        buttonOk.setText("Ok");
        buttonOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonOkActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelTitle)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelLanguage)
                            .addComponent(labelTheme))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(buttonOk, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(comboBoxLanguage, 0, 100, Short.MAX_VALUE)
                                .addComponent(comboBoxTheme, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))))
                .addContainerGap(210, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelTitle)
                .addGap(45, 45, 45)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelLanguage)
                    .addComponent(comboBoxLanguage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelTheme)
                    .addComponent(comboBoxTheme, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(50, 50, 50)
                .addComponent(buttonOk)
                .addContainerGap(82, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void buttonOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonOkActionPerformed
        if (!(comboBoxTheme.getSelectedItem().toString().equals(getTheme()))) {
            setTheme(comboBoxTheme.getSelectedItem().toString());
            applyTheme();
        }
    }//GEN-LAST:event_buttonOkActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonOk;
    private javax.swing.JComboBox comboBoxLanguage;
    private javax.swing.JComboBox comboBoxTheme;
    private javax.swing.JLabel labelLanguage;
    private javax.swing.JLabel labelTheme;
    private javax.swing.JLabel labelTitle;
    // End of variables declaration//GEN-END:variables
}

@@ -1283,16 +1283,183 @@
 etTheme;
+%0Aimport static htsquirrel.utilities.ConfigProperties.saveConfigProperties;%0Aimport java.io.IOException;%0Aimport java.util.logging.Level;%0Aimport java.util.logging.Logger;
 %0A%0A/**%0A *
@@ -5915,21 +5915,198 @@
     
-applyTheme();
+try %7B%0A                saveConfigProperties();%0A            %7D catch (IOException ex) %7B%0A                Logger.getLogger(SettingsBase.class.getName()).log(Level.SEVERE, null, ex);%0A            %7D
 %0A   

Save theme to config properties