1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.plugin.joscar;
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.ValidatedTextField;
31 import org.xnap.gui.util.GUIHelper;
32 import org.xnap.gui.util.GridBagHelper;
33
34 public class JOscarPreferencesPanel extends AbstractSettingsPanel
35 {
36
37
38
39 private JOscarPreferences prefs = JOscarPreferences.getInstance();
40
41 private JTextField jteServerHost;
42 private ValidatedTextField jteServerPort;
43
44 private JTextField jteUsername;
45 private JTextField jtePassword;
46 private JCheckBox jcAutoConnect;
47
48
49
50 public JOscarPreferencesPanel()
51 {
52 setLayout(new GridBagLayout());
53
54 JPanel jpServer = new JPanel(new GridBagLayout());
55 jpServer.setBorder(GUIHelper.createDefaultBorder(XNap.tr("Server")));
56 GridBagHelper.add(this, jpServer);
57
58 JLabel l = GridBagHelper.addLabel(jpServer, XNap.tr("Host"));
59 jteServerHost = new JTextField(prefs.getServerHost(), 20);
60 l.setLabelFor(jteServerHost);
61 GridBagHelper.add(jpServer, jteServerHost, false);
62
63 l = GridBagHelper.addLabel(jpServer, XNap.tr("Port"));
64 jteServerPort = new ValidatedTextField(prefs.getServerPort() + "",
65 5,ValidatedTextField.NUMBERS_INT);
66 l.setLabelFor(jteServerPort);
67 GridBagHelper.add(jpServer, jteServerPort, false);
68
69
70 JPanel jpLogin = new JPanel(new GridBagLayout());
71 jpLogin.setBorder(GUIHelper.createDefaultBorder(XNap.tr("Login")));
72 GridBagHelper.add(this, jpLogin);
73
74 l = GridBagHelper.addLabel(jpLogin, XNap.tr("UIN"));
75 jteUsername = new JTextField(prefs.getUsername(), 20);
76 l.setLabelFor(jteUsername);
77 GridBagHelper.add(jpLogin, jteUsername, false);
78
79 l = GridBagHelper.addLabel(jpLogin, XNap.tr("Password"));
80 jtePassword = new JTextField(prefs.getPassword(), 20);
81 l.setLabelFor(jtePassword);
82 GridBagHelper.add(jpLogin, jtePassword, false);
83
84
85 jcAutoConnect = new JCheckBox(XNap.tr("Connect on startup"),
86 prefs.getAutoconnect());
87 GridBagHelper.add(this, jcAutoConnect);
88
89 GridBagHelper.addVerticalSpacer(this);
90 GUIHelper.setMnemonics(this);
91 }
92
93
94
95 public void apply()
96 {
97 prefs.setServerHost(jteServerHost.getText());
98 prefs.setServerPort(jteServerPort.getIntValue());
99 prefs.setUsername(jteUsername.getText());
100 prefs.setPassword(jtePassword.getText());
101 prefs.setAutoconnect(jcAutoConnect.isSelected());
102 }
103
104 public String getTitle()
105 {
106 return JOscarPlugin.getInstance().getName();
107 }
108
109 /***
110 * @see xnap.gui.SettingsPanel#getDescription()
111 */
112 public String getDescription() {
113 return XNap.tr("ICQ Settings");
114 }
115
116 }
117