Statistics
| Revision:

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

History | View | Annotate | Download (32.4 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.awt.GridLayout;
45
import java.beans.PropertyChangeEvent;
46
import java.beans.PropertyChangeListener;
47
import java.io.File;
48
import java.text.DateFormat;
49

    
50
import javax.swing.ButtonGroup;
51
import javax.swing.ImageIcon;
52
import javax.swing.JDialog;
53
import javax.swing.JLabel;
54
import javax.swing.JList;
55
import javax.swing.JOptionPane;
56
import javax.swing.JPanel;
57
import javax.swing.JRadioButton;
58
import javax.swing.JScrollPane;
59

    
60
import org.gvsig.gui.beans.swing.JButton;
61

    
62
import com.hardcode.driverManager.Driver;
63
import com.hardcode.driverManager.DriverLoadException;
64
import com.hardcode.gdbms.engine.data.DataSource;
65
import com.hardcode.gdbms.engine.data.DataSourceFactory;
66
import com.hardcode.gdbms.engine.data.driver.DBDriver;
67
import com.hardcode.gdbms.engine.data.driver.DriverException;
68
import com.hardcode.gdbms.engine.data.driver.FileDriver;
69
import com.iver.andami.PluginServices;
70
import com.iver.andami.messages.NotificationManager;
71
import com.iver.andami.ui.mdiManager.SingletonView;
72
import com.iver.andami.ui.mdiManager.View;
73
import com.iver.andami.ui.mdiManager.ViewInfo;
74
import com.iver.cit.gvsig.ProjectExtension;
75
import com.iver.cit.gvsig.fmap.edition.EditableAdapter;
76
import com.iver.cit.gvsig.fmap.edition.IWriter;
77
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
78
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
79
import com.iver.cit.gvsig.gui.DataBaseOpenDialog;
80
import com.iver.cit.gvsig.gui.FOpenDialog;
81
import com.iver.cit.gvsig.gui.FileOpenDialog;
82
import com.iver.cit.gvsig.gui.Table;
83
import com.iver.cit.gvsig.gui.layout.Layout;
84
import com.iver.cit.gvsig.project.Project;
85
import com.iver.cit.gvsig.project.ProjectElement;
86
import com.iver.cit.gvsig.project.ProjectFactory;
87
import com.iver.cit.gvsig.project.ProjectMap;
88
import com.iver.cit.gvsig.project.ProjectTable;
89
import com.iver.cit.gvsig.project.ProjectView;
90
import com.iver.utiles.DefaultListModel;
91
import java.awt.CardLayout;
92
import java.awt.BorderLayout;
93
import java.awt.FlowLayout;
94

    
95

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

    
130
        /** Proyecto representado en la vista */
131
        private Project p;
132

    
133
        /**
134
         * Extension con la informaci?n, entre otras, sobre las extensiones para
135
         * las tablas
136
         */
137
        private ProjectExtension projectExtension;
138
        private JScrollPane jScrollPane = null;
139
        private JPanel jPanel4 = null;
140

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

    
149
                initialize();
150

    
151
                projectExtension = project;
152

    
153
                refreshControls();
154
        }
155

    
156
        /**
157
         * This is the default constructor
158
         *
159
         * @param project Extension
160
         */
161
        public ProjectWindow() {
162
                super();
163

    
164
                initialize();
165
                refreshControls();
166
        }
167

    
168
        public void setProjectExtension(ProjectExtension p) {
169
                projectExtension = p;
170
        }
171

    
172

    
173
        /**
174
         * Asigna el proyecto a la ventana
175
         *
176
         * @param p Proyecto con el que se operar? a trav?s de este di?logo
177
         */
178
        public void setProject(Project p) {
179
                this.p = p;
180
                p.addPropertyChangeListener(this);
181
                refreshControls();
182
        }
183

    
184
        /**
185
         * Activa los botones de la botonera del medio o los desactiva en funci?n
186
         * de que est? seleccionado o no un elemento de proyecto en la lista del
187
         * medio
188
         */
189
        private void activarBotones() {
190
                if (lstDocs.getSelectedIndex() != -1) {
191
                        btnAbrir.setEnabled(true);
192
                        btnBorrar.setEnabled(true);
193
                        btnRenombrar.setEnabled(true);
194
                        btnPropiedades.setEnabled(true);
195
                } else {
196
                        btnAbrir.setEnabled(false);
197
                        btnBorrar.setEnabled(false);
198
                        btnRenombrar.setEnabled(false);
199
                        btnPropiedades.setEnabled(false);
200
                }
201
        }
202

    
203
        /**
204
         * Refresca la lista de elementos de proyecto con vistas, mapas o tablas,
205
         * seg?n la opci?n activada
206
         */
207
        private void refreshList() {
208
                if (p != null) {
209
                        DefaultListModel model;
210

    
211
                        if (btnMapas.isSelected()) {
212
                                model = new DefaultListModel(p.getMaps());
213

    
214
                                //                                getBtnNuevo().setEnabled(true);
215
                        } else if (btnTablas.isSelected()) {
216
                                model = new DefaultListModel(p.getTables());
217

    
218
                                //                getBtnNuevo().setEnabled(false);
219
                        } else {
220
                                model = new DefaultListModel(p.getViews());
221

    
222
                                //                                getBtnNuevo().setEnabled(true);
223
                        }
224

    
225
                        lstDocs.setModel(model);
226

    
227
                        activarBotones();
228
                }
229
        }
230

    
231
        /**
232
         * Refresca las etiquetas con la informaci?n del proyecto
233
         */
234
        private void refreshProperties() {
235
                if (p != null) {
236
                        String aux;
237

    
238
                        lblNombreSesion.setText(p.getName());
239

    
240
                        String path = p.getPath();
241

    
242
                        if (path != null) {
243
                                File f = new File(path);
244
                                lblGuardado.setText(f.toString());
245
                        } else {
246
                                lblGuardado.setText("");
247
                        }
248

    
249
                        lblFecha.setText(p.getCreationDate());
250
                }
251
        }
252

    
253
        /**
254
         * Refresca todo el di?logo
255
         */
256
        public void refreshControls() {
257
                refreshList();
258
                refreshProperties();
259
        }
260

    
261
        /**
262
         * This method initializes this
263
         */
264
        private void initialize() {
265
                setLayout(new java.awt.FlowLayout());
266
                add(getJPanel(), null);
267
                add(getJPanel1(), null);
268
                add(getJPanel3(), null);
269

    
270
                this.setSize(430, 435);
271
                this.setPreferredSize(new java.awt.Dimension(430, 430));
272
                grupo.add(btnVistas);
273
                grupo.add(btnTablas);
274
                grupo.add(btnMapas);
275

    
276
                btnVistas.setSelected(true);
277
        }
278
        private String ask(String title, String content){
279
                JOptionPane pane = new JOptionPane();
280
                pane.setMessage(content);
281
                pane.setMessageType(JOptionPane.QUESTION_MESSAGE);
282
                pane.setWantsInput(true);
283
                pane.setInitialSelectionValue("");
284

    
285
                JDialog dlg = pane.createDialog((Component) PluginServices.getMainFrame(),
286
                                title);
287
                dlg.setModal(true);
288
                dlg.show();
289

    
290
                return pane.getInputValue().toString().trim();
291
        }
292

    
293
        /**
294
         * Crea un nuevo project element
295
         *
296
         * @throws Exception DOCUMENT ME!
297
         */
298
        private void nuevo() throws Exception {
299
                DateFormat df = DateFormat.getDateInstance();
300

    
301
                if (btnMapas.isSelected()) {
302
                        ProjectMap map = ProjectFactory.createMap(PluginServices.getText(
303
                                                this, "untitled"));
304
                        map.setModel(new Layout());
305
                        map.getModel().setProjectMap(map);
306
                        p.addMap(map);
307
                } else if (btnTablas.isSelected()) {
308
                        try {
309
                                FOpenDialog fopen = new FOpenDialog();
310
                                FileOpenDialog fod = new FileOpenDialog(new Class[] {
311
                                                        FileDriver.class}, false);
312
                                DataBaseOpenDialog dbod = new DataBaseOpenDialog();
313
                                dbod.setClasses(new Class[] { DBDriver.class });
314
                                fopen.addTab("Fichero", fod);
315
                                fopen.addTab("Base de datos", dbod);
316
                                PluginServices.getMDIManager().addView(fopen);
317

    
318
                                if (fopen.isAccepted()) {
319
                                        JPanel panel = fopen.getSelectedTab();
320
                                        ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
321

    
322
                                        if (panel instanceof FileOpenDialog) {
323
                                                File[] files = fod.getFiles();
324
                                                String[] driverNames = fod.getDriverNames();
325

    
326
                                                for (int i = 0; i < files.length; i++) {
327
                                                        String name = files[i].getName();
328

    
329
                                                        LayerFactory.getDataSourceFactory()
330
                                                                                .addFileDataSource(driverNames[i],
331
                                                                name, files[i].getAbsolutePath());
332

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

    
351
                                                        Table t = new Table();
352
                                                        t.setModel(projectTable);
353
                                                        projectTable.setAndamiView(t);
354
                                                        PluginServices.getMDIManager().addView(t);
355
                                                }
356
                                        } else if (panel instanceof DataBaseOpenDialog) {
357
                                                String driverName = dbod.getDriverName();
358
                                                int port = -1;
359

    
360
                                                try {
361
                                                        port = Integer.parseInt(dbod.getPort());
362
                                                } catch (NumberFormatException e) {
363
                                                }
364

    
365
                                                String name = dbod.getHost() + "/" +
366
                                                        dbod.getDataBase();
367

    
368
                                                if (port != -1) {
369
                                                        name = dbod.getHost() + ":" + port + "/" +
370
                                                                dbod.getDataBase();
371
                                                }
372

    
373
                                                String user = dbod.getUser().trim();
374
                                                String password = dbod.getPassword();
375

    
376
                                                if (user.equals("")) {
377
                                                        user = null;
378
                                                        password = null;
379
                                                }
380

    
381
                                                LayerFactory.getDataSourceFactory().addDBDataSourceByTable(name,
382
                                                        dbod.getHost(), port, user, password,
383
                                                        dbod.getDataBase(), dbod.getTable(), driverName);
384

    
385
                                                DataSource dataSource = LayerFactory.getDataSourceFactory()
386
                                                                                                                        .createRandomDataSource(name, DataSourceFactory.AUTOMATIC_OPENING);
387
                                                SelectableDataSource sds = new SelectableDataSource(dataSource);
388
                                                EditableAdapter auxea=new EditableAdapter();
389
                                // TODO: fjp: ESTO HAY QUE REVISARLO.
390
                                // Por ahora, para obtener un driver que sirva para esta
391
                                // fuente de datos, compruebo que implementa IWriteable.
392
                                // IWriter writer = (IWriter) LayerFactory.getWM().getWriter(driverNames[i]);
393
                                Driver drv = LayerFactory.getDM().getDriver(driverName);
394
//                                if (drv instanceof IWriter)
395
//                                {
396
//                                        auxea.setWriter((IWriter) drv);
397
//                                }
398

    
399
                                auxea.setOriginalDataSource(sds);
400
                                                ProjectTable projectTable = ProjectFactory.createTable(name,
401
                                                                auxea);
402
                                                ext.getProject().addTable(projectTable);
403

    
404
                                                Table t = new Table();
405
                                                t.setModel(projectTable);
406
                                                projectTable.setAndamiView(t);
407
                                                PluginServices.getMDIManager().addView(t);
408
                                        }
409
                                }
410
                        } catch (DriverLoadException e) {
411
                                NotificationManager.addError("Error al cargar los drivers", e);
412
                        }
413
                } else {
414
                        ProjectView vista = ProjectFactory.createView(PluginServices.getText(
415
                                                this, "untitled"));
416
                        p.addView(vista);
417
                }
418
        }
419

    
420
        /**
421
         * Abre la ventana de un nuevo project element
422
         */
423
        private void abrir() {
424
                if (btnMapas.isSelected()) {
425
                        int index = lstDocs.getSelectedIndex();
426

    
427
                        if (index == -1) {
428
                                return;
429
                        }
430
            ProjectMap projectMap = (ProjectMap) p.getMaps().get(index);
431
                        Layout l = projectMap.getModel();
432
            // System.out.println("l.getName " + l.getName() + " projectMap.getName " + projectMap.getName());
433
            projectMap.setName(l.getName());
434
            l.setProjectMap(projectMap);
435
                        l.fullRect();
436
            l.getViewInfo().setTitle(PluginServices.getText(this,
437
            "Mapa") + " : " +l.getName());
438
                        PluginServices.getMDIManager().addView(l);
439
                } else if (btnTablas.isSelected()) {
440
                        com.iver.cit.gvsig.gui.Table vista = new com.iver.cit.gvsig.gui.Table();
441
                        int index = lstDocs.getSelectedIndex();
442

    
443
                        if (index == -1) {
444
                                return;
445
                        }
446
                        ProjectTable pt=(ProjectTable) p.getTables().get(index);
447
                        vista.setModel(pt);
448
                        PluginServices.getMDIManager().addView(vista);
449
                } else {
450
                        com.iver.cit.gvsig.gui.View vista = new com.iver.cit.gvsig.gui.View();
451
                        int index = lstDocs.getSelectedIndex();
452

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

    
457
                        vista.setModel((ProjectView) p.getViews().get(index));
458
                        PluginServices.getMDIManager().addView(vista);
459
                }
460
        }
461

    
462
        /**
463
         * Cambia el nombre de un project element
464
         */
465
        private void renombrar() {
466
                ProjectElement elem = null;
467
                int index = lstDocs.getSelectedIndex();
468

    
469
                if (index == -1) {
470
                        return;
471
                }
472

    
473
                if (btnMapas.isSelected()) {
474
                        elem = (ProjectElement) p.getMaps().get(index);
475
                } else if (btnTablas.isSelected()) {
476
                        elem = (ProjectElement) p.getTables().get(index);
477
                } else {
478
                        elem = (ProjectElement) p.getViews().get(index);
479
                }
480

    
481
                if (elem.isLocked()) {
482
                        JOptionPane.showMessageDialog(this,        PluginServices.getText(this, "locked_element_it_cannot_be_renamed"));
483
                        return;
484
                }
485

    
486
                JOptionPane pane = new JOptionPane();
487
                pane.setMessage(PluginServices.getText(this, "introduce_nombre"));
488
                pane.setMessageType(JOptionPane.QUESTION_MESSAGE);
489
                pane.setWantsInput(true);
490
                pane.setInitialSelectionValue(elem.getName());
491
        pane.setInputValue(elem.getName());
492
                JDialog dlg = pane.createDialog((Component) PluginServices.getMainFrame(),
493
                                PluginServices.getText(this, "renombrar"));
494
                dlg.setModal(true);
495
                dlg.show();
496

    
497
                String nuevoNombre = pane.getInputValue().toString().trim();
498

    
499
                if (nuevoNombre.length() == 0) {
500
                        return;
501
                }
502

    
503
                if (nuevoNombre == null) {
504
                        return;
505
                }
506

    
507
                for (int i=0; i<lstDocs.getModel().getSize(); i++){
508
                        if (i==index) continue;
509
                        if (((ProjectElement)lstDocs.getModel().getElementAt(i)).getName().equals(nuevoNombre)){
510
                                JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this, "elemento_ya_existe"));
511
                                return;
512
                        }
513

    
514
                }
515
                elem.setName(nuevoNombre);
516

    
517
                refreshList();
518
        }
519

    
520
        /**
521
         * Borra un project element
522
         */
523
        private void borrar() {
524
                int res = JOptionPane.showConfirmDialog((Component) PluginServices.getMainFrame(),
525
                                PluginServices.getText(this, "confirmar_borrar"),
526
                                PluginServices.getText(this, "borrar"),
527
                                JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
528

    
529
                if (res == JOptionPane.YES_OPTION) {
530
                        int index = lstDocs.getSelectedIndex();
531

    
532
                        if (btnMapas.isSelected()) {
533
                                if (((ProjectElement) p.getMaps().get(index)).isLocked()) {
534
                                        JOptionPane.showMessageDialog(this,        PluginServices.getText(this, "locked_element_it_cannot_be_deleted"));
535
                                        return;
536
                                }
537
                                PluginServices.getMDIManager().closeSingletonView(p.getMaps()
538
                                                                                                                                   .get(index));
539
                                p.delMap(index);
540
                        } else if (btnTablas.isSelected()) {
541
                                if (((ProjectElement) p.getTables().get(index)).isLocked()) {
542
                                        JOptionPane.showMessageDialog(this,        PluginServices.getText(this, "locked_element_it_cannot_be_deleted"));
543
                                        return;
544
                                }
545
                                PluginServices.getMDIManager().closeSingletonView(p.getTables()
546
                                                                                                                                   .get(index));
547
                                p.delTable(index);
548
                        } else {
549
                                if (((ProjectElement) p.getViews().get(index)).isLocked()) {
550
                                        JOptionPane.showMessageDialog(this,        PluginServices.getText(this, "locked_element_it_cannot_be_deleted"));
551
                                        return;
552
                                }
553
                                PluginServices.getMDIManager().closeSingletonView(p.getViews()
554
                                                                                                                                   .get(index));
555
                                p.delView(index);
556
                        }
557

    
558
                        refreshList();
559
                }
560
        }
561

    
562
        /**
563
         * Muestra el di?logo de propiedades de un project element
564
         */
565
        private void propiedades() {
566
                int index = lstDocs.getSelectedIndex();
567

    
568
                if (index == -1) {
569
                        return;
570
                }
571

    
572
                View dlg = null;
573

    
574
                if (btnMapas.isSelected()) {
575
                        if (((ProjectElement) p.getMaps().get(index)).isLocked()) {
576
                                JOptionPane.showMessageDialog(this,        PluginServices.getText(this, "locked_element"));
577
                                return;
578
                        }
579
                        dlg = new MapProperties((ProjectMap) p.getMaps().get(index));
580
                } else if (btnTablas.isSelected()) {
581
                        if (((ProjectElement) p.getTables().get(index)).isLocked()) {
582
                                JOptionPane.showMessageDialog(this,        PluginServices.getText(this, "locked_element"));
583
                                return;
584
                        }
585
                        try {
586
                dlg = new TableProperties((ProjectTable) p.getTables().get(index));
587
            } catch (DriverException e) {
588
                NotificationManager.addError(e.getMessage(), e);
589
            }
590
                } else {
591
                        if (((ProjectElement) p.getViews().get(index)).isLocked()) {
592
                                JOptionPane.showMessageDialog(this,        PluginServices.getText(this, "locked_element"));
593
                                return;
594
                        }
595

    
596
                        dlg = new ViewProperties((ProjectView) p.getViews().get(index));
597
                }
598

    
599
                PluginServices.getMDIManager().addView(dlg);
600

    
601
                refreshControls();
602
                lstDocs.setSelectedIndex(index);
603
        }
604

    
605
        /**
606
         * This method initializes jPanel
607
         *
608
         * @return JPanel
609
         */
610
        private JPanel getJPanel() {
611
                if (jPanel == null) {
612
                        jPanel = new JPanel();
613

    
614
                        java.awt.FlowLayout layFlowLayout1 = new java.awt.FlowLayout();
615
                        layFlowLayout1.setHgap(15);
616
                        jPanel.setLayout(layFlowLayout1);
617
                        jPanel.add(getBtnVistas(), null);
618
                        jPanel.add(getBtnTablas(), null);
619
                        jPanel.add(getBtnMapas(), null);
620
                        jPanel.setName("tipoDocPanel");
621
                        jPanel.setPreferredSize(new java.awt.Dimension(430, 125));
622
                        jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
623
                                        null, PluginServices.getText(this, "tipos_de_documentos"),
624
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
625
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
626
                }
627

    
628
                return jPanel;
629
        }
630

    
631
        /**
632
         * This method initializes btnVistas
633
         *
634
         * @return JRadioButton
635
         */
636
        private JRadioButton getBtnVistas() {
637
                if (btnVistas == null) {
638
                        btnVistas = new JRadioButton();
639
                        btnVistas.setIcon(new ImageIcon(
640
                                        this.getClass().getClassLoader().getResource("images/Vista.png")));
641
                        btnVistas.setSelectedIcon(new ImageIcon(
642
                                        this.getClass().getClassLoader().getResource("images/Vista_sel.png")));
643
                        btnVistas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
644
                        btnVistas.setText(PluginServices.getText(this, "vistas"));
645
                        btnVistas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
646
                        btnVistas.setName("vistasBtn");
647
                        btnVistas.addChangeListener(new javax.swing.event.ChangeListener() {
648
                                        public void stateChanged(javax.swing.event.ChangeEvent e) {
649
                                                refreshList();
650
                                        }
651
                                });
652
                }
653

    
654
                return btnVistas;
655
        }
656

    
657
        /**
658
         * This method initializes btnTablas
659
         *
660
         * @return JRadioButton
661
         */
662
        private JRadioButton getBtnTablas() {
663
                if (btnTablas == null) {
664
                        btnTablas = new JRadioButton();
665
                        btnTablas.setIcon(new ImageIcon(
666
                                        this.getClass().getClassLoader().getResource("images/tablas.png")));
667
                        btnTablas.setSelectedIcon(new ImageIcon(
668
                                        this.getClass().getClassLoader().getResource("images/tablas_sel.png")));
669
                        btnTablas.setText(PluginServices.getText(this, "tablas"));
670
                        btnTablas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
671
                        btnTablas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
672
                        btnTablas.setName("tablasBtn");
673
                        btnTablas.addChangeListener(new javax.swing.event.ChangeListener() {
674
                                        public void stateChanged(javax.swing.event.ChangeEvent e) {
675
                                                refreshList();
676
                                        }
677
                                });
678
                }
679

    
680
                return btnTablas;
681
        }
682

    
683
        /**
684
         * This method initializes btnMapas
685
         *
686
         * @return JRadioButton
687
         */
688
        private JRadioButton getBtnMapas() {
689
                if (btnMapas == null) {
690
                        btnMapas = new JRadioButton();
691
                        btnMapas.setIcon(new ImageIcon(
692
                                        this.getClass().getClassLoader().getResource("images/mapas.png")));
693
                        btnMapas.setSelectedIcon(new ImageIcon(
694
                                        this.getClass().getClassLoader().getResource("images/mapas_sel.png")));
695
                        btnMapas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
696
                        btnMapas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
697
                        btnMapas.setText(PluginServices.getText(this, "mapas"));
698
                        btnMapas.addChangeListener(new javax.swing.event.ChangeListener() {
699
                                        public void stateChanged(javax.swing.event.ChangeEvent e) {
700
                                                refreshList();
701
                                        }
702
                                });
703
                }
704

    
705
                return btnMapas;
706
        }
707

    
708
        /**
709
         * This method initializes jPanel1
710
         *
711
         * @return JPanel
712
         */
713
        private JPanel getJPanel1() {
714
                if (jPanel1 == null) {
715
                        jPanel1 = new JPanel();
716

    
717
                        java.awt.BorderLayout layBorderLayout2 = new java.awt.BorderLayout();
718
                        layBorderLayout2.setVgap(30);
719
                        layBorderLayout2.setHgap(5);
720
                        jPanel1.setLayout(layBorderLayout2);
721
                        jPanel1.add(getJPanel2(), java.awt.BorderLayout.EAST);
722
                        jPanel1.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
723
                        jPanel1.setPreferredSize(new java.awt.Dimension(430,170));
724
                        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
725
                                        null,
726
                                        PluginServices.getText(this, "documentos_existentes"),
727
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
728
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
729
                }
730

    
731
                return jPanel1;
732
        }
733

    
734
        /**
735
         * This method initializes lstDocs
736
         *
737
         * @return JList
738
         */
739
        private JList getLstDocs() {
740
                if (lstDocs == null) {
741
                        lstDocs = new JList();
742
                        lstDocs.addMouseListener(new java.awt.event.MouseAdapter() {
743
                                        public void mouseClicked(java.awt.event.MouseEvent e) {
744
                                                if (e.getClickCount() == 2) {
745
                                                        abrir();
746
                                                }
747
                                        }
748
                                });
749
                        lstDocs.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
750
                                        public void valueChanged(
751
                                                javax.swing.event.ListSelectionEvent e) {
752
                                                activarBotones();
753
                                        }
754
                                });
755
                }
756

    
757
                return lstDocs;
758
        }
759

    
760
        /**
761
         * This method initializes jPanel2
762
         *
763
         * @return JPanel
764
         */
765
        private JPanel getJPanel2() {
766
                if (jPanel2 == null) {
767
                        jPanel2 = new JPanel();
768

    
769
                        jPanel2.setLayout(new GridLayout(5, 1, 5, 5));
770
                        jPanel2.add(getBtnNuevo(), null);
771
                        jPanel2.add(getBtnAbrir(), null);
772
                        jPanel2.add(getBtnRenombrar(), null);
773
                        jPanel2.add(getBtnBorrar(), null);
774
                        jPanel2.add(getBtnPropiedades(), null);
775
                        jPanel2.setPreferredSize(new java.awt.Dimension(100, 50));
776
                }
777

    
778
                return jPanel2;
779
        }
780

    
781
        /**
782
         * This method initializes btnNuevo
783
         *
784
         * @return JButton
785
         */
786
        private JButton getBtnNuevo() {
787
                if (btnNuevo == null) {
788
                        btnNuevo = new JButton();
789
                        btnNuevo.setPreferredSize(new java.awt.Dimension(80, 23));
790
                        btnNuevo.setName("btnNuevo");
791
                        btnNuevo.setText(PluginServices.getText(this, "nuevo"));
792
                        btnNuevo.setMargin(new java.awt.Insets(2, 2, 2, 2));
793
                        btnNuevo.addActionListener(new java.awt.event.ActionListener() {
794
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
795
                                                try {
796
                                                        nuevo();
797
                                                } catch (Exception e1) {
798
                                                        NotificationManager.addError(e1.getLocalizedMessage(),
799
                                                                e1);
800
                                                }
801
                                        }
802
                                });
803
                }
804

    
805
                return btnNuevo;
806
        }
807

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

    
828
                return btnPropiedades;
829
        }
830

    
831
        /**
832
         * This method initializes btnAbrir
833
         *
834
         * @return JButton
835
         */
836
        private JButton getBtnAbrir() {
837
                if (btnAbrir == null) {
838
                        btnAbrir = new JButton();
839
                        btnAbrir.setPreferredSize(new java.awt.Dimension(80, 23));
840
                        btnAbrir.setName("btnAbrir");
841
                        btnAbrir.setText(PluginServices.getText(this, "abrir"));
842
                        btnAbrir.setEnabled(false);
843
                        btnAbrir.setMargin(new java.awt.Insets(2, 2, 2, 2));
844
                        btnAbrir.addActionListener(new java.awt.event.ActionListener() {
845
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
846
                                                abrir();
847
                                        }
848
                                });
849
                }
850

    
851
                return btnAbrir;
852
        }
853

    
854
        /**
855
         * This method initializes btnBorrar
856
         *
857
         * @return JButton
858
         */
859
        private JButton getBtnBorrar() {
860
                if (btnBorrar == null) {
861
                        btnBorrar = new JButton();
862
                        btnBorrar.setPreferredSize(new java.awt.Dimension(80, 23));
863
                        btnBorrar.setText(PluginServices.getText(this, "borrar"));
864
                        btnBorrar.setName("btnBorrar");
865
                        btnBorrar.setEnabled(false);
866
                        btnBorrar.setMargin(new java.awt.Insets(2, 2, 2, 2));
867
                        btnBorrar.addActionListener(new java.awt.event.ActionListener() {
868
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
869
                                                borrar();
870
                                        }
871
                                });
872
                }
873

    
874
                return btnBorrar;
875
        }
876

    
877
        /**
878
         * This method initializes btnRenombrar
879
         *
880
         * @return JButton
881
         */
882
        private JButton getBtnRenombrar() {
883
                if (btnRenombrar == null) {
884
                        btnRenombrar = new JButton();
885
                        btnRenombrar.setPreferredSize(new java.awt.Dimension(80, 23));
886
                        btnRenombrar.setName("btnRenombrar");
887
                        btnRenombrar.setText(PluginServices.getText(this, "renombrar"));
888
                        btnRenombrar.setEnabled(false);
889
                        btnRenombrar.setMargin(new java.awt.Insets(2, 2, 2, 2));
890
                        btnRenombrar.addActionListener(new java.awt.event.ActionListener() {
891
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
892
                                                renombrar();
893
                                        }
894
                                });
895
                }
896

    
897
                return btnRenombrar;
898
        }
899

    
900
        /**
901
         * This method initializes jPanel3
902
         *
903
         * @return JPanel
904
         */
905
        private JPanel getJPanel3() {
906
                if (jPanel3 == null) {
907
                        jPanel3 = new JPanel();
908

    
909
                        java.awt.FlowLayout layFlowLayout3 = new java.awt.FlowLayout();
910
                        layFlowLayout3.setHgap(5);
911
                        layFlowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
912
                        jPanel3.setLayout(layFlowLayout3);
913
                        jPanel3.add(getJLabel(), null);
914
                        jPanel3.add(getLblNombreSesion(), null);
915
                        jPanel3.add(getJLabel1(), null);
916
                        jPanel3.add(getLblGuardado(), null);
917
                        jPanel3.add(getJLabel2(), null);
918
                        jPanel3.add(getLblFecha(), null);
919
                        jPanel3.setPreferredSize(new java.awt.Dimension(430, 125));
920
                        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(
921
                                        null, PluginServices.getText(this, "propiedades_sesion"),
922
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
923
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
924
                        jPanel3.add(getJPanel4(), null);
925
                }
926

    
927
                return jPanel3;
928
        }
929

    
930
        /**
931
         * This method initializes jLabel
932
         *
933
         * @return JLabel
934
         */
935
        private JLabel getJLabel() {
936
                if (jLabel == null) {
937
                        jLabel = new JLabel();
938
                        jLabel.setText(PluginServices.getText(this, "nombre_sesion") + ":");
939
                        jLabel.setPreferredSize(new java.awt.Dimension(150, 16));
940
                }
941

    
942
                return jLabel;
943
        }
944

    
945
        /**
946
         * This method initializes lblNombreSesion
947
         *
948
         * @return JLabel
949
         */
950
        private JLabel getLblNombreSesion() {
951
                if (lblNombreSesion == null) {
952
                        lblNombreSesion = new JLabel();
953
                        lblNombreSesion.setText("");
954
                        lblNombreSesion.setName("lblNombreSesion");
955
                        lblNombreSesion.setPreferredSize(new java.awt.Dimension(200, 16));
956
                        lblNombreSesion.setAutoscrolls(true);
957
                }
958

    
959
                return lblNombreSesion;
960
        }
961

    
962
        /**
963
         * This method initializes jLabel1
964
         *
965
         * @return JLabel
966
         */
967
        private JLabel getJLabel1() {
968
                if (jLabel1 == null) {
969
                        jLabel1 = new JLabel();
970
                        jLabel1.setText(PluginServices.getText(this, "guardado") + ":");
971
                        jLabel1.setPreferredSize(new java.awt.Dimension(150, 16));
972
                }
973

    
974
                return jLabel1;
975
        }
976

    
977
        /**
978
         * This method initializes lblGuardado
979
         *
980
         * @return JLabel
981
         */
982
        private JLabel getLblGuardado() {
983
                if (lblGuardado == null) {
984
                        lblGuardado = new JLabel();
985
                        lblGuardado.setText("");
986
                        lblGuardado.setPreferredSize(new java.awt.Dimension(200, 16));
987
                        lblGuardado.setAutoscrolls(true);
988
                }
989

    
990
                return lblGuardado;
991
        }
992

    
993
        /**
994
         * This method initializes jLabel2
995
         *
996
         * @return JLabel
997
         */
998
        private JLabel getJLabel2() {
999
                if (jLabel2 == null) {
1000
                        jLabel2 = new JLabel();
1001
                        jLabel2.setText(PluginServices.getText(this, "creation_date") +
1002
                                ":");
1003
                        jLabel2.setPreferredSize(new java.awt.Dimension(150, 16));
1004
                }
1005

    
1006
                return jLabel2;
1007
        }
1008

    
1009
        /**
1010
         * This method initializes lblFecha
1011
         *
1012
         * @return JLabel
1013
         */
1014
        private JLabel getLblFecha() {
1015
                if (lblFecha == null) {
1016
                        lblFecha = new JLabel();
1017
                        lblFecha.setText("");
1018
                        lblFecha.setPreferredSize(new java.awt.Dimension(200, 16));
1019
                        lblFecha.setAutoscrolls(true);
1020
                }
1021

    
1022
                return lblFecha;
1023
        }
1024

    
1025
        /**
1026
         * This method initializes btnImportar
1027
         *
1028
         * @return JButton
1029
         */
1030
        private JButton getBtnImportar() {
1031
                if (btnImportar == null) {
1032
                        btnImportar = new JButton();
1033
                        btnImportar.setPreferredSize(new java.awt.Dimension(80, 23));
1034
                        btnImportar.setText(PluginServices.getText(this, "importar"));
1035
                        btnImportar.setName("btnImportar");
1036
                        btnImportar.setMargin(new java.awt.Insets(2, 2, 2, 2));
1037
                        // TODO implement import
1038
                        btnImportar.setVisible(false);
1039
                }
1040

    
1041
                return btnImportar;
1042
        }
1043

    
1044
        /**
1045
         * This method initializes btnExportar
1046
         *
1047
         * @return JButton
1048
         */
1049
        private JButton getBtnExportar() {
1050
                if (btnExportar == null) {
1051
                        btnExportar = new JButton();
1052
                        btnExportar.setPreferredSize(new java.awt.Dimension(80, 23));
1053
                        btnExportar.setText(PluginServices.getText(this, "exportar"));
1054
                        btnExportar.setName("btnExportar");
1055
                        btnExportar.setMargin(new java.awt.Insets(2, 2, 2, 2));
1056
                        // TODO implement export
1057
                        btnExportar.setVisible(false);
1058
                }
1059

    
1060
                return btnExportar;
1061
        }
1062

    
1063
        /**
1064
         * This method initializes btnEditar
1065
         *
1066
         * @return JButton
1067
         */
1068
        private JButton getBtnEditar() {
1069
                if (btnEditar == null) {
1070
                        btnEditar = new JButton();
1071
                        btnEditar.setPreferredSize(new java.awt.Dimension(80, 23));
1072
                        btnEditar.setText(PluginServices.getText(this, "propiedades"));
1073

    
1074
                        btnEditar.setName("btnEditar");
1075
                        btnEditar.setMargin(new java.awt.Insets(2, 2, 2, 2));
1076

    
1077
                        btnEditar.addActionListener(new java.awt.event.ActionListener() {
1078
                                        public void actionPerformed(java.awt.event.ActionEvent e) {
1079
                                                ProjectProperties dlg = new ProjectProperties(p);
1080
                                                PluginServices.getMDIManager().addView(dlg);
1081
                                                refreshProperties();
1082
                                        }
1083
                                });
1084
                }
1085

    
1086
                return btnEditar;
1087
        }
1088

    
1089
        /**
1090
         * This method initializes jScrollPane
1091
         *
1092
         * @return JScrollPane
1093
         */
1094
        private JScrollPane getJScrollPane() {
1095
                if (jScrollPane == null) {
1096
                        jScrollPane = new JScrollPane();
1097
                        jScrollPane.setViewportView(getLstDocs());
1098
                        jScrollPane.setPreferredSize(new java.awt.Dimension(200, 100));
1099
                        jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
1100
                }
1101

    
1102
                return jScrollPane;
1103
        }
1104

    
1105
        /**
1106
         * @see com.iver.mdiApp.ui.MDIManager.SingletonView#getViewModel()
1107
         */
1108
        public Object getViewModel() {
1109
                return p;
1110
        }
1111

    
1112
    /**
1113
     * This method is used to get <strong>an initial</strong> ViewInfo object
1114
     * for this Project Manager window. It is not intended to retrieve the
1115
     * ViewInfo object in a later time.
1116
     * <strong>Use PluginServices.getMDIManager().getViewInfo(view)
1117
     * to retrieve the ViewInfo object at any time after the creation of the
1118
     * object.
1119
     *
1120
     * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
1121
     */
1122
        public ViewInfo getViewInfo() {
1123
                //if (m_viewInfo==null) {
1124
                        m_viewInfo = new ViewInfo();
1125
                        m_viewInfo.setWidth(this.getWidth()+8);
1126
                        m_viewInfo.setHeight(this.getHeight());
1127
                        m_viewInfo.setTitle(PluginServices.getText(this, "titulo"));
1128
                //}
1129
                return m_viewInfo;
1130
        }
1131

    
1132
        /**
1133
         * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
1134
         */
1135
        public void propertyChange(PropertyChangeEvent evt) {
1136
                refreshControls();
1137
        }
1138

    
1139
        /**
1140
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
1141
         */
1142
        public void viewActivated() {
1143
        }
1144

    
1145
        /**
1146
         * This method initializes jPanel4
1147
         *
1148
         * @return JPanel
1149
         */
1150
        private JPanel getJPanel4() {
1151
                if (jPanel4 == null) {
1152
                        jPanel4 = new JPanel();
1153

    
1154
                        jPanel4.setLayout(new FlowLayout(FlowLayout.RIGHT));
1155
                        jPanel4.setPreferredSize(new java.awt.Dimension(414, 30));
1156
                        jPanel4.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT);
1157
                        jPanel4.add(getBtnImportar(), null);
1158
                        jPanel4.add(getBtnExportar(), null);
1159
                        jPanel4.add(getBtnEditar(), null);
1160
                }
1161

    
1162
                return jPanel4;
1163
        }
1164
}  //  @jve:decl-index=0:visual-constraint="10,10"