Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / project / ProjectWindow.java @ 5870

History | View | Annotate | Download (33.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.Driver;
55
import com.hardcode.driverManager.DriverLoadException;
56
import com.hardcode.driverManager.DriverManager;
57
import com.hardcode.gdbms.engine.data.DataSource;
58
import com.hardcode.gdbms.engine.data.DataSourceFactory;
59
import com.hardcode.gdbms.engine.data.driver.DBDriver;
60
import com.hardcode.gdbms.engine.data.driver.DriverException;
61
import com.hardcode.gdbms.engine.data.driver.FileDriver;
62
import com.iver.andami.PluginServices;
63
import com.iver.andami.messages.NotificationManager;
64
import com.iver.andami.ui.mdiManager.SingletonView;
65
import com.iver.andami.ui.mdiManager.View;
66
import com.iver.andami.ui.mdiManager.ViewInfo;
67
import com.iver.cit.gvsig.ProjectExtension;
68
import com.iver.cit.gvsig.fmap.drivers.GeorreferencedRasterDriver;
69
import com.iver.cit.gvsig.fmap.edition.EditableAdapter;
70
import com.iver.cit.gvsig.fmap.edition.IWriter;
71
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
72
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
73
import com.iver.cit.gvsig.gui.DataBaseOpenDialog;
74
import com.iver.cit.gvsig.gui.FOpenDialog;
75
import com.iver.cit.gvsig.gui.FileOpenDialog;
76
import com.iver.cit.gvsig.gui.Table;
77
import com.iver.cit.gvsig.gui.layout.Layout;
78
import com.iver.cit.gvsig.project.Project;
79
import com.iver.cit.gvsig.project.ProjectElement;
80
import com.iver.cit.gvsig.project.ProjectFactory;
81
import com.iver.cit.gvsig.project.ProjectMap;
82
import com.iver.cit.gvsig.project.ProjectTable;
83
import com.iver.cit.gvsig.project.ProjectView;
84
import com.iver.utiles.DefaultListModel;
85

    
86

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

    
121
        /** Proyecto representado en la vista */
122
        private Project p;
123

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

    
132
        /**
133
         * This is the default constructor
134
         *
135
         * @param project Extension
136
         */
137
        public ProjectWindow(ProjectExtension project) {
138
                super();
139

    
140
                initialize();
141

    
142
                projectExtension = project;
143

    
144
                refreshControls();
145
        }
146

    
147
        /**
148
         * This is the default constructor
149
         *
150
         * @param project Extension
151
         */
152
        public ProjectWindow() {
153
                super();
154

    
155
                initialize();
156
                refreshControls();
157
        }
158

    
159
        public void setProjectExtension(ProjectExtension p) {
160
                projectExtension = p;
161
        }
162

    
163

    
164
        /**
165
         * Asigna el proyecto a la ventana
166
         *
167
         * @param p Proyecto con el que se operar? a trav?s de este di?logo
168
         */
169
        public void setProject(Project p) {
170
                this.p = p;
171
                p.addPropertyChangeListener(this);
172
                refreshControls();
173
        }
174

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

    
194
        /**
195
         * Refresca la lista de elementos de proyecto con vistas, mapas o tablas,
196
         * seg?n la opci?n activada
197
         */
198
        private void refreshList() {
199
                if (p != null) {
200
                        DefaultListModel model;
201

    
202
                        if (btnMapas.isSelected()) {
203
                                model = new DefaultListModel(p.getMaps());
204

    
205
                                //                                getBtnNuevo().setEnabled(true);
206
                        } else if (btnTablas.isSelected()) {
207
                                model = new DefaultListModel(p.getTables());
208

    
209
                                //                getBtnNuevo().setEnabled(false);
210
                        } else {
211
                                model = new DefaultListModel(p.getViews());
212

    
213
                                //                                getBtnNuevo().setEnabled(true);
214
                        }
215

    
216
                        lstDocs.setModel(model);
217

    
218
                        activarBotones();
219
                }
220
        }
221

    
222
        /**
223
         * Refresca las etiquetas con la informaci?n del proyecto
224
         */
225
        private void refreshProperties() {
226
                if (p != null) {
227
                        String aux;
228

    
229
                        lblNombreSesion.setText(p.getName());
230

    
231
                        String path = p.getPath();
232

    
233
                        if (path != null) {
234
                                File f = new File(path);
235
                                lblGuardado.setText(f.toString());
236
                        } else {
237
                                lblGuardado.setText("");
238
                        }
239

    
240
                        lblFecha.setText(p.getCreationDate());
241
                }
242
        }
243

    
244
        /**
245
         * Refresca todo el di?logo
246
         */
247
        public void refreshControls() {
248
                refreshList();
249
                refreshProperties();
250
        }
251

    
252
        /**
253
         * This method initializes this
254
         */
255
        private void initialize() {
256
                setLayout(new java.awt.FlowLayout());
257
                add(getJPanel(), null);
258
                add(getJPanel1(), null);
259
                add(getJPanel3(), null);
260

    
261
                this.setSize(400, 450);
262
                this.setPreferredSize(new java.awt.Dimension(400, 430));
263
                grupo.add(btnVistas);
264
                grupo.add(btnTablas);
265
                grupo.add(btnMapas);
266

    
267
                btnVistas.setSelected(true);
268
        }
269
        private String ask(String title, String content){
270
                JOptionPane pane = new JOptionPane();
271
                pane.setMessage(content);
272
                pane.setMessageType(JOptionPane.QUESTION_MESSAGE);
273
                pane.setWantsInput(true);
274
                pane.setInitialSelectionValue("");
275

    
276
                JDialog dlg = pane.createDialog((Component) PluginServices.getMainFrame(),
277
                                title);
278
                dlg.setModal(true);
279
                dlg.show();
280

    
281
                return pane.getInputValue().toString().trim();
282
        }
283

    
284
        /**
285
         * Crea un nuevo project element
286
         *
287
         * @throws Exception DOCUMENT ME!
288
         */
289
        private void nuevo() throws Exception {
290
                DateFormat df = DateFormat.getDateInstance();
291

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

    
309
                                if (fopen.isAccepted()) {
310
                                        JPanel panel = fopen.getSelectedTab();
311
                                        ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
312

    
313
                                        if (panel instanceof FileOpenDialog) {
314
                                                File[] files = fod.getFiles();
315
                                                String[] driverNames = fod.getDriverNames();
316

    
317
                                                for (int i = 0; i < files.length; i++) {
318
                                                        String name = files[i].getName();
319

    
320
                                                        LayerFactory.getDataSourceFactory()
321
                                                                                .addFileDataSource(driverNames[i],
322
                                                                name, files[i].getAbsolutePath());
323

    
324
                                                        DataSource dataSource = LayerFactory.getDataSourceFactory()
325
                                                                                                                                .createRandomDataSource(name, DataSourceFactory.AUTOMATIC_OPENING);
326
                                                        SelectableDataSource sds = new SelectableDataSource(dataSource);
327
                                                        EditableAdapter auxea=new EditableAdapter();
328
                                        auxea.setOriginalDataSource(sds);
329
                                        // TODO: fjp: ESTO HAY QUE REVISARLO.
330
                                        // Por ahora, para obtener un driver que sirva para esta
331
                                        // fuente de datos, compruebo que implementa IWriteable.
332
                                        // IWriter writer = (IWriter) LayerFactory.getWM().getWriter(driverNames[i]);
333
                                        Driver drv = LayerFactory.getDM().getDriver(driverNames[i]);
334
                                        if (drv instanceof IWriter)
335
                                        {
336
                                                auxea.setWriter((IWriter) drv);
337
                                        }
338
                                                        ProjectTable projectTable = ProjectFactory.createTable(name,
339
                                                                        auxea);
340
                                                        ext.getProject().addTable(projectTable);
341

    
342
                                                        Table t = new Table();
343
                                                        t.setModel(projectTable);
344
                                                        projectTable.setAndamiView(t);
345
                                                        PluginServices.getMDIManager().addView(t);
346
                                                }
347
                                        } else if (panel instanceof DataBaseOpenDialog) {
348
                                                String driverName = dbod.getDriverName();
349
                                                int port = -1;
350

    
351
                                                try {
352
                                                        port = Integer.parseInt(dbod.getPort());
353
                                                } catch (NumberFormatException e) {
354
                                                }
355

    
356
                                                String name = dbod.getHost() + "/" +
357
                                                        dbod.getDataBase();
358

    
359
                                                if (port != -1) {
360
                                                        name = dbod.getHost() + ":" + port + "/" +
361
                                                                dbod.getDataBase();
362
                                                }
363

    
364
                                                String user = dbod.getUser().trim();
365
                                                String password = dbod.getPassword();
366

    
367
                                                if (user.equals("")) {
368
                                                        user = null;
369
                                                        password = null;
370
                                                }
371

    
372
                                                LayerFactory.getDataSourceFactory().addDBDataSourceByTable(name,
373
                                                        dbod.getHost(), port, user, password,
374
                                                        dbod.getDataBase(), dbod.getTable(), driverName);
375

    
376
                                                DataSource dataSource = LayerFactory.getDataSourceFactory()
377
                                                                                                                        .createRandomDataSource(name, DataSourceFactory.AUTOMATIC_OPENING);
378
                                                SelectableDataSource sds = new SelectableDataSource(dataSource);
379
                                                EditableAdapter auxea=new EditableAdapter();
380
                                // TODO: fjp: ESTO HAY QUE REVISARLO.
381
                                // Por ahora, para obtener un driver que sirva para esta
382
                                // fuente de datos, compruebo que implementa IWriteable.
383
                                // IWriter writer = (IWriter) LayerFactory.getWM().getWriter(driverNames[i]);
384
                                Driver drv = LayerFactory.getDM().getDriver(driverName);
385
                                if (drv instanceof IWriter)
386
                                {
387
                                        auxea.setWriter((IWriter) drv);
388
                                }
389

    
390
                                auxea.setOriginalDataSource(sds);
391
                                                ProjectTable projectTable = ProjectFactory.createTable(name,
392
                                                                auxea);
393
                                                ext.getProject().addTable(projectTable);
394

    
395
                                                Table t = new Table();
396
                                                t.setModel(projectTable);
397
                                                projectTable.setAndamiView(t);
398
                                                PluginServices.getMDIManager().addView(t);
399
                                        }
400
                                }
401
                        } catch (DriverLoadException e) {
402
                                NotificationManager.addError("Error al cargar los drivers", e);
403
                        }
404
                } else {
405
                        ProjectView vista = ProjectFactory.createView(PluginServices.getText(
406
                                                this, "untitled"));
407
                        p.addView(vista);
408
                }
409
        }
410

    
411
        /**
412
         * Abre la ventana de un nuevo project element
413
         */
414
        private void abrir() {
415
                if (btnMapas.isSelected()) {
416
                        int index = lstDocs.getSelectedIndex();
417

    
418
                        if (index == -1) {
419
                                return;
420
                        }
421
            ProjectMap projectMap = (ProjectMap) p.getMaps().get(index);
422
                        Layout l = projectMap.getModel();
423
            // System.out.println("l.getName " + l.getName() + " projectMap.getName " + projectMap.getName());
424
            projectMap.setName(l.getName());
425
            l.setProjectMap(projectMap);
426
                        l.fullRect();
427
            l.getViewInfo().setTitle(PluginServices.getText(this,
428
            "Mapa") + " : " +l.getName());
429
                        PluginServices.getMDIManager().addView(l);
430
                } else if (btnTablas.isSelected()) {
431
                        com.iver.cit.gvsig.gui.Table vista = new com.iver.cit.gvsig.gui.Table();
432
                        int index = lstDocs.getSelectedIndex();
433

    
434
                        if (index == -1) {
435
                                return;
436
                        }
437
                        ProjectTable pt=(ProjectTable) p.getTables().get(index);
438
                        vista.setModel(pt);
439
                        PluginServices.getMDIManager().addView(vista);
440
                } else {
441
                        com.iver.cit.gvsig.gui.View vista = new com.iver.cit.gvsig.gui.View();
442
                        int index = lstDocs.getSelectedIndex();
443

    
444
                        if (index == -1) {
445
                                return;
446
                        }
447

    
448
                        vista.setModel((ProjectView) p.getViews().get(index));
449
                        PluginServices.getMDIManager().addView(vista);
450
                }
451
        }
452

    
453
        /**
454
         * Cambia el nombre de un project element
455
         */
456
        private void renombrar() {
457
                ProjectElement elem = null;
458
                int index = lstDocs.getSelectedIndex();
459

    
460
                if (index == -1) {
461
                        return;
462
                }
463

    
464
                if (btnMapas.isSelected()) {
465
                        elem = (ProjectElement) p.getMaps().get(index);
466
                } else if (btnTablas.isSelected()) {
467
                        elem = (ProjectElement) p.getTables().get(index);
468
                } else {
469
                        elem = (ProjectElement) p.getViews().get(index);
470
                }
471

    
472
                if (elem.isLocked()) {
473
                        JOptionPane.showMessageDialog(this,        PluginServices.getText(this, "locked_element_it_cannot_be_renamed"));
474
                        return;
475
                }
476
                
477
                JOptionPane pane = new JOptionPane();
478
                pane.setMessage(PluginServices.getText(this, "introduce_nombre"));
479
                pane.setMessageType(JOptionPane.QUESTION_MESSAGE);
480
                pane.setWantsInput(true);
481
                pane.setInitialSelectionValue(elem.getName());
482
        pane.setInputValue(elem.getName());
483
                JDialog dlg = pane.createDialog((Component) PluginServices.getMainFrame(),
484
                                PluginServices.getText(this, "renombrar"));
485
                dlg.setModal(true);
486
                dlg.show();
487

    
488
                String nuevoNombre = pane.getInputValue().toString().trim();
489

    
490
                if (nuevoNombre.length() == 0) {
491
                        return;
492
                }
493

    
494
                if (nuevoNombre == null) {
495
                        return;
496
                }
497

    
498
                for (int i=0; i<lstDocs.getModel().getSize(); i++){
499
                        if (i==index) continue;
500
                        if (((ProjectElement)lstDocs.getModel().getElementAt(i)).getName().equals(nuevoNombre)){
501
                                JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this, "elemento_ya_existe"));
502
                                return;
503
                        }
504

    
505
                }
506
                elem.setName(nuevoNombre);
507

    
508
                refreshList();
509
        }
510

    
511
        /**
512
         * Borra un project element
513
         */
514
        private void borrar() {
515
                int res = JOptionPane.showConfirmDialog((Component) PluginServices.getMainFrame(),
516
                                PluginServices.getText(this, "confirmar_borrar"),
517
                                PluginServices.getText(this, "borrar"),
518
                                JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
519

    
520
                if (res == JOptionPane.YES_OPTION) {
521
                        int index = lstDocs.getSelectedIndex();
522

    
523
                        if (btnMapas.isSelected()) {
524
                                if (((ProjectElement) p.getMaps().get(index)).isLocked()) {
525
                                        JOptionPane.showMessageDialog(this,        PluginServices.getText(this, "locked_element_it_cannot_be_deleted"));
526
                                        return;
527
                                }
528
                                PluginServices.getMDIManager().closeSingletonView(p.getMaps()
529
                                                                                                                                   .get(index));
530
                                p.delMap(index);
531
                        } else if (btnTablas.isSelected()) {
532
                                if (((ProjectElement) p.getTables().get(index)).isLocked()) {
533
                                        JOptionPane.showMessageDialog(this,        PluginServices.getText(this, "locked_element_it_cannot_be_deleted"));
534
                                        return;
535
                                }
536
                                PluginServices.getMDIManager().closeSingletonView(p.getTables()
537
                                                                                                                                   .get(index));
538
                                p.delTable(index);
539
                        } else {
540
                                if (((ProjectElement) p.getViews().get(index)).isLocked()) {
541
                                        JOptionPane.showMessageDialog(this,        PluginServices.getText(this, "locked_element_it_cannot_be_deleted"));
542
                                        return;
543
                                }
544
                                PluginServices.getMDIManager().closeSingletonView(p.getViews()
545
                                                                                                                                   .get(index));
546
                                p.delView(index);
547
                        }
548

    
549
                        refreshList();
550
                }
551
        }
552

    
553
        /**
554
         * Muestra el di?logo de propiedades de un project element
555
         */
556
        private void propiedades() {
557
                int index = lstDocs.getSelectedIndex();
558

    
559
                if (index == -1) {
560
                        return;
561
                }
562

    
563
                View dlg = null;
564

    
565
                if (btnMapas.isSelected()) {
566
                        if (((ProjectElement) p.getMaps().get(index)).isLocked()) {
567
                                JOptionPane.showMessageDialog(this,        PluginServices.getText(this, "locked_element"));
568
                                return;
569
                        }
570
                        dlg = new MapProperties((ProjectMap) p.getMaps().get(index));
571
                } else if (btnTablas.isSelected()) {
572
                        if (((ProjectElement) p.getTables().get(index)).isLocked()) {
573
                                JOptionPane.showMessageDialog(this,        PluginServices.getText(this, "locked_element"));
574
                                return;
575
                        }
576
                        try {
577
                dlg = new TableProperties((ProjectTable) p.getTables().get(index));
578
            } catch (DriverException e) {
579
                NotificationManager.addError(e.getMessage(), e);
580
            }
581
                } else {
582
                        if (((ProjectElement) p.getViews().get(index)).isLocked()) {
583
                                JOptionPane.showMessageDialog(this,        PluginServices.getText(this, "locked_element"));
584
                                return;
585
                        }
586
                        
587
                        dlg = new ViewProperties((ProjectView) p.getViews().get(index));
588
                }
589

    
590
                PluginServices.getMDIManager().addView(dlg);
591

    
592
                refreshControls();
593
                lstDocs.setSelectedIndex(index);
594
        }
595

    
596
        /**
597
         * This method initializes jPanel
598
         *
599
         * @return javax.swing.JPanel
600
         */
601
        private javax.swing.JPanel getJPanel() {
602
                if (jPanel == null) {
603
                        jPanel = new javax.swing.JPanel();
604

    
605
                        java.awt.FlowLayout layFlowLayout1 = new java.awt.FlowLayout();
606
                        layFlowLayout1.setHgap(15);
607
                        jPanel.setLayout(layFlowLayout1);
608
                        jPanel.add(getBtnVistas(), null);
609
                        jPanel.add(getBtnTablas(), null);
610
                        jPanel.add(getBtnMapas(), null);
611
                        jPanel.setName("tipoDocPanel");
612
                        jPanel.setPreferredSize(new java.awt.Dimension(390, 125));
613
                        jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
614
                                        null, PluginServices.getText(this, "tipos_de_documentos"),
615
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
616
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
617
                }
618

    
619
                return jPanel;
620
        }
621

    
622
        /**
623
         * This method initializes btnVistas
624
         *
625
         * @return javax.swing.JRadioButton
626
         */
627
        private javax.swing.JRadioButton getBtnVistas() {
628
                if (btnVistas == null) {
629
                        btnVistas = new javax.swing.JRadioButton();
630
                        btnVistas.setIcon(new javax.swing.ImageIcon(
631
                                        this.getClass().getClassLoader().getResource("images/Vista.png")));
632
                        btnVistas.setSelectedIcon(new javax.swing.ImageIcon(
633
                                        this.getClass().getClassLoader().getResource("images/Vista_sel.png")));
634
                        btnVistas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
635
                        btnVistas.setText(PluginServices.getText(this, "vistas"));
636
                        btnVistas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
637
                        btnVistas.setName("vistasBtn");
638
                        btnVistas.addChangeListener(new javax.swing.event.ChangeListener() {
639
                                        public void stateChanged(javax.swing.event.ChangeEvent e) {
640
                                                refreshList();
641
                                        }
642
                                });
643
                }
644

    
645
                return btnVistas;
646
        }
647

    
648
        /**
649
         * This method initializes btnTablas
650
         *
651
         * @return javax.swing.JRadioButton
652
         */
653
        private javax.swing.JRadioButton getBtnTablas() {
654
                if (btnTablas == null) {
655
                        btnTablas = new javax.swing.JRadioButton();
656
                        btnTablas.setIcon(new javax.swing.ImageIcon(
657
                                        this.getClass().getClassLoader().getResource("images/tablas.png")));
658
                        btnTablas.setSelectedIcon(new javax.swing.ImageIcon(
659
                                        this.getClass().getClassLoader().getResource("images/tablas_sel.png")));
660
                        btnTablas.setText(PluginServices.getText(this, "tablas"));
661
                        btnTablas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
662
                        btnTablas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
663
                        btnTablas.setName("tablasBtn");
664
                        btnTablas.addChangeListener(new javax.swing.event.ChangeListener() {
665
                                        public void stateChanged(javax.swing.event.ChangeEvent e) {
666
                                                refreshList();
667
                                        }
668
                                });
669
                }
670

    
671
                return btnTablas;
672
        }
673

    
674
        /**
675
         * This method initializes btnMapas
676
         *
677
         * @return javax.swing.JRadioButton
678
         */
679
        private javax.swing.JRadioButton getBtnMapas() {
680
                if (btnMapas == null) {
681
                        btnMapas = new javax.swing.JRadioButton();
682
                        btnMapas.setIcon(new javax.swing.ImageIcon(
683
                                        this.getClass().getClassLoader().getResource("images/mapas.png")));
684
                        btnMapas.setSelectedIcon(new javax.swing.ImageIcon(
685
                                        this.getClass().getClassLoader().getResource("images/mapas_sel.png")));
686
                        btnMapas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
687
                        btnMapas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
688
                        btnMapas.setText(PluginServices.getText(this, "mapas"));
689
                        btnMapas.addChangeListener(new javax.swing.event.ChangeListener() {
690
                                        public void stateChanged(javax.swing.event.ChangeEvent e) {
691
                                                refreshList();
692
                                        }
693
                                });
694
                }
695

    
696
                return btnMapas;
697
        }
698

    
699
        /**
700
         * This method initializes jPanel1
701
         *
702
         * @return javax.swing.JPanel
703
         */
704
        private javax.swing.JPanel getJPanel1() {
705
                if (jPanel1 == null) {
706
                        jPanel1 = new javax.swing.JPanel();
707

    
708
                        java.awt.BorderLayout layBorderLayout2 = new java.awt.BorderLayout();
709
                        layBorderLayout2.setVgap(30);
710
                        jPanel1.setLayout(layBorderLayout2);
711
                        jPanel1.add(getJPanel2(), java.awt.BorderLayout.EAST);
712
                        jPanel1.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
713
                        jPanel1.setPreferredSize(new java.awt.Dimension(390, 170));
714
                        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
715
                                        null,
716
                                        PluginServices.getText(this, "documentos_existentes"),
717
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
718
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
719
                }
720

    
721
                return jPanel1;
722
        }
723

    
724
        /**
725
         * This method initializes lstDocs
726
         *
727
         * @return javax.swing.JList
728
         */
729
        private javax.swing.JList getLstDocs() {
730
                if (lstDocs == null) {
731
                        lstDocs = new javax.swing.JList();
732
                        lstDocs.addMouseListener(new java.awt.event.MouseAdapter() {
733
                                        public void mouseClicked(java.awt.event.MouseEvent e) {
734
                                                if (e.getClickCount() == 2) {
735
                                                        abrir();
736
                                                }
737
                                        }
738
                                });
739
                        lstDocs.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
740
                                        public void valueChanged(
741
                                                javax.swing.event.ListSelectionEvent e) {
742
                                                activarBotones();
743
                                        }
744
                                });
745
                }
746

    
747
                return lstDocs;
748
        }
749

    
750
        /**
751
         * This method initializes jPanel2
752
         *
753
         * @return javax.swing.JPanel
754
         */
755
        private javax.swing.JPanel getJPanel2() {
756
                if (jPanel2 == null) {
757
                        jPanel2 = new javax.swing.JPanel();
758

    
759
                        java.awt.FlowLayout layFlowLayout11 = new java.awt.FlowLayout();
760
                        layFlowLayout11.setVgap(5);
761
                        jPanel2.setLayout(layFlowLayout11);
762
                        jPanel2.add(getBtnNuevo(), null);
763
                        jPanel2.add(getBtnAbrir(), null);
764
                        jPanel2.add(getBtnRenombrar(), null);
765
                        jPanel2.add(getBtnBorrar(), null);
766
                        jPanel2.add(getBtnPropiedades(), null);
767
                        jPanel2.setPreferredSize(new java.awt.Dimension(100, 50));
768
                }
769

    
770
                return jPanel2;
771
        }
772

    
773
        /**
774
         * This method initializes btnNuevo
775
         *
776
         * @return javax.swing.JButton
777
         */
778
        private javax.swing.JButton getBtnNuevo() {
779
                if (btnNuevo == null) {
780
                        btnNuevo = new javax.swing.JButton();
781
                        btnNuevo.setPreferredSize(new java.awt.Dimension(80, 23));
782
                        btnNuevo.setName("btnNuevo");
783
                        btnNuevo.setText(PluginServices.getText(this, "nuevo"));
784
                        btnNuevo.setMargin(new java.awt.Insets(2, 2, 2, 2));
785
                        btnNuevo.addActionListener(new java.awt.event.ActionListener() {
786
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
787
                                                try {
788
                                                        nuevo();
789
                                                } catch (Exception e1) {
790
                                                        NotificationManager.addError(e1.getLocalizedMessage(),
791
                                                                e1);
792
                                                }
793
                                        }
794
                                });
795
                }
796

    
797
                return btnNuevo;
798
        }
799

    
800
        /**
801
         * This method initializes btnPropiedades
802
         *
803
         * @return javax.swing.JButton
804
         */
805
        private javax.swing.JButton getBtnPropiedades() {
806
                if (btnPropiedades == null) {
807
                        btnPropiedades = new javax.swing.JButton();
808
                        btnPropiedades.setPreferredSize(new java.awt.Dimension(80, 23));
809
                        btnPropiedades.setText(PluginServices.getText(this, "propiedades"));
810
                        btnPropiedades.setName("btnPropiedades");
811
                        btnPropiedades.setEnabled(false);
812
                        btnPropiedades.setMargin(new java.awt.Insets(2, 2, 2, 2));
813
                        btnPropiedades.addActionListener(new java.awt.event.ActionListener() {
814
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
815
                                                propiedades();
816
                                        }
817
                                });
818
                }
819

    
820
                return btnPropiedades;
821
        }
822

    
823
        /**
824
         * This method initializes btnAbrir
825
         *
826
         * @return javax.swing.JButton
827
         */
828
        private javax.swing.JButton getBtnAbrir() {
829
                if (btnAbrir == null) {
830
                        btnAbrir = new javax.swing.JButton();
831
                        btnAbrir.setPreferredSize(new java.awt.Dimension(80, 23));
832
                        btnAbrir.setName("btnAbrir");
833
                        btnAbrir.setText(PluginServices.getText(this, "abrir"));
834
                        btnAbrir.setEnabled(false);
835
                        btnAbrir.setMargin(new java.awt.Insets(2, 2, 2, 2));
836
                        btnAbrir.addActionListener(new java.awt.event.ActionListener() {
837
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
838
                                                abrir();
839
                                        }
840
                                });
841
                }
842

    
843
                return btnAbrir;
844
        }
845

    
846
        /**
847
         * This method initializes btnBorrar
848
         *
849
         * @return javax.swing.JButton
850
         */
851
        private javax.swing.JButton getBtnBorrar() {
852
                if (btnBorrar == null) {
853
                        btnBorrar = new javax.swing.JButton();
854
                        btnBorrar.setPreferredSize(new java.awt.Dimension(80, 23));
855
                        btnBorrar.setText(PluginServices.getText(this, "borrar"));
856
                        btnBorrar.setName("btnBorrar");
857
                        btnBorrar.setEnabled(false);
858
                        btnBorrar.setMargin(new java.awt.Insets(2, 2, 2, 2));
859
                        btnBorrar.addActionListener(new java.awt.event.ActionListener() {
860
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
861
                                                borrar();
862
                                        }
863
                                });
864
                }
865

    
866
                return btnBorrar;
867
        }
868

    
869
        /**
870
         * This method initializes btnRenombrar
871
         *
872
         * @return javax.swing.JButton
873
         */
874
        private javax.swing.JButton getBtnRenombrar() {
875
                if (btnRenombrar == null) {
876
                        btnRenombrar = new javax.swing.JButton();
877
                        btnRenombrar.setPreferredSize(new java.awt.Dimension(80, 23));
878
                        btnRenombrar.setName("btnRenombrar");
879
                        btnRenombrar.setText(PluginServices.getText(this, "renombrar"));
880
                        btnRenombrar.setEnabled(false);
881
                        btnRenombrar.setMargin(new java.awt.Insets(2, 2, 2, 2));
882
                        btnRenombrar.addActionListener(new java.awt.event.ActionListener() {
883
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
884
                                                renombrar();
885
                                        }
886
                                });
887
                }
888

    
889
                return btnRenombrar;
890
        }
891

    
892
        /**
893
         * This method initializes jPanel3
894
         *
895
         * @return javax.swing.JPanel
896
         */
897
        private javax.swing.JPanel getJPanel3() {
898
                if (jPanel3 == null) {
899
                        jPanel3 = new javax.swing.JPanel();
900

    
901
                        java.awt.FlowLayout layFlowLayout3 = new java.awt.FlowLayout();
902
                        layFlowLayout3.setHgap(5);
903
                        layFlowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
904
                        jPanel3.setLayout(layFlowLayout3);
905
                        jPanel3.add(getJLabel(), null);
906
                        jPanel3.add(getLblNombreSesion(), null);
907
                        jPanel3.add(getJLabel1(), null);
908
                        jPanel3.add(getLblGuardado(), null);
909
                        jPanel3.add(getJLabel2(), null);
910
                        jPanel3.add(getLblFecha(), null);
911
                        jPanel3.add(getJPanel4(), null);
912
                        jPanel3.setPreferredSize(new java.awt.Dimension(390, 125));
913
                        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(
914
                                        null, PluginServices.getText(this, "propiedades_sesion"),
915
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
916
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
917
                }
918

    
919
                return jPanel3;
920
        }
921

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

    
934
                return jLabel;
935
        }
936

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

    
951
                return lblNombreSesion;
952
        }
953

    
954
        /**
955
         * This method initializes jLabel1
956
         *
957
         * @return javax.swing.JLabel
958
         */
959
        private javax.swing.JLabel getJLabel1() {
960
                if (jLabel1 == null) {
961
                        jLabel1 = new javax.swing.JLabel();
962
                        jLabel1.setText(PluginServices.getText(this, "guardado") + ":");
963
                        jLabel1.setPreferredSize(new java.awt.Dimension(150, 16));
964
                }
965

    
966
                return jLabel1;
967
        }
968

    
969
        /**
970
         * This method initializes lblGuardado
971
         *
972
         * @return javax.swing.JLabel
973
         */
974
        private javax.swing.JLabel getLblGuardado() {
975
                if (lblGuardado == null) {
976
                        lblGuardado = new javax.swing.JLabel();
977
                        lblGuardado.setText("");
978
                        lblGuardado.setPreferredSize(new java.awt.Dimension(200, 16));
979
                        lblGuardado.setAutoscrolls(true);
980
                }
981

    
982
                return lblGuardado;
983
        }
984

    
985
        /**
986
         * This method initializes jLabel2
987
         *
988
         * @return javax.swing.JLabel
989
         */
990
        private javax.swing.JLabel getJLabel2() {
991
                if (jLabel2 == null) {
992
                        jLabel2 = new javax.swing.JLabel();
993
                        jLabel2.setText(PluginServices.getText(this, "creation_date") +
994
                                ":");
995
                        jLabel2.setPreferredSize(new java.awt.Dimension(150, 16));
996
                }
997

    
998
                return jLabel2;
999
        }
1000

    
1001
        /**
1002
         * This method initializes lblFecha
1003
         *
1004
         * @return javax.swing.JLabel
1005
         */
1006
        private javax.swing.JLabel getLblFecha() {
1007
                if (lblFecha == null) {
1008
                        lblFecha = new javax.swing.JLabel();
1009
                        lblFecha.setText("");
1010
                        lblFecha.setPreferredSize(new java.awt.Dimension(200, 16));
1011
                        lblFecha.setAutoscrolls(true);
1012
                }
1013

    
1014
                return lblFecha;
1015
        }
1016

    
1017
        /**
1018
         * This method initializes btnImportar
1019
         *
1020
         * @return javax.swing.JButton
1021
         */
1022
        private javax.swing.JButton getBtnImportar() {
1023
                if (btnImportar == null) {
1024
                        btnImportar = new javax.swing.JButton();
1025
                        btnImportar.setPreferredSize(new java.awt.Dimension(80, 23));
1026
                        btnImportar.setText(PluginServices.getText(this, "importar"));
1027
                        btnImportar.setMargin(new java.awt.Insets(2, 2, 2, 2));
1028
                }
1029

    
1030
                return btnImportar;
1031
        }
1032

    
1033
        /**
1034
         * This method initializes btnExportar
1035
         *
1036
         * @return javax.swing.JButton
1037
         */
1038
        private javax.swing.JButton getBtnExportar() {
1039
                if (btnExportar == null) {
1040
                        btnExportar = new javax.swing.JButton();
1041
                        btnExportar.setPreferredSize(new java.awt.Dimension(80, 23));
1042
                        btnExportar.setText(PluginServices.getText(this, "exportar"));
1043
                        btnExportar.setMargin(new java.awt.Insets(2, 2, 2, 2));
1044
                }
1045

    
1046
                return btnExportar;
1047
        }
1048

    
1049
        /**
1050
         * This method initializes btnEditar
1051
         *
1052
         * @return javax.swing.JButton
1053
         */
1054
        private javax.swing.JButton getBtnEditar() {
1055
                if (btnEditar == null) {
1056
                        btnEditar = new javax.swing.JButton();
1057
                        btnEditar.setPreferredSize(new java.awt.Dimension(80, 23));
1058
                        btnEditar.setText(PluginServices.getText(this, "propiedades"));
1059

    
1060
                        btnEditar.setMargin(new java.awt.Insets(2, 2, 2, 2));
1061

    
1062
                        final JPanel f = this;
1063
                        btnEditar.addActionListener(new java.awt.event.ActionListener() {
1064
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
1065
                                                ProjectProperties dlg = new ProjectProperties(p);
1066
                                                PluginServices.getMDIManager().addView(dlg);
1067
                                                refreshProperties();
1068
                                        }
1069
                                });
1070
                }
1071

    
1072
                return btnEditar;
1073
        }
1074

    
1075
        /**
1076
         * This method initializes jScrollPane
1077
         *
1078
         * @return javax.swing.JScrollPane
1079
         */
1080
        private javax.swing.JScrollPane getJScrollPane() {
1081
                if (jScrollPane == null) {
1082
                        jScrollPane = new javax.swing.JScrollPane();
1083
                        jScrollPane.setViewportView(getLstDocs());
1084
                        jScrollPane.setPreferredSize(new java.awt.Dimension(200, 100));
1085
                        jScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
1086
                }
1087

    
1088
                return jScrollPane;
1089
        }
1090

    
1091
        /**
1092
         * @see com.iver.mdiApp.ui.MDIManager.SingletonView#getViewModel()
1093
         */
1094
        public Object getViewModel() {
1095
                return p;
1096
        }
1097

    
1098
    /**
1099
     * This method is used to get <strong>an initial</strong> ViewInfo object
1100
     * for this Project Manager window. It is not intended to retrieve the
1101
     * ViewInfo object in a later time.
1102
     * <strong>Use PluginServices.getMDIManager().getViewInfo(view)
1103
     * to retrieve the ViewInfo object at any time after the creation of the
1104
     * object.
1105
     *
1106
     * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
1107
     */
1108
        public ViewInfo getViewInfo() {
1109
                if (m_viewInfo==null) {
1110
                        m_viewInfo = new ViewInfo();
1111
                        m_viewInfo.setWidth(400);
1112
                        m_viewInfo.setHeight(430);
1113
                        m_viewInfo.setTitle(PluginServices.getText(this, "titulo"));
1114
                }
1115
                return m_viewInfo;
1116
        }
1117

    
1118
        /**
1119
         * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
1120
         */
1121
        public void propertyChange(PropertyChangeEvent evt) {
1122
                refreshControls();
1123
        }
1124

    
1125
        /**
1126
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
1127
         */
1128
        public void viewActivated() {
1129
        }
1130

    
1131
        /**
1132
         * This method initializes jPanel4
1133
         *
1134
         * @return javax.swing.JPanel
1135
         */
1136
        private javax.swing.JPanel getJPanel4() {
1137
                if (jPanel4 == null) {
1138
                        jPanel4 = new javax.swing.JPanel();
1139

    
1140
                        java.awt.FlowLayout layFlowLayout2 = new java.awt.FlowLayout();
1141
                        layFlowLayout2.setHgap(30);
1142
                        jPanel4.setLayout(layFlowLayout2);
1143
                        jPanel4.add(getBtnImportar(), null);
1144
                        jPanel4.add(getBtnExportar(), null);
1145
                        jPanel4.add(getBtnEditar(), null);
1146
                        jPanel4.setPreferredSize(new java.awt.Dimension(360, 30));
1147
                }
1148

    
1149
                return jPanel4;
1150
        }
1151
}