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.GridBagConstraints; |
43 | |
import java.awt.GridBagLayout; |
44 | |
import java.awt.Insets; |
45 | |
|
46 | |
import javax.swing.JLabel; |
47 | |
import javax.swing.JPanel; |
48 | |
import javax.swing.JScrollPane; |
49 | |
import javax.swing.JTextArea; |
50 | |
import javax.swing.JTextField; |
51 | |
import javax.swing.SwingConstants; |
52 | |
|
53 | |
import org.argouml.application.api.Argo; |
54 | |
import org.argouml.configuration.Configuration; |
55 | |
import org.argouml.i18n.Translator; |
56 | |
import org.argouml.kernel.Project; |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | 900 | public class ProjectSettingsTabProperties extends JPanel implements |
66 | |
GUIProjectSettingsTabInterface { |
67 | |
|
68 | |
private Project p; |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
private JTextField userFullname; |
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
private JTextField userEmail; |
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
private JTextArea description; |
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
private JTextField version; |
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | 900 | ProjectSettingsTabProperties() { |
100 | 900 | setLayout(new BorderLayout()); |
101 | 900 | JPanel top = new JPanel(); |
102 | 900 | top.setLayout(new GridBagLayout()); |
103 | |
|
104 | 900 | GridBagConstraints labelConstraints = new GridBagConstraints(); |
105 | |
|
106 | 900 | labelConstraints.anchor = GridBagConstraints.LINE_START; |
107 | 900 | labelConstraints.gridy = 0; |
108 | 900 | labelConstraints.gridx = 0; |
109 | 900 | labelConstraints.gridwidth = 1; |
110 | 900 | labelConstraints.gridheight = 1; |
111 | 900 | labelConstraints.insets = new Insets(2, 20, 2, 4); |
112 | 900 | labelConstraints.anchor = |
113 | |
GridBagConstraints.FIRST_LINE_START; |
114 | |
|
115 | 900 | GridBagConstraints fieldConstraints = new GridBagConstraints(); |
116 | |
|
117 | 900 | fieldConstraints.anchor = GridBagConstraints.LINE_END; |
118 | 900 | fieldConstraints.fill = GridBagConstraints.BOTH; |
119 | 900 | fieldConstraints.gridy = 0; |
120 | 900 | fieldConstraints.gridx = 1; |
121 | 900 | fieldConstraints.gridwidth = 3; |
122 | 900 | fieldConstraints.gridheight = 1; |
123 | 900 | fieldConstraints.weightx = 1.0; |
124 | 900 | fieldConstraints.insets = new Insets(2, 4, 2, 20); |
125 | |
|
126 | |
|
127 | 900 | labelConstraints.gridy = 0; |
128 | 900 | fieldConstraints.gridy = 0; |
129 | 900 | top.add(new JLabel(Translator.localize("label.user")), |
130 | |
labelConstraints); |
131 | 900 | userFullname = new JTextField(); |
132 | 900 | top.add(userFullname, fieldConstraints); |
133 | |
|
134 | |
|
135 | 900 | labelConstraints.gridy = 1; |
136 | 900 | fieldConstraints.gridy = 1; |
137 | 900 | top.add(new JLabel(Translator.localize("label.email")), |
138 | |
labelConstraints); |
139 | 900 | userEmail = new JTextField(); |
140 | 900 | top.add(userEmail, fieldConstraints); |
141 | |
|
142 | |
|
143 | 900 | labelConstraints.gridy = 2; |
144 | 900 | fieldConstraints.gridy = 2; |
145 | 900 | fieldConstraints.weighty = 1.0; |
146 | 900 | labelConstraints.weighty = 1.0; |
147 | 900 | JLabel lblDescription = new JLabel( |
148 | |
Translator.localize("label.project.description")); |
149 | 900 | lblDescription.setVerticalAlignment(SwingConstants.TOP); |
150 | 900 | top.add(lblDescription, |
151 | |
labelConstraints); |
152 | 900 | description = new JTextArea(); |
153 | 900 | JScrollPane area = new JScrollPane(description); |
154 | 900 | area.setVerticalScrollBarPolicy( |
155 | |
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
156 | 900 | description.setMargin(new Insets(3, 3, 3, 3)); |
157 | 900 | description.setLineWrap(true); |
158 | 900 | description.setWrapStyleWord(true); |
159 | 900 | top.add(area, fieldConstraints); |
160 | |
|
161 | |
|
162 | |
|
163 | |
|
164 | 900 | labelConstraints.gridy = 3; |
165 | 900 | fieldConstraints.gridy = 3; |
166 | 900 | fieldConstraints.weighty = 0.0; |
167 | 900 | labelConstraints.weighty = 0.0; |
168 | 900 | top.add(new JLabel(Translator.localize("label.argouml.version")), |
169 | |
labelConstraints); |
170 | 900 | version = new JTextField(); |
171 | 900 | version.setEditable(false); |
172 | 900 | top.add(version, fieldConstraints); |
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | 900 | add(top, BorderLayout.CENTER); |
178 | 900 | } |
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
public void handleSettingsTabRefresh() { |
184 | 106 | assert p != null; |
185 | 106 | userFullname.setText(p.getAuthorname()); |
186 | 106 | userEmail.setText(p.getAuthoremail()); |
187 | 106 | description.setText(p.getDescription()); |
188 | 106 | description.setCaretPosition(0); |
189 | 106 | version.setText(p.getVersion()); |
190 | 106 | } |
191 | |
|
192 | |
|
193 | |
|
194 | |
|
195 | |
public void handleSettingsTabSave() { |
196 | 12 | assert p != null; |
197 | 12 | p.setAuthorname(userFullname.getText()); |
198 | 12 | p.setAuthoremail(userEmail.getText()); |
199 | 12 | p.setDescription(description.getText()); |
200 | 12 | } |
201 | |
|
202 | |
|
203 | |
|
204 | |
|
205 | |
public void handleSettingsTabCancel() { |
206 | 6 | handleSettingsTabRefresh(); |
207 | 6 | } |
208 | |
|
209 | |
|
210 | |
|
211 | |
|
212 | |
public void handleResetToDefault() { |
213 | 6 | userFullname.setText(Configuration.getString(Argo.KEY_USER_FULLNAME)); |
214 | 6 | userEmail.setText(Configuration.getString(Argo.KEY_USER_EMAIL)); |
215 | |
|
216 | 6 | } |
217 | |
|
218 | |
|
219 | |
|
220 | |
|
221 | 100 | public String getTabKey() { return "tab.user"; } |
222 | |
|
223 | |
|
224 | |
|
225 | |
|
226 | 100 | public JPanel getTabPanel() { return this; } |
227 | |
|
228 | |
public void setProject(Project project) { |
229 | 100 | assert project != null; |
230 | 100 | p = project; |
231 | 100 | } |
232 | |
} |