1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
package org.argouml.ui; |
40 | |
|
41 | |
import java.awt.BorderLayout; |
42 | |
import java.awt.Component; |
43 | |
import java.awt.GridBagConstraints; |
44 | |
import java.awt.GridBagLayout; |
45 | |
import java.awt.Insets; |
46 | |
|
47 | |
import javax.swing.BoxLayout; |
48 | |
import javax.swing.JLabel; |
49 | |
import javax.swing.JPanel; |
50 | |
import javax.swing.JTextField; |
51 | |
|
52 | |
import org.argouml.application.api.Argo; |
53 | |
import org.argouml.application.api.GUISettingsTabInterface; |
54 | |
import org.argouml.configuration.Configuration; |
55 | |
import org.argouml.i18n.Translator; |
56 | |
import org.argouml.swingext.JLinkButton; |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
class SettingsTabUser extends JPanel |
65 | |
implements GUISettingsTabInterface { |
66 | |
|
67 | |
private JPanel topPanel; |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
private JTextField userFullname; |
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
private JTextField userEmail; |
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | 900 | SettingsTabUser() { |
87 | |
|
88 | 900 | } |
89 | |
|
90 | |
private void buildPanel() { |
91 | 19 | setLayout(new BorderLayout()); |
92 | |
|
93 | 19 | topPanel = new JPanel(); |
94 | 19 | topPanel.setLayout(new BorderLayout()); |
95 | |
|
96 | 19 | JPanel warning = new JPanel(); |
97 | 19 | warning.setLayout(new BoxLayout(warning, BoxLayout.PAGE_AXIS)); |
98 | 19 | JLabel warningLabel = new JLabel(Translator.localize("label.warning")); |
99 | 19 | warningLabel.setAlignmentX(Component.RIGHT_ALIGNMENT); |
100 | 19 | warning.add(warningLabel); |
101 | |
|
102 | 19 | JLinkButton projectSettings = new JLinkButton(); |
103 | 19 | projectSettings.setAction(new ActionProjectSettings()); |
104 | 19 | projectSettings.setText(Translator.localize("button.project-settings")); |
105 | 19 | projectSettings.setIcon(null); |
106 | 19 | projectSettings.setAlignmentX(Component.RIGHT_ALIGNMENT); |
107 | 19 | warning.add(projectSettings); |
108 | |
|
109 | 19 | topPanel.add(warning, BorderLayout.NORTH); |
110 | |
|
111 | 19 | JPanel settings = new JPanel(); |
112 | 19 | settings.setLayout(new GridBagLayout()); |
113 | |
|
114 | 19 | GridBagConstraints labelConstraints = new GridBagConstraints(); |
115 | 19 | labelConstraints.anchor = GridBagConstraints.WEST; |
116 | 19 | labelConstraints.gridy = 0; |
117 | 19 | labelConstraints.gridx = 0; |
118 | 19 | labelConstraints.gridwidth = 1; |
119 | 19 | labelConstraints.gridheight = 1; |
120 | 19 | labelConstraints.insets = new Insets(2, 20, 2, 4); |
121 | |
|
122 | 19 | GridBagConstraints fieldConstraints = new GridBagConstraints(); |
123 | 19 | fieldConstraints.anchor = GridBagConstraints.EAST; |
124 | 19 | fieldConstraints.fill = GridBagConstraints.HORIZONTAL; |
125 | 19 | fieldConstraints.gridy = 0; |
126 | 19 | fieldConstraints.gridx = 1; |
127 | 19 | fieldConstraints.gridwidth = 3; |
128 | 19 | fieldConstraints.gridheight = 1; |
129 | 19 | fieldConstraints.weightx = 1.0; |
130 | 19 | fieldConstraints.insets = new Insets(2, 4, 2, 20); |
131 | |
|
132 | 19 | labelConstraints.gridy = 0; |
133 | 19 | fieldConstraints.gridy = 0; |
134 | 19 | settings.add(new JLabel(Translator.localize("label.user")), |
135 | |
labelConstraints); |
136 | 19 | JTextField j = new JTextField(); |
137 | 19 | userFullname = j; |
138 | 19 | settings.add(userFullname, fieldConstraints); |
139 | |
|
140 | 19 | labelConstraints.gridy = 1; |
141 | 19 | fieldConstraints.gridy = 1; |
142 | 19 | settings.add(new JLabel(Translator.localize("label.email")), |
143 | |
labelConstraints); |
144 | 19 | JTextField j1 = new JTextField(); |
145 | 19 | userEmail = j1; |
146 | 19 | settings.add(userEmail, fieldConstraints); |
147 | 19 | topPanel.add(settings, BorderLayout.CENTER); |
148 | |
|
149 | 19 | add(topPanel, BorderLayout.NORTH); |
150 | 19 | } |
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
public void handleSettingsTabRefresh() { |
156 | 19 | userFullname.setText(Configuration.getString(Argo.KEY_USER_FULLNAME)); |
157 | 19 | userEmail.setText(Configuration.getString(Argo.KEY_USER_EMAIL)); |
158 | 19 | } |
159 | |
|
160 | |
|
161 | |
|
162 | |
|
163 | |
public void handleSettingsTabSave() { |
164 | 0 | Configuration.setString(Argo.KEY_USER_FULLNAME, userFullname.getText()); |
165 | 0 | Configuration.setString(Argo.KEY_USER_EMAIL, userEmail.getText()); |
166 | 0 | } |
167 | |
|
168 | |
|
169 | |
|
170 | |
|
171 | |
public void handleSettingsTabCancel() { |
172 | 0 | handleSettingsTabRefresh(); |
173 | 0 | } |
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
public void handleResetToDefault() { |
179 | |
|
180 | 0 | } |
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
public String getTabKey() { |
186 | 19 | return "tab.user"; |
187 | |
} |
188 | |
|
189 | |
|
190 | |
|
191 | |
|
192 | |
public JPanel getTabPanel() { |
193 | 19 | if (topPanel == null) { |
194 | 19 | buildPanel(); |
195 | |
} |
196 | 19 | return this; |
197 | |
} |
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | |
private static final long serialVersionUID = -742258688091914619L; |
203 | |
} |