Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / project / ProjectProperties.java @ 5037

History | View | Annotate | Download (14.1 KB)

1 1222 fernando
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.gui.project;
42
43
44
import java.awt.Color;
45
import java.io.File;
46
47
import javax.swing.JColorChooser;
48
import javax.swing.JPanel;
49
50
import com.iver.andami.PluginServices;
51
import com.iver.andami.Utilities;
52
import com.iver.andami.ui.mdiManager.View;
53
import com.iver.andami.ui.mdiManager.ViewInfo;
54
import com.iver.cit.gvsig.project.Project;
55
56
57
/**
58
 * Propiedades del proyecto
59
 *
60
 * @author Fernando Gonz?lez Cort?s
61
 */
62
public class ProjectProperties extends JPanel implements View {
63
    private Project project = null;
64
    private javax.swing.JPanel pane = null;
65
    private javax.swing.JPanel jPanel = null;
66
    private javax.swing.JLabel jLabel = null;
67
    private javax.swing.JLabel jLabel1 = null;
68
    private javax.swing.JLabel jLabel2 = null;
69
    private javax.swing.JLabel jLabel3 = null;
70
    private javax.swing.JLabel jLabel4 = null;
71
    private javax.swing.JTextField txtName = null;
72
    private javax.swing.JTextField txtPath = null;
73
    private javax.swing.JTextField txtCreationDate = null;
74
    private javax.swing.JTextField txtModificationDate = null;
75
    private javax.swing.JTextField txtOwner = null;
76
    private javax.swing.JLabel jLabel5 = null;
77
    private javax.swing.JTextArea txtComments = null;
78
    private javax.swing.JButton btnOk = null;
79
    private javax.swing.JButton btnCancel = null;
80
    private javax.swing.JLabel jLabel6 = null;
81
    private javax.swing.JLabel lblColor = null;
82
    private javax.swing.JButton btnColor = null;
83
    private javax.swing.JScrollPane jScrollPane = null;
84
    private ViewInfo m_viewinfo = null;
85
    /**
86
     * This is the default constructor
87
     *
88
     * @param owner Frame padre del di?logo
89
     * @param p Proyecto cuyos datos se muestran en el di?logo
90
     */
91
    public ProjectProperties(Project p) {
92
        project = p;
93
        initialize();
94
    }
95
96
    /**
97
     * This method initializes this
98
     */
99
    private void initialize() {
100
                setLayout(new java.awt.BorderLayout());
101
                add(getJPanel(), java.awt.BorderLayout.CENTER);
102
103
        getTxtName().setText(project.getName());
104
105
        String path = project.getPath();
106
107
        if (path != null) {
108
            File f = new File(path);
109
            getTxtPath().setText(f.toString());
110
        } else {
111
            getTxtPath().setText("");
112
        }
113
114
        getTxtOwner().setText(project.getOwner());
115
        getTxtComments().setText(project.getComments());
116
        getTxtCreationDate().setText(project.getCreationDate());
117
        getTxtModificationDate().setText(project.getModificationDate());
118
119
        getLblColor().setBackground(project.getSelectionColor());
120
    }
121
122
    /**
123
     * This method initializes jPanel
124
     *
125
     * @return javax.swing.JPanel
126
     */
127
    private javax.swing.JPanel getJPanel() {
128
        if (jPanel == null) {
129
            jPanel = new javax.swing.JPanel();
130
            jPanel.add(getJLabel(), null);
131
            jPanel.add(getTxtName(), null);
132
            jPanel.add(getJLabel1(), null);
133
            jPanel.add(getTxtPath(), null);
134
            jPanel.add(getJLabel2(), null);
135
            jPanel.add(getTxtCreationDate(), null);
136
            jPanel.add(getJLabel3(), null);
137
            jPanel.add(getTxtModificationDate(), null);
138
            jPanel.add(getJLabel4(), null);
139
            jPanel.add(getTxtOwner(), null);
140
            jPanel.add(getJLabel5(), null);
141
            jPanel.add(getJScrollPane(), null);
142
            jPanel.add(getJLabel6(), null);
143
            jPanel.add(getLblColor(), null);
144
            jPanel.add(getBtnColor(), null);
145
            jPanel.add(getBtnOk(), null);
146
            jPanel.add(getBtnCancel(), null);
147
            jPanel.setPreferredSize(new java.awt.Dimension(150, 10));
148
        }
149
150
        return jPanel;
151
    }
152
153
    /**
154
     * This method initializes jLabel
155
     *
156
     * @return javax.swing.JLabel
157
     */
158
    private javax.swing.JLabel getJLabel() {
159
        if (jLabel == null) {
160
            jLabel = new javax.swing.JLabel();
161
            jLabel.setText(PluginServices.getText(this, "nombre_sesion") + ":");
162
            jLabel.setPreferredSize(new java.awt.Dimension(149, 16));
163
        }
164
165
        return jLabel;
166
    }
167
168
    /**
169
     * This method initializes jLabel1
170
     *
171
     * @return javax.swing.JLabel
172
     */
173
    private javax.swing.JLabel getJLabel1() {
174
        if (jLabel1 == null) {
175
            jLabel1 = new javax.swing.JLabel();
176
            jLabel1.setText(PluginServices.getText(this, "path") + ":");
177
            jLabel1.setPreferredSize(new java.awt.Dimension(149, 16));
178
        }
179
180
        return jLabel1;
181
    }
182
183
    /**
184
     * This method initializes jLabel2
185
     *
186
     * @return javax.swing.JLabel
187
     */
188
    private javax.swing.JLabel getJLabel2() {
189
        if (jLabel2 == null) {
190
            jLabel2 = new javax.swing.JLabel();
191
            jLabel2.setText(PluginServices.getText(this, "creation_date") + ":");
192
            jLabel2.setPreferredSize(new java.awt.Dimension(149, 16));
193
        }
194
195
        return jLabel2;
196
    }
197
198
    /**
199
     * This method initializes jLabel3
200
     *
201
     * @return javax.swing.JLabel
202
     */
203
    private javax.swing.JLabel getJLabel3() {
204
        if (jLabel3 == null) {
205
            jLabel3 = new javax.swing.JLabel();
206
            jLabel3.setText(PluginServices.getText(this, "modification_date") +
207
                ":");
208
            jLabel3.setPreferredSize(new java.awt.Dimension(149, 16));
209
        }
210
211
        return jLabel3;
212
    }
213
214
    /**
215
     * This method initializes jLabel4
216
     *
217
     * @return javax.swing.JLabel
218
     */
219
    private javax.swing.JLabel getJLabel4() {
220
        if (jLabel4 == null) {
221
            jLabel4 = new javax.swing.JLabel();
222
            jLabel4.setText(PluginServices.getText(this, "owner") + ":");
223
            jLabel4.setPreferredSize(new java.awt.Dimension(149, 16));
224
        }
225
226
        return jLabel4;
227
    }
228
229
    /**
230
     * This method initializes txtName
231
     *
232
     * @return javax.swing.JTextField
233
     */
234
    private javax.swing.JTextField getTxtName() {
235
        if (txtName == null) {
236
            txtName = new javax.swing.JTextField();
237
            txtName.setPreferredSize(new java.awt.Dimension(160, 20));
238
        }
239
240
        return txtName;
241
    }
242
243
    /**
244
     * This method initializes txtPath
245
     *
246
     * @return javax.swing.JTextField
247
     */
248
    private javax.swing.JTextField getTxtPath() {
249
        if (txtPath == null) {
250
            txtPath = new javax.swing.JTextField();
251
            txtPath.setPreferredSize(new java.awt.Dimension(160, 20));
252
            txtPath.setEditable(false);
253
            txtPath.setBackground(java.awt.Color.white);
254
        }
255
256
        return txtPath;
257
    }
258
259
    /**
260
     * This method initializes txtCreationDate
261
     *
262
     * @return javax.swing.JTextField
263
     */
264
    private javax.swing.JTextField getTxtCreationDate() {
265
        if (txtCreationDate == null) {
266
            txtCreationDate = new javax.swing.JTextField();
267
            txtCreationDate.setPreferredSize(new java.awt.Dimension(160, 20));
268
            txtCreationDate.setEditable(false);
269
            txtCreationDate.setBackground(java.awt.Color.white);
270
        }
271
272
        return txtCreationDate;
273
    }
274
275
    /**
276
     * This method initializes txtModificationDate
277
     *
278
     * @return javax.swing.JTextField
279
     */
280
    private javax.swing.JTextField getTxtModificationDate() {
281
        if (txtModificationDate == null) {
282
            txtModificationDate = new javax.swing.JTextField();
283
            txtModificationDate.setPreferredSize(new java.awt.Dimension(160, 20));
284
            txtModificationDate.setEditable(false);
285
            txtModificationDate.setBackground(java.awt.Color.white);
286
        }
287
288
        return txtModificationDate;
289
    }
290
291
    /**
292
     * This method initializes txtOwner
293
     *
294
     * @return javax.swing.JTextField
295
     */
296
    private javax.swing.JTextField getTxtOwner() {
297
        if (txtOwner == null) {
298
            txtOwner = new javax.swing.JTextField();
299
            txtOwner.setPreferredSize(new java.awt.Dimension(160, 20));
300
        }
301
302
        return txtOwner;
303
    }
304
305
    /**
306
     * This method initializes jLabel5
307
     *
308
     * @return javax.swing.JLabel
309
     */
310
    private javax.swing.JLabel getJLabel5() {
311
        if (jLabel5 == null) {
312
            jLabel5 = new javax.swing.JLabel();
313
            jLabel5.setText(PluginServices.getText(this, "comentarios") + ":");
314
            jLabel5.setPreferredSize(new java.awt.Dimension(119, 16));
315
            jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
316
        }
317
318
        return jLabel5;
319
    }
320
321
    /**
322
     * This method initializes txtComments
323
     *
324
     * @return javax.swing.JTextArea
325
     */
326
    private javax.swing.JTextArea getTxtComments() {
327
        if (txtComments == null) {
328
            txtComments = new javax.swing.JTextArea();
329
            txtComments.setRows(1);
330
            txtComments.setColumns(20);
331
        }
332
333
        return txtComments;
334
    }
335
336
    /**
337
     * This method initializes btnOk
338
     *
339
     * @return javax.swing.JButton
340
     */
341
    private javax.swing.JButton getBtnOk() {
342
        if (btnOk == null) {
343
            btnOk = new javax.swing.JButton();
344
            btnOk.setPreferredSize(new java.awt.Dimension(100, 30));
345
            btnOk.setText(PluginServices.getText(this, "ok") + ":");
346
347
            btnOk.addActionListener(new java.awt.event.ActionListener() {
348
                    public void actionPerformed(java.awt.event.ActionEvent e) {
349
                        project.setName(txtName.getText());
350
                        project.setOwner(txtOwner.getText());
351
                        project.setComments(txtComments.getText());
352
                        project.setSelectionColor(lblColor.getBackground());
353
                        PluginServices.getMDIManager().closeView(ProjectProperties.this);
354
                    }
355
                });
356
        }
357
358
        return btnOk;
359
    }
360
361
    /**
362
     * This method initializes btnCancel
363
     *
364
     * @return javax.swing.JButton
365
     */
366
    private javax.swing.JButton getBtnCancel() {
367
        if (btnCancel == null) {
368
            btnCancel = new javax.swing.JButton();
369
            btnCancel.setPreferredSize(new java.awt.Dimension(100, 30));
370
            btnCancel.setText(PluginServices.getText(this, "cancel") + ":");
371
372
            btnCancel.addActionListener(new java.awt.event.ActionListener() {
373
                    public void actionPerformed(java.awt.event.ActionEvent e) {
374
                                                PluginServices.getMDIManager().closeView(ProjectProperties.this);
375
                    }
376
                });
377
        }
378
379
        return btnCancel;
380
    }
381
382
    /**
383
     * This method initializes jLabel6
384
     *
385
     * @return javax.swing.JLabel
386
     */
387
    private javax.swing.JLabel getJLabel6() {
388
        if (jLabel6 == null) {
389
            jLabel6 = new javax.swing.JLabel();
390
            jLabel6.setText(PluginServices.getText(this, "selection_color") +
391
                ":");
392
            jLabel6.setPreferredSize(new java.awt.Dimension(190, 16));
393
        }
394
395
        return jLabel6;
396
    }
397
398
    /**
399
     * This method initializes lblColor
400
     *
401
     * @return javax.swing.JLabel
402
     */
403
    private javax.swing.JLabel getLblColor() {
404
        if (lblColor == null) {
405
            lblColor = new javax.swing.JLabel();
406
407
            //                        lblColor.setText("");
408
            lblColor.setPreferredSize(new java.awt.Dimension(30, 16));
409
            lblColor.setOpaque(true);
410
        }
411
412
        return lblColor;
413
    }
414
415
    /**
416
     * This method initializes btnColor
417
     *
418
     * @return javax.swing.JButton
419
     */
420
    private javax.swing.JButton getBtnColor() {
421
        if (btnColor == null) {
422
            btnColor = new javax.swing.JButton();
423
            btnColor.setPreferredSize(new java.awt.Dimension(34, 16));
424
            btnColor.setText("...");
425
426
            btnColor.addActionListener(new java.awt.event.ActionListener() {
427
                    public void actionPerformed(java.awt.event.ActionEvent e) {
428
                        Color ret = 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 javax.swing.JScrollPane
446
     */
447
    private javax.swing.JScrollPane getJScrollPane() {
448
        if (jScrollPane == null) {
449
            jScrollPane = new javax.swing.JScrollPane();
450
            jScrollPane.setViewportView(getTxtComments());
451
            jScrollPane.setPreferredSize(new java.awt.Dimension(310, 70));
452
        }
453
454
        return jScrollPane;
455
    }
456
457
        /**
458
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
459
         */
460
        public ViewInfo getViewInfo() {
461
                ViewInfo m_viewinfo=new ViewInfo(ViewInfo.MODALDIALOG);
462
                   m_viewinfo.setWidth(341);
463
                   m_viewinfo.setHeight(311);
464
                   m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_sesion"));
465
                return m_viewinfo;
466
        }
467
468
        /**
469
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
470
         */
471
        public void viewActivated() {
472
        }
473
}
474
475
476
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"