Statistics
| Revision:

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

History | View | Annotate | Download (29.7 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

    
115
        /** Proyecto representado en la vista */
116
        private Project p;
117

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

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

    
134
                initialize();
135

    
136
                projectExtension = project;
137

    
138
                refreshControls();
139
        }
140

    
141
        /**
142
         * Asigna el proyecto a la ventana
143
         *
144
         * @param p Proyecto con el que se operar? a trav?s de este di?logo
145
         */
146
        public void setProject(Project p) {
147
                this.p = p;
148
                p.addPropertyChangeListener(this);
149
                refreshControls();
150
        }
151

    
152
        /**
153
         * Activa los botones de la botonera del medio o los desactiva en funci?n
154
         * de que est? seleccionado o no un elemento de proyecto en la lista del
155
         * medio
156
         */
157
        private void activarBotones() {
158
                if (lstDocs.getSelectedIndex() != -1) {
159
                        btnAbrir.setEnabled(true);
160
                        btnBorrar.setEnabled(true);
161
                        btnRenombrar.setEnabled(true);
162
                        btnPropiedades.setEnabled(true);
163
                } else {
164
                        btnAbrir.setEnabled(false);
165
                        btnBorrar.setEnabled(false);
166
                        btnRenombrar.setEnabled(false);
167
                        btnPropiedades.setEnabled(false);
168
                }
169
        }
170

    
171
        /**
172
         * Refresca la lista de elementos de proyecto con vistas, mapas o tablas,
173
         * seg?n la opci?n activada
174
         */
175
        private void refreshList() {
176
                if (p != null) {
177
                        DefaultListModel model;
178

    
179
                        if (btnMapas.isSelected()) {
180
                                model = new DefaultListModel(p.getMaps());
181

    
182
                                //                                getBtnNuevo().setEnabled(true);
183
                        } else if (btnTablas.isSelected()) {
184
                                model = new DefaultListModel(p.getTables());
185

    
186
                                //                getBtnNuevo().setEnabled(false);
187
                        } else {
188
                                model = new DefaultListModel(p.getViews());
189

    
190
                                //                                getBtnNuevo().setEnabled(true);
191
                        }
192

    
193
                        lstDocs.setModel(model);
194

    
195
                        activarBotones();
196
                }
197
        }
198

    
199
        /**
200
         * Refresca las etiquetas con la informaci?n del proyecto
201
         */
202
        private void refreshProperties() {
203
                if (p != null) {
204
                        String aux;
205

    
206
                        lblNombreSesion.setText(p.getName());
207

    
208
                        String path = p.getPath();
209

    
210
                        if (path != null) {
211
                                File f = new File(path);
212
                                lblGuardado.setText(f.toString());
213
                        } else {
214
                                lblGuardado.setText("");
215
                        }
216

    
217
                        lblFecha.setText(p.getCreationDate());
218
                }
219
        }
220

    
221
        /**
222
         * Refresca todo el di?logo
223
         */
224
        public void refreshControls() {
225
                refreshList();
226
                refreshProperties();
227
        }
228

    
229
        /**
230
         * This method initializes this
231
         */
232
        private void initialize() {
233
                setLayout(new java.awt.FlowLayout());
234
                add(getJPanel(), null);
235
                add(getJPanel1(), null);
236
                add(getJPanel3(), null);
237

    
238
                this.setSize(400, 450);
239
                this.setPreferredSize(new java.awt.Dimension(400, 430));
240
                grupo.add(btnVistas);
241
                grupo.add(btnTablas);
242
                grupo.add(btnMapas);
243

    
244
                btnVistas.setSelected(true);
245
        }
246
        private String ask(String title, String content){
247
                JOptionPane pane = new JOptionPane();
248
                pane.setMessage(content);
249
                pane.setMessageType(JOptionPane.QUESTION_MESSAGE);
250
                pane.setWantsInput(true);
251
                pane.setInitialSelectionValue("");
252

    
253
                JDialog dlg = pane.createDialog((Component) PluginServices.getMainFrame(),
254
                                title);
255
                dlg.setModal(true);
256
                dlg.show();
257

    
258
                return pane.getInputValue().toString().trim();
259
        }
260

    
261
        /**
262
         * Crea un nuevo project element
263
         *
264
         * @throws Exception DOCUMENT ME!
265
         */
266
        private void nuevo() throws Exception {
267
                DateFormat df = DateFormat.getDateInstance();
268

    
269
                if (btnMapas.isSelected()) {
270
                        ProjectMap map = ProjectFactory.createMap(PluginServices.getText(
271
                                                this, "untitled"));
272
                        map.setModel(new Layout());
273
                        map.getModel().setProjectMap(map);
274
                        p.addMap(map);
275
                } else if (btnTablas.isSelected()) {
276
                        try {
277
                                FOpenDialog fopen = new FOpenDialog();
278
                                FileOpenDialog fod = new FileOpenDialog(new Class[] {
279
                                                        FileDriver.class}, false);
280
                                DataBaseOpenDialog dbod = new DataBaseOpenDialog();
281
                                dbod.setClasses(new Class[] { DBDriver.class });
282
                                fopen.addTab("Fichero", fod);
283
                                fopen.addTab("Base de datos", dbod);
284
                                PluginServices.getMDIManager().addView(fopen);
285

    
286
                                if (fopen.isAccepted()) {
287
                                        JPanel panel = fopen.getSelectedTab();
288
                                        ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
289

    
290
                                        if (panel instanceof FileOpenDialog) {
291
                                                File[] files = fod.getFiles();
292
                                                String[] driverNames = fod.getDriverNames();
293

    
294
                                                for (int i = 0; i < files.length; i++) {
295
                                                        String name = files[i].getName();
296

    
297
                                                        LayerFactory.getDataSourceFactory()
298
                                                                                .addFileDataSource(driverNames[i],
299
                                                                name, files[i].getAbsolutePath());
300

    
301
                                                        DataSource dataSource = LayerFactory.getDataSourceFactory()
302
                                                                                                                                .createRandomDataSource(name, DataSourceFactory.AUTOMATIC_OPENING);
303
                                                        SelectableDataSource sds = new SelectableDataSource(dataSource);
304
                                                        ProjectTable projectTable = ProjectFactory.createTable(name,
305
                                                                        sds);
306
                                                        ext.getProject().addTable(projectTable);
307

    
308
                                                        Table t = new Table();
309
                                                        t.setModel(projectTable);
310
                                                        PluginServices.getMDIManager().addView(t);
311
                                                }
312
                                        } else if (panel instanceof DataBaseOpenDialog) {
313
                                                String driverName = dbod.getDriverName();
314
                                                int port = -1;
315

    
316
                                                try {
317
                                                        port = Integer.parseInt(dbod.getPort());
318
                                                } catch (NumberFormatException e) {
319
                                                }
320

    
321
                                                String name = dbod.getHost() + "/" +
322
                                                        dbod.getDataBase();
323

    
324
                                                if (port != -1) {
325
                                                        name = dbod.getHost() + ":" + port + "/" +
326
                                                                dbod.getDataBase();
327
                                                }
328
                                                
329
                                                String user = dbod.getUser().trim();
330
                                                String password = dbod.getPassword();
331

    
332
                                                if (user.equals("")) {
333
                                                        user = null;
334
                                                        password = null;
335
                                                }
336

    
337
                                                LayerFactory.getDataSourceFactory().addDBDataSourceByTable(name,
338
                                                        dbod.getHost(), port, user, password,
339
                                                        dbod.getDataBase(), dbod.getTable(), driverName);
340

    
341
                                                DataSource dataSource = LayerFactory.getDataSourceFactory()
342
                                                                                                                        .createRandomDataSource(name, DataSourceFactory.AUTOMATIC_OPENING);
343
                                                SelectableDataSource sds = new SelectableDataSource(dataSource);
344

    
345
                                                ProjectTable projectTable = ProjectFactory.createTable(name,
346
                                                                sds);
347
                                                ext.getProject().addTable(projectTable);
348

    
349
                                                Table t = new Table();
350
                                                t.setModel(projectTable);
351
                                                PluginServices.getMDIManager().addView(t);
352
                                        }
353
                                }
354
                        } catch (DriverLoadException e) {
355
                                NotificationManager.addError("Error al cargar los drivers", e);
356
                        }
357
                } else {
358
                        ProjectView vista = ProjectFactory.createView(PluginServices.getText(
359
                                                this, "untitled"));
360
                        p.addView(vista);
361
                }
362
        }
363

    
364
        /**
365
         * Abre la ventana de un nuevo project element
366
         */
367
        private void abrir() {
368
                if (btnMapas.isSelected()) {
369
                        int index = lstDocs.getSelectedIndex();
370

    
371
                        if (index == -1) {
372
                                return;
373
                        }
374
            ProjectMap projectMap = (ProjectMap) p.getMaps().get(index); 
375
                        Layout l = projectMap.getModel();
376
            // System.out.println("l.getName " + l.getName() + " projectMap.getName " + projectMap.getName());
377
            projectMap.setName(l.getName());
378
            l.setProjectMap(projectMap);
379
                        l.fullRect();
380
            l.getViewInfo().setTitle(l.getName());
381
                        PluginServices.getMDIManager().addView(l);
382
                } else if (btnTablas.isSelected()) {
383
                        com.iver.cit.gvsig.gui.Table vista = new com.iver.cit.gvsig.gui.Table();
384
                        int index = lstDocs.getSelectedIndex();
385

    
386
                        if (index == -1) {
387
                                return;
388
                        }
389

    
390
                        vista.setModel((ProjectTable) p.getTables().get(index));
391
                        PluginServices.getMDIManager().addView(vista);
392
                } else {
393
                        com.iver.cit.gvsig.gui.View vista = new com.iver.cit.gvsig.gui.View();
394
                        int index = lstDocs.getSelectedIndex();
395

    
396
                        if (index == -1) {
397
                                return;
398
                        }
399

    
400
                        vista.setModel((ProjectView) p.getViews().get(index));
401
                        PluginServices.getMDIManager().addView(vista);
402
                }
403
        }
404

    
405
        /**
406
         * Cambia el nombre de un project element
407
         */
408
        private void renombrar() {
409
                ProjectElement elem = null;
410
                int index = lstDocs.getSelectedIndex();
411
                
412
                if (index == -1) {
413
                        return;
414
                }
415

    
416
                if (btnMapas.isSelected()) {
417
                        elem = (ProjectElement) p.getMaps().get(index);
418
                } else if (btnTablas.isSelected()) {
419
                        elem = (ProjectElement) p.getTables().get(index);
420
                } else {
421
                        elem = (ProjectElement) p.getViews().get(index);
422
                }
423

    
424
                JOptionPane pane = new JOptionPane();
425
                pane.setMessage(PluginServices.getText(this, "introduce_nombre"));
426
                pane.setMessageType(JOptionPane.QUESTION_MESSAGE);
427
                pane.setWantsInput(true);
428
                pane.setInitialSelectionValue(elem.getName());
429
        pane.setInputValue(elem.getName());
430
                JDialog dlg = pane.createDialog((Component) PluginServices.getMainFrame(),
431
                                PluginServices.getText(this, "renombrar"));
432
                dlg.setModal(true);
433
                dlg.show();
434

    
435
                String nuevoNombre = pane.getInputValue().toString().trim();
436

    
437
                if (nuevoNombre.length() == 0) {
438
                        return;
439
                }
440

    
441
                if (nuevoNombre == null) {
442
                        return;
443
                }
444

    
445
                for (int i=0; i<lstDocs.getModel().getSize(); i++){
446
                        if (i==index) continue;
447
                        if (((ProjectElement)lstDocs.getModel().getElementAt(i)).getName().equals(nuevoNombre)){
448
                                JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this, "elemento_ya_existe"));
449
                                return;
450
                        }
451
                                
452
                }
453
                elem.setName(nuevoNombre);
454

    
455
                refreshList();
456
        }
457

    
458
        /**
459
         * Borra un project element
460
         */
461
        private void borrar() {
462
                int res = JOptionPane.showConfirmDialog((Component) PluginServices.getMainFrame(),
463
                                PluginServices.getText(this, "confirmar_borrar"),
464
                                PluginServices.getText(this, "borrar"),
465
                                JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
466

    
467
                if (res == JOptionPane.YES_OPTION) {
468
                        int index = lstDocs.getSelectedIndex();
469

    
470
                        if (btnMapas.isSelected()) {
471
                                PluginServices.getMDIManager().closeSingletonView(p.getMaps()
472
                                                                                                                                   .get(index));
473
                                p.delMap(index);
474
                        } else if (btnTablas.isSelected()) {
475
                                PluginServices.getMDIManager().closeSingletonView(p.getTables()
476
                                                                                                                                   .get(index));
477
                                p.delTable(index);
478
                        } else {
479
                                PluginServices.getMDIManager().closeSingletonView(p.getViews()
480
                                                                                                                                   .get(index));
481
                                p.delView(index);
482
                        }
483

    
484
                        refreshList();
485
                }
486
        }
487

    
488
        /**
489
         * Muestra el di?logo de propiedades de un project element
490
         */
491
        private void propiedades() {
492
                int index = lstDocs.getSelectedIndex();
493

    
494
                if (index == -1) {
495
                        return;
496
                }
497

    
498
                View dlg = null;
499

    
500
                if (btnMapas.isSelected()) {
501
                        dlg = new MapProperties((ProjectMap) p.getMaps().get(index));
502
                } else if (btnTablas.isSelected()) {
503
                        try {
504
                dlg = new TableProperties((ProjectTable) p.getTables().get(index));
505
            } catch (DriverException e) {
506
                NotificationManager.addError(e.getMessage(), e);
507
            }
508
                } else {
509
                        dlg = new ViewProperties((ProjectView) p.getViews().get(index));
510
                }
511

    
512
                PluginServices.getMDIManager().addView(dlg);
513

    
514
                refreshControls();
515
                lstDocs.setSelectedIndex(index);
516
        }
517

    
518
        /**
519
         * This method initializes jPanel
520
         *
521
         * @return javax.swing.JPanel
522
         */
523
        private javax.swing.JPanel getJPanel() {
524
                if (jPanel == null) {
525
                        jPanel = new javax.swing.JPanel();
526

    
527
                        java.awt.FlowLayout layFlowLayout1 = new java.awt.FlowLayout();
528
                        layFlowLayout1.setHgap(15);
529
                        jPanel.setLayout(layFlowLayout1);
530
                        jPanel.add(getBtnVistas(), null);
531
                        jPanel.add(getBtnTablas(), null);
532
                        jPanel.add(getBtnMapas(), null);
533
                        jPanel.setName("tipoDocPanel");
534
                        jPanel.setPreferredSize(new java.awt.Dimension(390, 125));
535
                        jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
536
                                        null, PluginServices.getText(this, "tipos_de_documentos"),
537
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
538
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
539
                }
540

    
541
                return jPanel;
542
        }
543

    
544
        /**
545
         * This method initializes btnVistas
546
         *
547
         * @return javax.swing.JRadioButton
548
         */
549
        private javax.swing.JRadioButton getBtnVistas() {
550
                if (btnVistas == null) {
551
                        btnVistas = new javax.swing.JRadioButton();
552
                        btnVistas.setIcon(new javax.swing.ImageIcon(
553
                                        this.getClass().getClassLoader().getResource("images/Vista.png")));
554
                        btnVistas.setSelectedIcon(new javax.swing.ImageIcon(
555
                                        this.getClass().getClassLoader().getResource("images/Vista_sel.png")));
556
                        btnVistas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
557
                        btnVistas.setText(PluginServices.getText(this, "vistas"));
558
                        btnVistas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
559
                        btnVistas.setName("vistasBtn");
560
                        btnVistas.addChangeListener(new javax.swing.event.ChangeListener() {
561
                                        public void stateChanged(javax.swing.event.ChangeEvent e) {
562
                                                refreshList();
563
                                        }
564
                                });
565
                }
566

    
567
                return btnVistas;
568
        }
569

    
570
        /**
571
         * This method initializes btnTablas
572
         *
573
         * @return javax.swing.JRadioButton
574
         */
575
        private javax.swing.JRadioButton getBtnTablas() {
576
                if (btnTablas == null) {
577
                        btnTablas = new javax.swing.JRadioButton();
578
                        btnTablas.setIcon(new javax.swing.ImageIcon(
579
                                        this.getClass().getClassLoader().getResource("images/tablas.png")));
580
                        btnTablas.setSelectedIcon(new javax.swing.ImageIcon(
581
                                        this.getClass().getClassLoader().getResource("images/tablas_sel.png")));
582
                        btnTablas.setText(PluginServices.getText(this, "tablas"));
583
                        btnTablas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
584
                        btnTablas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
585
                        btnTablas.setName("tablasBtn");
586
                        btnTablas.addChangeListener(new javax.swing.event.ChangeListener() {
587
                                        public void stateChanged(javax.swing.event.ChangeEvent e) {
588
                                                refreshList();
589
                                        }
590
                                });
591
                }
592

    
593
                return btnTablas;
594
        }
595

    
596
        /**
597
         * This method initializes btnMapas
598
         *
599
         * @return javax.swing.JRadioButton
600
         */
601
        private javax.swing.JRadioButton getBtnMapas() {
602
                if (btnMapas == null) {
603
                        btnMapas = new javax.swing.JRadioButton();
604
                        btnMapas.setIcon(new javax.swing.ImageIcon(
605
                                        this.getClass().getClassLoader().getResource("images/mapas.png")));
606
                        btnMapas.setSelectedIcon(new javax.swing.ImageIcon(
607
                                        this.getClass().getClassLoader().getResource("images/mapas_sel.png")));
608
                        btnMapas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
609
                        btnMapas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
610
                        btnMapas.setText(PluginServices.getText(this, "mapas"));
611
                        btnMapas.addChangeListener(new javax.swing.event.ChangeListener() {
612
                                        public void stateChanged(javax.swing.event.ChangeEvent e) {
613
                                                refreshList();
614
                                        }
615
                                });
616
                }
617

    
618
                return btnMapas;
619
        }
620

    
621
        /**
622
         * This method initializes jPanel1
623
         *
624
         * @return javax.swing.JPanel
625
         */
626
        private javax.swing.JPanel getJPanel1() {
627
                if (jPanel1 == null) {
628
                        jPanel1 = new javax.swing.JPanel();
629

    
630
                        java.awt.BorderLayout layBorderLayout2 = new java.awt.BorderLayout();
631
                        layBorderLayout2.setVgap(30);
632
                        jPanel1.setLayout(layBorderLayout2);
633
                        jPanel1.add(getJPanel2(), java.awt.BorderLayout.EAST);
634
                        jPanel1.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
635
                        jPanel1.setPreferredSize(new java.awt.Dimension(390, 170));
636
                        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
637
                                        null,
638
                                        PluginServices.getText(this, "documentos_existentes"),
639
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
640
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
641
                }
642

    
643
                return jPanel1;
644
        }
645

    
646
        /**
647
         * This method initializes lstDocs
648
         *
649
         * @return javax.swing.JList
650
         */
651
        private javax.swing.JList getLstDocs() {
652
                if (lstDocs == null) {
653
                        lstDocs = new javax.swing.JList();
654
                        lstDocs.addMouseListener(new java.awt.event.MouseAdapter() {
655
                                        public void mouseClicked(java.awt.event.MouseEvent e) {
656
                                                if (e.getClickCount() == 2) {
657
                                                        abrir();
658
                                                }
659
                                        }
660
                                });
661
                        lstDocs.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
662
                                        public void valueChanged(
663
                                                javax.swing.event.ListSelectionEvent e) {
664
                                                activarBotones();
665
                                        }
666
                                });
667
                }
668

    
669
                return lstDocs;
670
        }
671

    
672
        /**
673
         * This method initializes jPanel2
674
         *
675
         * @return javax.swing.JPanel
676
         */
677
        private javax.swing.JPanel getJPanel2() {
678
                if (jPanel2 == null) {
679
                        jPanel2 = new javax.swing.JPanel();
680

    
681
                        java.awt.FlowLayout layFlowLayout11 = new java.awt.FlowLayout();
682
                        layFlowLayout11.setVgap(5);
683
                        jPanel2.setLayout(layFlowLayout11);
684
                        jPanel2.add(getBtnNuevo(), null);
685
                        jPanel2.add(getBtnAbrir(), null);
686
                        jPanel2.add(getBtnRenombrar(), null);
687
                        jPanel2.add(getBtnBorrar(), null);
688
                        jPanel2.add(getBtnPropiedades(), null);
689
                        jPanel2.setPreferredSize(new java.awt.Dimension(100, 50));
690
                }
691

    
692
                return jPanel2;
693
        }
694

    
695
        /**
696
         * This method initializes btnNuevo
697
         *
698
         * @return javax.swing.JButton
699
         */
700
        private javax.swing.JButton getBtnNuevo() {
701
                if (btnNuevo == null) {
702
                        btnNuevo = new javax.swing.JButton();
703
                        btnNuevo.setPreferredSize(new java.awt.Dimension(80, 23));
704
                        btnNuevo.setName("btnNuevo");
705
                        btnNuevo.setText(PluginServices.getText(this, "nuevo"));
706
                        btnNuevo.setMargin(new java.awt.Insets(2, 2, 2, 2));
707
                        btnNuevo.addActionListener(new java.awt.event.ActionListener() {
708
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
709
                                                try {
710
                                                        nuevo();
711
                                                } catch (Exception e1) {
712
                                                        NotificationManager.addError(e1.getLocalizedMessage(),
713
                                                                e1);
714
                                                }
715
                                        }
716
                                });
717
                }
718

    
719
                return btnNuevo;
720
        }
721

    
722
        /**
723
         * This method initializes btnPropiedades
724
         *
725
         * @return javax.swing.JButton
726
         */
727
        private javax.swing.JButton getBtnPropiedades() {
728
                if (btnPropiedades == null) {
729
                        btnPropiedades = new javax.swing.JButton();
730
                        btnPropiedades.setPreferredSize(new java.awt.Dimension(80, 23));
731
                        btnPropiedades.setText(PluginServices.getText(this, "propiedades"));
732
                        btnPropiedades.setName("btnPropiedades");
733
                        btnPropiedades.setEnabled(false);
734
                        btnPropiedades.setMargin(new java.awt.Insets(2, 2, 2, 2));
735
                        btnPropiedades.addActionListener(new java.awt.event.ActionListener() {
736
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
737
                                                propiedades();
738
                                        }
739
                                });
740
                }
741

    
742
                return btnPropiedades;
743
        }
744

    
745
        /**
746
         * This method initializes btnAbrir
747
         *
748
         * @return javax.swing.JButton
749
         */
750
        private javax.swing.JButton getBtnAbrir() {
751
                if (btnAbrir == null) {
752
                        btnAbrir = new javax.swing.JButton();
753
                        btnAbrir.setPreferredSize(new java.awt.Dimension(80, 23));
754
                        btnAbrir.setName("btnAbrir");
755
                        btnAbrir.setText(PluginServices.getText(this, "abrir"));
756
                        btnAbrir.setEnabled(false);
757
                        btnAbrir.setMargin(new java.awt.Insets(2, 2, 2, 2));
758
                        btnAbrir.addActionListener(new java.awt.event.ActionListener() {
759
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
760
                                                abrir();
761
                                        }
762
                                });
763
                }
764

    
765
                return btnAbrir;
766
        }
767

    
768
        /**
769
         * This method initializes btnBorrar
770
         *
771
         * @return javax.swing.JButton
772
         */
773
        private javax.swing.JButton getBtnBorrar() {
774
                if (btnBorrar == null) {
775
                        btnBorrar = new javax.swing.JButton();
776
                        btnBorrar.setPreferredSize(new java.awt.Dimension(80, 23));
777
                        btnBorrar.setText(PluginServices.getText(this, "borrar"));
778
                        btnBorrar.setName("btnBorrar");
779
                        btnBorrar.setEnabled(false);
780
                        btnBorrar.setMargin(new java.awt.Insets(2, 2, 2, 2));
781
                        btnBorrar.addActionListener(new java.awt.event.ActionListener() {
782
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
783
                                                borrar();
784
                                        }
785
                                });
786
                }
787

    
788
                return btnBorrar;
789
        }
790

    
791
        /**
792
         * This method initializes btnRenombrar
793
         *
794
         * @return javax.swing.JButton
795
         */
796
        private javax.swing.JButton getBtnRenombrar() {
797
                if (btnRenombrar == null) {
798
                        btnRenombrar = new javax.swing.JButton();
799
                        btnRenombrar.setPreferredSize(new java.awt.Dimension(80, 23));
800
                        btnRenombrar.setName("btnRenombrar");
801
                        btnRenombrar.setText(PluginServices.getText(this, "renombrar"));
802
                        btnRenombrar.setEnabled(false);
803
                        btnRenombrar.setMargin(new java.awt.Insets(2, 2, 2, 2));
804
                        btnRenombrar.addActionListener(new java.awt.event.ActionListener() {
805
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
806
                                                renombrar();
807
                                        }
808
                                });
809
                }
810

    
811
                return btnRenombrar;
812
        }
813

    
814
        /**
815
         * This method initializes jPanel3
816
         *
817
         * @return javax.swing.JPanel
818
         */
819
        private javax.swing.JPanel getJPanel3() {
820
                if (jPanel3 == null) {
821
                        jPanel3 = new javax.swing.JPanel();
822

    
823
                        java.awt.FlowLayout layFlowLayout3 = new java.awt.FlowLayout();
824
                        layFlowLayout3.setHgap(5);
825
                        layFlowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
826
                        jPanel3.setLayout(layFlowLayout3);
827
                        jPanel3.add(getJLabel(), null);
828
                        jPanel3.add(getLblNombreSesion(), null);
829
                        jPanel3.add(getJLabel1(), null);
830
                        jPanel3.add(getLblGuardado(), null);
831
                        jPanel3.add(getJLabel2(), null);
832
                        jPanel3.add(getLblFecha(), null);
833
                        jPanel3.add(getJPanel4(), null);
834
                        jPanel3.setPreferredSize(new java.awt.Dimension(390, 125));
835
                        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(
836
                                        null, PluginServices.getText(this, "propiedades_sesion"),
837
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
838
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
839
                }
840

    
841
                return jPanel3;
842
        }
843

    
844
        /**
845
         * This method initializes jLabel
846
         *
847
         * @return javax.swing.JLabel
848
         */
849
        private javax.swing.JLabel getJLabel() {
850
                if (jLabel == null) {
851
                        jLabel = new javax.swing.JLabel();
852
                        jLabel.setText(PluginServices.getText(this, "nombre_sesion") + ":");
853
                        jLabel.setPreferredSize(new java.awt.Dimension(150, 16));
854
                }
855

    
856
                return jLabel;
857
        }
858

    
859
        /**
860
         * This method initializes lblNombreSesion
861
         *
862
         * @return javax.swing.JLabel
863
         */
864
        private javax.swing.JLabel getLblNombreSesion() {
865
                if (lblNombreSesion == null) {
866
                        lblNombreSesion = new javax.swing.JLabel();
867
                        lblNombreSesion.setText("");
868
                        lblNombreSesion.setName("lblNombreSesion");
869
                        lblNombreSesion.setPreferredSize(new java.awt.Dimension(200, 16));
870
                        lblNombreSesion.setAutoscrolls(true);
871
                }
872

    
873
                return lblNombreSesion;
874
        }
875

    
876
        /**
877
         * This method initializes jLabel1
878
         *
879
         * @return javax.swing.JLabel
880
         */
881
        private javax.swing.JLabel getJLabel1() {
882
                if (jLabel1 == null) {
883
                        jLabel1 = new javax.swing.JLabel();
884
                        jLabel1.setText(PluginServices.getText(this, "guardado") + ":");
885
                        jLabel1.setPreferredSize(new java.awt.Dimension(150, 16));
886
                }
887

    
888
                return jLabel1;
889
        }
890

    
891
        /**
892
         * This method initializes lblGuardado
893
         *
894
         * @return javax.swing.JLabel
895
         */
896
        private javax.swing.JLabel getLblGuardado() {
897
                if (lblGuardado == null) {
898
                        lblGuardado = new javax.swing.JLabel();
899
                        lblGuardado.setText("");
900
                        lblGuardado.setPreferredSize(new java.awt.Dimension(200, 16));
901
                        lblGuardado.setAutoscrolls(true);
902
                }
903

    
904
                return lblGuardado;
905
        }
906

    
907
        /**
908
         * This method initializes jLabel2
909
         *
910
         * @return javax.swing.JLabel
911
         */
912
        private javax.swing.JLabel getJLabel2() {
913
                if (jLabel2 == null) {
914
                        jLabel2 = new javax.swing.JLabel();
915
                        jLabel2.setText(PluginServices.getText(this, "creation_date") +
916
                                ":");
917
                        jLabel2.setPreferredSize(new java.awt.Dimension(150, 16));
918
                }
919

    
920
                return jLabel2;
921
        }
922

    
923
        /**
924
         * This method initializes lblFecha
925
         *
926
         * @return javax.swing.JLabel
927
         */
928
        private javax.swing.JLabel getLblFecha() {
929
                if (lblFecha == null) {
930
                        lblFecha = new javax.swing.JLabel();
931
                        lblFecha.setText("");
932
                        lblFecha.setPreferredSize(new java.awt.Dimension(200, 16));
933
                        lblFecha.setAutoscrolls(true);
934
                }
935

    
936
                return lblFecha;
937
        }
938

    
939
        /**
940
         * This method initializes btnImportar
941
         *
942
         * @return javax.swing.JButton
943
         */
944
        private javax.swing.JButton getBtnImportar() {
945
                if (btnImportar == null) {
946
                        btnImportar = new javax.swing.JButton();
947
                        btnImportar.setPreferredSize(new java.awt.Dimension(80, 23));
948
                        btnImportar.setText(PluginServices.getText(this, "importar"));
949
                        btnImportar.setMargin(new java.awt.Insets(2, 2, 2, 2));
950
                }
951

    
952
                return btnImportar;
953
        }
954

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

    
968
                return btnExportar;
969
        }
970

    
971
        /**
972
         * This method initializes btnEditar
973
         *
974
         * @return javax.swing.JButton
975
         */
976
        private javax.swing.JButton getBtnEditar() {
977
                if (btnEditar == null) {
978
                        btnEditar = new javax.swing.JButton();
979
                        btnEditar.setPreferredSize(new java.awt.Dimension(80, 23));
980
                        btnEditar.setText(PluginServices.getText(this, "propiedades"));
981

    
982
                        btnEditar.setMargin(new java.awt.Insets(2, 2, 2, 2));
983

    
984
                        final JPanel f = this;
985
                        btnEditar.addActionListener(new java.awt.event.ActionListener() {
986
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
987
                                                ProjectProperties dlg = new ProjectProperties(p);
988
                                                PluginServices.getMDIManager().addView(dlg);
989
                                                refreshProperties();
990
                                        }
991
                                });
992
                }
993

    
994
                return btnEditar;
995
        }
996

    
997
        /**
998
         * This method initializes jScrollPane
999
         *
1000
         * @return javax.swing.JScrollPane
1001
         */
1002
        private javax.swing.JScrollPane getJScrollPane() {
1003
                if (jScrollPane == null) {
1004
                        jScrollPane = new javax.swing.JScrollPane();
1005
                        jScrollPane.setViewportView(getLstDocs());
1006
                        jScrollPane.setPreferredSize(new java.awt.Dimension(200, 100));
1007
                        jScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
1008
                }
1009

    
1010
                return jScrollPane;
1011
        }
1012

    
1013
        /**
1014
         * @see com.iver.mdiApp.ui.MDIManager.SingletonView#getViewModel()
1015
         */
1016
        public Object getViewModel() {
1017
                return p;
1018
        }
1019

    
1020
        /**
1021
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
1022
         */
1023
        public ViewInfo getViewInfo() {
1024
                ViewInfo m_viewinfo = new ViewInfo();
1025
                m_viewinfo.setWidth(400);
1026
                m_viewinfo.setHeight(430);
1027
                m_viewinfo.setTitle(PluginServices.getText(this, "titulo"));
1028

    
1029
                return m_viewinfo;
1030
        }
1031

    
1032
        /**
1033
         * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
1034
         */
1035
        public void propertyChange(PropertyChangeEvent evt) {
1036
                refreshControls();
1037
        }
1038

    
1039
        /**
1040
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
1041
         */
1042
        public void viewActivated() {
1043
        }
1044

    
1045
        /**
1046
         * This method initializes jPanel4
1047
         *
1048
         * @return javax.swing.JPanel
1049
         */
1050
        private javax.swing.JPanel getJPanel4() {
1051
                if (jPanel4 == null) {
1052
                        jPanel4 = new javax.swing.JPanel();
1053

    
1054
                        java.awt.FlowLayout layFlowLayout2 = new java.awt.FlowLayout();
1055
                        layFlowLayout2.setHgap(30);
1056
                        jPanel4.setLayout(layFlowLayout2);
1057
                        jPanel4.add(getBtnImportar(), null);
1058
                        jPanel4.add(getBtnExportar(), null);
1059
                        jPanel4.add(getBtnEditar(), null);
1060
                        jPanel4.setPreferredSize(new java.awt.Dimension(360, 30));
1061
                }
1062

    
1063
                return jPanel4;
1064
        }
1065
}