Statistics
| Revision:

gvsig-catalog / org.gvsig.catalog / branches / org.gvsig.catalog-CSW2.0.2 / org.gvsig.catalog / org.gvsig.catalog.lib / src / main / java / org / gvsig / catalog / ui / chooseresource / ChooseResourceDialogPanel.java @ 55

History | View | Annotate | Download (5.04 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 org.gvsig.catalog.ui.chooseresource;
43
import java.awt.Dimension;
44
import java.awt.FlowLayout;
45
import java.awt.event.ActionEvent;
46
import java.awt.event.ActionListener;
47
import java.util.Collection;
48

    
49
import javax.swing.BoxLayout;
50
import javax.swing.JButton;
51
import javax.swing.JCheckBox;
52
import javax.swing.JFrame;
53
import javax.swing.JPanel;
54

    
55
import org.gvsig.catalog.schemas.Resource;
56
import org.gvsig.catalog.utils.resourcestable.ButtonEditor;
57
import org.gvsig.catalog.utils.resourcestable.ButtonRenderer;
58
import org.gvsig.i18n.Messages;
59

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

    
98
/**
99
 * 
100
 * 
101
 */
102
    private java.util.Collection resources = new java.util.ArrayList();
103

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

    
126
/**
127
 * 
128
 * 
129
 * 
130
 * @return 
131
 */
132
    public ChooseResourcePanel getControlsPanel() {        
133
        if (controlsPanel == null) {
134
            controlsPanel = new ChooseResourcePanel(resources);
135
            controlsPanel.setPreferredSize(new java.awt.Dimension(575, 110));
136
            controlsPanel.setLocation(0, 0);
137
        }
138
        return controlsPanel;
139
    } 
140

    
141
/**
142
 * 
143
 * 
144
 * 
145
 * @return 
146
 */
147
    public JPanel getButtonPanel() {        
148
        if (buttonsPanel == null) {
149
            FlowLayout flowLayout = new FlowLayout();
150
            flowLayout.setAlignment(FlowLayout.RIGHT);
151
                buttonsPanel = new JPanel(flowLayout);
152
            buttonsPanel.add(getCloseButton());
153
        }
154
        return buttonsPanel;
155
    } 
156

    
157
/**
158
 * 
159
 * 
160
 * 
161
 * @return 
162
 */
163
    public JButton getCloseButton() {        
164
        if (cerrar == null) {
165
            cerrar = new JButton(Messages.getText("close"));
166
            cerrar.setPreferredSize(new Dimension(80, 23));
167
            cerrar.setActionCommand("close");
168
        }
169
        return cerrar;
170
    } 
171

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

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

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

    
208
/**
209
 * 
210
 * 
211
 */
212
    public void closeButtonActionPerformed() {        
213
       parent.setVisible(false);
214
    } 
215

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