svn-gvsig-desktop / tags / v2_0_0_Build_2060 / applications / appgvSIG / src / org / gvsig / app / project / documents / gui / ProjectProperties.java @ 39341
History | View | Annotate | Download (13 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.app.project.documents.gui; |
23 |
|
24 |
import java.awt.Color; |
25 |
import java.awt.Dimension; |
26 |
import java.awt.FlowLayout; |
27 |
import java.awt.GridBagConstraints; |
28 |
import java.awt.GridBagLayout; |
29 |
import java.awt.GridLayout; |
30 |
import java.awt.Insets; |
31 |
import java.io.File; |
32 |
|
33 |
import javax.swing.JButton; |
34 |
import javax.swing.JColorChooser; |
35 |
import javax.swing.JComponent; |
36 |
import javax.swing.JLabel; |
37 |
import javax.swing.JPanel; |
38 |
import javax.swing.JScrollPane; |
39 |
import javax.swing.JTextArea; |
40 |
import javax.swing.JTextField; |
41 |
|
42 |
import org.gvsig.andami.PluginServices; |
43 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
44 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
45 |
import org.gvsig.app.extension.ProjectExtension; |
46 |
import org.gvsig.app.project.Project; |
47 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
48 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
49 |
|
50 |
/**
|
51 |
* Propiedades del proyecto
|
52 |
*
|
53 |
* @author Fernando Gonz?lez Cort?s
|
54 |
* @author gvSIG team
|
55 |
*/
|
56 |
public class ProjectProperties extends JPanel implements IWindow { |
57 |
|
58 |
private static final long serialVersionUID = 8952351479171919349L; |
59 |
private Project project = null; |
60 |
private JPanel jPanel = null; |
61 |
private JLabel jLabel = null; |
62 |
private JLabel jLabel1 = null; |
63 |
private JLabel jLabel2 = null; |
64 |
private JLabel jLabel3 = null; |
65 |
private JLabel jLabel4 = null; |
66 |
private JTextField txtName = null; |
67 |
private JTextField txtPath = null; |
68 |
private JTextField txtCreationDate = null; |
69 |
private JTextField txtModificationDate = null; |
70 |
private JTextField txtOwner = null; |
71 |
private JLabel jLabel5 = null; |
72 |
private JTextArea txtComments = null; |
73 |
private JLabel jLabel6 = null; |
74 |
private JLabel lblColor = null; |
75 |
private JButton btnColor = null; |
76 |
private JScrollPane jScrollPane = null; |
77 |
|
78 |
/**
|
79 |
* This is the default constructor
|
80 |
*
|
81 |
* @param owner
|
82 |
* Frame padre del di?logo
|
83 |
* @param p
|
84 |
* Proyecto cuyos datos se muestran en el di?logo
|
85 |
*/
|
86 |
public ProjectProperties(Project p) {
|
87 |
project = p; |
88 |
initialize(); |
89 |
} |
90 |
|
91 |
/**
|
92 |
* This method initializes this
|
93 |
*/
|
94 |
private void initialize() { |
95 |
setLayout(new GridLayout(1, 1, 0, 0)); |
96 |
add(getJPanel()); |
97 |
|
98 |
getTxtName().setText(project.getName()); |
99 |
|
100 |
String path = ProjectExtension.getPath();
|
101 |
|
102 |
if (path != null) { |
103 |
File f = new File(path); |
104 |
getTxtPath().setText(f.toString()); |
105 |
} else {
|
106 |
getTxtPath().setText("");
|
107 |
} |
108 |
|
109 |
getTxtOwner().setText(project.getOwner()); |
110 |
getTxtComments().setText(project.getComments()); |
111 |
getTxtCreationDate().setText(project.getCreationDate()); |
112 |
getTxtModificationDate().setText(project.getModificationDate()); |
113 |
|
114 |
getLblColor().setBackground(project.getSelectionColor()); |
115 |
} |
116 |
|
117 |
/**
|
118 |
* This method initializes jPanel
|
119 |
*
|
120 |
* @return JPanel
|
121 |
*/
|
122 |
private JPanel getJPanel() { |
123 |
if (jPanel == null) { |
124 |
|
125 |
jPanel = new JPanel(new GridBagLayout()); |
126 |
GridBagConstraints c = new GridBagConstraints(); |
127 |
c.insets = new Insets(2, 5, 0, 5); |
128 |
c.gridy = -1;
|
129 |
|
130 |
addRow(c, getJLabel(), getTxtName()); |
131 |
addRow(c, getJLabel1(), getTxtPath()); |
132 |
addRow(c, getJLabel2(), getTxtCreationDate()); |
133 |
addRow(c, getJLabel3(), getTxtModificationDate()); |
134 |
addRow(c, getJLabel4(), getTxtOwner()); |
135 |
|
136 |
c.anchor = GridBagConstraints.WEST;
|
137 |
c.weightx = 0.0d;
|
138 |
c.gridx = 0;
|
139 |
c.gridy++; |
140 |
jPanel.add(getJLabel6(), c); |
141 |
|
142 |
JPanel colorPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
143 |
colorPanel.add(getLblColor()); |
144 |
colorPanel.add(getBtnColor()); |
145 |
|
146 |
c.fill = GridBagConstraints.HORIZONTAL;
|
147 |
c.weightx = 1.0d;
|
148 |
c.gridx = 1;
|
149 |
jPanel.add(colorPanel, c); |
150 |
|
151 |
c.anchor = GridBagConstraints.WEST;
|
152 |
c.weightx = 0.0d;
|
153 |
c.gridx = 0;
|
154 |
c.gridy++; |
155 |
jPanel.add(getJLabel5(), c); |
156 |
|
157 |
c.fill = GridBagConstraints.BOTH;
|
158 |
c.weightx = 1.0d;
|
159 |
c.gridy++; |
160 |
c.gridwidth = 2;
|
161 |
jPanel.add(getJScrollPane(), c); |
162 |
|
163 |
java.awt.event.ActionListener okAction = |
164 |
new java.awt.event.ActionListener() {
|
165 |
|
166 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
167 |
project.setName(txtName.getText()); |
168 |
|
169 |
// PluginServices.getMainFrame().setTitle(project.getName());
|
170 |
|
171 |
project.setOwner(txtOwner.getText()); |
172 |
project.setComments(txtComments.getText()); |
173 |
project.setSelectionColor(lblColor.getBackground()); |
174 |
PluginServices.getMDIManager().closeWindow( |
175 |
ProjectProperties.this); |
176 |
} |
177 |
}, cancelAction = new java.awt.event.ActionListener() {
|
178 |
|
179 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
180 |
PluginServices.getMDIManager().closeWindow( |
181 |
ProjectProperties.this); |
182 |
} |
183 |
}; |
184 |
|
185 |
c.anchor = GridBagConstraints.EAST;
|
186 |
c.gridx = 0;
|
187 |
c.gridwidth = 2;
|
188 |
c.gridy++; |
189 |
c.weightx = 1.0d;
|
190 |
|
191 |
jPanel.add(new AcceptCancelPanel(okAction, cancelAction), c);
|
192 |
} |
193 |
|
194 |
return jPanel;
|
195 |
} |
196 |
|
197 |
private void addRow(GridBagConstraints c, JComponent label, JComponent text) { |
198 |
c.anchor = GridBagConstraints.WEST;
|
199 |
c.weightx = 0.0d;
|
200 |
c.gridx = 0;
|
201 |
c.gridy++; |
202 |
jPanel.add(label, c); |
203 |
|
204 |
c.fill = GridBagConstraints.HORIZONTAL;
|
205 |
c.weightx = 1.0d;
|
206 |
c.gridx = 1;
|
207 |
jPanel.add(text, c); |
208 |
} |
209 |
|
210 |
/**
|
211 |
* This method initializes jLabel
|
212 |
*
|
213 |
* @return JLabel
|
214 |
*/
|
215 |
private JLabel getJLabel() { |
216 |
if (jLabel == null) { |
217 |
jLabel = new JLabel(); |
218 |
jLabel.setText(PluginServices.getText(this, "nombre_sesion") + ":"); |
219 |
} |
220 |
|
221 |
return jLabel;
|
222 |
} |
223 |
|
224 |
/**
|
225 |
* This method initializes jLabel1
|
226 |
*
|
227 |
* @return JLabel
|
228 |
*/
|
229 |
private JLabel getJLabel1() { |
230 |
if (jLabel1 == null) { |
231 |
jLabel1 = new JLabel(); |
232 |
jLabel1.setText(PluginServices.getText(this, "path") + ":"); |
233 |
} |
234 |
|
235 |
return jLabel1;
|
236 |
} |
237 |
|
238 |
/**
|
239 |
* This method initializes jLabel2
|
240 |
*
|
241 |
* @return JLabel
|
242 |
*/
|
243 |
private JLabel getJLabel2() { |
244 |
if (jLabel2 == null) { |
245 |
jLabel2 = new JLabel(); |
246 |
jLabel2 |
247 |
.setText(PluginServices.getText(this, "creation_date") + ":"); |
248 |
} |
249 |
|
250 |
return jLabel2;
|
251 |
} |
252 |
|
253 |
/**
|
254 |
* This method initializes jLabel3
|
255 |
*
|
256 |
* @return JLabel
|
257 |
*/
|
258 |
private JLabel getJLabel3() { |
259 |
if (jLabel3 == null) { |
260 |
jLabel3 = new JLabel(); |
261 |
jLabel3.setText(PluginServices.getText(this, "modification_date") |
262 |
+ ":");
|
263 |
} |
264 |
|
265 |
return jLabel3;
|
266 |
} |
267 |
|
268 |
/**
|
269 |
* This method initializes jLabel4
|
270 |
*
|
271 |
* @return JLabel
|
272 |
*/
|
273 |
private JLabel getJLabel4() { |
274 |
if (jLabel4 == null) { |
275 |
jLabel4 = new JLabel(); |
276 |
jLabel4.setText(PluginServices.getText(this, "owner") + ":"); |
277 |
} |
278 |
|
279 |
return jLabel4;
|
280 |
} |
281 |
|
282 |
/**
|
283 |
* This method initializes txtName
|
284 |
*
|
285 |
* @return JTextField
|
286 |
*/
|
287 |
private JTextField getTxtName() { |
288 |
if (txtName == null) { |
289 |
txtName = new JTextField(20); |
290 |
} |
291 |
|
292 |
return txtName;
|
293 |
} |
294 |
|
295 |
/**
|
296 |
* This method initializes txtPath
|
297 |
*
|
298 |
* @return JTextField
|
299 |
*/
|
300 |
private JTextField getTxtPath() { |
301 |
if (txtPath == null) { |
302 |
txtPath = new JTextField(20); |
303 |
txtPath.setEditable(false);
|
304 |
txtPath.setBackground(java.awt.Color.white); |
305 |
} |
306 |
|
307 |
return txtPath;
|
308 |
} |
309 |
|
310 |
/**
|
311 |
* This method initializes txtCreationDate
|
312 |
*
|
313 |
* @return JTextField
|
314 |
*/
|
315 |
private JTextField getTxtCreationDate() { |
316 |
if (txtCreationDate == null) { |
317 |
txtCreationDate = new JTextField(20); |
318 |
txtCreationDate.setEditable(false);
|
319 |
txtCreationDate.setBackground(java.awt.Color.white); |
320 |
} |
321 |
|
322 |
return txtCreationDate;
|
323 |
} |
324 |
|
325 |
/**
|
326 |
* This method initializes txtModificationDate
|
327 |
*
|
328 |
* @return JTextField
|
329 |
*/
|
330 |
private JTextField getTxtModificationDate() { |
331 |
if (txtModificationDate == null) { |
332 |
txtModificationDate = new JTextField(20); |
333 |
txtModificationDate.setEditable(false);
|
334 |
txtModificationDate.setBackground(java.awt.Color.white); |
335 |
} |
336 |
|
337 |
return txtModificationDate;
|
338 |
} |
339 |
|
340 |
/**
|
341 |
* This method initializes txtOwner
|
342 |
*
|
343 |
* @return JTextField
|
344 |
*/
|
345 |
private JTextField getTxtOwner() { |
346 |
if (txtOwner == null) { |
347 |
txtOwner = new JTextField(20); |
348 |
} |
349 |
|
350 |
return txtOwner;
|
351 |
} |
352 |
|
353 |
/**
|
354 |
* This method initializes jLabel5
|
355 |
*
|
356 |
* @return JLabel
|
357 |
*/
|
358 |
private JLabel getJLabel5() { |
359 |
if (jLabel5 == null) { |
360 |
jLabel5 = new JLabel(); |
361 |
jLabel5.setText(PluginServices.getText(this, "comentarios") + ":"); |
362 |
} |
363 |
|
364 |
return jLabel5;
|
365 |
} |
366 |
|
367 |
/**
|
368 |
* This method initializes txtComments
|
369 |
*
|
370 |
* @return JTextArea
|
371 |
*/
|
372 |
private JTextArea getTxtComments() { |
373 |
if (txtComments == null) { |
374 |
txtComments = new JTextArea(); |
375 |
txtComments.setRows(4);
|
376 |
txtComments.setColumns(20);
|
377 |
} |
378 |
|
379 |
return txtComments;
|
380 |
} |
381 |
|
382 |
/**
|
383 |
* This method initializes jLabel6
|
384 |
*
|
385 |
* @return JLabel
|
386 |
*/
|
387 |
private JLabel getJLabel6() { |
388 |
if (jLabel6 == null) { |
389 |
jLabel6 = new JLabel(); |
390 |
jLabel6.setText(PluginServices.getText(this, "selection_color") |
391 |
+ ":");
|
392 |
} |
393 |
|
394 |
return jLabel6;
|
395 |
} |
396 |
|
397 |
/**
|
398 |
* This method initializes lblColor
|
399 |
*
|
400 |
* @return JLabel
|
401 |
*/
|
402 |
private JLabel getLblColor() { |
403 |
if (lblColor == null) { |
404 |
lblColor = new JLabel(); |
405 |
|
406 |
lblColor.setPreferredSize(getBtnColor().getPreferredSize()); |
407 |
lblColor.setOpaque(true);
|
408 |
} |
409 |
|
410 |
return lblColor;
|
411 |
} |
412 |
|
413 |
/**
|
414 |
* This method initializes btnColor
|
415 |
*
|
416 |
* @return JButton
|
417 |
*/
|
418 |
private JButton getBtnColor() { |
419 |
if (btnColor == null) { |
420 |
btnColor = |
421 |
ToolsSwingLocator.getUsabilitySwingManager().createJButton( |
422 |
"...");
|
423 |
|
424 |
btnColor.addActionListener(new java.awt.event.ActionListener() {
|
425 |
|
426 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
427 |
Color ret =
|
428 |
JColorChooser.showDialog(ProjectProperties.this,
|
429 |
PluginServices.getText(this, "selection_color"), |
430 |
lblColor.getBackground()); |
431 |
|
432 |
if (ret != null) { |
433 |
lblColor.setBackground(ret); |
434 |
} |
435 |
} |
436 |
}); |
437 |
} |
438 |
|
439 |
return btnColor;
|
440 |
} |
441 |
|
442 |
/**
|
443 |
* This method initializes jScrollPane
|
444 |
*
|
445 |
* @return JScrollPane
|
446 |
*/
|
447 |
private JScrollPane getJScrollPane() { |
448 |
if (jScrollPane == null) { |
449 |
jScrollPane = new JScrollPane(getTxtComments()); |
450 |
Dimension dim = getTxtComments().getPreferredSize();
|
451 |
jScrollPane |
452 |
.setMinimumSize(new Dimension(dim.width, dim.height + 10)); |
453 |
} |
454 |
|
455 |
return jScrollPane;
|
456 |
} |
457 |
|
458 |
/**
|
459 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
460 |
*/
|
461 |
public WindowInfo getWindowInfo() {
|
462 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
463 |
this.validate();
|
464 |
Dimension dim = getPreferredSize();
|
465 |
m_viewinfo.setWidth(dim.width); |
466 |
m_viewinfo.setHeight(dim.height); |
467 |
m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_sesion")); |
468 |
return m_viewinfo;
|
469 |
} |
470 |
|
471 |
/**
|
472 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
|
473 |
*/
|
474 |
public void viewActivated() { |
475 |
} |
476 |
|
477 |
public Object getWindowProfile() { |
478 |
return WindowInfo.DIALOG_PROFILE;
|
479 |
} |
480 |
|
481 |
} |