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  package org.xnap.plugin.limewire;
21  
22  import java.awt.GridBagLayout;
23  
24  import javax.swing.JCheckBox;
25  
26  import org.xnap.XNap;
27  import org.xnap.gui.AbstractSettingsPanel;
28  import org.xnap.gui.component.*;
29  import org.xnap.gui.util.*;
30  
31  /***
32   * Provides the LimeWire preferences panel.
33   */
34  public class LimeWirePreferencesPanel extends AbstractSettingsPanel {
35      
36      //--- Data field(s) ---
37  
38      private LimeWirePreferences limewirePrefs = 
39  		LimeWirePlugin.getPreferences();
40  
41      private JCheckBox jcbAutoConnect;
42  	private ValidatedTextField localPortTextField;
43      private JCheckBox ultraPeerDisabledCheckBox;
44  
45      //--- Constructor(s) ---
46  
47      public LimeWirePreferencesPanel()
48      {
49  		setLayout(new GridBagLayout());
50  
51  		// local port
52  		localPortTextField = new ValidatedTextField
53  			(limewirePrefs.getPort() + "", 5, ValidatedTextField.NUMBERS_INT);
54  		GridBagHelper.addLabel(this, XNap.tr("Local Port")).setLabelFor
55  			(localPortTextField);
56  		GridBagHelper.add(this, localPortTextField, false);
57  
58          jcbAutoConnect
59  			= new JCheckBox(XNap.tr("Connect To Network On Startup"), 
60  							limewirePrefs.getAutoConnect()); 
61          GridBagHelper.add(this, jcbAutoConnect);
62  	
63  		ultraPeerDisabledCheckBox = new JCheckBox
64  			(XNap.tr("Disable UltraPeer capabilities"),
65  			 limewirePrefs.getDisableUltraPeer());
66  		GridBagHelper.add(this, ultraPeerDisabledCheckBox);
67  
68  		GridBagHelper.addVerticalSpacer(this);
69  		GUIHelper.setMnemonics(this);
70      }
71  
72      //--- Method(s) ---
73  
74      public void apply() 
75      {
76  		limewirePrefs.setAutoConnect(jcbAutoConnect.isSelected());
77  		limewirePrefs.setPort(localPortTextField.getIntValue());
78  		limewirePrefs.setDisableUltraPeer
79  			(ultraPeerDisabledCheckBox.isSelected());
80      }
81  
82      public String getDescription()
83      {
84  		return XNap.tr("LimeWire connection configuration.");
85      }
86  
87      public String getTitle()
88      {
89  		return LimeWirePlugin.getInstance().getInfo().getName();
90      }
91  
92  }
93  
94  
95