Package fr.valhalla.mailcheck.gui

Source Code of fr.valhalla.mailcheck.gui.GlobalPreferencesFrame

/*   Valhalla MailChecker -- Simple IMAP Mail Checker
*    Copyright (C) 2010-2011  Guillaume Florimond (gflorimond at gmail dot com)
*
*    This program 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, either version 3 of the License, or
*    any later version.
*
*    This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/*
* GlobalPreferencesFrame.java
*
* Created on 27 mai 2010, 17:19:24
*/

package fr.valhalla.mailcheck.gui;

import fr.valhalla.mailcheck.GlobalPreferences;
import fr.valhalla.mailcheck.utils.WindowUtils;
import java.awt.SystemTray;

/**
*
* @author guillaume
*/
public class GlobalPreferencesFrame extends javax.swing.JFrame {

    GlobalPreferences prefs;

    /** Creates new form GlobalPreferencesFrame */
    public GlobalPreferencesFrame() {
        // Initialisation
        prefs = new GlobalPreferences();
        initComponents();

        // Remplissage des préférences
        if(prefs.openMainWindowOnStart)
            openMainWindowOnStartCheckBox.setSelected(true);
        if(prefs.showGUIWarnings)
            showGUIWarningsCheckBox.setSelected(true);

        // Cas spécial : le systray n'est pas disponible
        // dans ce cas, il faut afficher la fenêtre principale, sinon on ne peut rien faire
        if (!SystemTray.isSupported()) {
            openMainWindowOnStartCheckBox.setEnabled(false);
        }

        // Positionnement et affichage
        WindowUtils.centerFrameOnScreen(this);
        setVisible(true);
    }

    /** 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() {

        jLabel1 = new javax.swing.JLabel();
        openMainWindowOnStartCheckBox = new javax.swing.JCheckBox();
        showGUIWarningsCheckBox = new javax.swing.JCheckBox();
        miniCheckPaneCheckBox = new javax.swing.JCheckBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel1.setText("Préférences générales");

        openMainWindowOnStartCheckBox.setText("Afficher la fenêtre des comptes au démarrage");
        openMainWindowOnStartCheckBox.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                openMainWindowOnStartCheckBoxStateChanged(evt);
            }
        });

        showGUIWarningsCheckBox.setText("Afficher les avertissements et erreurs");
        showGUIWarningsCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                showGUIWarningsCheckBoxActionPerformed(evt);
            }
        });

        miniCheckPaneCheckBox.setText("Liste des comptes miniature");
        miniCheckPaneCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miniCheckPaneCheckBoxActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, miniCheckPaneCheckBox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, showGUIWarningsCheckBox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, openMainWindowOnStartCheckBox, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(openMainWindowOnStartCheckBox)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(showGUIWarningsCheckBox)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(miniCheckPaneCheckBox)
                .addContainerGap(185, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void openMainWindowOnStartCheckBoxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_openMainWindowOnStartCheckBoxStateChanged
        if(openMainWindowOnStartCheckBox.isSelected())
            prefs.openMainWindowOnStart = true;
        else
            prefs.openMainWindowOnStart = false;
        prefs.savePreferences();
    }//GEN-LAST:event_openMainWindowOnStartCheckBoxStateChanged

    private void showGUIWarningsCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showGUIWarningsCheckBoxActionPerformed
        if(showGUIWarningsCheckBox.isSelected())
            prefs.showGUIWarnings = true;
        else
            prefs.showGUIWarnings = false;
        prefs.savePreferences();
    }//GEN-LAST:event_showGUIWarningsCheckBoxActionPerformed

    private void miniCheckPaneCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miniCheckPaneCheckBoxActionPerformed
        if(miniCheckPaneCheckBox.isSelected())
            prefs.useMiniCheckPane = true;
        else
            prefs.useMiniCheckPane = false;
        prefs.savePreferences();
    }//GEN-LAST:event_miniCheckPaneCheckBoxActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JCheckBox miniCheckPaneCheckBox;
    private javax.swing.JCheckBox openMainWindowOnStartCheckBox;
    private javax.swing.JCheckBox showGUIWarningsCheckBox;
    // End of variables declaration//GEN-END:variables

}
TOP

Related Classes of fr.valhalla.mailcheck.gui.GlobalPreferencesFrame

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.