Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / ui / chooseResource / ChooseResourceDialogPanel.java @ 3566

History | View | Annotate | Download (5.22 KB)

1

    
2
/* gvSIG. Sistema de Informaci??n Geogr??fica de la Generalitat Valenciana
3
*
4
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
*
20
* For more information, contact:
21
*
22
*  Generalitat Valenciana
23
*   Conselleria d'Infraestructures i Transport
24
*   Av. Blasco Ib????ez, 50
25
*   46010 VALENCIA
26
*   SPAIN
27
*
28
*      +34 963862235
29
*   gvsig@gva.es
30
*      www.gvsig.gva.es
31
*
32
*    or
33
*
34
*   IVER T.I. S.A
35
*   Salamanca 50
36
*   46005 Valencia
37
*   Spain
38
*
39
*   +34 963163400
40
*   dac@iver.es
41
*/
42
package es.gva.cit.catalogClient.ui.chooseResource;
43
import es.gva.cit.catalogClient.schemas.discoverer.Resource;
44
import es.gva.cit.catalogClient.traductor.ITranslator;
45
import es.gva.cit.catalogClient.traductor.Translator;
46
import es.gva.cit.catalogClient.utils.ResourcesTable.ButtonEditor;
47
import es.gva.cit.catalogClient.utils.ResourcesTable.ButtonRenderer;
48
import java.awt.Dimension;
49
import java.awt.FlowLayout;
50
import java.awt.event.ActionEvent;
51
import java.awt.event.ActionListener;
52
import java.util.Collection;
53
import javax.swing.BoxLayout;
54
import javax.swing.JButton;
55
import javax.swing.JCheckBox;
56
import javax.swing.JFrame;
57
import javax.swing.JPanel;
58

    
59
/**
60
 * this class represent the "choose resource frame". It is basically
61
 * contains ?? list with all the geo-resources that can be loaded. *
62
 * 
63
 * 
64
 * @author Jorge Piera Llodra (piera_jor@gva.es)
65
 */
66
public class ChooseResourceDialogPanel extends JPanel implements ActionListener {
67
//It is needed to close the frame
68
/**
69
 * 
70
 * 
71
 */
72
    private JFrame parent;
73
//Panels
74
/**
75
 * 
76
 * 
77
 */
78
    private JPanel ppalPanel = null;
79
/**
80
 * 
81
 * 
82
 */
83
    private ChooseResourcePanel controlsPanel = null;
84
/**
85
 * 
86
 * 
87
 */
88
    private JPanel buttonsPanel = null;
89
//Buttons
90
/**
91
 * 
92
 * 
93
 */
94
    private JButton cerrar = null;
95
//Others
96
/**
97
 * 
98
 * 
99
 */
100
    private ITranslator translator = null;
101

    
102
/**
103
 * 
104
 * 
105
 */
106
    private java.util.Collection resources = new java.util.ArrayList();
107

    
108
/**
109
 * This method initializes
110
 * 
111
 * 
112
 * @param resources 
113
 * @param translator 
114
 */
115
    public  ChooseResourceDialogPanel(Collection resources, ITranslator translator) {        
116
               
117
        this.resources = resources;
118
        this.translator = translator;
119
          
120
        ppalPanel = new JPanel();
121
        ppalPanel.setLayout(new BoxLayout(ppalPanel, BoxLayout.Y_AXIS));
122
        
123
        ppalPanel.add(getControlsPanel(), null);
124
        ppalPanel.add(getButtonPanel(), null);
125
        
126
        
127
        add(ppalPanel);
128
        setDefaultButtonListeners();
129
    } 
130

    
131
/**
132
 * 
133
 * 
134
 * 
135
 * @return 
136
 */
137
    public ChooseResourcePanel getControlsPanel() {        
138
        if (controlsPanel == null) {
139
            controlsPanel = new ChooseResourcePanel(resources,translator);
140
            controlsPanel.setPreferredSize(new java.awt.Dimension(575, 110));
141
            controlsPanel.setLocation(0, 0);
142
        }
143
        return controlsPanel;
144
    } 
145

    
146
/**
147
 * 
148
 * 
149
 * 
150
 * @return 
151
 */
152
    public JPanel getButtonPanel() {        
153
        if (buttonsPanel == null) {
154
            buttonsPanel = new JPanel(new FlowLayout());
155
            buttonsPanel.add(getCloseButton());
156
        }
157
        return buttonsPanel;
158
    } 
159

    
160
/**
161
 * 
162
 * 
163
 * 
164
 * @return 
165
 */
166
    public JButton getCloseButton() {        
167
        if (cerrar == null) {
168
            cerrar = new JButton(Translator.getText(translator,"close"));
169
            cerrar.setSize(new Dimension(30, 20));
170
            cerrar.setActionCommand("close");
171
        }
172
        return cerrar;
173
    } 
174

    
175
/**
176
 * 
177
 * 
178
 */
179
    public void setDefaultButtonListeners() {        
180
        getCloseButton().addActionListener(this);
181
        getControlsPanel().getTable().getColumn(Translator.getText(translator,"resourceShowColumn")).setCellRenderer(new ButtonRenderer());
182
        getControlsPanel().getTable().getColumn(Translator.getText(translator,"resourceShowColumn")).setCellEditor(new ButtonEditor(new JCheckBox(),resources,this));
183
        
184
    } 
185

    
186
/**
187
 * 
188
 * 
189
 * 
190
 * @param e 
191
 */
192
    public void actionPerformed(ActionEvent e) {        
193
        //Cerrar
194
        if (e.getActionCommand() == "close") {
195
           closeButtonActionPerformed();
196
        }   
197
        System.out.println(e.getActionCommand());
198
        
199
    } 
200

    
201
/**
202
 * 
203
 * 
204
 * 
205
 * @param resource 
206
 */
207
    public void resourceButtonActionPerformed(Resource resource) {        
208
        System.out.println(resource.getLinkage() + " no se puede cargar sin usar gvSIG");
209
    } 
210

    
211
/**
212
 * 
213
 * 
214
 */
215
    public void closeButtonActionPerformed() {        
216
       parent.setVisible(false);
217
    } 
218

    
219
/**
220
 * 
221
 * 
222
 * 
223
 * @param parent The parent to set.
224
 */
225
    public void setParent(JFrame parent) {        
226
        this.parent = parent;
227
    } 
228
 }