Package xnap.plugin.nap.gui

Source Code of xnap.plugin.nap.gui.OpenNapServerPreferencesPanel

/*
*  XNap - A P2P framework and client.
*
*  See the file AUTHORS for copyright information.
*
*  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.
*
*  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, write to the Free Software
*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

package xnap.plugin.nap.gui;

import java.awt.Component;
import java.awt.GridBagLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import org.xnap.XNap;
import org.xnap.gui.AbstractSettingsPanel;
import org.xnap.gui.action.EnableAction;
import org.xnap.gui.component.MultiLineLabel;
import org.xnap.gui.component.ValidatedTextField;
import org.xnap.gui.component.XNapCheckBox;
import org.xnap.gui.util.GUIHelper;
import org.xnap.gui.util.GridBagHelper;
import org.xnap.plugin.opennap.OpenNapPlugin;
import org.xnap.plugin.opennap.util.OpenNapPreferences;

public class OpenNapServerPreferencesPanel extends AbstractSettingsPanel {

    //--- Data Field(s) ----

    private OpenNapPreferences napPrefs = OpenNapPlugin.getPreferences();

  private EnableAction autoFetchNapigatorAction;
  private ValidatedTextField autoFetchNapigatorIntervalTextField;
  private JTextArea serverListTextArea;
 
    //--- Constructor(s) ---

    public OpenNapServerPreferencesPanel()
    {
    setLayout(new GridBagLayout());

    JPanel jpStartup = new JPanel(new GridBagLayout());
    jpStartup.setBorder(GUIHelper.createDefaultBorder
              (XNap.tr("Server List")));
    GridBagHelper.add(this, jpStartup);

    GridBagHelper.add(jpStartup, new MultiLineLabel(XNap.tr("XNap can fetch lists of OpenNap server addresses. These lists are provided by service providers that are not affiliated with the XNap project.")));
   
    serverListTextArea = new JTextArea(napPrefs.getNapigatorURL(), 5, 40);
    GridBagHelper.add(jpStartup, new JScrollPane(serverListTextArea));
   
        autoFetchNapigatorIntervalTextField = new ValidatedTextField
      (napPrefs.getAutoFetchNapigatorInterval() + "", 5,
       ValidatedTextField.NUMBERS_INT);
    autoFetchNapigatorAction
      = new EnableAction
        (XNap.tr("Refresh lists every"),
         new Component[] { autoFetchNapigatorIntervalTextField },
         napPrefs.getAutoFetchNapigator());
    GridBagHelper.addComponent
      (jpStartup, new XNapCheckBox(autoFetchNapigatorAction));
    GridBagHelper.addComponent
      (jpStartup, autoFetchNapigatorIntervalTextField);
    GridBagHelper.addLabel(jpStartup, XNap.tr("hours"));
    // XXX: workaroung to ensure left alignment
    GridBagHelper.add(jpStartup, new JLabel());

    GridBagHelper.addVerticalSpacer(this);
    GUIHelper.setMnemonics(this);
    }

    //--- Method(s) ---

    public void apply()
    {
      napPrefs.setNapigatorURL(serverListTextArea.getText());
    napPrefs.setAutoFetchNapigator(autoFetchNapigatorAction.isSelected());
    napPrefs.setAutoFetchNapigatorInterval
      (autoFetchNapigatorIntervalTextField.getIntValue());
    }

    public String getTitle()
    {
    return XNap.tr("Server List");
    }

}
TOP

Related Classes of xnap.plugin.nap.gui.OpenNapServerPreferencesPanel

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.