Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / extensions / extPublish / src / org / gvsig / publish / gui / addResource / AddResourcePanel.java @ 22616

History | View | Annotate | Download (4.24 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004-2006 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 Iba?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.publish.gui.addResource;
42

    
43
import java.awt.event.ActionListener;
44
import java.util.EventListener;
45

    
46
import javax.swing.JPanel;
47
import javax.swing.event.TreeSelectionListener;
48
import javax.swing.tree.TreeSelectionModel;
49

    
50
import org.gvsig.gui.beans.swing.JButton;
51
import org.gvsig.publish.PublishLogger;
52
import org.gvsig.publish.infoproject.IProjectInfo;
53

    
54
import com.iver.andami.PluginServices;
55

    
56

    
57
public class AddResourcePanel extends JPanel {
58
        
59
        public AddResourcePanel(){
60
                super();
61
                initComponents();
62
                tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
63
                initLabels();                
64
        }
65
        private void initLabels(){                
66
                treePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(PluginServices.getText(this, "publish_resources")));
67
                addButton.setText(PluginServices.getText(this,"publish_add"));
68
        cancelButton.setText(PluginServices.getText(this, "publish_cancel"));
69
        }
70
    private void initComponents() {
71
        java.awt.GridBagConstraints gridBagConstraints;
72

    
73
        treePanel = new javax.swing.JPanel();
74
        jScrollPane1 = new javax.swing.JScrollPane();
75
        tree = new javax.swing.JTree();
76
        buttonsPanel = new javax.swing.JPanel();
77
        addButton = new JButton();
78
        cancelButton = new JButton();
79

    
80
        setLayout(new java.awt.BorderLayout());
81

    
82
        treePanel.setLayout(new java.awt.GridBagLayout());
83

    
84
        
85
        jScrollPane1.setViewportView(tree);
86

    
87
        gridBagConstraints = new java.awt.GridBagConstraints();
88
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
89
        gridBagConstraints.weightx = 1.0;
90
        gridBagConstraints.weighty = 1.0;
91
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
92
        treePanel.add(jScrollPane1, gridBagConstraints);
93

    
94
        add(treePanel, java.awt.BorderLayout.CENTER);
95

    
96
        buttonsPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
97

    
98
        
99
        buttonsPanel.add(addButton);
100

    
101
        buttonsPanel.add(cancelButton);
102

    
103
        add(buttonsPanel, java.awt.BorderLayout.SOUTH);
104

    
105
    }// </editor-fold>
106
    
107
    
108
    // Variables declaration - do not modify
109
    private JButton addButton;
110
    private javax.swing.JPanel buttonsPanel;
111
    private JButton cancelButton;
112
    private javax.swing.JScrollPane jScrollPane1;
113
    private javax.swing.JTree tree;
114
    private javax.swing.JPanel treePanel;
115
    // End of variables declaration
116
                  
117
        public void setListener(EventListener listener) {
118
                //Sets tree listener
119
                tree.addTreeSelectionListener((TreeSelectionListener) listener);
120
                //Sets buttons listener                
121
                addButton.addActionListener((ActionListener)listener);
122
                addButton.setActionCommand(AddResourceController.ADDRESOURCE_EVENT_ACCEPT);
123
                cancelButton.addActionListener((ActionListener)listener);
124
                cancelButton.setActionCommand(AddResourceController.ADDRESOURCE_EVENT_CANCEL);                
125
        }
126
         
127
                
128
        public void setModel(IProjectInfo project){
129
                if (project == null){
130
                        PublishLogger.getLog().error("ERROR AddResourcePanel: the project can't be null");                
131
                }else{                
132
                        tree.setModel(new ProjectInfoTreeModel(project));
133
                }
134
        }
135
}