1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.plugin.gift.gui;
21
22 import java.awt.GridBagLayout;
23
24 import javax.swing.*;
25 import javax.swing.JPanel;
26 import javax.swing.JTextField;
27
28 import org.xnap.XNap;
29 import org.xnap.gui.AbstractSettingsPanel;
30 import org.xnap.gui.component.FilePanel;
31 import org.xnap.gui.component.ValidatedTextField;
32 import org.xnap.gui.util.GUIHelper;
33 import org.xnap.gui.util.GridBagHelper;
34 import org.xnap.plugin.gift.GiFTPlugin;
35 import org.xnap.plugin.gift.util.GiFTPreferences;
36
37 public class GiFTPreferencesPanel extends AbstractSettingsPanel
38 {
39
40
41
42
43 private static GiFTPreferences prefs = GiFTPreferences.getInstance();
44
45 private FilePanel fpGiftDaemon;
46 private ValidatedTextField jteHttpPort;
47 private JTextField jteGiftHost;
48 private ValidatedTextField jteGiftPort;
49 private JCheckBox jcbStartEngine;
50 private JCheckBox jcbAutoConnect;
51
52
53
54
55 public GiFTPreferencesPanel()
56 {
57 setLayout(new GridBagLayout());
58
59 JPanel jpCommand = new JPanel(new GridBagLayout());
60 jpCommand.setBorder(GUIHelper.createDefaultBorder(XNap.tr("Daemon Command")));
61 GridBagHelper.add(this, jpCommand);
62
63 fpGiftDaemon = new FilePanel(prefs.getGiftDaemon(), 20);
64 GridBagHelper.add(jpCommand, fpGiftDaemon);
65
66 jcbStartEngine = new JCheckBox(XNap.tr("Launch giFT on Startup"),
67 prefs.getStartDaemon());
68 GridBagHelper.add(jpCommand, jcbStartEngine);
69
70 JPanel jpDaemon = new JPanel(new GridBagLayout());
71 jpDaemon.setBorder(GUIHelper.createDefaultBorder(XNap.tr("Daemon")));
72 GridBagHelper.add(this, jpDaemon);
73
74 JLabel l = GridBagHelper.addLabel(jpDaemon, XNap.tr("Host"));
75 jteGiftHost = new JTextField(prefs.getGiftHost(), 20);
76 l.setLabelFor(jteGiftHost);
77 GridBagHelper.add(jpDaemon, jteGiftHost, false);
78
79 l = GridBagHelper.addLabel(jpDaemon, XNap.tr("Port"));
80 jteGiftPort = new ValidatedTextField(prefs.getDaemonPort() + "",
81 5,ValidatedTextField.NUMBERS_INT);
82 l.setLabelFor(jteGiftPort);
83 GridBagHelper.add(jpDaemon, jteGiftPort, false);
84
85 l = GridBagHelper.addLabel(jpDaemon, XNap.tr("HTTP Port"));
86 jteHttpPort = new ValidatedTextField(prefs.getHttpPort() + "",
87 5,ValidatedTextField.NUMBERS_INT);
88 l.setLabelFor(jteHttpPort);
89 GridBagHelper.add(jpDaemon, jteHttpPort, false);
90
91 jcbAutoConnect = new JCheckBox
92 (XNap.tr("Connect to giFT on Startup", 1), prefs.getAutoconnect());
93 GridBagHelper.add(jpDaemon, jcbAutoConnect);
94
95 GridBagHelper.addVerticalSpacer(this);
96 GUIHelper.setMnemonics(this);
97 }
98
99
100
101 public void apply()
102 {
103 prefs.setGiftDaemon(fpGiftDaemon.getFilename());
104 prefs.setGiftHost(jteGiftHost.getText());
105 prefs.setDaemonPort(jteGiftPort.getIntValue());
106 prefs.setHttpPort(jteHttpPort.getIntValue());
107 prefs.setAutoconnect(jcbAutoConnect.isSelected());
108 prefs.setStartDaemon(jcbStartEngine.isSelected());
109
110 }
111
112 public String getTitle()
113 {
114 return GiFTPlugin.getInstance().getInfo().getName();
115 }
116
117 /***
118 * @see xnap.gui.SettingsPanel#getDescription()
119 */
120 public String getDescription()
121 {
122 return XNap.tr("giFT settings");
123 }
124
125 }
126
127