001/*
002 * Copyright 2010-2015 Institut Pasteur.
003 * 
004 * This file is part of Icy.
005 * 
006 * Icy is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 * 
011 * Icy is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014 * GNU General Public License for more details.
015 * 
016 * You should have received a copy of the GNU General Public License
017 * along with Icy. If not, see <http://www.gnu.org/licenses/>.
018 */
019package icy.gui.preferences;
020
021import icy.preferences.PluginPreferences;
022
023import javax.swing.Box;
024import javax.swing.BoxLayout;
025import javax.swing.JCheckBox;
026
027public class PluginPreferencePanel extends PreferencePanel
028{
029    private static final long serialVersionUID = 6383733826888489205L;
030
031    public static final String NODE_NAME = "Plugin";
032
033    /**
034     * gui
035     */
036    final JCheckBox autoUpdateCheckBox;
037    private final JCheckBox allowBetaCheckBox;
038
039    PluginPreferencePanel(PreferenceFrame parent)
040    {
041        super(parent, NODE_NAME, PreferenceFrame.NODE_NAME);
042
043        autoUpdateCheckBox = new JCheckBox("Enable automatic update");
044        autoUpdateCheckBox
045                .setToolTipText("Enable (silent) automatic update for plugins as soon a new version is available");
046        allowBetaCheckBox = new JCheckBox("Allow beta version");
047        allowBetaCheckBox
048                .setToolTipText("Show beta version in online plugins, also beta version can be used for update");
049
050        load();
051
052        mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
053
054        mainPanel.add(autoUpdateCheckBox);
055        mainPanel.add(Box.createVerticalStrut(6));
056        mainPanel.add(allowBetaCheckBox);
057        mainPanel.add(Box.createVerticalStrut(6));
058        mainPanel.add(Box.createVerticalGlue());
059    }
060
061    @Override
062    protected void load()
063    {
064        autoUpdateCheckBox.setSelected(PluginPreferences.getAutomaticUpdate());
065        allowBetaCheckBox.setSelected(PluginPreferences.getAllowBeta());
066    }
067
068    @Override
069    protected void save()
070    {
071        PluginPreferences.setAutomaticUpdate(autoUpdateCheckBox.isSelected());
072        PluginPreferences.setAllowBeta(allowBetaCheckBox.isSelected());
073    }
074}