svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / gui / ProjectGeneralPropertiesPage.java @ 43913
History | View | Annotate | Download (10.9 KB)
1 |
package org.gvsig.app.project.documents.gui; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.Dimension; |
5 |
import java.awt.FlowLayout; |
6 |
import java.awt.GridBagConstraints; |
7 |
import java.awt.GridBagLayout; |
8 |
import java.awt.GridLayout; |
9 |
import java.awt.Insets; |
10 |
import java.io.File; |
11 |
import javax.swing.JButton; |
12 |
import javax.swing.JColorChooser; |
13 |
import javax.swing.JComponent; |
14 |
import javax.swing.JLabel; |
15 |
import javax.swing.JPanel; |
16 |
import javax.swing.JScrollPane; |
17 |
import javax.swing.JTextArea; |
18 |
import javax.swing.JTextField; |
19 |
import org.gvsig.andami.PluginServices; |
20 |
import org.gvsig.app.extension.ProjectExtension; |
21 |
import org.gvsig.app.project.Project; |
22 |
import org.gvsig.propertypage.PropertiesPage; |
23 |
import org.gvsig.tools.ToolsLocator; |
24 |
import org.gvsig.tools.i18n.I18nManager; |
25 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
26 |
|
27 |
public class ProjectGeneralPropertiesPage extends JPanel implements PropertiesPage { |
28 |
|
29 |
private Project project = null; |
30 |
|
31 |
private JPanel jPanel = null; |
32 |
private JLabel jLabel = null; |
33 |
private JLabel jLabel1 = null; |
34 |
private JLabel jLabel2 = null; |
35 |
private JLabel jLabel3 = null; |
36 |
private JLabel jLabel4 = null; |
37 |
private JTextField txtName = null; |
38 |
private JTextField txtPath = null; |
39 |
private JTextField txtCreationDate = null; |
40 |
private JTextField txtModificationDate = null; |
41 |
private JTextField txtOwner = null; |
42 |
private JLabel jLabel5 = null; |
43 |
private JTextArea txtComments = null; |
44 |
private JLabel jLabel6 = null; |
45 |
private JLabel lblColor = null; |
46 |
private JButton btnColor = null; |
47 |
private JScrollPane jScrollPane = null; |
48 |
|
49 |
public ProjectGeneralPropertiesPage(Project project) {
|
50 |
this.project = project;
|
51 |
initComponents(); |
52 |
} |
53 |
|
54 |
@Override
|
55 |
public void setData(Object data) { |
56 |
|
57 |
} |
58 |
|
59 |
@Override
|
60 |
public boolean whenAccept() { |
61 |
return whenApply();
|
62 |
} |
63 |
|
64 |
@Override
|
65 |
public boolean whenApply() { |
66 |
project.setName(txtName.getText()); |
67 |
project.setOwner(txtOwner.getText()); |
68 |
project.setComments(txtComments.getText()); |
69 |
project.setSelectionColor(lblColor.getBackground()); |
70 |
|
71 |
return true; |
72 |
} |
73 |
|
74 |
@Override
|
75 |
public boolean whenCancel() { |
76 |
return true; |
77 |
} |
78 |
|
79 |
@Override
|
80 |
public String getTitle() { |
81 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
82 |
return i18nManager.getTranslation("General"); |
83 |
} |
84 |
|
85 |
public int getPriority() { |
86 |
return 1000; |
87 |
} |
88 |
|
89 |
public JComponent asJComponent() { |
90 |
return this; |
91 |
} |
92 |
|
93 |
private void initComponents() { |
94 |
setLayout(new GridLayout(1, 1, 0, 0)); |
95 |
add(getJPanel()); |
96 |
|
97 |
getTxtName().setText(project.getName()); |
98 |
|
99 |
String path = ProjectExtension.getPath();
|
100 |
|
101 |
if ( path != null ) { |
102 |
File f = new File(path); |
103 |
getTxtPath().setText(f.toString()); |
104 |
} else {
|
105 |
getTxtPath().setText("");
|
106 |
} |
107 |
|
108 |
getTxtOwner().setText(project.getOwner()); |
109 |
getTxtComments().setText(project.getComments()); |
110 |
getTxtCreationDate().setText(project.getCreationDate()); |
111 |
getTxtModificationDate().setText(project.getModificationDate()); |
112 |
|
113 |
getLblColor().setBackground(project.getSelectionColor()); |
114 |
} |
115 |
|
116 |
/**
|
117 |
* This method initializes jPanel
|
118 |
*
|
119 |
* @return JPanel
|
120 |
*/
|
121 |
private JPanel getJPanel() { |
122 |
if ( jPanel == null ) { |
123 |
|
124 |
jPanel = new JPanel(new GridBagLayout()); |
125 |
GridBagConstraints c = new GridBagConstraints(); |
126 |
c.insets = new Insets(2, 5, 0, 5); |
127 |
c.gridy = -1;
|
128 |
|
129 |
addRow(c, getJLabel(), getTxtName()); |
130 |
addRow(c, getJLabel1(), getTxtPath()); |
131 |
addRow(c, getJLabel2(), getTxtCreationDate()); |
132 |
addRow(c, getJLabel3(), getTxtModificationDate()); |
133 |
addRow(c, getJLabel4(), getTxtOwner()); |
134 |
|
135 |
c.anchor = GridBagConstraints.WEST;
|
136 |
c.weightx = 0.0d;
|
137 |
c.gridx = 0;
|
138 |
c.gridy++; |
139 |
jPanel.add(getJLabel6(), c); |
140 |
|
141 |
JPanel colorPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
142 |
colorPanel.add(getLblColor()); |
143 |
colorPanel.add(getBtnColor()); |
144 |
|
145 |
c.fill = GridBagConstraints.HORIZONTAL;
|
146 |
c.weightx = 1.0d;
|
147 |
c.gridx = 1;
|
148 |
jPanel.add(colorPanel, c); |
149 |
|
150 |
c.anchor = GridBagConstraints.WEST;
|
151 |
c.weightx = 0.0d;
|
152 |
c.gridx = 0;
|
153 |
c.gridy++; |
154 |
jPanel.add(getJLabel5(), c); |
155 |
|
156 |
c.fill = GridBagConstraints.BOTH;
|
157 |
c.weightx = 1.0d;
|
158 |
c.gridy++; |
159 |
c.gridwidth = 2;
|
160 |
jPanel.add(getJScrollPane(), c); |
161 |
|
162 |
c.anchor = GridBagConstraints.EAST;
|
163 |
c.gridx = 0;
|
164 |
c.gridwidth = 2;
|
165 |
c.gridy++; |
166 |
c.weightx = 1.0d;
|
167 |
} |
168 |
|
169 |
return jPanel;
|
170 |
} |
171 |
|
172 |
private void addRow(GridBagConstraints c, JComponent label, JComponent text) { |
173 |
c.anchor = GridBagConstraints.WEST;
|
174 |
c.weightx = 0.0d;
|
175 |
c.gridx = 0;
|
176 |
c.gridy++; |
177 |
jPanel.add(label, c); |
178 |
|
179 |
c.fill = GridBagConstraints.HORIZONTAL;
|
180 |
c.weightx = 1.0d;
|
181 |
c.gridx = 1;
|
182 |
jPanel.add(text, c); |
183 |
} |
184 |
|
185 |
/**
|
186 |
* This method initializes jLabel
|
187 |
*
|
188 |
* @return JLabel
|
189 |
*/
|
190 |
private JLabel getJLabel() { |
191 |
if ( jLabel == null ) { |
192 |
jLabel = new JLabel(); |
193 |
jLabel.setText(PluginServices.getText(this, "nombre_sesion") + ":"); |
194 |
} |
195 |
|
196 |
return jLabel;
|
197 |
} |
198 |
|
199 |
/**
|
200 |
* This method initializes jLabel1
|
201 |
*
|
202 |
* @return JLabel
|
203 |
*/
|
204 |
private JLabel getJLabel1() { |
205 |
if ( jLabel1 == null ) { |
206 |
jLabel1 = new JLabel(); |
207 |
jLabel1.setText(PluginServices.getText(this, "path") + ":"); |
208 |
} |
209 |
|
210 |
return jLabel1;
|
211 |
} |
212 |
|
213 |
/**
|
214 |
* This method initializes jLabel2
|
215 |
*
|
216 |
* @return JLabel
|
217 |
*/
|
218 |
private JLabel getJLabel2() { |
219 |
if ( jLabel2 == null ) { |
220 |
jLabel2 = new JLabel(); |
221 |
jLabel2 |
222 |
.setText(PluginServices.getText(this, "creation_date") + ":"); |
223 |
} |
224 |
|
225 |
return jLabel2;
|
226 |
} |
227 |
|
228 |
/**
|
229 |
* This method initializes jLabel3
|
230 |
*
|
231 |
* @return JLabel
|
232 |
*/
|
233 |
private JLabel getJLabel3() { |
234 |
if ( jLabel3 == null ) { |
235 |
jLabel3 = new JLabel(); |
236 |
jLabel3.setText(PluginServices.getText(this, "modification_date") |
237 |
+ ":");
|
238 |
} |
239 |
|
240 |
return jLabel3;
|
241 |
} |
242 |
|
243 |
/**
|
244 |
* This method initializes jLabel4
|
245 |
*
|
246 |
* @return JLabel
|
247 |
*/
|
248 |
private JLabel getJLabel4() { |
249 |
if ( jLabel4 == null ) { |
250 |
jLabel4 = new JLabel(); |
251 |
jLabel4.setText(PluginServices.getText(this, "owner") + ":"); |
252 |
} |
253 |
|
254 |
return jLabel4;
|
255 |
} |
256 |
|
257 |
/**
|
258 |
* This method initializes txtName
|
259 |
*
|
260 |
* @return JTextField
|
261 |
*/
|
262 |
private JTextField getTxtName() { |
263 |
if ( txtName == null ) { |
264 |
txtName = new JTextField(20); |
265 |
} |
266 |
|
267 |
return txtName;
|
268 |
} |
269 |
|
270 |
/**
|
271 |
* This method initializes txtPath
|
272 |
*
|
273 |
* @return JTextField
|
274 |
*/
|
275 |
private JTextField getTxtPath() { |
276 |
if ( txtPath == null ) { |
277 |
txtPath = new JTextField(20); |
278 |
txtPath.setEditable(false);
|
279 |
txtPath.setBackground(java.awt.Color.white); |
280 |
} |
281 |
|
282 |
return txtPath;
|
283 |
} |
284 |
|
285 |
/**
|
286 |
* This method initializes txtCreationDate
|
287 |
*
|
288 |
* @return JTextField
|
289 |
*/
|
290 |
private JTextField getTxtCreationDate() { |
291 |
if ( txtCreationDate == null ) { |
292 |
txtCreationDate = new JTextField(20); |
293 |
txtCreationDate.setEditable(false);
|
294 |
txtCreationDate.setBackground(java.awt.Color.white); |
295 |
} |
296 |
|
297 |
return txtCreationDate;
|
298 |
} |
299 |
|
300 |
/**
|
301 |
* This method initializes txtModificationDate
|
302 |
*
|
303 |
* @return JTextField
|
304 |
*/
|
305 |
private JTextField getTxtModificationDate() { |
306 |
if ( txtModificationDate == null ) { |
307 |
txtModificationDate = new JTextField(20); |
308 |
txtModificationDate.setEditable(false);
|
309 |
txtModificationDate.setBackground(java.awt.Color.white); |
310 |
} |
311 |
|
312 |
return txtModificationDate;
|
313 |
} |
314 |
|
315 |
/**
|
316 |
* This method initializes txtOwner
|
317 |
*
|
318 |
* @return JTextField
|
319 |
*/
|
320 |
private JTextField getTxtOwner() { |
321 |
if ( txtOwner == null ) { |
322 |
txtOwner = new JTextField(20); |
323 |
} |
324 |
|
325 |
return txtOwner;
|
326 |
} |
327 |
|
328 |
/**
|
329 |
* This method initializes jLabel5
|
330 |
*
|
331 |
* @return JLabel
|
332 |
*/
|
333 |
private JLabel getJLabel5() { |
334 |
if ( jLabel5 == null ) { |
335 |
jLabel5 = new JLabel(); |
336 |
jLabel5.setText(PluginServices.getText(this, "comentarios") + ":"); |
337 |
} |
338 |
|
339 |
return jLabel5;
|
340 |
} |
341 |
|
342 |
/**
|
343 |
* This method initializes txtComments
|
344 |
*
|
345 |
* @return JTextArea
|
346 |
*/
|
347 |
private JTextArea getTxtComments() { |
348 |
if ( txtComments == null ) { |
349 |
txtComments = new JTextArea(); |
350 |
txtComments.setRows(4);
|
351 |
txtComments.setColumns(20);
|
352 |
} |
353 |
|
354 |
return txtComments;
|
355 |
} |
356 |
|
357 |
/**
|
358 |
* This method initializes jLabel6
|
359 |
*
|
360 |
* @return JLabel
|
361 |
*/
|
362 |
private JLabel getJLabel6() { |
363 |
if ( jLabel6 == null ) { |
364 |
jLabel6 = new JLabel(); |
365 |
jLabel6.setText(PluginServices.getText(this, "selection_color") |
366 |
+ ":");
|
367 |
} |
368 |
|
369 |
return jLabel6;
|
370 |
} |
371 |
|
372 |
/**
|
373 |
* This method initializes lblColor
|
374 |
*
|
375 |
* @return JLabel
|
376 |
*/
|
377 |
private JLabel getLblColor() { |
378 |
if ( lblColor == null ) { |
379 |
lblColor = new JLabel(); |
380 |
|
381 |
lblColor.setPreferredSize(getBtnColor().getPreferredSize()); |
382 |
lblColor.setOpaque(true);
|
383 |
} |
384 |
|
385 |
return lblColor;
|
386 |
} |
387 |
|
388 |
/**
|
389 |
* This method initializes btnColor
|
390 |
*
|
391 |
* @return JButton
|
392 |
*/
|
393 |
private JButton getBtnColor() { |
394 |
if ( btnColor == null ) { |
395 |
btnColor |
396 |
= ToolsSwingLocator.getUsabilitySwingManager().createJButton( |
397 |
"...");
|
398 |
|
399 |
btnColor.addActionListener(new java.awt.event.ActionListener() {
|
400 |
|
401 |
@Override
|
402 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
403 |
Color ret
|
404 |
= JColorChooser.showDialog(ProjectGeneralPropertiesPage.this,
|
405 |
PluginServices.getText(this, "selection_color"), |
406 |
lblColor.getBackground()); |
407 |
|
408 |
if ( ret != null ) { |
409 |
lblColor.setBackground(ret); |
410 |
} |
411 |
} |
412 |
}); |
413 |
} |
414 |
|
415 |
return btnColor;
|
416 |
} |
417 |
|
418 |
/**
|
419 |
* This method initializes jScrollPane
|
420 |
*
|
421 |
* @return JScrollPane
|
422 |
*/
|
423 |
private JScrollPane getJScrollPane() { |
424 |
if ( jScrollPane == null ) { |
425 |
jScrollPane = new JScrollPane(getTxtComments()); |
426 |
Dimension dim = getTxtComments().getPreferredSize();
|
427 |
jScrollPane |
428 |
.setMinimumSize(new Dimension(dim.width, dim.height + 10)); |
429 |
} |
430 |
|
431 |
return jScrollPane;
|
432 |
} |
433 |
|
434 |
} |