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.jtella;
21  
22  import java.awt.GridBagLayout;
23  
24  import javax.swing.JCheckBox;
25  import javax.swing.JPanel;
26  
27  import org.xnap.XNap;
28  import org.xnap.gui.AbstractSettingsPanel;
29  import org.xnap.gui.component.HostList;
30  import org.xnap.gui.util.GUIHelper;
31  import org.xnap.gui.util.GridBagHelper;
32  
33  /***
34   * Provides the JTella preferences panel.
35   */
36  public class JTellaPreferencesPanel extends AbstractSettingsPanel {
37      
38      //--- Data field(s) ---
39  
40      private JTellaPreferences jtellaPrefs = JTellaPlugin.getPreferences();
41  
42      private JCheckBox jcbAutoConnect;
43      private HostList hlHostCaches;
44  
45      //--- Constructor(s) ---
46  
47      public JTellaPreferencesPanel()
48      {
49  		setLayout(new GridBagLayout());
50  
51          jcbAutoConnect
52  			= new JCheckBox(XNap.tr("Connect To Network On Startup"), 
53  							jtellaPrefs.getAutoConnect()); 
54          GridBagHelper.add(this, jcbAutoConnect);
55  	
56  		JPanel jpHostCaches = new JPanel(new GridBagLayout());
57  		jpHostCaches.setBorder
58  			(GUIHelper.createDefaultBorder(XNap.tr("Host Caches")));
59          GridBagHelper.add(this, jpHostCaches);
60  
61  		GridBagHelper.add(jpHostCaches, 
62  						  XNap.tr("Ask these caches for hosts."));
63  		hlHostCaches = new HostList(5, jtellaPrefs.getHostCaches());
64  		GridBagHelper.add(jpHostCaches, hlHostCaches);
65  
66  		GridBagHelper.addVerticalSpacer(this);
67      }
68  
69      //--- Method(s) ---
70  
71      public void apply() 
72      {
73  		jtellaPrefs.setAutoConnect(jcbAutoConnect.isSelected());
74  		jtellaPrefs.setHostCaches(hlHostCaches.getStringItems());
75      }
76  
77      public String getDescription()
78      {
79  		return XNap.tr("JTella connection configuration.");
80      }
81  
82      public String getTitle()
83      {
84  		return JTellaPlugin.getInstance().getInfo().getName();
85      }
86  
87  }
88  
89  
90