Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / gui / ProjectWindow.java @ 31496

History | View | Annotate | Download (29.1 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 org.gvsig.app.project.documents.gui;
42

    
43
import java.awt.Component;
44
import java.awt.FlowLayout;
45
import java.awt.GridBagConstraints;
46
import java.awt.GridBagLayout;
47
import java.awt.GridLayout;
48
import java.awt.Insets;
49
import java.beans.PropertyChangeEvent;
50
import java.beans.PropertyChangeListener;
51
import java.io.File;
52
import java.util.ArrayList;
53
import java.util.Collections;
54
import java.util.Comparator;
55
import java.util.List;
56

    
57
import javax.swing.ButtonGroup;
58
import javax.swing.JDialog;
59
import javax.swing.JLabel;
60
import javax.swing.JList;
61
import javax.swing.JOptionPane;
62
import javax.swing.JPanel;
63
import javax.swing.JRadioButton;
64
import javax.swing.JScrollPane;
65
import javax.swing.border.TitledBorder;
66

    
67
import org.gvsig.andami.PluginServices;
68
import org.gvsig.andami.help.Help;
69
import org.gvsig.andami.messages.NotificationManager;
70
import org.gvsig.andami.ui.mdiManager.IWindow;
71
import org.gvsig.andami.ui.mdiManager.SingletonWindow;
72
import org.gvsig.andami.ui.mdiManager.WindowInfo;
73
import org.gvsig.app.extension.ProjectExtension;
74
import org.gvsig.app.project.Project;
75
import org.gvsig.app.project.ProjectManager;
76
import org.gvsig.app.project.documents.Document;
77
import org.gvsig.app.project.documents.DocumentManager;
78
import org.gvsig.app.project.documents.AbstractDocument;
79
import org.gvsig.gui.beans.swing.JButton;
80
import org.gvsig.utils.DefaultListModel;
81

    
82
/**
83
 * Clase principal del proyecto donde se puede operar para crear cualquier tipo
84
 * de documento.
85
 * 
86
 * @author Vicente Caballero Navarro
87
 */
88
public class ProjectWindow extends JPanel implements PropertyChangeListener,
89
                IWindow, SingletonWindow {
90
        /**
91
         * 
92
         */
93
        private static final long serialVersionUID = 7315293357719796556L;
94
        private JPanel jPanel = null;
95
        private JRadioButton[] btnsDocuments = null;
96
        private ButtonGroup grupo = new ButtonGroup();
97
        private JPanel jPanel1 = null;
98
        private JList lstDocs = null;
99
        private JPanel jPanel2 = null;
100
        private JButton btnNuevo = null;
101
        private JButton btnPropiedades = null;
102
        private JButton btnAbrir = null;
103
        private JButton btnBorrar = null;
104
        private JButton btnRenombrar = null;
105
        private JPanel jPanel3 = null;
106
        private JLabel jLabel = null;
107
        private JLabel lblNombreSesion = null;
108
        private JLabel jLabel1 = null;
109
        private JLabel lblGuardado = null;
110
        private JLabel jLabel2 = null;
111
        private JLabel lblFecha = null;
112
        private JButton btnImportar = null;
113
        private JButton btnExportar = null;
114
        private JButton btnEditar = null;
115
        // The properties of the Project Manager window (size, position, etc):
116
        private WindowInfo m_viewInfo = null;
117

    
118
        private Project project;
119

    
120
        private JScrollPane jScrollPane = null;
121
        private JPanel jPanel4 = null;
122
        private JScrollPane jScrollPane1 = null;
123

    
124
        /**
125
         * This is the default constructor
126
         * 
127
         * @param project
128
         *            Extension
129
         */
130
        public ProjectWindow() {
131
                super();
132
                initialize();
133
                refreshControls();
134
                Help.getHelp().enableHelp(this, this.getClass().getName());
135
        }
136

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

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

    
172
        /**
173
         * Refresca la lista de elementos de proyecto con vistas, mapas o tablas,
174
         * seg?n la opci?n activada
175
         */
176
        private void refreshList() {
177
                if (project != null) {
178
                        DefaultListModel model = null;
179
                        String tituloMarco = PluginServices.getText(this,
180
                                        "documentos_existentes");
181

    
182
                        String doctype = getDocumentSelected();
183
                        model = new DefaultListModel(project.getDocuments(doctype));
184
                        tituloMarco = getDocumentSelectedName();
185

    
186
                        lstDocs.setModel(model);
187
                        ((TitledBorder) getJPanel1().getBorder()).setTitle(tituloMarco);
188
                        getJPanel1().repaint(1);
189
                        activarBotones();
190
                }
191
        }
192

    
193
        /**
194
         * Devuelve el nombre del tipo de documento activo (el mismo que
195
         * ProjectDocumentFactory.getRegisterName)
196
         * 
197
         * 
198
         * @return
199
         */
200

    
201
        public String getDocumentSelected() {
202
                JRadioButton btnSelected = null;
203
                for (int i = 0; i < btnsDocuments.length; i++) {
204
                        if (btnsDocuments[i].isSelected()) {
205
                                btnSelected = btnsDocuments[i];
206
                                return btnSelected.getName();
207
                        }
208
                }
209

    
210
                return null;
211
        }
212

    
213
        private String getDocumentSelectedName() {
214
                JRadioButton btnSelected = null;
215
                for (int i = 0; i < btnsDocuments.length; i++) {
216
                        if (btnsDocuments[i].isSelected()) {
217
                                btnSelected = btnsDocuments[i];
218
                                return btnSelected.getText();
219
                        }
220
                }
221

    
222
                return null;
223
        }
224

    
225
        /**
226
         * Refresca las etiquetas con la informaci?n del proyecto
227
         */
228
        private void refreshProperties() {
229
                if (project != null) {
230
                        lblNombreSesion.setText(project.getName());
231
                        String path = ProjectExtension.getPath();
232
                        if (path != null) {
233
                                File f = new File(path);
234
                                lblGuardado.setText(f.toString());
235
                        } else {
236
                                lblGuardado.setText("");
237
                        }
238
                        lblFecha.setText(project.getCreationDate());
239
                }
240
        }
241

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

    
250
        /**
251
         * This method initializes this
252
         */
253
        private void initialize() {
254
                GridBagConstraints gridBagConstraints = new GridBagConstraints();
255
                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
256
                gridBagConstraints.weightx = 1.0;
257
                gridBagConstraints.weighty = 1.0;
258
                GridBagLayout layout = new GridBagLayout();
259
                setLayout(layout);
260
                GridBagConstraints c = new GridBagConstraints();
261
                c.fill = GridBagConstraints.HORIZONTAL;
262
                c.weightx = 1.0;
263
                c.weighty = 0;
264
                c.gridy = 0;
265
                c.insets = new Insets(2, 5, 2, 5);
266

    
267
                layout.setConstraints(getJPanel(), c);
268
                add(getJPanel(), null);
269

    
270
                c.fill = GridBagConstraints.BOTH;
271
                c.gridy = 1;
272
                c.weightx = 1.0;
273
                c.weighty = 1.0;
274
                layout.setConstraints(getJPanel1(), c);
275
                add(getJPanel1(), null);
276
                c.fill = GridBagConstraints.HORIZONTAL;
277
                c.weightx = 0;
278
                c.weighty = 0;
279
                c.gridy = 2;
280
                layout.setConstraints(getJPanel3(), c);
281
                add(getJPanel3(), null);
282

    
283
                this.setSize(430, 544);
284
                this.setPreferredSize(new java.awt.Dimension(430, 554));
285
                this.setMinimumSize(new java.awt.Dimension(430, 554));
286
                this.add(getJScrollPane1(), gridBagConstraints);
287
                for (int i = 0; i < btnsDocuments.length; i++) {
288
                        grupo.add(btnsDocuments[i]);
289
                }
290
                if (btnsDocuments.length > 0) {
291
                        btnsDocuments[0].setSelected(true);
292
                }
293
        }
294

    
295
        private Document createDocumentInProject(String doctype) {
296
                try {
297
                        Document document = ProjectManager.getInstance()
298
                                        .createDocumentByUser(doctype);
299
                        if (document == null) {
300
                                return null;
301
                        }
302
                        project.add(document);
303
                        lstDocs.setSelectedIndex( ((DefaultListModel)lstDocs.getModel()).indexOf(document) );
304
                        return document;
305
                } catch (Exception e) {
306
                        NotificationManager.addError(e);
307
                }
308
                return null;
309
        }
310

    
311
        /**
312
         * Crea un nuevo project element
313
         * 
314
         * @throws Exception
315
         *             DOCUMENT ME!
316
         */
317
        private void newProjectDocument() throws Exception {
318
                String doctype = getDocumentSelected();
319
                createDocumentInProject(doctype);
320
        }
321

    
322
        /**
323
         * Abre la ventana de un nuevo documento
324
         */
325
        private void abrir() {
326
                int[] indexes = lstDocs.getSelectedIndices();
327
                for (int i = indexes.length - 1; i >= 0; i--) {
328
                        int index = indexes[i];
329
                        if (index == -1) {
330
                                return;
331
                        }
332
                        String doctype = getDocumentSelected();
333
                        List<Document> documents = project.getDocuments(doctype);
334
                        Document doc = documents.get(index);
335
                        IWindow window = doc.getFactory().getMainWindow(doc);
336
                        if (window == null) {
337
                                JOptionPane.showMessageDialog((Component) PluginServices
338
                                                .getMainFrame(), PluginServices.getText(this,
339
                                                "error_opening_the_document"));
340
                                return;
341
                        }
342
                        PluginServices.getMDIManager().addWindow(window);
343
                }
344
                project.setModified(true);
345
        }
346

    
347
        /**
348
         * Cambia el nombre de un project element
349
         */
350
        private void renombrar() {
351
                int index = lstDocs.getSelectedIndex();
352

    
353
                if (index == -1) {
354
                        return;
355
                }
356
                String doctype = getDocumentSelected();
357
                List<Document> documents = project.getDocuments(doctype);
358
                Document doc = documents.get(index);
359

    
360
                if (doc.isLocked()) {
361
                        JOptionPane.showMessageDialog(this, PluginServices.getText(this,
362
                                        "locked_element_it_cannot_be_renamed"));
363
                        return;
364
                }
365

    
366
                JOptionPane pane = new JOptionPane();
367
                pane.setMessage(PluginServices.getText(this, "introduce_nombre"));
368
                pane.setMessageType(JOptionPane.QUESTION_MESSAGE);
369
                pane.setWantsInput(true);
370
                pane.setInitialSelectionValue(doc.getName());
371
                pane.setInputValue(doc.getName());
372
                JDialog dlg = pane.createDialog((Component) PluginServices
373
                                .getMainFrame(), PluginServices.getText(this, "renombrar"));
374
                dlg.setModal(true);
375
                dlg.setVisible(true);
376

    
377
                String nuevoNombre = pane.getInputValue().toString().trim();
378

    
379
                if (nuevoNombre.length() == 0) {
380
                        return;
381
                }
382

    
383
                if (nuevoNombre == null) {
384
                        return;
385
                }
386

    
387
                for (int i = 0; i < lstDocs.getModel().getSize(); i++) {
388
                        if (i == index) {
389
                                continue;
390
                        }
391
                        if (((AbstractDocument) lstDocs.getModel().getElementAt(i))
392
                                        .getName().equals(nuevoNombre)) {
393
                                JOptionPane.showMessageDialog((Component) PluginServices
394
                                                .getMainFrame(), PluginServices.getText(this,
395
                                                "elemento_ya_existe"));
396
                                return;
397
                        }
398

    
399
                }
400
                doc.setName(nuevoNombre);
401

    
402
                refreshList();
403
                project.setModified(true);
404
        }
405

    
406
        /**
407
         * Borra un project element
408
         */
409
        private void borrar() {
410
                int res = JOptionPane.showConfirmDialog((Component) PluginServices
411
                                .getMainFrame(), PluginServices.getText(this,
412
                                "confirmar_borrar"), PluginServices.getText(this, "borrar"),
413
                                JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
414

    
415
                int lastremoved = 0;
416
                if (res == JOptionPane.YES_OPTION) {
417
                        int[] indexes = lstDocs.getSelectedIndices();
418
                        for (int i = indexes.length - 1; i >= 0; i--) {
419
                                int index = indexes[i];
420
                                String s = getDocumentSelected();
421
                                List<Document> documents = project.getDocuments(s);
422
                                Document doc = (AbstractDocument) documents.get(index);
423
                                if (doc.isLocked()) {
424
                                        JOptionPane.showMessageDialog(this, PluginServices.getText(
425
                                                        this, "locked_element_it_cannot_be_deleted"));
426
                                        return;
427
                                }
428
                                PluginServices.getMDIManager().closeSingletonWindow(doc);
429
                                project.remove(doc);
430
                                lastremoved = index;
431
                        }
432
                        if( lastremoved > lstDocs.getModel().getSize() ) {
433
                                lastremoved = lstDocs.getModel().getSize();
434
                        }
435
                        if( lastremoved > 0 ) {
436
                                lstDocs.setSelectedIndex(lastremoved);
437
                        }
438
                        refreshList();
439
                        project.setModified(true);
440
                }
441
        }
442

    
443
        /**
444
         * Muestra el di?logo de propiedades de un project element
445
         */
446
        private void propiedades() {
447
                int index = lstDocs.getSelectedIndex();
448

    
449
                if (index == -1) {
450
                        return;
451
                }
452

    
453
                IWindow dlg = null;
454
                String doctype = getDocumentSelected();
455
                List<Document> documents = project.getDocuments(doctype);
456
                Document doc = (AbstractDocument) documents.get(index);
457
                if (doc.isLocked()) {
458
                        JOptionPane.showMessageDialog(this, PluginServices.getText(this,
459
                                        "locked_element"));
460
                        return;
461
                }
462
                dlg = doc.getFactory().getPropertiesWindow(doc);
463
                PluginServices.getMDIManager().addWindow(dlg);
464

    
465
                refreshControls();
466
                lstDocs.setSelectedIndex(index);
467
                project.setModified(true);
468
        }
469

    
470
        /**
471
         * This method initializes jPanel
472
         * 
473
         * @return JPanel
474
         */
475
        private JPanel getJPanel() {
476
                if (jPanel == null) {
477
                        jPanel = new JPanel();
478

    
479
                        java.awt.FlowLayout layFlowLayout1 = new java.awt.FlowLayout();
480
                        layFlowLayout1.setHgap(15);
481
                        jPanel.setLayout(layFlowLayout1);
482
                        JRadioButton[] btns = getBtnDocuments();
483
                        for (int i = 0; i < btns.length; i++) {
484
                                jPanel.add(btns[i], null);
485
                        }
486
                        jPanel.setName("tipoDocPanel");
487
                        // jPanel.setPreferredSize(new java.awt.Dimension(700, 200));
488
                        jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
489
                                        PluginServices.getText(this, "tipos_de_documentos"),
490
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
491
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
492
                                        null));
493
                }
494

    
495
                return jPanel;
496
        }
497

    
498
        /**
499
         * This method initializes btnVistas
500
         * 
501
         * @return JRadioButton
502
         */
503
        private JRadioButton[] getBtnDocuments() {
504
                if (btnsDocuments == null) {
505

    
506
                        List<JRadioButton> btns = new ArrayList<JRadioButton>();
507
                        List<DocumentManager> factories = ProjectManager.getInstance()
508
                                        .getDocumentManager();
509
                        Collections.sort(factories, new Comparator<DocumentManager>() {
510
                                public int compare(DocumentManager arg0, DocumentManager arg1) {
511
                                        return arg0.getPriority() - arg1.getPriority();
512
                                }
513

    
514
                        });
515
                        for (DocumentManager documentFactory : factories) {
516
                                JRadioButton rb = new JRadioButton();
517

    
518
                                rb.setIcon(documentFactory.getIcon());
519
                                rb.setSelectedIcon(documentFactory.getIconSelected());
520
                                rb.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
521
                                rb.setText(documentFactory.getTitle());
522
                                rb.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
523
                                rb.setName(documentFactory.getTypeName());
524
                                rb.addChangeListener(new javax.swing.event.ChangeListener() {
525
                                        public void stateChanged(javax.swing.event.ChangeEvent e) {
526
                                                refreshList();
527
                                        }
528
                                });
529
                                btns.add(rb);
530
                        }
531
                        btnsDocuments = btns.toArray(new JRadioButton[0]);
532
                }
533
                return btnsDocuments;
534
        }
535

    
536
        /**
537
         * This method initializes jPanel1
538
         * 
539
         * @return JPanel
540
         */
541
        private JPanel getJPanel1() {
542
                if (jPanel1 == null) {
543
                        jPanel1 = new JPanel();
544

    
545
                        GridBagLayout layout2 = new GridBagLayout();
546
                        GridBagConstraints c = new GridBagConstraints();
547

    
548
                        jPanel1.setLayout(layout2);
549
                        c.insets = new Insets(2, 5, 2, 5);
550
                        c.anchor = GridBagConstraints.WEST;
551
                        c.fill = GridBagConstraints.BOTH;
552
                        c.weightx = 1.0;
553
                        c.weighty = 1.0;
554
                        layout2.setConstraints(getJScrollPane(), c);
555
                        jPanel1.add(getJScrollPane());
556

    
557
                        c.anchor = GridBagConstraints.EAST;
558

    
559
                        c.fill = GridBagConstraints.NONE;
560
                        c.weightx = 0;
561
                        c.weighty = 0;
562
                        layout2.setConstraints(getJPanel2(), c);
563
                        jPanel1.add(getJPanel2());
564

    
565
                        // jPanel1.setPreferredSize(new java.awt.Dimension(430,170));
566
                        jPanel1.setMinimumSize(new java.awt.Dimension(430, 170));
567
                        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
568
                                        null,
569
                                        PluginServices.getText(this, "documentos_existentes"),
570
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
571
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
572
                                        null));
573
                }
574

    
575
                return jPanel1;
576
        }
577

    
578
        /**
579
         * This method initializes lstDocs
580
         * 
581
         * @return JList
582
         */
583
        private JList getLstDocs() {
584
                if (lstDocs == null) {
585
                        lstDocs = new JList();
586
                        lstDocs.addMouseListener(new java.awt.event.MouseAdapter() {
587
                                public AbstractDocument[] getSelecteds() {
588
                                        if (lstDocs.getSelectedIndex() < 0) {
589
                                                return new AbstractDocument[0];
590
                                        }
591
                                        Object[] seleteds = lstDocs.getSelectedValues();
592
                                        AbstractDocument[] returnValue = new AbstractDocument[seleteds.length];
593
                                        System.arraycopy(seleteds, 0, returnValue, 0,
594
                                                        seleteds.length);
595
                                        return returnValue;
596
                                }
597

    
598
                                public AbstractDocument getItem(java.awt.event.MouseEvent e) {
599
                                        if (lstDocs.getSelectedIndex() < 0) {
600
                                                return null;
601
                                        }
602
                                        // Component c = lstDocs.getComponentAt(e.getPoint());
603

    
604
                                        return null;
605
                                }
606

    
607
                                public void mouseClicked(java.awt.event.MouseEvent e) {
608
                                        if (e.getButton() == java.awt.event.MouseEvent.BUTTON3) {
609
                                                /*
610
                                                 * getDocumentSelected();//ProjectView
611
                                                 * getDocumentSelectedName();//Vista
612
                                                 */
613
                                                String docType = getDocumentSelected();
614
                                                AbstractDocument[] selecteds = this.getSelecteds();
615

    
616
                                                if (selecteds == null) {
617
                                                        return;
618
                                                }
619
                                                DocumentContextMenu menu = new DocumentContextMenu(
620
                                                                docType, this.getItem(e), selecteds);
621
                                                if (!menu.hasActions()) {
622
                                                        return;
623
                                                }
624
                                                lstDocs.add(menu);
625
                                                menu.show(e.getComponent(), e.getX(), e.getY());
626
                                                return;
627
                                        }
628

    
629
                                        if (e.getClickCount() == 2) {
630
                                                abrir();
631
                                        }
632

    
633
                                }
634
                        });
635
                        lstDocs
636
                                        .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
637
                                                public void valueChanged(
638
                                                                javax.swing.event.ListSelectionEvent e) {
639
                                                        activarBotones();
640
                                                }
641
                                        });
642
                }
643

    
644
                return lstDocs;
645
        }
646

    
647
        /**
648
         * This method initializes jPanel2
649
         * 
650
         * @return JPanel
651
         */
652
        private JPanel getJPanel2() {
653
                if (jPanel2 == null) {
654
                        jPanel2 = new JPanel();
655

    
656
                        // FlowLayout layout = new FlowLayout();
657
                        GridLayout layout = new GridLayout(5, 1);
658
                        layout.setVgap(7);
659

    
660
                        jPanel2.setLayout(layout);
661
                        jPanel2.add(getBtnNuevo(), null);
662
                        jPanel2.add(getBtnAbrir(), null);
663
                        jPanel2.add(getBtnRenombrar(), null);
664
                        jPanel2.add(getBtnBorrar(), null);
665
                        jPanel2.add(getBtnPropiedades(), null);
666
                        jPanel2.setPreferredSize(new java.awt.Dimension(100, 150));
667
                        jPanel2.setMinimumSize(new java.awt.Dimension(100, 150));
668
                        jPanel2.setMaximumSize(new java.awt.Dimension(100, 150));
669
                }
670

    
671
                return jPanel2;
672
        }
673

    
674
        /**
675
         * This method initializes btnNuevo
676
         * 
677
         * @return JButton
678
         */
679
        private JButton getBtnNuevo() {
680
                if (btnNuevo == null) {
681
                        btnNuevo = new JButton();
682
                        btnNuevo.setName("btnNuevo");
683
                        btnNuevo.setText(PluginServices.getText(this, "nuevo"));
684
                        btnNuevo.setMargin(new java.awt.Insets(2, 2, 2, 2));
685
                        btnNuevo.addActionListener(new java.awt.event.ActionListener() {
686
                                public void actionPerformed(java.awt.event.ActionEvent e) {
687
                                        try {
688
                                                newProjectDocument();
689
                                        } catch (Exception e1) {
690
                                                NotificationManager.addError(e1.getLocalizedMessage(),
691
                                                                e1);
692
                                        }
693
                                }
694
                        });
695
                }
696

    
697
                return btnNuevo;
698
        }
699

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

    
720
                return btnPropiedades;
721
        }
722

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

    
742
                return btnAbrir;
743
        }
744

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

    
764
                return btnBorrar;
765
        }
766

    
767
        /**
768
         * This method initializes btnRenombrar
769
         * 
770
         * @return JButton
771
         */
772
        private JButton getBtnRenombrar() {
773
                if (btnRenombrar == null) {
774
                        btnRenombrar = new JButton();
775
                        btnRenombrar.setName("btnRenombrar");
776
                        btnRenombrar.setText(PluginServices.getText(this, "renombrar"));
777
                        btnRenombrar.setEnabled(false);
778
                        btnRenombrar.setMargin(new java.awt.Insets(2, 2, 2, 2));
779
                        btnRenombrar.addActionListener(new java.awt.event.ActionListener() {
780
                                public void actionPerformed(java.awt.event.ActionEvent e) {
781
                                        renombrar();
782
                                }
783
                        });
784
                }
785

    
786
                return btnRenombrar;
787
        }
788

    
789
        /**
790
         * This method initializes jPanel3
791
         * 
792
         * @return JPanel
793
         */
794
        private JPanel getJPanel3() {
795
                if (jPanel3 == null) {
796
                        jPanel3 = new JPanel();
797

    
798
                        GridBagLayout layout3 = new GridBagLayout();
799
                        GridBagConstraints c = new GridBagConstraints();
800
                        jPanel3.setLayout(layout3);
801
                        c.insets = new Insets(2, 5, 0, 5);
802
                        c.anchor = GridBagConstraints.WEST;
803
                        c.gridx = 0;
804
                        c.gridy = 0;
805
                        layout3.setConstraints(getJLabel(), c);
806
                        jPanel3.add(getJLabel(), null);
807
                        c.fill = GridBagConstraints.HORIZONTAL;
808
                        c.weightx = 1.0;
809
                        c.gridx = 1;
810
                        layout3.setConstraints(getLblNombreSesion(), c);
811
                        jPanel3.add(getLblNombreSesion(), null);
812

    
813
                        c.gridx = 0;
814
                        c.gridy = 1;
815
                        c.fill = GridBagConstraints.NONE;
816
                        c.weightx = 0.0;
817
                        layout3.setConstraints(getJLabel1(), c);
818
                        jPanel3.add(getJLabel1(), null);
819
                        c.fill = GridBagConstraints.HORIZONTAL;
820
                        c.weightx = 1.0;
821
                        c.gridx = 1;
822
                        layout3.setConstraints(getLblGuardado(), c);
823
                        jPanel3.add(getLblGuardado(), null);
824

    
825
                        c.gridx = 0;
826
                        c.gridy = 2;
827
                        c.fill = GridBagConstraints.NONE;
828
                        c.weightx = 0.0;
829
                        layout3.setConstraints(getJLabel2(), c);
830
                        jPanel3.add(getJLabel2(), null);
831

    
832
                        c.fill = GridBagConstraints.HORIZONTAL;
833
                        c.weightx = 1.0;
834
                        c.gridx = 1;
835
                        layout3.setConstraints(getLblFecha(), c);
836
                        jPanel3.add(getLblFecha(), null);
837
                        jPanel3.setPreferredSize(new java.awt.Dimension(430, 125));
838
                        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(
839
                                        null, PluginServices.getText(this, "propiedades_sesion"),
840
                                        javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
841
                                        javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
842
                                        null));
843
                        c.gridx = 1;
844
                        c.gridy = 4;
845
                        c.anchor = GridBagConstraints.EAST;
846
                        layout3.setConstraints(getJPanel4(), c);
847
                        jPanel3.add(getJPanel4(), null);
848
                }
849

    
850
                return jPanel3;
851
        }
852

    
853
        /**
854
         * This method initializes jLabel
855
         * 
856
         * @return JLabel
857
         */
858
        private JLabel getJLabel() {
859
                if (jLabel == null) {
860
                        jLabel = new JLabel();
861
                        jLabel.setText(PluginServices.getText(this, "nombre_sesion") + ":");
862
                        jLabel.setPreferredSize(new java.awt.Dimension(150, 16));
863
                }
864

    
865
                return jLabel;
866
        }
867

    
868
        /**
869
         * This method initializes lblNombreSesion
870
         * 
871
         * @return JLabel
872
         */
873
        private JLabel getLblNombreSesion() {
874
                if (lblNombreSesion == null) {
875
                        lblNombreSesion = new JLabel();
876
                        lblNombreSesion.setText("");
877
                        lblNombreSesion.setName("lblNombreSesion");
878
                        lblNombreSesion.setPreferredSize(new java.awt.Dimension(200, 16));
879
                        lblNombreSesion.setAutoscrolls(true);
880
                }
881

    
882
                return lblNombreSesion;
883
        }
884

    
885
        /**
886
         * This method initializes jLabel1
887
         * 
888
         * @return JLabel
889
         */
890
        private JLabel getJLabel1() {
891
                if (jLabel1 == null) {
892
                        jLabel1 = new JLabel();
893
                        jLabel1.setText(PluginServices.getText(this, "guardado") + ":");
894
                        jLabel1.setPreferredSize(new java.awt.Dimension(150, 16));
895
                }
896

    
897
                return jLabel1;
898
        }
899

    
900
        /**
901
         * This method initializes lblGuardado
902
         * 
903
         * @return JLabel
904
         */
905
        private JLabel getLblGuardado() {
906
                if (lblGuardado == null) {
907
                        lblGuardado = new JLabel();
908
                        lblGuardado.setText("");
909
                        lblGuardado.setPreferredSize(new java.awt.Dimension(200, 16));
910
                        lblGuardado.setAutoscrolls(true);
911
                }
912

    
913
                return lblGuardado;
914
        }
915

    
916
        /**
917
         * This method initializes jLabel2
918
         * 
919
         * @return JLabel
920
         */
921
        private JLabel getJLabel2() {
922
                if (jLabel2 == null) {
923
                        jLabel2 = new JLabel();
924
                        jLabel2
925
                                        .setText(PluginServices.getText(this, "creation_date")
926
                                                        + ":");
927
                        jLabel2.setPreferredSize(new java.awt.Dimension(150, 16));
928
                }
929

    
930
                return jLabel2;
931
        }
932

    
933
        /**
934
         * This method initializes lblFecha
935
         * 
936
         * @return JLabel
937
         */
938
        private JLabel getLblFecha() {
939
                if (lblFecha == null) {
940
                        lblFecha = new JLabel();
941
                        lblFecha.setText("");
942
                        lblFecha.setPreferredSize(new java.awt.Dimension(200, 16));
943
                        lblFecha.setAutoscrolls(true);
944
                }
945

    
946
                return lblFecha;
947
        }
948

    
949
        /**
950
         * This method initializes btnImportar
951
         * 
952
         * @return JButton
953
         */
954
        private JButton getBtnImportar() {
955
                if (btnImportar == null) {
956
                        btnImportar = new JButton();
957
                        btnImportar.setPreferredSize(new java.awt.Dimension(80, 23));
958
                        btnImportar.setText(PluginServices.getText(this, "importar"));
959
                        btnImportar.setName("btnImportar");
960
                        btnImportar.setMargin(new java.awt.Insets(2, 2, 2, 2));
961
                        // TODO implement import
962
                        btnImportar.setVisible(false);
963
                }
964

    
965
                return btnImportar;
966
        }
967

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

    
984
                return btnExportar;
985
        }
986

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

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

    
1001
                        btnEditar.addActionListener(new java.awt.event.ActionListener() {
1002
                                public void actionPerformed(java.awt.event.ActionEvent e) {
1003
                                        ProjectProperties dlg = new ProjectProperties(project);
1004
                                        PluginServices.getMDIManager().addWindow(dlg);
1005
                                        refreshProperties();
1006
                                }
1007
                        });
1008
                }
1009

    
1010
                return btnEditar;
1011
        }
1012

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

    
1027
                return jScrollPane;
1028
        }
1029

    
1030
        /**
1031
         * @see com.iver.mdiApp.ui.MDIManager.SingletonWindow#getWindowModel()
1032
         */
1033
        public Object getWindowModel() {
1034
                return project;
1035
        }
1036

    
1037
        public Project getProject() {
1038
                return project;
1039
        }
1040

    
1041
        /**
1042
         * This method is used to get <strong>an initial</strong> ViewInfo object
1043
         * for this Project Manager window. It is not intended to retrieve the
1044
         * ViewInfo object in a later time. <strong>Use
1045
         * PluginServices.getMDIManager().getViewInfo(view) to retrieve the ViewInfo
1046
         * object at any time after the creation of the object.
1047
         * 
1048
         * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
1049
         */
1050
        public WindowInfo getWindowInfo() {
1051
                if (m_viewInfo == null) {
1052
                        m_viewInfo = new WindowInfo(WindowInfo.MAXIMIZABLE);
1053
                        // m_viewInfo = new
1054
                        // ViewInfo(ViewInfo.MAXIMIZABLE+ViewInfo.RESIZABLE);
1055
                        m_viewInfo.setWidth(this.getWidth());
1056
                        m_viewInfo.setHeight(this.getHeight());
1057
                        m_viewInfo.setNormalWidth(this.getPreferredSize().width);
1058
                        m_viewInfo.setNormalHeight(this.getPreferredSize().height);
1059

    
1060
                        m_viewInfo.setTitle(PluginServices.getText(this, "titulo"));
1061
                }
1062
                return m_viewInfo;
1063
        }
1064

    
1065
        /**
1066
         * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
1067
         */
1068
        public void propertyChange(PropertyChangeEvent evt) {
1069
                refreshControls();
1070
        }
1071

    
1072
        // /**
1073
        // * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
1074
        // */
1075
        // public void viewActivated() {
1076
        // // do nothing
1077
        // }
1078

    
1079
        /**
1080
         * This method initializes jPanel4
1081
         * 
1082
         * @return JPanel
1083
         */
1084
        private JPanel getJPanel4() {
1085
                if (jPanel4 == null) {
1086
                        jPanel4 = new JPanel();
1087

    
1088
                        jPanel4.setLayout(new FlowLayout(FlowLayout.RIGHT));
1089
                        jPanel4.setPreferredSize(new java.awt.Dimension(414, 30));
1090
                        jPanel4
1091
                                        .setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT);
1092
                        jPanel4.add(getBtnImportar(), null);
1093
                        jPanel4.add(getBtnExportar(), null);
1094
                        jPanel4.add(getBtnEditar(), null);
1095
                }
1096

    
1097
                return jPanel4;
1098
        }
1099

    
1100
        /**
1101
         * This method initializes jScrollPane1
1102
         * 
1103
         * @return javax.swing.JScrollPane
1104
         */
1105
        private JScrollPane getJScrollPane1() {
1106
                if (jScrollPane1 == null) {
1107
                        jScrollPane1 = new JScrollPane();
1108
                        jScrollPane1
1109
                                        .setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_NEVER);
1110
                        jScrollPane1.setPreferredSize(new java.awt.Dimension(433, 200));
1111
                        jScrollPane1.setViewportView(getJPanel());
1112
                }
1113
                return jScrollPane1;
1114
        }
1115

    
1116
        public Object getWindowProfile() {
1117
                return WindowInfo.PROJECT_PROFILE;
1118
        }
1119

    
1120
}