Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / gui / ProjectProperties.java @ 7304

History | View | Annotate | Download (15 KB)

1
/* 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.project.documents.gui;
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 org.gvsig.gui.beans.AcceptCancelPanel;
51

    
52
import com.iver.andami.PluginServices;
53
import com.iver.andami.Utilities;
54
import com.iver.andami.ui.mdiManager.IWindow;
55
import com.iver.andami.ui.mdiManager.WindowInfo;
56
import com.iver.cit.gvsig.ProjectExtension;
57
import com.iver.cit.gvsig.project.Project;
58

    
59

    
60
/**
61
 * Propiedades del proyecto
62
 *
63
 * @author Fernando Gonz?lez Cort?s
64
 */
65
public class ProjectProperties extends JPanel implements IWindow {
66
    private Project project = null;
67
    private javax.swing.JPanel pane = null;
68
    private javax.swing.JPanel jPanel = null;
69
    private javax.swing.JLabel jLabel = null;
70
    private javax.swing.JLabel jLabel1 = null;
71
    private javax.swing.JLabel jLabel2 = null;
72
    private javax.swing.JLabel jLabel3 = null;
73
    private javax.swing.JLabel jLabel4 = null;
74
    private javax.swing.JTextField txtName = null;
75
    private javax.swing.JTextField txtPath = null;
76
    private javax.swing.JTextField txtCreationDate = null;
77
    private javax.swing.JTextField txtModificationDate = null;
78
    private javax.swing.JTextField txtOwner = null;
79
    private javax.swing.JLabel jLabel5 = null;
80
    private javax.swing.JTextArea txtComments = null;
81
    private javax.swing.JButton btnOk = null;
82
    private javax.swing.JButton btnCancel = null;
83
    private javax.swing.JLabel jLabel6 = null;
84
    private javax.swing.JLabel lblColor = null;
85
    private javax.swing.JButton btnColor = null;
86
    private javax.swing.JScrollPane jScrollPane = null;
87
    private WindowInfo m_viewinfo = null;
88
    /**
89
     * This is the default constructor
90
     *
91
     * @param owner Frame padre del di?logo
92
     * @param p Proyecto cuyos datos se muestran en el di?logo
93
     */
94
    public ProjectProperties(Project p) {
95
        project = p;
96
        initialize();
97
    }
98

    
99
    /**
100
     * This method initializes this
101
     */
102
    private void initialize() {
103
                setLayout(new java.awt.BorderLayout());
104
                add(getJPanel(), java.awt.BorderLayout.CENTER);
105

    
106
        getTxtName().setText(project.getName());
107

    
108
        String path = ProjectExtension.getPath();
109

    
110
        if (path != null) {
111
            File f = new File(path);
112
            getTxtPath().setText(f.toString());
113
        } else {
114
            getTxtPath().setText("");
115
        }
116

    
117
        getTxtOwner().setText(project.getOwner());
118
        getTxtComments().setText(project.getComments());
119
        getTxtCreationDate().setText(project.getCreationDate());
120
        getTxtModificationDate().setText(project.getModificationDate());
121

    
122
        getLblColor().setBackground(project.getSelectionColor());
123
    }
124

    
125
    /**
126
     * This method initializes jPanel
127
     *
128
     * @return javax.swing.JPanel
129
     */
130
    private javax.swing.JPanel getJPanel() {
131
        if (jPanel == null) {
132
            jPanel = new javax.swing.JPanel();
133
            jPanel.add(getJLabel(), null);
134
            jPanel.add(getTxtName(), null);
135
            jPanel.add(getJLabel1(), null);
136
            jPanel.add(getTxtPath(), null);
137
            jPanel.add(getJLabel2(), null);
138
            jPanel.add(getTxtCreationDate(), null);
139
            jPanel.add(getJLabel3(), null);
140
            jPanel.add(getTxtModificationDate(), null);
141
            jPanel.add(getJLabel4(), null);
142
            jPanel.add(getTxtOwner(), null);
143
            jPanel.add(getJLabel5(), null);
144
            jPanel.add(getJScrollPane(), null);
145
            jPanel.add(getJLabel6(), null);
146
            jPanel.add(getLblColor(), null);
147
            jPanel.add(getBtnColor(), null);
148
            java.awt.event.ActionListener okAction = new java.awt.event.ActionListener() {
149
                public void actionPerformed(java.awt.event.ActionEvent e) {
150
                    project.setName(txtName.getText());
151
                    project.setOwner(txtOwner.getText());
152
                    project.setComments(txtComments.getText());
153
                    project.setSelectionColor(lblColor.getBackground());
154
                    PluginServices.getMDIManager().closeWindow(ProjectProperties.this);
155
                }
156
            }, cancelAction = new java.awt.event.ActionListener() {
157
                public void actionPerformed(java.awt.event.ActionEvent e) {
158
                                        PluginServices.getMDIManager().closeWindow(ProjectProperties.this);
159
                }
160
            };
161
            jPanel.add(new AcceptCancelPanel(okAction, cancelAction));
162
            jPanel.setPreferredSize(new java.awt.Dimension(150, 10));
163
        }
164

    
165
        return jPanel;
166
    }
167

    
168
    /**
169
     * This method initializes jLabel
170
     *
171
     * @return javax.swing.JLabel
172
     */
173
    private javax.swing.JLabel getJLabel() {
174
        if (jLabel == null) {
175
            jLabel = new javax.swing.JLabel();
176
            jLabel.setText(PluginServices.getText(this, "nombre_sesion") + ":");
177
            jLabel.setPreferredSize(new java.awt.Dimension(149, 16));
178
        }
179

    
180
        return jLabel;
181
    }
182

    
183
    /**
184
     * This method initializes jLabel1
185
     *
186
     * @return javax.swing.JLabel
187
     */
188
    private javax.swing.JLabel getJLabel1() {
189
        if (jLabel1 == null) {
190
            jLabel1 = new javax.swing.JLabel();
191
            jLabel1.setText(PluginServices.getText(this, "path") + ":");
192
            jLabel1.setPreferredSize(new java.awt.Dimension(149, 16));
193
        }
194

    
195
        return jLabel1;
196
    }
197

    
198
    /**
199
     * This method initializes jLabel2
200
     *
201
     * @return javax.swing.JLabel
202
     */
203
    private javax.swing.JLabel getJLabel2() {
204
        if (jLabel2 == null) {
205
            jLabel2 = new javax.swing.JLabel();
206
            jLabel2.setText(PluginServices.getText(this, "creation_date") + ":");
207
            jLabel2.setPreferredSize(new java.awt.Dimension(149, 16));
208
        }
209

    
210
        return jLabel2;
211
    }
212

    
213
    /**
214
     * This method initializes jLabel3
215
     *
216
     * @return javax.swing.JLabel
217
     */
218
    private javax.swing.JLabel getJLabel3() {
219
        if (jLabel3 == null) {
220
            jLabel3 = new javax.swing.JLabel();
221
            jLabel3.setText(PluginServices.getText(this, "modification_date") +
222
                ":");
223
            jLabel3.setPreferredSize(new java.awt.Dimension(149, 16));
224
        }
225

    
226
        return jLabel3;
227
    }
228

    
229
    /**
230
     * This method initializes jLabel4
231
     *
232
     * @return javax.swing.JLabel
233
     */
234
    private javax.swing.JLabel getJLabel4() {
235
        if (jLabel4 == null) {
236
            jLabel4 = new javax.swing.JLabel();
237
            jLabel4.setText(PluginServices.getText(this, "owner") + ":");
238
            jLabel4.setPreferredSize(new java.awt.Dimension(149, 16));
239
        }
240

    
241
        return jLabel4;
242
    }
243

    
244
    /**
245
     * This method initializes txtName
246
     *
247
     * @return javax.swing.JTextField
248
     */
249
    private javax.swing.JTextField getTxtName() {
250
        if (txtName == null) {
251
            txtName = new javax.swing.JTextField();
252
            txtName.setPreferredSize(new java.awt.Dimension(160, 20));
253
        }
254

    
255
        return txtName;
256
    }
257

    
258
    /**
259
     * This method initializes txtPath
260
     *
261
     * @return javax.swing.JTextField
262
     */
263
    private javax.swing.JTextField getTxtPath() {
264
        if (txtPath == null) {
265
            txtPath = new javax.swing.JTextField();
266
            txtPath.setPreferredSize(new java.awt.Dimension(160, 20));
267
            txtPath.setEditable(false);
268
            txtPath.setBackground(java.awt.Color.white);
269
        }
270

    
271
        return txtPath;
272
    }
273

    
274
    /**
275
     * This method initializes txtCreationDate
276
     *
277
     * @return javax.swing.JTextField
278
     */
279
    private javax.swing.JTextField getTxtCreationDate() {
280
        if (txtCreationDate == null) {
281
            txtCreationDate = new javax.swing.JTextField();
282
            txtCreationDate.setPreferredSize(new java.awt.Dimension(160, 20));
283
            txtCreationDate.setEditable(false);
284
            txtCreationDate.setBackground(java.awt.Color.white);
285
        }
286

    
287
        return txtCreationDate;
288
    }
289

    
290
    /**
291
     * This method initializes txtModificationDate
292
     *
293
     * @return javax.swing.JTextField
294
     */
295
    private javax.swing.JTextField getTxtModificationDate() {
296
        if (txtModificationDate == null) {
297
            txtModificationDate = new javax.swing.JTextField();
298
            txtModificationDate.setPreferredSize(new java.awt.Dimension(160, 20));
299
            txtModificationDate.setEditable(false);
300
            txtModificationDate.setBackground(java.awt.Color.white);
301
        }
302

    
303
        return txtModificationDate;
304
    }
305

    
306
    /**
307
     * This method initializes txtOwner
308
     *
309
     * @return javax.swing.JTextField
310
     */
311
    private javax.swing.JTextField getTxtOwner() {
312
        if (txtOwner == null) {
313
            txtOwner = new javax.swing.JTextField();
314
            txtOwner.setPreferredSize(new java.awt.Dimension(160, 20));
315
        }
316

    
317
        return txtOwner;
318
    }
319

    
320
    /**
321
     * This method initializes jLabel5
322
     *
323
     * @return javax.swing.JLabel
324
     */
325
    private javax.swing.JLabel getJLabel5() {
326
        if (jLabel5 == null) {
327
            jLabel5 = new javax.swing.JLabel();
328
            jLabel5.setText(PluginServices.getText(this, "comentarios") + ":");
329
            jLabel5.setPreferredSize(new java.awt.Dimension(119, 16));
330
            jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
331
        }
332

    
333
        return jLabel5;
334
    }
335

    
336
    /**
337
     * This method initializes txtComments
338
     *
339
     * @return javax.swing.JTextArea
340
     */
341
    private javax.swing.JTextArea getTxtComments() {
342
        if (txtComments == null) {
343
            txtComments = new javax.swing.JTextArea();
344
            txtComments.setRows(1);
345
            txtComments.setColumns(20);
346
        }
347

    
348
        return txtComments;
349
    }
350

    
351
//    /**
352
//     * This method initializes btnOk
353
//     *
354
//     * @return javax.swing.JButton
355
//     */
356
//    private javax.swing.JButton getBtnOk() {
357
//        if (btnOk == null) {
358
//            btnOk = new javax.swing.JButton();
359
//            btnOk.setPreferredSize(new java.awt.Dimension(100, 30));
360
//            btnOk.setText(PluginServices.getText(this, "ok") + ":");
361
//
362
//            btnOk.addActionListener(new java.awt.event.ActionListener() {
363
//                    public void actionPerformed(java.awt.event.ActionEvent e) {
364
//                        project.setName(txtName.getText());
365
//                        project.setOwner(txtOwner.getText());
366
//                        project.setComments(txtComments.getText());
367
//                        project.setSelectionColor(lblColor.getBackground());
368
//                        PluginServices.getMDIManager().closeView(ProjectProperties.this);
369
//                    }
370
//                });
371
//        }
372
//
373
//        return btnOk;
374
//    }
375
//
376
//    /**
377
//     * This method initializes btnCancel
378
//     *
379
//     * @return javax.swing.JButton
380
//     */
381
//    private javax.swing.JButton getBtnCancel() {
382
//        if (btnCancel == null) {
383
//            btnCancel = new javax.swing.JButton();
384
//            btnCancel.setPreferredSize(new java.awt.Dimension(100, 30));
385
//            btnCancel.setText(PluginServices.getText(this, "cancel") + ":");
386
//
387
//            btnCancel.addActionListener(new java.awt.event.ActionListener() {
388
//                    public void actionPerformed(java.awt.event.ActionEvent e) {
389
//                                                PluginServices.getMDIManager().closeView(ProjectProperties.this);
390
//                    }
391
//                });
392
//        }
393
//
394
//        return btnCancel;
395
//    }
396

    
397
    /**
398
     * This method initializes jLabel6
399
     *
400
     * @return javax.swing.JLabel
401
     */
402
    private javax.swing.JLabel getJLabel6() {
403
        if (jLabel6 == null) {
404
            jLabel6 = new javax.swing.JLabel();
405
            jLabel6.setText(PluginServices.getText(this, "selection_color") +
406
                ":");
407
            jLabel6.setPreferredSize(new java.awt.Dimension(190, 16));
408
        }
409

    
410
        return jLabel6;
411
    }
412

    
413
    /**
414
     * This method initializes lblColor
415
     *
416
     * @return javax.swing.JLabel
417
     */
418
    private javax.swing.JLabel getLblColor() {
419
        if (lblColor == null) {
420
            lblColor = new javax.swing.JLabel();
421

    
422
            //                        lblColor.setText("");
423
            lblColor.setPreferredSize(new java.awt.Dimension(30, 16));
424
            lblColor.setOpaque(true);
425
        }
426

    
427
        return lblColor;
428
    }
429

    
430
    /**
431
     * This method initializes btnColor
432
     *
433
     * @return javax.swing.JButton
434
     */
435
    private javax.swing.JButton getBtnColor() {
436
        if (btnColor == null) {
437
            btnColor = new javax.swing.JButton();
438
            btnColor.setPreferredSize(new java.awt.Dimension(34, 16));
439
            btnColor.setText("...");
440

    
441
            btnColor.addActionListener(new java.awt.event.ActionListener() {
442
                    public void actionPerformed(java.awt.event.ActionEvent e) {
443
                        Color ret = JColorChooser.showDialog(ProjectProperties.this,
444
                                        PluginServices.getText(this, "selection_color"),
445
                                lblColor.getBackground());
446

    
447
                        if (ret != null) {
448
                            lblColor.setBackground(ret);
449
                        }
450
                    }
451
                });
452
        }
453

    
454
        return btnColor;
455
    }
456

    
457
    /**
458
     * This method initializes jScrollPane
459
     *
460
     * @return javax.swing.JScrollPane
461
     */
462
    private javax.swing.JScrollPane getJScrollPane() {
463
        if (jScrollPane == null) {
464
            jScrollPane = new javax.swing.JScrollPane();
465
            jScrollPane.setViewportView(getTxtComments());
466
            jScrollPane.setPreferredSize(new java.awt.Dimension(310, 70));
467
        }
468

    
469
        return jScrollPane;
470
    }
471

    
472
        /**
473
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
474
         */
475
        public WindowInfo getWindowInfo() {
476
                WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
477
                   m_viewinfo.setWidth(340);
478
                   m_viewinfo.setHeight(250);
479
                   m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_sesion"));
480
                return m_viewinfo;
481
        }
482

    
483
        /**
484
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
485
         */
486
        public void viewActivated() {
487
        }
488
}
489

    
490

    
491
//  @jve:visual-info  decl-index=0 visual-constraint="10,10"