View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  
21  package org.xnap.plugin.opennap.gui;
22  
23  import javax.swing.JCheckBox;
24  
25  import java.awt.GridBagLayout;
26  
27  import org.xnap.XNap;
28  import org.xnap.gui.AbstractSettingsPanel;
29  import org.xnap.gui.component.MultiLineLabel;
30  import org.xnap.gui.component.PortPanel;
31  import org.xnap.gui.util.GUIHelper;
32  import org.xnap.gui.util.GridBagHelper;
33  import org.xnap.plugin.opennap.OpenNapPlugin;
34  import org.xnap.plugin.opennap.util.OpenNapPreferences;
35  
36  public class OpenNapWizardPanel extends AbstractSettingsPanel {
37  
38      //--- Data Field(s) ----
39  
40      private OpenNapPreferences napPrefs = OpenNapPlugin.getPreferences();
41  
42      private JCheckBox jcAutoFetchNapigator;
43      private PortPanel jpPort;
44      private JCheckBox jcUseAutoconnector;
45      
46      //--- Constructor(s) ---
47  
48      public OpenNapWizardPanel()
49      {
50  		setLayout(new GridBagLayout());
51  
52  		// local port
53  		GridBagHelper.add
54  			(this, GUIHelper.createSeparator(XNap.tr("Local Port")));
55  
56  		GridBagHelper.add(this, new MultiLineLabel
57  			(XNap.tr("Enable if you can receive incoming connections. Choose a single port or port range that is not used and accesible for incoming connects.")));
58  		jpPort = new PortPanel(!napPrefs.getFirewalled(),
59  							   napPrefs.getLocalPortRange(), 20);
60  
61  		GridBagHelper.add(this, jpPort, false);
62  
63  		GridBagHelper.add
64  			(this, GUIHelper.createSeparator(XNap.tr("Actions to execute when plugin is loaded")));
65  
66  		GridBagHelper.add(this, new MultiLineLabel
67  			(XNap.tr("Napigator provides a list of independently operated OpenNap servers. These servers might have special terms of use, please see the chat panel for according messages.")));
68  		jcAutoFetchNapigator 
69  			= new JCheckBox(XNap.tr("Download list of servers from Napigator"), 
70                              napPrefs.getAutoFetchNapigator());
71          GridBagHelper.add(this, jcAutoFetchNapigator);
72  		jcUseAutoconnector = new JCheckBox(XNap.tr("Automatically connect to servers"),
73  										   napPrefs.getUseAutoconnector());
74  		GridBagHelper.add(this, jcUseAutoconnector);
75  	
76  		GridBagHelper.addVerticalSpacer(this);
77      }
78  
79      //--- Method(s) ---
80  	
81      public void apply()
82      {
83  		napPrefs.setFirewalled(!jpPort.isSelected());
84  		napPrefs.setLocalPortRange(jpPort.getPort());
85  
86  		napPrefs.setAutoFetchNapigator(jcAutoFetchNapigator.isSelected());
87  		napPrefs.setUseAutoconnector(jcUseAutoconnector.isSelected());
88      }
89  
90      public String getDescription()
91      {
92  		return XNap.tr("Configure your OpenNap settings. Ignore the local port setting if you are firewalled.");
93  
94      }
95  
96      public String getTitle()
97      {
98  		return XNap.tr("OpenNap settings");
99      }
100 
101 
102 }