Statistics
| Revision:

svn-gvsig-desktop / tags / gvSIGv0_6_1RELEASE / applications / appgvSIG / src / com / iver / cit / gvsig / gui / project / ProjectWindow.java @ 5222

History | View | Annotate | Download (30.2 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.gui.project;
42

    
43
import java.awt.Component;
44
import java.beans.PropertyChangeEvent;
45
import java.beans.PropertyChangeListener;
46
import java.io.File;
47
import java.text.DateFormat;
48

    
49
import javax.swing.ButtonGroup;
50
import javax.swing.JDialog;
51
import javax.swing.JOptionPane;
52
import javax.swing.JPanel;
53

    
54
import com.hardcode.driverManager.DriverLoadException;
55
import com.hardcode.gdbms.engine.data.DataSource;
56
import com.hardcode.gdbms.engine.data.DataSourceFactory;
57
import com.hardcode.gdbms.engine.data.driver.DBDriver;
58
import com.hardcode.gdbms.engine.data.driver.DriverException;
59
import com.hardcode.gdbms.engine.data.driver.FileDriver;
60
import com.iver.andami.PluginServices;
61
import com.iver.andami.messages.NotificationManager;
62
import com.iver.andami.ui.mdiManager.SingletonView;
63
import com.iver.andami.ui.mdiManager.View;
64
import com.iver.andami.ui.mdiManager.ViewInfo;
65
import com.iver.cit.gvsig.ProjectExtension;
66
import com.iver.cit.gvsig.fmap.drivers.GeorreferencedRasterDriver;
67
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
68
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
69
import com.iver.cit.gvsig.gui.DataBaseOpenDialog;
70
import com.iver.cit.gvsig.gui.FOpenDialog;
71
import com.iver.cit.gvsig.gui.FileOpenDialog;
72
import com.iver.cit.gvsig.gui.Table;
73
import com.iver.cit.gvsig.gui.layout.Layout;
74
import com.iver.cit.gvsig.project.Project;
75
import com.iver.cit.gvsig.project.ProjectElement;
76
import com.iver.cit.gvsig.project.ProjectFactory;
77
import com.iver.cit.gvsig.project.ProjectMap;
78
import com.iver.cit.gvsig.project.ProjectTable;
79
import com.iver.cit.gvsig.project.ProjectView;
80
import com.iver.utiles.DefaultListModel;
81

    
82

    
83
/**
84
 * Clase principal del proyecto donde se puede operar para crear vistas,
85
 * tablas, mapas, ...
86
 *
87
 * @author Fernando Gonz?lez Cort?s
88
 */
89
public class ProjectWindow extends JPanel implements PropertyChangeListener,
90
        View, SingletonView {
91
        private javax.swing.JPanel jPanel = null;
92
        private javax.swing.JRadioButton btnVistas = null;
93
        private javax.swing.JRadioButton btnTablas = null;
94
        private javax.swing.JRadioButton btnMapas = null;
95
        private ButtonGroup grupo = new ButtonGroup();
96
        private javax.swing.JPanel jPanel1 = null;
97
        private javax.swing.JList lstDocs = null;
98
        private javax.swing.JPanel jPanel2 = null;
99
        private javax.swing.JButton btnNuevo = null;
100
        private javax.swing.JButton btnPropiedades = null;
101
        private javax.swing.JButton btnAbrir = null;
102
        private javax.swing.JButton btnBorrar = null;
103
        private javax.swing.JButton btnRenombrar = null;
104
        private javax.swing.JPanel jPanel3 = null;
105
        private javax.swing.JLabel jLabel = null;
106
        private javax.swing.JLabel lblNombreSesion = null;
107
        private javax.swing.JLabel jLabel1 = null;
108
        private javax.swing.JLabel lblGuardado = null;
109
        private javax.swing.JLabel jLabel2 = null;
110
        private javax.swing.JLabel lblFecha = null;
111
        private javax.swing.JButton btnImportar = null;
112
        private javax.swing.JButton btnExportar = null;
113
        private javax.swing.JButton btnEditar = null;
114
        // The properties of the Project Manager window (size, position, etc):
115
        private ViewInfo m_viewInfo=null;
116

    
117
        /** Proyecto representado en la vista */
118
        private Project p;
119

    
120
        /**
121
         * Extension con la informaci?n, entre otras, sobre las extensiones para
122
         * las tablas
123
         */
124
        private ProjectExtension projectExtension;
125
        private javax.swing.JScrollPane jScrollPane = null;
126
        private javax.swing.JPanel jPanel4 = null;
127

    
128
        /**
129
         * This is the default constructor
130
         *
131
         * @param project Extension
132
         */
133
        public ProjectWindow(ProjectExtension project) {
134
                super();
135

    
136
                initialize();
137

    
138
                projectExtension = project;
139

    
140
                refreshControls();
141
        }
142

    
143
        /**
144
         * This is the default constructor
145
         *
146
         * @param project Extension
147
         */
148
        public ProjectWindow() {
149
                super();
150

    
151
                initialize();
152
                refreshControls();
153
        }
154
        
155
        public void setProjectExtension(ProjectExtension p) {
156
                projectExtension = p;
157
        }
158
        
159
        /**
160
         * Asigna el proyecto a la ventana
161
         *
162
         * @param p Proyecto con el que se operar? a trav?s de este di?logo
163
         */
164
        public void setProject(Project p) {
165
                this.p = p;
166
                p.addPropertyChangeListener(this);
167
                refreshControls();
168
        }
169

    
170
        /**
171
         * Activa los botones de la botonera del medio o los desactiva en funci?n
172
         * de que est? seleccionado o no un elemento de proyecto en la lista del
173
         * medio
174
         */
175
        private void activarBotones() {
176
                if (lstDocs.getSelectedIndex() != -1) {
177
                        btnAbrir.setEnabled(true);
178
                        btnBorrar.setEnabled(true);
179
                        btnRenombrar.setEnabled(true);
180
                        btnPropiedades.setEnabled(true);
181
                } else {
182
                        btnAbrir.setEnabled(false);
183
                        btnBorrar.setEnabled(false);
184
                        btnRenombrar.setEnabled(false);
185
                        btnPropiedades.setEnabled(false);
186
                }
187
        }
188

    
189
        /**
190
         * Refresca la lista de elementos de proyecto con vistas, mapas o tablas,
191
         * seg?n la opci?n activada
192
         */
193
        private void refreshList() {
194
                if (p != null) {
195
                        DefaultListModel model;
196

    
197
                        if (btnMapas.isSelected()) {
198
                                model = new DefaultListModel(p.getMaps());
199

    
200
                                //                                getBtnNuevo().setEnabled(true);
201
                        } else if (btnTablas.isSelected()) {
202
                                model = new DefaultListModel(p.getTables());
203

    
204
                                //                getBtnNuevo().setEnabled(false);
205
                        } else {
206
                                model = new DefaultListModel(p.getViews());
207

    
208
                                //                                getBtnNuevo().setEnabled(true);
209
                        }
210

    
211
                        lstDocs.setModel(model);
212

    
213
                        activarBotones();
214
                }
215
        }
216

    
217
        /**
218
         * Refresca las etiquetas con la informaci?n del proyecto
219
         */
220
        private void refreshProperties() {
221
                if (p != null) {
222
                        String aux;
223

    
224
                        lblNombreSesion.setText(p.getName());
225

    
226
                        String path = p.getPath();
227

    
228
                        if (path != null) {
229
                                File f = new File(path);
230
                                lblGuardado.setText(f.toString());
231
                        } else {
232
                                lblGuardado.setText("");
233
                        }
234

    
235
                        lblFecha.setText(p.getCreationDate());
236
                }
237
        }
238

    
239
        /**
240
         * Refresca todo el di?logo
241
         */
242
        public void refreshControls() {
243
                refreshList();
244
                refreshProperties();
245
        }
246

    
247
        /**
248
         * This method initializes this
249
         */
250
        private void initialize() {
251
                setLayout(new java.awt.FlowLayout());
252
                add(getJPanel(), null);
253
                add(getJPanel1(), null);
254
                add(getJPanel3(), null);
255

    
256
                this.setSize(400, 450);
257
                this.setPreferredSize(new java.awt.Dimension(400, 430));
258
                grupo.add(btnVistas);
259
                grupo.add(btnTablas);
260
                grupo.add(btnMapas);
261

    
262
                btnVistas.setSelected(true);
263
        }
264
        private String ask(String title, String content){
265
                JOptionPane pane = new JOptionPane();
266
                pane.setMessage(content);
267
                pane.setMessageType(JOptionPane.QUESTION_MESSAGE);
268
                pane.setWantsInput(true);
269
                pane.setInitialSelectionValue("");
270

    
271
                JDialog dlg = pane.createDialog((Component) PluginServices.getMainFrame(),
272
                                title);
273
                dlg.setModal(true);
274
                dlg.show();
275

    
276
                return pane.getInputValue().toString().trim();
277
        }
278

    
279
        /**
280
         * Crea un nuevo project element
281
         *
282
         * @throws Exception DOCUMENT ME!
283
         */
284
        private void nuevo() throws Exception {
285
                DateFormat df = DateFormat.getDateInstance();
286

    
287
                if (btnMapas.isSelected()) {
288
                        ProjectMap map = ProjectFactory.createMap(PluginServices.getText(
289
                                                this, "untitled"));
290
                        map.setModel(new Layout());
291
                        map.getModel().setProjectMap(map);
292
                        p.addMap(map);
293
                } else if (btnTablas.isSelected()) {
294
                        try {
295
                                FOpenDialog fopen = new FOpenDialog();
296
                                FileOpenDialog fod = new FileOpenDialog(new Class[] {
297
                                                        FileDriver.class}, false);
298
                                DataBaseOpenDialog dbod = new DataBaseOpenDialog();
299
                                dbod.setClasses(new Class[] { DBDriver.class });
300
                                fopen.addTab("Fichero", fod);
301
                                fopen.addTab("Base de datos", dbod);
302
                                PluginServices.getMDIManager().addView(fopen);
303

    
304
                                if (fopen.isAccepted()) {
305
                                        JPanel panel = fopen.getSelectedTab();
306
                                        ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
307

    
308
                                        if (panel instanceof FileOpenDialog) {
309
                                                File[] files = fod.getFiles();
310
                                                String[] driverNames = fod.getDriverNames();
311

    
312
                                                for (int i = 0; i < files.length; i++) {
313
                                                        String name = files[i].getName();
314

    
315
                                                        LayerFactory.getDataSourceFactory()
316
                                                                                .addFileDataSource(driverNames[i],
317
                                                                name, files[i].getAbsolutePath());
318

    
319
                                                        DataSource dataSource = LayerFactory.getDataSourceFactory()
320
                                                                                                                                .createRandomDataSource(name, DataSourceFactory.AUTOMATIC_OPENING);
321
                                                        SelectableDataSource sds = new SelectableDataSource(dataSource);
322
                                                        ProjectTable projectTable = ProjectFactory.createTable(name,
323
                                                                        sds);
324
                                                        ext.getProject().addTable(projectTable);
325

    
326
                                                        Table t = new Table();
327
                                                        t.setModel(projectTable);
328
                                                        projectTable.setAndamiView(t);
329
                                                        PluginServices.getMDIManager().addView(t);
330
                                                }
331
                                        } else if (panel instanceof DataBaseOpenDialog) {
332
                                                String driverName = dbod.getDriverName();
333
                                                int port = -1;
334

    
335
                                                try {
336
                                                        port = Integer.parseInt(dbod.getPort());
337
                                                } catch (NumberFormatException e) {
338
                                                }
339

    
340
                                                String name = dbod.getHost() + "/" +
341
                                                        dbod.getDataBase();
342

    
343
                                                if (port != -1) {
344
                                                        name = dbod.getHost() + ":" + port + "/" +
345
                                                                dbod.getDataBase();
346
                                                }
347
                                                
348
                                                String user = dbod.getUser().trim();
349
                                                String password = dbod.getPassword();
350

    
351
                                                if (user.equals("")) {
352
                                                        user = null;
353
                                                        password = null;
354
                                                }
355

    
356
                                                LayerFactory.getDataSourceFactory().addDBDataSourceByTable(name,
357
                                                        dbod.getHost(), port, user, password,
358
                                                        dbod.getDataBase(), dbod.getTable(), driverName);
359

    
360
                                                DataSource dataSource = LayerFactory.getDataSourceFactory()
361
                                                                                                                        .createRandomDataSource(name, DataSourceFactory.AUTOMATIC_OPENING);
362
                                                SelectableDataSource sds = new SelectableDataSource(dataSource);
363

    
364
                                                ProjectTable projectTable = ProjectFactory.createTable(name,
365
                                                                sds);
366
                                                ext.getProject().addTable(projectTable);
367

    
368
                                                Table t = new Table();
369
                                                t.setModel(projectTable);
370
                                                projectTable.setAndamiView(t);
371
                                                PluginServices.getMDIManager().addView(t);
372
                                        }
373
                                }
374
                        } catch (DriverLoadException e) {
375
                                NotificationManager.addError("Error al cargar los drivers", e);
376
                        }
377
                } else {
378
                        ProjectView vista = ProjectFactory.createView(PluginServices.getText(
379
                                                this, "untitled"));
380
                        p.addView(vista);
381
                }
382
        }
383

    
384
        /**
385
         * Abre la ventana de un nuevo project element
386
         */
387
        private void abrir() {
388
                if (btnMapas.isSelected()) {
389
                        int index = lstDocs.getSelectedIndex();
390

    
391
                        if (index == -1) {
392
                                return;
393
                        }
394

    
395
                        Layout l = (Layout) ((ProjectMap) p.getMaps().get(index)).getModel();
396
                        l.fullRect();
397
                        PluginServices.getMDIManager().addView(l);
398
                } else if (btnTablas.isSelected()) {
399
                        com.iver.cit.gvsig.gui.Table vista = new com.iver.cit.gvsig.gui.Table();
400
                        int index = lstDocs.getSelectedIndex();
401

    
402
                        if (index == -1) {
403
                                return;
404
                        }
405

    
406
                        vista.setModel((ProjectTable) p.getTables().get(index));
407
                        PluginServices.getMDIManager().addView(vista);
408
                } else {
409
                        com.iver.cit.gvsig.gui.View vista = new com.iver.cit.gvsig.gui.View();
410
                        int index = lstDocs.getSelectedIndex();
411

    
412
                        if (index == -1) {
413
                                return;
414
                        }
415

    
416
                        vista.setModel((ProjectView) p.getViews().get(index));
417
                        PluginServices.getMDIManager().addView(vista);
418
                }
419
        }
420

    
421
        /**
422
         * Cambia el nombre de un project element
423
         */
424
        private void renombrar() {
425
                ProjectElement elem = null;
426
                int index = lstDocs.getSelectedIndex();
427
                
428
                if (index == -1) {
429
                        return;
430
                }
431

    
432
                if (btnMapas.isSelected()) {
433
                        elem = (ProjectElement) p.getMaps().get(index);
434
                } else if (btnTablas.isSelected()) {
435
                        elem = (ProjectElement) p.getTables().get(index);
436
                } else {
437
                        elem = (ProjectElement) p.getViews().get(index);
438
                }
439

    
440
                JOptionPane pane = new JOptionPane();
441
                pane.setMessage(PluginServices.getText(this, "introduce_nombre"));
442
                pane.setMessageType(JOptionPane.QUESTION_MESSAGE);
443
                pane.setWantsInput(true);
444
                pane.setInitialSelectionValue(elem.getName());
445
        pane.setInputValue(elem.getName());
446
                JDialog dlg = pane.createDialog((Component) PluginServices.getMainFrame(),
447
                                PluginServices.getText(this, "renombrar"));
448
                dlg.setModal(true);
449
                dlg.show();
450

    
451
                String nuevoNombre = pane.getInputValue().toString().trim();
452

    
453
                if (nuevoNombre.length() == 0) {
454
                        return;
455
                }
456

    
457
                if (nuevoNombre == null) {
458
                        return;
459
                }
460

    
461
                for (int i=0; i<lstDocs.getModel().getSize(); i++){
462
                        if (i==index) continue;
463
                        if (((ProjectElement)lstDocs.getModel().getElementAt(i)).getName().equals(nuevoNombre)){
464
                                JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this, "elemento_ya_existe"));
465
                                return;
466
                        }
467
                                
468
                }
469
                elem.setName(nuevoNombre);
470

    
471
                refreshList();
472
        }
473

    
474
        /**
475
         * Borra un project element
476
         */
477
        private void borrar() {
478
                int res = JOptionPane.showConfirmDialog((Component) PluginServices.getMainFrame(),
479
                                PluginServices.getText(this, "confirmar_borrar"),
480
                                PluginServices.getText(this, "borrar"),
481
                                JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
482

    
483
                if (res == JOptionPane.YES_OPTION) {
484
                        int index = lstDocs.getSelectedIndex();
485

    
486
                        if (btnMapas.isSelected()) {
487
                                PluginServices.getMDIManager().closeSingletonView(p.getMaps()
488
                                                                                                                                   .get(index));
489
                                p.delMap(index);
490
                        } else if (btnTablas.isSelected()) {
491
                                PluginServices.getMDIManager().closeSingletonView(p.getTables()
492
                                                                                                                                   .get(index));
493
                                p.delTable(index);
494
                        } else {
495
                                PluginServices.getMDIManager().closeSingletonView(p.getViews()
496
                                                                                                                                   .get(index));
497
                                p.delView(index);
498
                        }
499

    
500
                        refreshList();
501
                }
502
        }
503

    
504
        /**
505
         * Muestra el di?logo de propiedades de un project element
506
         */
507
        private void propiedades() {
508
                int index = lstDocs.getSelectedIndex();
509

    
510
                if (index == -1) {
511
                        return;
512
                }
513

    
514
                View dlg = null;
515

    
516
                if (btnMapas.isSelected()) {
517
                        dlg = new MapProperties((ProjectMap) p.getMaps().get(index));
518
                } else if (btnTablas.isSelected()) {
519
                        try {
520
                dlg = new TableProperties((ProjectTable) p.getTables().get(index));
521
            } catch (DriverException e) {
522
                NotificationManager.addError(e.getMessage(), e);
523
            }
524
                } else {
525
                        dlg = new ViewProperties((ProjectView) p.getViews().get(index));
526
                }
527

    
528
                PluginServices.getMDIManager().addView(dlg);
529

    
530
                refreshControls();
531
                lstDocs.setSelectedIndex(index);
532
        }
533

    
534
        /**
535
         * This method initializes jPanel
536
         *
537
         * @return javax.swing.JPanel
538
         */
539
        private javax.swing.JPanel getJPanel() {
540
                if (jPanel == null) {
541
                        jPanel = new javax.swing.JPanel();
542

    
543
                        java.awt.FlowLayout layFlowLayout1 = new java.awt.FlowLayout();
544
                        layFlowLayout1.setHgap(15);
545
                        jPanel.setLayout(layFlowLayout1);
546
                        jPanel.add(getBtnVistas(), null);
547
                        jPanel.add(getBtnTablas(), null);
548
                        jPanel.add(getBtnMapas(), null);
549
                        jPanel.setName("tipoDocPanel");
550
                        jPanel.setPreferredSize(new java.awt.Dimension(390, 125));
551
                        jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
552
                                        null, PluginServices.getText(this, "tipos_de_documentos"),
553
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
554
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
555
                }
556

    
557
                return jPanel;
558
        }
559

    
560
        /**
561
         * This method initializes btnVistas
562
         *
563
         * @return javax.swing.JRadioButton
564
         */
565
        private javax.swing.JRadioButton getBtnVistas() {
566
                if (btnVistas == null) {
567
                        btnVistas = new javax.swing.JRadioButton();
568
                        btnVistas.setIcon(new javax.swing.ImageIcon(
569
                                        this.getClass().getClassLoader().getResource("images/Vista.png")));
570
                        btnVistas.setSelectedIcon(new javax.swing.ImageIcon(
571
                                        this.getClass().getClassLoader().getResource("images/Vista_sel.png")));
572
                        btnVistas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
573
                        btnVistas.setText(PluginServices.getText(this, "vistas"));
574
                        btnVistas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
575
                        btnVistas.setName("vistasBtn");
576
                        btnVistas.addChangeListener(new javax.swing.event.ChangeListener() {
577
                                        public void stateChanged(javax.swing.event.ChangeEvent e) {
578
                                                refreshList();
579
                                        }
580
                                });
581
                }
582

    
583
                return btnVistas;
584
        }
585

    
586
        /**
587
         * This method initializes btnTablas
588
         *
589
         * @return javax.swing.JRadioButton
590
         */
591
        private javax.swing.JRadioButton getBtnTablas() {
592
                if (btnTablas == null) {
593
                        btnTablas = new javax.swing.JRadioButton();
594
                        btnTablas.setIcon(new javax.swing.ImageIcon(
595
                                        this.getClass().getClassLoader().getResource("images/tablas.png")));
596
                        btnTablas.setSelectedIcon(new javax.swing.ImageIcon(
597
                                        this.getClass().getClassLoader().getResource("images/tablas_sel.png")));
598
                        btnTablas.setText(PluginServices.getText(this, "tablas"));
599
                        btnTablas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
600
                        btnTablas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
601
                        btnTablas.setName("tablasBtn");
602
                        btnTablas.addChangeListener(new javax.swing.event.ChangeListener() {
603
                                        public void stateChanged(javax.swing.event.ChangeEvent e) {
604
                                                refreshList();
605
                                        }
606
                                });
607
                }
608

    
609
                return btnTablas;
610
        }
611

    
612
        /**
613
         * This method initializes btnMapas
614
         *
615
         * @return javax.swing.JRadioButton
616
         */
617
        private javax.swing.JRadioButton getBtnMapas() {
618
                if (btnMapas == null) {
619
                        btnMapas = new javax.swing.JRadioButton();
620
                        btnMapas.setIcon(new javax.swing.ImageIcon(
621
                                        this.getClass().getClassLoader().getResource("images/mapas.png")));
622
                        btnMapas.setSelectedIcon(new javax.swing.ImageIcon(
623
                                        this.getClass().getClassLoader().getResource("images/mapas_sel.png")));
624
                        btnMapas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
625
                        btnMapas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
626
                        btnMapas.setText(PluginServices.getText(this, "mapas"));
627
                        btnMapas.addChangeListener(new javax.swing.event.ChangeListener() {
628
                                        public void stateChanged(javax.swing.event.ChangeEvent e) {
629
                                                refreshList();
630
                                        }
631
                                });
632
                }
633

    
634
                return btnMapas;
635
        }
636

    
637
        /**
638
         * This method initializes jPanel1
639
         *
640
         * @return javax.swing.JPanel
641
         */
642
        private javax.swing.JPanel getJPanel1() {
643
                if (jPanel1 == null) {
644
                        jPanel1 = new javax.swing.JPanel();
645

    
646
                        java.awt.BorderLayout layBorderLayout2 = new java.awt.BorderLayout();
647
                        layBorderLayout2.setVgap(30);
648
                        jPanel1.setLayout(layBorderLayout2);
649
                        jPanel1.add(getJPanel2(), java.awt.BorderLayout.EAST);
650
                        jPanel1.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
651
                        jPanel1.setPreferredSize(new java.awt.Dimension(390, 170));
652
                        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
653
                                        null,
654
                                        PluginServices.getText(this, "documentos_existentes"),
655
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
656
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
657
                }
658

    
659
                return jPanel1;
660
        }
661

    
662
        /**
663
         * This method initializes lstDocs
664
         *
665
         * @return javax.swing.JList
666
         */
667
        private javax.swing.JList getLstDocs() {
668
                if (lstDocs == null) {
669
                        lstDocs = new javax.swing.JList();
670
                        lstDocs.addMouseListener(new java.awt.event.MouseAdapter() {
671
                                        public void mouseClicked(java.awt.event.MouseEvent e) {
672
                                                if (e.getClickCount() == 2) {
673
                                                        abrir();
674
                                                }
675
                                        }
676
                                });
677
                        lstDocs.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
678
                                        public void valueChanged(
679
                                                javax.swing.event.ListSelectionEvent e) {
680
                                                activarBotones();
681
                                        }
682
                                });
683
                }
684

    
685
                return lstDocs;
686
        }
687

    
688
        /**
689
         * This method initializes jPanel2
690
         *
691
         * @return javax.swing.JPanel
692
         */
693
        private javax.swing.JPanel getJPanel2() {
694
                if (jPanel2 == null) {
695
                        jPanel2 = new javax.swing.JPanel();
696

    
697
                        java.awt.FlowLayout layFlowLayout11 = new java.awt.FlowLayout();
698
                        layFlowLayout11.setVgap(5);
699
                        jPanel2.setLayout(layFlowLayout11);
700
                        jPanel2.add(getBtnNuevo(), null);
701
                        jPanel2.add(getBtnAbrir(), null);
702
                        jPanel2.add(getBtnRenombrar(), null);
703
                        jPanel2.add(getBtnBorrar(), null);
704
                        jPanel2.add(getBtnPropiedades(), null);
705
                        jPanel2.setPreferredSize(new java.awt.Dimension(100, 50));
706
                }
707

    
708
                return jPanel2;
709
        }
710

    
711
        /**
712
         * This method initializes btnNuevo
713
         *
714
         * @return javax.swing.JButton
715
         */
716
        private javax.swing.JButton getBtnNuevo() {
717
                if (btnNuevo == null) {
718
                        btnNuevo = new javax.swing.JButton();
719
                        btnNuevo.setPreferredSize(new java.awt.Dimension(80, 23));
720
                        btnNuevo.setName("btnNuevo");
721
                        btnNuevo.setText(PluginServices.getText(this, "nuevo"));
722
                        btnNuevo.setMargin(new java.awt.Insets(2, 2, 2, 2));
723
                        btnNuevo.addActionListener(new java.awt.event.ActionListener() {
724
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
725
                                                try {
726
                                                        nuevo();
727
                                                } catch (Exception e1) {
728
                                                        NotificationManager.addError(e1.getLocalizedMessage(),
729
                                                                e1);
730
                                                }
731
                                        }
732
                                });
733
                }
734

    
735
                return btnNuevo;
736
        }
737

    
738
        /**
739
         * This method initializes btnPropiedades
740
         *
741
         * @return javax.swing.JButton
742
         */
743
        private javax.swing.JButton getBtnPropiedades() {
744
                if (btnPropiedades == null) {
745
                        btnPropiedades = new javax.swing.JButton();
746
                        btnPropiedades.setPreferredSize(new java.awt.Dimension(80, 23));
747
                        btnPropiedades.setText(PluginServices.getText(this, "propiedades"));
748
                        btnPropiedades.setName("btnPropiedades");
749
                        btnPropiedades.setEnabled(false);
750
                        btnPropiedades.setMargin(new java.awt.Insets(2, 2, 2, 2));
751
                        btnPropiedades.addActionListener(new java.awt.event.ActionListener() {
752
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
753
                                                propiedades();
754
                                        }
755
                                });
756
                }
757

    
758
                return btnPropiedades;
759
        }
760

    
761
        /**
762
         * This method initializes btnAbrir
763
         *
764
         * @return javax.swing.JButton
765
         */
766
        private javax.swing.JButton getBtnAbrir() {
767
                if (btnAbrir == null) {
768
                        btnAbrir = new javax.swing.JButton();
769
                        btnAbrir.setPreferredSize(new java.awt.Dimension(80, 23));
770
                        btnAbrir.setName("btnAbrir");
771
                        btnAbrir.setText(PluginServices.getText(this, "abrir"));
772
                        btnAbrir.setEnabled(false);
773
                        btnAbrir.setMargin(new java.awt.Insets(2, 2, 2, 2));
774
                        btnAbrir.addActionListener(new java.awt.event.ActionListener() {
775
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
776
                                                abrir();
777
                                        }
778
                                });
779
                }
780

    
781
                return btnAbrir;
782
        }
783

    
784
        /**
785
         * This method initializes btnBorrar
786
         *
787
         * @return javax.swing.JButton
788
         */
789
        private javax.swing.JButton getBtnBorrar() {
790
                if (btnBorrar == null) {
791
                        btnBorrar = new javax.swing.JButton();
792
                        btnBorrar.setPreferredSize(new java.awt.Dimension(80, 23));
793
                        btnBorrar.setText(PluginServices.getText(this, "borrar"));
794
                        btnBorrar.setName("btnBorrar");
795
                        btnBorrar.setEnabled(false);
796
                        btnBorrar.setMargin(new java.awt.Insets(2, 2, 2, 2));
797
                        btnBorrar.addActionListener(new java.awt.event.ActionListener() {
798
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
799
                                                borrar();
800
                                        }
801
                                });
802
                }
803

    
804
                return btnBorrar;
805
        }
806

    
807
        /**
808
         * This method initializes btnRenombrar
809
         *
810
         * @return javax.swing.JButton
811
         */
812
        private javax.swing.JButton getBtnRenombrar() {
813
                if (btnRenombrar == null) {
814
                        btnRenombrar = new javax.swing.JButton();
815
                        btnRenombrar.setPreferredSize(new java.awt.Dimension(80, 23));
816
                        btnRenombrar.setName("btnRenombrar");
817
                        btnRenombrar.setText(PluginServices.getText(this, "renombrar"));
818
                        btnRenombrar.setEnabled(false);
819
                        btnRenombrar.setMargin(new java.awt.Insets(2, 2, 2, 2));
820
                        btnRenombrar.addActionListener(new java.awt.event.ActionListener() {
821
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
822
                                                renombrar();
823
                                        }
824
                                });
825
                }
826

    
827
                return btnRenombrar;
828
        }
829

    
830
        /**
831
         * This method initializes jPanel3
832
         *
833
         * @return javax.swing.JPanel
834
         */
835
        private javax.swing.JPanel getJPanel3() {
836
                if (jPanel3 == null) {
837
                        jPanel3 = new javax.swing.JPanel();
838

    
839
                        java.awt.FlowLayout layFlowLayout3 = new java.awt.FlowLayout();
840
                        layFlowLayout3.setHgap(5);
841
                        layFlowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
842
                        jPanel3.setLayout(layFlowLayout3);
843
                        jPanel3.add(getJLabel(), null);
844
                        jPanel3.add(getLblNombreSesion(), null);
845
                        jPanel3.add(getJLabel1(), null);
846
                        jPanel3.add(getLblGuardado(), null);
847
                        jPanel3.add(getJLabel2(), null);
848
                        jPanel3.add(getLblFecha(), null);
849
                        jPanel3.add(getJPanel4(), null);
850
                        jPanel3.setPreferredSize(new java.awt.Dimension(390, 125));
851
                        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(
852
                                        null, PluginServices.getText(this, "propiedades_sesion"),
853
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
854
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
855
                }
856

    
857
                return jPanel3;
858
        }
859

    
860
        /**
861
         * This method initializes jLabel
862
         *
863
         * @return javax.swing.JLabel
864
         */
865
        private javax.swing.JLabel getJLabel() {
866
                if (jLabel == null) {
867
                        jLabel = new javax.swing.JLabel();
868
                        jLabel.setText(PluginServices.getText(this, "nombre_sesion") + ":");
869
                        jLabel.setPreferredSize(new java.awt.Dimension(150, 16));
870
                }
871

    
872
                return jLabel;
873
        }
874

    
875
        /**
876
         * This method initializes lblNombreSesion
877
         *
878
         * @return javax.swing.JLabel
879
         */
880
        private javax.swing.JLabel getLblNombreSesion() {
881
                if (lblNombreSesion == null) {
882
                        lblNombreSesion = new javax.swing.JLabel();
883
                        lblNombreSesion.setText("");
884
                        lblNombreSesion.setName("lblNombreSesion");
885
                        lblNombreSesion.setPreferredSize(new java.awt.Dimension(200, 16));
886
                        lblNombreSesion.setAutoscrolls(true);
887
                }
888

    
889
                return lblNombreSesion;
890
        }
891

    
892
        /**
893
         * This method initializes jLabel1
894
         *
895
         * @return javax.swing.JLabel
896
         */
897
        private javax.swing.JLabel getJLabel1() {
898
                if (jLabel1 == null) {
899
                        jLabel1 = new javax.swing.JLabel();
900
                        jLabel1.setText(PluginServices.getText(this, "guardado") + ":");
901
                        jLabel1.setPreferredSize(new java.awt.Dimension(150, 16));
902
                }
903

    
904
                return jLabel1;
905
        }
906

    
907
        /**
908
         * This method initializes lblGuardado
909
         *
910
         * @return javax.swing.JLabel
911
         */
912
        private javax.swing.JLabel getLblGuardado() {
913
                if (lblGuardado == null) {
914
                        lblGuardado = new javax.swing.JLabel();
915
                        lblGuardado.setText("");
916
                        lblGuardado.setPreferredSize(new java.awt.Dimension(200, 16));
917
                        lblGuardado.setAutoscrolls(true);
918
                }
919

    
920
                return lblGuardado;
921
        }
922

    
923
        /**
924
         * This method initializes jLabel2
925
         *
926
         * @return javax.swing.JLabel
927
         */
928
        private javax.swing.JLabel getJLabel2() {
929
                if (jLabel2 == null) {
930
                        jLabel2 = new javax.swing.JLabel();
931
                        jLabel2.setText(PluginServices.getText(this, "creation_date") +
932
                                ":");
933
                        jLabel2.setPreferredSize(new java.awt.Dimension(150, 16));
934
                }
935

    
936
                return jLabel2;
937
        }
938

    
939
        /**
940
         * This method initializes lblFecha
941
         *
942
         * @return javax.swing.JLabel
943
         */
944
        private javax.swing.JLabel getLblFecha() {
945
                if (lblFecha == null) {
946
                        lblFecha = new javax.swing.JLabel();
947
                        lblFecha.setText("");
948
                        lblFecha.setPreferredSize(new java.awt.Dimension(200, 16));
949
                        lblFecha.setAutoscrolls(true);
950
                }
951

    
952
                return lblFecha;
953
        }
954

    
955
        /**
956
         * This method initializes btnImportar
957
         *
958
         * @return javax.swing.JButton
959
         */
960
        private javax.swing.JButton getBtnImportar() {
961
                if (btnImportar == null) {
962
                        btnImportar = new javax.swing.JButton();
963
                        btnImportar.setPreferredSize(new java.awt.Dimension(80, 23));
964
                        btnImportar.setText(PluginServices.getText(this, "importar"));
965
                        btnImportar.setMargin(new java.awt.Insets(2, 2, 2, 2));
966
                }
967

    
968
                return btnImportar;
969
        }
970

    
971
        /**
972
         * This method initializes btnExportar
973
         *
974
         * @return javax.swing.JButton
975
         */
976
        private javax.swing.JButton getBtnExportar() {
977
                if (btnExportar == null) {
978
                        btnExportar = new javax.swing.JButton();
979
                        btnExportar.setPreferredSize(new java.awt.Dimension(80, 23));
980
                        btnExportar.setText(PluginServices.getText(this, "exportar"));
981
                        btnExportar.setMargin(new java.awt.Insets(2, 2, 2, 2));
982
                }
983

    
984
                return btnExportar;
985
        }
986

    
987
        /**
988
         * This method initializes btnEditar
989
         *
990
         * @return javax.swing.JButton
991
         */
992
        private javax.swing.JButton getBtnEditar() {
993
                if (btnEditar == null) {
994
                        btnEditar = new javax.swing.JButton();
995
                        btnEditar.setPreferredSize(new java.awt.Dimension(80, 23));
996
                        btnEditar.setText(PluginServices.getText(this, "propiedades"));
997

    
998
                        btnEditar.setMargin(new java.awt.Insets(2, 2, 2, 2));
999

    
1000
                        final JPanel f = this;
1001
                        btnEditar.addActionListener(new java.awt.event.ActionListener() {
1002
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
1003
                                                ProjectProperties dlg = new ProjectProperties(p);
1004
                                                PluginServices.getMDIManager().addView(dlg);
1005
                                                refreshProperties();
1006
                                        }
1007
                                });
1008
                }
1009

    
1010
                return btnEditar;
1011
        }
1012

    
1013
        /**
1014
         * This method initializes jScrollPane
1015
         *
1016
         * @return javax.swing.JScrollPane
1017
         */
1018
        private javax.swing.JScrollPane getJScrollPane() {
1019
                if (jScrollPane == null) {
1020
                        jScrollPane = new javax.swing.JScrollPane();
1021
                        jScrollPane.setViewportView(getLstDocs());
1022
                        jScrollPane.setPreferredSize(new java.awt.Dimension(200, 100));
1023
                        jScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
1024
                }
1025

    
1026
                return jScrollPane;
1027
        }
1028

    
1029
        /**
1030
         * @see com.iver.mdiApp.ui.MDIManager.SingletonView#getViewModel()
1031
         */
1032
        public Object getViewModel() {
1033
                return p;
1034
        }
1035

    
1036
    /**
1037
     * This method is used to get <strong>an initial</strong> ViewInfo object
1038
     * for this Project Manager window. It is not intended to retrieve the
1039
     * ViewInfo object in a later time.
1040
     * <strong>Use PluginServices.getMDIManager().getViewInfo(view)
1041
     * to retrieve the ViewInfo object at any time after the creation of the
1042
     * object.
1043
     * 
1044
     * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
1045
     */
1046
        public ViewInfo getViewInfo() {
1047
                if (m_viewInfo==null) {
1048
                        m_viewInfo = new ViewInfo(ViewInfo.RESIZABLE);
1049
                        m_viewInfo.setWidth(400);
1050
                        m_viewInfo.setHeight(430);
1051
                        m_viewInfo.setTitle(PluginServices.getText(this, "titulo"));
1052
                }
1053
                return m_viewInfo;
1054
        }
1055

    
1056
        /**
1057
         * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
1058
         */
1059
        public void propertyChange(PropertyChangeEvent evt) {
1060
                refreshControls();
1061
        }
1062

    
1063
        /**
1064
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
1065
         */
1066
        public void viewActivated() {
1067
        }
1068

    
1069
        /**
1070
         * This method initializes jPanel4
1071
         *
1072
         * @return javax.swing.JPanel
1073
         */
1074
        private javax.swing.JPanel getJPanel4() {
1075
                if (jPanel4 == null) {
1076
                        jPanel4 = new javax.swing.JPanel();
1077

    
1078
                        java.awt.FlowLayout layFlowLayout2 = new java.awt.FlowLayout();
1079
                        layFlowLayout2.setHgap(30);
1080
                        jPanel4.setLayout(layFlowLayout2);
1081
                        jPanel4.add(getBtnImportar(), null);
1082
                        jPanel4.add(getBtnExportar(), null);
1083
                        jPanel4.add(getBtnEditar(), null);
1084
                        jPanel4.setPreferredSize(new java.awt.Dimension(360, 30));
1085
                }
1086

    
1087
                return jPanel4;
1088
        }
1089
}