Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / gui / ProjectProperties.java @ 38608

History | View | Annotate | Download (12.9 KB)

1 36411 cordinyana
/* gvSIG. Geographic Information System of the Valencian Government
2 7304 caballero
 *
3 36411 cordinyana
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6 7304 caballero
 * 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 36411 cordinyana
 *
11 7304 caballero
 * 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 36411 cordinyana
 *
16 7304 caballero
 * 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 36411 cordinyana
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21 7304 caballero
 */
22 29598 jpiera
package org.gvsig.app.project.documents.gui;
23 7304 caballero
24
import java.awt.Color;
25 37840 cordinyana
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 7304 caballero
import java.io.File;
32
33 37840 cordinyana
import javax.swing.JButton;
34 7304 caballero
import javax.swing.JColorChooser;
35 37840 cordinyana
import javax.swing.JComponent;
36
import javax.swing.JLabel;
37 7304 caballero
import javax.swing.JPanel;
38 37840 cordinyana
import javax.swing.JScrollPane;
39
import javax.swing.JTextArea;
40
import javax.swing.JTextField;
41 7304 caballero
42 29598 jpiera
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 7304 caballero
import org.gvsig.gui.beans.AcceptCancelPanel;
48 37840 cordinyana
import org.gvsig.tools.swing.api.ToolsSwingLocator;
49 7304 caballero
50
/**
51
 * Propiedades del proyecto
52 36411 cordinyana
 *
53 7304 caballero
 * @author Fernando Gonz?lez Cort?s
54 37840 cordinyana
 * @author gvSIG team
55 7304 caballero
 */
56
public class ProjectProperties extends JPanel implements IWindow {
57 36411 cordinyana
58
    private static final long serialVersionUID = 8952351479171919349L;
59 7304 caballero
    private Project project = null;
60 37840 cordinyana
    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 36411 cordinyana
78 7304 caballero
    /**
79
     * This is the default constructor
80 36411 cordinyana
     *
81
     * @param owner
82
     *            Frame padre del di?logo
83
     * @param p
84
     *            Proyecto cuyos datos se muestran en el di?logo
85 7304 caballero
     */
86
    public ProjectProperties(Project p) {
87
        project = p;
88
        initialize();
89
    }
90
91
    /**
92
     * This method initializes this
93
     */
94
    private void initialize() {
95 37840 cordinyana
        setLayout(new GridLayout(1, 1, 0, 0));
96
        add(getJPanel());
97 7304 caballero
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 36411 cordinyana
     *
120 37840 cordinyana
     * @return JPanel
121 7304 caballero
     */
122 37840 cordinyana
    private JPanel getJPanel() {
123 7304 caballero
        if (jPanel == null) {
124 37840 cordinyana
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 36411 cordinyana
            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
                        project.setOwner(txtOwner.getText());
169
                        project.setComments(txtComments.getText());
170
                        project.setSelectionColor(lblColor.getBackground());
171
                        PluginServices.getMDIManager().closeWindow(
172
                            ProjectProperties.this);
173
                    }
174
                }, cancelAction = new java.awt.event.ActionListener() {
175
176 7304 caballero
                public void actionPerformed(java.awt.event.ActionEvent e) {
177 36411 cordinyana
                    PluginServices.getMDIManager().closeWindow(
178
                        ProjectProperties.this);
179 7304 caballero
                }
180
            };
181 37840 cordinyana
182
            c.anchor = GridBagConstraints.EAST;
183
            c.gridx = 0;
184
            c.gridwidth = 2;
185
            c.gridy++;
186
            c.weightx = 1.0d;
187
188
            jPanel.add(new AcceptCancelPanel(okAction, cancelAction), c);
189 7304 caballero
        }
190
191
        return jPanel;
192
    }
193
194 37840 cordinyana
    private void addRow(GridBagConstraints c, JComponent label, JComponent text) {
195
        c.anchor = GridBagConstraints.WEST;
196
        c.weightx = 0.0d;
197
        c.gridx = 0;
198
        c.gridy++;
199
        jPanel.add(label, c);
200
201
        c.fill = GridBagConstraints.HORIZONTAL;
202
        c.weightx = 1.0d;
203
        c.gridx = 1;
204
        jPanel.add(text, c);
205
    }
206
207 7304 caballero
    /**
208
     * This method initializes jLabel
209 36411 cordinyana
     *
210 37840 cordinyana
     * @return JLabel
211 7304 caballero
     */
212 37840 cordinyana
    private JLabel getJLabel() {
213 7304 caballero
        if (jLabel == null) {
214 37840 cordinyana
            jLabel = new JLabel();
215 7304 caballero
            jLabel.setText(PluginServices.getText(this, "nombre_sesion") + ":");
216
        }
217
218
        return jLabel;
219
    }
220
221
    /**
222
     * This method initializes jLabel1
223 36411 cordinyana
     *
224 37840 cordinyana
     * @return JLabel
225 7304 caballero
     */
226 37840 cordinyana
    private JLabel getJLabel1() {
227 7304 caballero
        if (jLabel1 == null) {
228 37840 cordinyana
            jLabel1 = new JLabel();
229 7304 caballero
            jLabel1.setText(PluginServices.getText(this, "path") + ":");
230
        }
231
232
        return jLabel1;
233
    }
234
235
    /**
236
     * This method initializes jLabel2
237 36411 cordinyana
     *
238 37840 cordinyana
     * @return JLabel
239 7304 caballero
     */
240 37840 cordinyana
    private JLabel getJLabel2() {
241 7304 caballero
        if (jLabel2 == null) {
242 37840 cordinyana
            jLabel2 = new JLabel();
243 36411 cordinyana
            jLabel2
244
                .setText(PluginServices.getText(this, "creation_date") + ":");
245 7304 caballero
        }
246
247
        return jLabel2;
248
    }
249
250
    /**
251
     * This method initializes jLabel3
252 36411 cordinyana
     *
253 37840 cordinyana
     * @return JLabel
254 7304 caballero
     */
255 37840 cordinyana
    private JLabel getJLabel3() {
256 7304 caballero
        if (jLabel3 == null) {
257 37840 cordinyana
            jLabel3 = new JLabel();
258 36411 cordinyana
            jLabel3.setText(PluginServices.getText(this, "modification_date")
259
                + ":");
260 7304 caballero
        }
261
262
        return jLabel3;
263
    }
264
265
    /**
266
     * This method initializes jLabel4
267 36411 cordinyana
     *
268 37840 cordinyana
     * @return JLabel
269 7304 caballero
     */
270 37840 cordinyana
    private JLabel getJLabel4() {
271 7304 caballero
        if (jLabel4 == null) {
272 37840 cordinyana
            jLabel4 = new JLabel();
273 7304 caballero
            jLabel4.setText(PluginServices.getText(this, "owner") + ":");
274
        }
275
276
        return jLabel4;
277
    }
278
279
    /**
280
     * This method initializes txtName
281 36411 cordinyana
     *
282 37840 cordinyana
     * @return JTextField
283 7304 caballero
     */
284 37840 cordinyana
    private JTextField getTxtName() {
285 7304 caballero
        if (txtName == null) {
286 37840 cordinyana
            txtName = new JTextField(20);
287 7304 caballero
        }
288
289
        return txtName;
290
    }
291
292
    /**
293
     * This method initializes txtPath
294 36411 cordinyana
     *
295 37840 cordinyana
     * @return JTextField
296 7304 caballero
     */
297 37840 cordinyana
    private JTextField getTxtPath() {
298 7304 caballero
        if (txtPath == null) {
299 37840 cordinyana
            txtPath = new JTextField(20);
300 7304 caballero
            txtPath.setEditable(false);
301
            txtPath.setBackground(java.awt.Color.white);
302
        }
303
304
        return txtPath;
305
    }
306
307
    /**
308
     * This method initializes txtCreationDate
309 36411 cordinyana
     *
310 37840 cordinyana
     * @return JTextField
311 7304 caballero
     */
312 37840 cordinyana
    private JTextField getTxtCreationDate() {
313 7304 caballero
        if (txtCreationDate == null) {
314 37840 cordinyana
            txtCreationDate = new JTextField(20);
315 7304 caballero
            txtCreationDate.setEditable(false);
316
            txtCreationDate.setBackground(java.awt.Color.white);
317
        }
318
319
        return txtCreationDate;
320
    }
321
322
    /**
323
     * This method initializes txtModificationDate
324 36411 cordinyana
     *
325 37840 cordinyana
     * @return JTextField
326 7304 caballero
     */
327 37840 cordinyana
    private JTextField getTxtModificationDate() {
328 7304 caballero
        if (txtModificationDate == null) {
329 37840 cordinyana
            txtModificationDate = new JTextField(20);
330 7304 caballero
            txtModificationDate.setEditable(false);
331
            txtModificationDate.setBackground(java.awt.Color.white);
332
        }
333
334
        return txtModificationDate;
335
    }
336
337
    /**
338
     * This method initializes txtOwner
339 36411 cordinyana
     *
340 37840 cordinyana
     * @return JTextField
341 7304 caballero
     */
342 37840 cordinyana
    private JTextField getTxtOwner() {
343 7304 caballero
        if (txtOwner == null) {
344 37840 cordinyana
            txtOwner = new JTextField(20);
345 7304 caballero
        }
346
347
        return txtOwner;
348
    }
349
350
    /**
351
     * This method initializes jLabel5
352 36411 cordinyana
     *
353 37840 cordinyana
     * @return JLabel
354 7304 caballero
     */
355 37840 cordinyana
    private JLabel getJLabel5() {
356 7304 caballero
        if (jLabel5 == null) {
357 37840 cordinyana
            jLabel5 = new JLabel();
358 7304 caballero
            jLabel5.setText(PluginServices.getText(this, "comentarios") + ":");
359
        }
360
361
        return jLabel5;
362
    }
363
364
    /**
365
     * This method initializes txtComments
366 36411 cordinyana
     *
367 37840 cordinyana
     * @return JTextArea
368 7304 caballero
     */
369 37840 cordinyana
    private JTextArea getTxtComments() {
370 7304 caballero
        if (txtComments == null) {
371 37840 cordinyana
            txtComments = new JTextArea();
372
            txtComments.setRows(4);
373 7304 caballero
            txtComments.setColumns(20);
374
        }
375
376
        return txtComments;
377
    }
378
379
    /**
380
     * This method initializes jLabel6
381 36411 cordinyana
     *
382 37840 cordinyana
     * @return JLabel
383 7304 caballero
     */
384 37840 cordinyana
    private JLabel getJLabel6() {
385 7304 caballero
        if (jLabel6 == null) {
386 37840 cordinyana
            jLabel6 = new JLabel();
387 36411 cordinyana
            jLabel6.setText(PluginServices.getText(this, "selection_color")
388
                + ":");
389 7304 caballero
        }
390
391
        return jLabel6;
392
    }
393
394
    /**
395
     * This method initializes lblColor
396 36411 cordinyana
     *
397 37840 cordinyana
     * @return JLabel
398 7304 caballero
     */
399 37840 cordinyana
    private JLabel getLblColor() {
400 7304 caballero
        if (lblColor == null) {
401 37840 cordinyana
            lblColor = new JLabel();
402 7304 caballero
403 37840 cordinyana
            lblColor.setPreferredSize(getBtnColor().getPreferredSize());
404 7304 caballero
            lblColor.setOpaque(true);
405
        }
406
407
        return lblColor;
408
    }
409
410
    /**
411
     * This method initializes btnColor
412 36411 cordinyana
     *
413 37840 cordinyana
     * @return JButton
414 7304 caballero
     */
415 37840 cordinyana
    private JButton getBtnColor() {
416 7304 caballero
        if (btnColor == null) {
417 37840 cordinyana
            btnColor =
418
                ToolsSwingLocator.getUsabilitySwingManager().createJButton(
419
                    "...");
420 7304 caballero
421
            btnColor.addActionListener(new java.awt.event.ActionListener() {
422
423 36411 cordinyana
                public void actionPerformed(java.awt.event.ActionEvent e) {
424
                    Color ret =
425
                        JColorChooser.showDialog(ProjectProperties.this,
426
                            PluginServices.getText(this, "selection_color"),
427
                            lblColor.getBackground());
428
429
                    if (ret != null) {
430
                        lblColor.setBackground(ret);
431 7304 caballero
                    }
432 36411 cordinyana
                }
433
            });
434 7304 caballero
        }
435
436
        return btnColor;
437
    }
438
439
    /**
440
     * This method initializes jScrollPane
441 36411 cordinyana
     *
442 37840 cordinyana
     * @return JScrollPane
443 7304 caballero
     */
444 37840 cordinyana
    private JScrollPane getJScrollPane() {
445 7304 caballero
        if (jScrollPane == null) {
446 37840 cordinyana
            jScrollPane = new JScrollPane(getTxtComments());
447
            Dimension dim = getTxtComments().getPreferredSize();
448
            jScrollPane
449
                .setMinimumSize(new Dimension(dim.width, dim.height + 10));
450 7304 caballero
        }
451
452
        return jScrollPane;
453
    }
454
455 36411 cordinyana
    /**
456
     * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
457
     */
458
    public WindowInfo getWindowInfo() {
459
        WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
460 37840 cordinyana
        this.validate();
461
        Dimension dim = getPreferredSize();
462
        m_viewinfo.setWidth(dim.width);
463
        m_viewinfo.setHeight(dim.height);
464 36411 cordinyana
        m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_sesion"));
465
        return m_viewinfo;
466
    }
467 7304 caballero
468 36411 cordinyana
    /**
469
     * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
470
     */
471
    public void viewActivated() {
472
    }
473 26449 jmvivo
474 36411 cordinyana
    public Object getWindowProfile() {
475
        return WindowInfo.DIALOG_PROFILE;
476
    }
477 26449 jmvivo
478 7304 caballero
}