1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.plugin.opennap.gui;
21
22 import java.awt.Component;
23 import java.awt.GridBagLayout;
24
25 import javax.swing.JLabel;
26 import javax.swing.JPanel;
27 import javax.swing.JScrollPane;
28 import javax.swing.JTextArea;
29
30 import org.xnap.XNap;
31 import org.xnap.gui.AbstractSettingsPanel;
32 import org.xnap.gui.action.EnableAction;
33 import org.xnap.gui.component.MultiLineLabel;
34 import org.xnap.gui.component.ValidatedTextField;
35 import org.xnap.gui.component.XNapCheckBox;
36 import org.xnap.gui.util.GUIHelper;
37 import org.xnap.gui.util.GridBagHelper;
38 import org.xnap.plugin.opennap.OpenNapPlugin;
39 import org.xnap.plugin.opennap.util.OpenNapPreferences;
40
41 public class OpenNapServerPreferencesPanel extends AbstractSettingsPanel {
42
43
44
45 private OpenNapPreferences napPrefs = OpenNapPlugin.getPreferences();
46
47 private EnableAction autoFetchNapigatorAction;
48 private ValidatedTextField autoFetchNapigatorIntervalTextField;
49 private JTextArea serverListTextArea;
50
51
52
53 public OpenNapServerPreferencesPanel()
54 {
55 setLayout(new GridBagLayout());
56
57 JPanel jpStartup = new JPanel(new GridBagLayout());
58 jpStartup.setBorder(GUIHelper.createDefaultBorder
59 (XNap.tr("Server List")));
60 GridBagHelper.add(this, jpStartup);
61
62 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.")));
63
64 serverListTextArea = new JTextArea(napPrefs.getNapigatorURL(), 5, 40);
65 GridBagHelper.add(jpStartup, new JScrollPane(serverListTextArea));
66
67 autoFetchNapigatorIntervalTextField = new ValidatedTextField
68 (napPrefs.getAutoFetchNapigatorInterval() + "", 5,
69 ValidatedTextField.NUMBERS_INT);
70 autoFetchNapigatorAction
71 = new EnableAction
72 (XNap.tr("Refresh lists every"),
73 new Component[] { autoFetchNapigatorIntervalTextField },
74 napPrefs.getAutoFetchNapigator());
75 GridBagHelper.addComponent
76 (jpStartup, new XNapCheckBox(autoFetchNapigatorAction));
77 GridBagHelper.addComponent
78 (jpStartup, autoFetchNapigatorIntervalTextField);
79 GridBagHelper.addLabel(jpStartup, XNap.tr("hours"));
80
81 GridBagHelper.add(jpStartup, new JLabel());
82
83 GridBagHelper.addVerticalSpacer(this);
84 GUIHelper.setMnemonics(this);
85 }
86
87
88
89 public void apply()
90 {
91 napPrefs.setNapigatorURL(serverListTextArea.getText());
92 napPrefs.setAutoFetchNapigator(autoFetchNapigatorAction.isSelected());
93 napPrefs.setAutoFetchNapigatorInterval
94 (autoFetchNapigatorIntervalTextField.getIntValue());
95 }
96
97 public String getTitle()
98 {
99 return XNap.tr("Server List");
100 }
101
102 }