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