Statistics
| Revision:

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

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

    
80

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

    
113
    /** Proyecto representado en la vista */
114
    private Project p;
115

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

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

    
132
        initialize();
133

    
134
        projectExtension = project;
135

    
136
        refreshControls();
137
    }
138

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

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

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

    
177
            if (btnMapas.isSelected()) {
178
                model = new DefaultListModel(p.getMaps());
179

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

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

    
188
                //                                getBtnNuevo().setEnabled(true);
189
            }
190

    
191
            lstDocs.setModel(model);
192

    
193
            activarBotones();
194
        }
195
    }
196

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

    
204
            lblNombreSesion.setText(p.getName());
205

    
206
            String path = p.getPath();
207

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

    
215
            lblFecha.setText(p.getCreationDate());
216
        }
217
    }
218

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

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

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

    
242
        btnVistas.setSelected(true);
243
    }
244

    
245
    /**
246
     * Crea un nuevo project element
247
     *
248
     * @throws Exception DOCUMENT ME!
249
     */
250
    private void nuevo() throws Exception {
251
        DateFormat df = DateFormat.getDateInstance();
252

    
253
        if (btnMapas.isSelected()) {
254
            ProjectMap map = ProjectFactory.createMap(PluginServices.getText(
255
                        this, "untitled"));
256
            map.setModel(new Layout());
257
            map.getModel().setProjectMap(map);
258
            p.addMap(map);
259
        } else if (btnTablas.isSelected()) {
260
            try {
261
                FOpenDialog fopen = new FOpenDialog();
262
                FileOpenDialog fod = new FileOpenDialog(new Class[]{FileDriver.class, GeorreferencedRasterDriver.class});
263
                DataBaseOpenDialog dbod = new DataBaseOpenDialog();
264
                dbod.setClasses(new Class[] { DBDriver.class });
265
                fopen.addTab("Fichero", fod);
266
                fopen.addTab("Base de datos", dbod);
267
                PluginServices.getMDIManager().addView(fopen);
268

    
269
                if (fopen.isAccepted()) {
270
                    JPanel panel = fopen.getSelectedTab();
271

    
272
                    if (panel instanceof FileOpenDialog) {
273
                            File[] files = fod.getFiles();
274
                            String[] driverNames = fod.getDriverNames();
275
                            for (int i = 0; i < files.length; i++) {
276
                                String name = files[i].getName();
277
                            DataSourceFactory.addFileDataSource(driverNames[i], name, files[i].getAbsolutePath(), files[i].getAbsolutePath());
278

    
279
                            DataSource dataSource = DataSourceFactory.createRandomDataSource(name);
280
                            SelectableDataSource sds = new SelectableDataSource(dataSource);
281
                            ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
282
                            ProjectTable projectTable = ProjectFactory.createTable(null, sds);
283
                            ext.getProject().addTable(projectTable);
284

    
285
                            Table t = new Table();
286
                            t.setModel(projectTable);
287
                            PluginServices.getMDIManager().addView(t);
288
                                                }
289
                    } else if (panel instanceof DataBaseOpenDialog) {
290
                        String driverName = dbod.getDriverName();
291
                        int port = -1;
292

    
293
                        try {
294
                            port = Integer.parseInt(dbod.getPort());
295
                        } catch (NumberFormatException e) {
296
                        }
297

    
298
                        String name = dbod.getHost() + "/" +
299
                            dbod.getDataBase();
300

    
301
                        if (port != -1) {
302
                            name = dbod.getHost() + ":" + port + "/" +
303
                                dbod.getDataBase();
304
                        }
305

    
306
                        String user = dbod.getUser().trim();
307
                        String password = dbod.getPassword();
308

    
309
                        if (user.equals("")) {
310
                            user = null;
311
                            password = null;
312
                        }
313

    
314
                        DataSourceFactory.addDBDataSource(name, dbod.getHost(),
315
                            port, user, password, dbod.getDataBase(),
316
                            dbod.getTable(), driverName);
317

    
318
                        DataSource dataSource = DataSourceFactory.createRandomDataSource(name);
319
                        SelectableDataSource sds = new SelectableDataSource(dataSource);
320

    
321
                        ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
322
                        ProjectTable projectTable = ProjectFactory.createTable(null, sds);
323
                        ext.getProject().addTable(projectTable);
324

    
325
                        Table t = new Table();
326
                        t.setModel(projectTable);
327
                        PluginServices.getMDIManager().addView(t);
328
                    }
329
                }
330
            } catch (DriverLoadException e) {
331
                    NotificationManager.addError("Error al cargar los drivers", e);
332
            }
333
        } else {
334
            ProjectView vista = ProjectFactory.createView(PluginServices.getText(
335
                        this, "untitled"));
336
            p.addView(vista);
337
        }
338
    }
339

    
340
    /**
341
     * Abre la ventana de un nuevo project element
342
     */
343
    private void abrir() {
344
        if (btnMapas.isSelected()) {
345
            int index = lstDocs.getSelectedIndex();
346

    
347
            if (index == -1) {
348
                return;
349
            }
350

    
351
            Layout l = (Layout)((ProjectMap) p.getMaps().get(index)).getModel();
352
            l.fullRect();
353
            PluginServices.getMDIManager().addView(l);
354
        } else if (btnTablas.isSelected()) {
355
            com.iver.cit.gvsig.gui.Table vista = new com.iver.cit.gvsig.gui.Table();
356
            int index = lstDocs.getSelectedIndex();
357

    
358
            if (index == -1) {
359
                return;
360
            }
361

    
362
            vista.setModel((ProjectTable) p.getTables().get(index));
363
            PluginServices.getMDIManager().addView(vista);
364
        } else {
365
            com.iver.cit.gvsig.gui.View vista = new com.iver.cit.gvsig.gui.View();
366
            int index = lstDocs.getSelectedIndex();
367

    
368
            if (index == -1) {
369
                return;
370
            }
371

    
372
            vista.setModel((ProjectView) p.getViews().get(index));
373
            PluginServices.getMDIManager().addView(vista);
374
            
375
        }
376
    }
377

    
378
    /**
379
     * Cambia el nombre de un project element
380
     */
381
    private void renombrar() {
382
        ProjectElement elem = null;
383
        int index = lstDocs.getSelectedIndex();
384

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

    
389
        if (btnMapas.isSelected()) {
390
            elem = (ProjectElement) p.getMaps().get(index);
391
        } else if (btnTablas.isSelected()) {
392
            elem = (ProjectElement) p.getTables().get(index);
393
        } else {
394
            elem = (ProjectElement) p.getViews().get(index);
395
        }
396

    
397
        JOptionPane pane = new JOptionPane();
398
        pane.setMessage(PluginServices.getText(this, "introduce_nombre"));
399
        pane.setMessageType(JOptionPane.QUESTION_MESSAGE);
400
        pane.setWantsInput(true);
401
        pane.setInitialSelectionValue(elem.getName());
402

    
403
        JDialog dlg = pane.createDialog((Component) PluginServices.getMainFrame(),
404
                        PluginServices.getText(this, "renombrar"));
405
        dlg.setModal(true);
406
        dlg.show();
407

    
408
        String nuevoNombre = pane.getInputValue().toString().trim();
409

    
410
        if (nuevoNombre.length() == 0) {
411
            return;
412
        }
413

    
414
        if (nuevoNombre == null) {
415
            return;
416
        }
417

    
418
        elem.setName(nuevoNombre);
419

    
420
        refreshList();
421
    }
422

    
423
    /**
424
     * Borra un project element
425
     */
426
    private void borrar() {
427
        int res = JOptionPane.showConfirmDialog((Component) PluginServices.getMainFrame(),
428
                        PluginServices.getText(this, "confirmar_borrar"),
429
                        PluginServices.getText(this, "borrar"),
430
                JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
431

    
432
        if (res == JOptionPane.YES_OPTION) {
433
            int index = lstDocs.getSelectedIndex();
434

    
435
            if (btnMapas.isSelected()) {
436
                p.delMap(index);
437
            } else if (btnTablas.isSelected()) {
438
                p.delTable(index);
439
            } else {
440
                p.delView(index);
441
            }
442

    
443
            refreshList();
444
        }
445
    }
446

    
447
    /**
448
     * Muestra el di?logo de propiedades de un project element
449
     */
450
    private void propiedades() {
451
        int index = lstDocs.getSelectedIndex();
452

    
453
        if (index == -1) {
454
            return;
455
        }
456

    
457
        View dlg;
458

    
459
        if (btnMapas.isSelected()) {
460
            dlg = new MapProperties((ProjectMap) p.getMaps().get(index));
461
        } else if (btnTablas.isSelected()) {
462
            dlg = new TableProperties((ProjectTable) p.getTables().get(index));
463
        } else {
464
            dlg = new ViewProperties((ProjectView) p.getViews().get(index));
465
        }
466

    
467
        PluginServices.getMDIManager().addView(dlg);
468

    
469
        refreshControls();
470
        lstDocs.setSelectedIndex(index);
471
    }
472

    
473
    /**
474
     * This method initializes jPanel
475
     *
476
     * @return javax.swing.JPanel
477
     */
478
    private javax.swing.JPanel getJPanel() {
479
        if (jPanel == null) {
480
            jPanel = new javax.swing.JPanel();
481

    
482
            java.awt.FlowLayout layFlowLayout1 = new java.awt.FlowLayout();
483
            layFlowLayout1.setHgap(15);
484
            jPanel.setLayout(layFlowLayout1);
485
            jPanel.add(getBtnVistas(), null);
486
            jPanel.add(getBtnTablas(), null);
487
            jPanel.add(getBtnMapas(), null);
488
            jPanel.setName("tipoDocPanel");
489
            jPanel.setPreferredSize(new java.awt.Dimension(390, 125));
490
            jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
491
                    null, PluginServices.getText(this, "tipos_de_documentos"),
492
                    javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
493
                    javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
494
        }
495

    
496
        return jPanel;
497
    }
498

    
499
    /**
500
     * This method initializes btnVistas
501
     *
502
     * @return javax.swing.JRadioButton
503
     */
504
    private javax.swing.JRadioButton getBtnVistas() {
505
        if (btnVistas == null) {
506
            btnVistas = new javax.swing.JRadioButton();
507
            btnVistas.setIcon(new javax.swing.ImageIcon(
508
                    this.getClass().getClassLoader().getResource("images/Vista.png")));
509
            btnVistas.setSelectedIcon(new javax.swing.ImageIcon(
510
                    this.getClass().getClassLoader().getResource("images/Vista_sel.png")));
511
            btnVistas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
512
            btnVistas.setText(PluginServices.getText(this, "vistas"));
513
            btnVistas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
514
            btnVistas.setName("vistasBtn");
515
            btnVistas.addChangeListener(new javax.swing.event.ChangeListener() {
516
                    public void stateChanged(javax.swing.event.ChangeEvent e) {
517
                        refreshList();
518
                    }
519
                });
520
        }
521

    
522
        return btnVistas;
523
    }
524

    
525
    /**
526
     * This method initializes btnTablas
527
     *
528
     * @return javax.swing.JRadioButton
529
     */
530
    private javax.swing.JRadioButton getBtnTablas() {
531
        if (btnTablas == null) {
532
            btnTablas = new javax.swing.JRadioButton();
533
            btnTablas.setIcon(new javax.swing.ImageIcon(
534
                    this.getClass().getClassLoader().getResource("images/tablas.png")));
535
            btnTablas.setSelectedIcon(new javax.swing.ImageIcon(
536
                    this.getClass().getClassLoader().getResource("images/tablas_sel.png")));
537
            btnTablas.setText(PluginServices.getText(this, "tablas"));
538
            btnTablas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
539
            btnTablas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
540
            btnTablas.setName("tablasBtn");
541
            btnTablas.addChangeListener(new javax.swing.event.ChangeListener() {
542
                    public void stateChanged(javax.swing.event.ChangeEvent e) {
543
                        refreshList();
544
                    }
545
                });
546
        }
547

    
548
        return btnTablas;
549
    }
550

    
551
    /**
552
     * This method initializes btnMapas
553
     *
554
     * @return javax.swing.JRadioButton
555
     */
556
    private javax.swing.JRadioButton getBtnMapas() {
557
        if (btnMapas == null) {
558
            btnMapas = new javax.swing.JRadioButton();
559
            btnMapas.setIcon(new javax.swing.ImageIcon(
560
                    this.getClass().getClassLoader().getResource("images/mapas.png")));
561
            btnMapas.setSelectedIcon(new javax.swing.ImageIcon(
562
                    this.getClass().getClassLoader().getResource("images/mapas_sel.png")));
563
            btnMapas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
564
            btnMapas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
565
            btnMapas.setText(PluginServices.getText(this, "mapas"));
566
            btnMapas.addChangeListener(new javax.swing.event.ChangeListener() {
567
                    public void stateChanged(javax.swing.event.ChangeEvent e) {
568
                        refreshList();
569
                    }
570
                });
571
        }
572

    
573
        return btnMapas;
574
    }
575

    
576
    /**
577
     * This method initializes jPanel1
578
     *
579
     * @return javax.swing.JPanel
580
     */
581
    private javax.swing.JPanel getJPanel1() {
582
        if (jPanel1 == null) {
583
            jPanel1 = new javax.swing.JPanel();
584

    
585
            java.awt.BorderLayout layBorderLayout2 = new java.awt.BorderLayout();
586
            layBorderLayout2.setVgap(30);
587
            jPanel1.setLayout(layBorderLayout2);
588
            jPanel1.add(getJPanel2(), java.awt.BorderLayout.EAST);
589
            jPanel1.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
590
            jPanel1.setPreferredSize(new java.awt.Dimension(390, 170));
591
            jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
592
                    null, PluginServices.getText(this, "documentos_existentes"),
593
                    javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
594
                    javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
595
        }
596

    
597
        return jPanel1;
598
    }
599

    
600
    /**
601
     * This method initializes lstDocs
602
     *
603
     * @return javax.swing.JList
604
     */
605
    private javax.swing.JList getLstDocs() {
606
        if (lstDocs == null) {
607
            lstDocs = new javax.swing.JList();
608
            lstDocs.addMouseListener(new java.awt.event.MouseAdapter() {
609
                    public void mouseClicked(java.awt.event.MouseEvent e) {
610
                        if (e.getClickCount() == 2) {
611
                            abrir();
612
                        }
613
                    }
614
                });
615
            lstDocs.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
616
                    public void valueChanged(
617
                        javax.swing.event.ListSelectionEvent e) {
618
                        activarBotones();
619
                    }
620
                });
621
        }
622

    
623
        return lstDocs;
624
    }
625

    
626
    /**
627
     * This method initializes jPanel2
628
     *
629
     * @return javax.swing.JPanel
630
     */
631
    private javax.swing.JPanel getJPanel2() {
632
        if (jPanel2 == null) {
633
            jPanel2 = new javax.swing.JPanel();
634

    
635
            java.awt.FlowLayout layFlowLayout11 = new java.awt.FlowLayout();
636
            layFlowLayout11.setVgap(5);
637
            jPanel2.setLayout(layFlowLayout11);
638
            jPanel2.add(getBtnNuevo(), null);
639
            jPanel2.add(getBtnAbrir(), null);
640
            jPanel2.add(getBtnRenombrar(), null);
641
            jPanel2.add(getBtnBorrar(), null);
642
            jPanel2.add(getBtnPropiedades(), null);
643
            jPanel2.setPreferredSize(new java.awt.Dimension(100, 50));
644
        }
645

    
646
        return jPanel2;
647
    }
648

    
649
    /**
650
     * This method initializes btnNuevo
651
     *
652
     * @return javax.swing.JButton
653
     */
654
    private javax.swing.JButton getBtnNuevo() {
655
        if (btnNuevo == null) {
656
            btnNuevo = new javax.swing.JButton();
657
            btnNuevo.setPreferredSize(new java.awt.Dimension(80, 23));
658
            btnNuevo.setName("btnNuevo");
659
            btnNuevo.setText(PluginServices.getText(this, "nuevo"));
660
            btnNuevo.setMargin(new java.awt.Insets(2, 2, 2, 2));
661
            btnNuevo.addActionListener(new java.awt.event.ActionListener() {
662
                    public void actionPerformed(java.awt.event.ActionEvent e) {
663
                        try {
664
                            nuevo();
665
                        } catch (Exception e1) {
666
                            NotificationManager.addError(e1.getLocalizedMessage(),
667
                                e1);
668
                        }
669
                    }
670
                });
671
        }
672

    
673
        return btnNuevo;
674
    }
675

    
676
    /**
677
     * This method initializes btnPropiedades
678
     *
679
     * @return javax.swing.JButton
680
     */
681
    private javax.swing.JButton getBtnPropiedades() {
682
        if (btnPropiedades == null) {
683
            btnPropiedades = new javax.swing.JButton();
684
            btnPropiedades.setPreferredSize(new java.awt.Dimension(80, 23));
685
            btnPropiedades.setText(PluginServices.getText(this, "propiedades"));
686
            btnPropiedades.setName("btnPropiedades");
687
            btnPropiedades.setEnabled(false);
688
            btnPropiedades.setMargin(new java.awt.Insets(2, 2, 2, 2));
689
            btnPropiedades.addActionListener(new java.awt.event.ActionListener() {
690
                    public void actionPerformed(java.awt.event.ActionEvent e) {
691
                        propiedades();
692
                    }
693
                });
694
        }
695

    
696
        return btnPropiedades;
697
    }
698

    
699
    /**
700
     * This method initializes btnAbrir
701
     *
702
     * @return javax.swing.JButton
703
     */
704
    private javax.swing.JButton getBtnAbrir() {
705
        if (btnAbrir == null) {
706
            btnAbrir = new javax.swing.JButton();
707
            btnAbrir.setPreferredSize(new java.awt.Dimension(80, 23));
708
            btnAbrir.setName("btnAbrir");
709
            btnAbrir.setText(PluginServices.getText(this, "abrir"));
710
            btnAbrir.setEnabled(false);
711
            btnAbrir.setMargin(new java.awt.Insets(2, 2, 2, 2));
712
            btnAbrir.addActionListener(new java.awt.event.ActionListener() {
713
                    public void actionPerformed(java.awt.event.ActionEvent e) {
714
                        abrir();
715
                    }
716
                });
717
        }
718

    
719
        return btnAbrir;
720
    }
721

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

    
742
        return btnBorrar;
743
    }
744

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

    
765
        return btnRenombrar;
766
    }
767

    
768
    /**
769
     * This method initializes jPanel3
770
     *
771
     * @return javax.swing.JPanel
772
     */
773
    private javax.swing.JPanel getJPanel3() {
774
        if (jPanel3 == null) {
775
            jPanel3 = new javax.swing.JPanel();
776

    
777
            java.awt.FlowLayout layFlowLayout3 = new java.awt.FlowLayout();
778
            layFlowLayout3.setHgap(5);
779
            layFlowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
780
            jPanel3.setLayout(layFlowLayout3);
781
            jPanel3.add(getJLabel(), null);
782
            jPanel3.add(getLblNombreSesion(), null);
783
            jPanel3.add(getJLabel1(), null);
784
            jPanel3.add(getLblGuardado(), null);
785
            jPanel3.add(getJLabel2(), null);
786
            jPanel3.add(getLblFecha(), null);
787
            jPanel3.add(getJPanel4(), null);
788
            jPanel3.setPreferredSize(new java.awt.Dimension(390, 125));
789
            jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(
790
                    null, PluginServices.getText(this, "propiedades_sesion"),
791
                    javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
792
                    javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
793
        }
794

    
795
        return jPanel3;
796
    }
797

    
798
    /**
799
     * This method initializes jLabel
800
     *
801
     * @return javax.swing.JLabel
802
     */
803
    private javax.swing.JLabel getJLabel() {
804
        if (jLabel == null) {
805
            jLabel = new javax.swing.JLabel();
806
            jLabel.setText(PluginServices.getText(this, "nombre_sesion") + ":");
807
            jLabel.setPreferredSize(new java.awt.Dimension(150, 16));
808
        }
809

    
810
        return jLabel;
811
    }
812

    
813
    /**
814
     * This method initializes lblNombreSesion
815
     *
816
     * @return javax.swing.JLabel
817
     */
818
    private javax.swing.JLabel getLblNombreSesion() {
819
        if (lblNombreSesion == null) {
820
            lblNombreSesion = new javax.swing.JLabel();
821
            lblNombreSesion.setText("");
822
            lblNombreSesion.setName("lblNombreSesion");
823
            lblNombreSesion.setPreferredSize(new java.awt.Dimension(200, 16));
824
            lblNombreSesion.setAutoscrolls(true);
825
        }
826

    
827
        return lblNombreSesion;
828
    }
829

    
830
    /**
831
     * This method initializes jLabel1
832
     *
833
     * @return javax.swing.JLabel
834
     */
835
    private javax.swing.JLabel getJLabel1() {
836
        if (jLabel1 == null) {
837
            jLabel1 = new javax.swing.JLabel();
838
            jLabel1.setText(PluginServices.getText(this, "guardado") + ":");
839
            jLabel1.setPreferredSize(new java.awt.Dimension(150, 16));
840
        }
841

    
842
        return jLabel1;
843
    }
844

    
845
    /**
846
     * This method initializes lblGuardado
847
     *
848
     * @return javax.swing.JLabel
849
     */
850
    private javax.swing.JLabel getLblGuardado() {
851
        if (lblGuardado == null) {
852
            lblGuardado = new javax.swing.JLabel();
853
            lblGuardado.setText("");
854
            lblGuardado.setPreferredSize(new java.awt.Dimension(200, 16));
855
            lblGuardado.setAutoscrolls(true);
856
        }
857

    
858
        return lblGuardado;
859
    }
860

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

    
873
        return jLabel2;
874
    }
875

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

    
889
        return lblFecha;
890
    }
891

    
892
    /**
893
     * This method initializes btnImportar
894
     *
895
     * @return javax.swing.JButton
896
     */
897
    private javax.swing.JButton getBtnImportar() {
898
        if (btnImportar == null) {
899
            btnImportar = new javax.swing.JButton();
900
            btnImportar.setPreferredSize(new java.awt.Dimension(80, 23));
901
            btnImportar.setText(PluginServices.getText(this, "importar"));
902
            btnImportar.setMargin(new java.awt.Insets(2, 2, 2, 2));
903
        }
904

    
905
        return btnImportar;
906
    }
907

    
908
    /**
909
     * This method initializes btnExportar
910
     *
911
     * @return javax.swing.JButton
912
     */
913
    private javax.swing.JButton getBtnExportar() {
914
        if (btnExportar == null) {
915
            btnExportar = new javax.swing.JButton();
916
            btnExportar.setPreferredSize(new java.awt.Dimension(80, 23));
917
            btnExportar.setText(PluginServices.getText(this, "exportar"));
918
            btnExportar.setMargin(new java.awt.Insets(2, 2, 2, 2));
919
        }
920

    
921
        return btnExportar;
922
    }
923

    
924
    /**
925
     * This method initializes btnEditar
926
     *
927
     * @return javax.swing.JButton
928
     */
929
    private javax.swing.JButton getBtnEditar() {
930
        if (btnEditar == null) {
931
            btnEditar = new javax.swing.JButton();
932
            btnEditar.setPreferredSize(new java.awt.Dimension(80, 23));
933
            btnEditar.setText(PluginServices.getText(this, "propiedades"));
934

    
935
            btnEditar.setMargin(new java.awt.Insets(2, 2, 2, 2));
936

    
937
            final JPanel f = this;
938
            btnEditar.addActionListener(new java.awt.event.ActionListener() {
939
                    public void actionPerformed(java.awt.event.ActionEvent e) {
940
                        ProjectProperties dlg = new ProjectProperties(p);
941
                        PluginServices.getMDIManager().addView(dlg);
942
                        refreshProperties();
943
                    }
944
                });
945
        }
946

    
947
        return btnEditar;
948
    }
949

    
950
    /**
951
     * This method initializes jScrollPane
952
     *
953
     * @return javax.swing.JScrollPane
954
     */
955
    private javax.swing.JScrollPane getJScrollPane() {
956
        if (jScrollPane == null) {
957
            jScrollPane = new javax.swing.JScrollPane();
958
            jScrollPane.setViewportView(getLstDocs());
959
            jScrollPane.setPreferredSize(new java.awt.Dimension(200, 100));
960
            jScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
961
        }
962

    
963
        return jScrollPane;
964
    }
965

    
966
    /**
967
     * @see com.iver.mdiApp.ui.MDIManager.SingletonView#getViewModel()
968
     */
969
    public Object getViewModel() {
970
        return p;
971
    }
972

    
973
    /**
974
     * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
975
     */
976
    public ViewInfo getViewInfo() {
977
        ViewInfo m_viewinfo = new ViewInfo();
978
        m_viewinfo.setWidth(400);
979
        m_viewinfo.setHeight(430);
980
        m_viewinfo.setTitle(PluginServices.getText(this, "titulo"));
981
        
982
        return m_viewinfo;
983
    }
984

    
985
    /**
986
     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
987
     */
988
    public void propertyChange(PropertyChangeEvent evt) {
989
        refreshControls();
990
    }
991

    
992
    /**
993
     * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
994
     */
995
    public void viewActivated() {
996
    }
997

    
998
    /**
999
     * This method initializes jPanel4
1000
     *
1001
     * @return javax.swing.JPanel
1002
     */
1003
    private javax.swing.JPanel getJPanel4() {
1004
        if (jPanel4 == null) {
1005
            jPanel4 = new javax.swing.JPanel();
1006

    
1007
            java.awt.FlowLayout layFlowLayout2 = new java.awt.FlowLayout();
1008
            layFlowLayout2.setHgap(30);
1009
            jPanel4.setLayout(layFlowLayout2);
1010
            jPanel4.add(getBtnImportar(), null);
1011
            jPanel4.add(getBtnExportar(), null);
1012
            jPanel4.add(getBtnEditar(), null);
1013
            jPanel4.setPreferredSize(new java.awt.Dimension(360, 30));
1014
        }
1015

    
1016
        return jPanel4;
1017
    }
1018
}