Statistics
| Revision:

root / trunk / applications / appCatalogAndGazetteerClient / src / es / gva / cit / catalog / ui / chooseresource / ChooseResourceDialogPanel.java @ 15558

History | View | Annotate | Download (5.05 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.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.i18n.Messages;
56

    
57
import es.gva.cit.catalog.schemas.Resource;
58
import es.gva.cit.catalog.utils.resourcestable.ButtonEditor;
59
import es.gva.cit.catalog.utils.resourcestable.ButtonRenderer;
60

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

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

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

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

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

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

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

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

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

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

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