Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_2_Build_897 / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / ui / chooseResource / ChooseResourceDialogPanel.java @ 10444

History | View | Annotate | Download (5.08 KB)

1 3566 jorpiell
2 3593 jorpiell
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3 3213 jorpiell
*
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 3593 jorpiell
*   Av. Blasco Ib??ez, 50
25 3213 jorpiell
*   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 3613 jorpiell
import es.gva.cit.catalogClient.schemas.discoverer.Resource;
44
import es.gva.cit.catalogClient.utils.ResourcesTable.ButtonEditor;
45
import es.gva.cit.catalogClient.utils.ResourcesTable.ButtonRenderer;
46 3213 jorpiell
import java.awt.Dimension;
47
import java.awt.FlowLayout;
48
import java.awt.event.ActionEvent;
49
import java.awt.event.ActionListener;
50 3566 jorpiell
import java.util.Collection;
51 3213 jorpiell
import javax.swing.BoxLayout;
52
import javax.swing.JButton;
53
import javax.swing.JCheckBox;
54
import javax.swing.JFrame;
55
import javax.swing.JPanel;
56
57 4713 cesar
import org.gvsig.i18n.Messages;
58
59 3213 jorpiell
/**
60 3463 jorpiell
 * this class represent the "choose resource frame". It is basically
61 3595 jorpiell
 * contains a list with all the geo-resources that can be loaded. *
62 3566 jorpiell
 *
63
 *
64 3213 jorpiell
 * @author Jorge Piera Llodra (piera_jor@gva.es)
65
 */
66
public class ChooseResourceDialogPanel extends JPanel implements ActionListener {
67 3566 jorpiell
//It is needed to close the frame
68
/**
69
 *
70
 *
71
 */
72 3213 jorpiell
    private JFrame parent;
73 3566 jorpiell
//Panels
74
/**
75
 *
76
 *
77
 */
78 3213 jorpiell
    private JPanel ppalPanel = null;
79 3566 jorpiell
/**
80
 *
81
 *
82
 */
83
    private ChooseResourcePanel controlsPanel = null;
84
/**
85
 *
86
 *
87
 */
88 3213 jorpiell
    private JPanel buttonsPanel = null;
89 3566 jorpiell
//Buttons
90
/**
91
 *
92
 *
93
 */
94 3213 jorpiell
    private JButton cerrar = null;
95 3566 jorpiell
//Others
96 3213 jorpiell
97 3566 jorpiell
/**
98
 *
99
 *
100
 */
101
    private java.util.Collection resources = new java.util.ArrayList();
102 3213 jorpiell
103 3566 jorpiell
/**
104
 * This method initializes
105
 *
106
 *
107
 * @param resources
108
 * @param translator
109
 */
110 4713 cesar
    public  ChooseResourceDialogPanel(Collection resources) {
111 3463 jorpiell
112 3213 jorpiell
        this.resources = resources;
113
114
        ppalPanel = new JPanel();
115
        ppalPanel.setLayout(new BoxLayout(ppalPanel, BoxLayout.Y_AXIS));
116
117
        ppalPanel.add(getControlsPanel(), null);
118
        ppalPanel.add(getButtonPanel(), null);
119
120
121
        add(ppalPanel);
122
        setDefaultButtonListeners();
123 3566 jorpiell
    }
124 3213 jorpiell
125 3566 jorpiell
/**
126
 *
127
 *
128
 *
129
 * @return
130
 */
131
    public ChooseResourcePanel getControlsPanel() {
132
        if (controlsPanel == null) {
133 4713 cesar
            controlsPanel = new ChooseResourcePanel(resources);
134 3566 jorpiell
            controlsPanel.setPreferredSize(new java.awt.Dimension(575, 110));
135
            controlsPanel.setLocation(0, 0);
136 3213 jorpiell
        }
137 3566 jorpiell
        return controlsPanel;
138
    }
139 3213 jorpiell
140 3566 jorpiell
/**
141
 *
142
 *
143
 *
144
 * @return
145
 */
146
    public JPanel getButtonPanel() {
147 3213 jorpiell
        if (buttonsPanel == null) {
148 4346 jorpiell
            FlowLayout flowLayout = new FlowLayout();
149
            flowLayout.setAlignment(FlowLayout.RIGHT);
150
                buttonsPanel = new JPanel(flowLayout);
151 3213 jorpiell
            buttonsPanel.add(getCloseButton());
152
        }
153
        return buttonsPanel;
154 3566 jorpiell
    }
155
156
/**
157
 *
158
 *
159
 *
160
 * @return
161
 */
162
    public JButton getCloseButton() {
163 3213 jorpiell
        if (cerrar == null) {
164 4713 cesar
            cerrar = new JButton(Messages.getText("close"));
165 4346 jorpiell
            cerrar.setPreferredSize(new Dimension(80, 23));
166 3463 jorpiell
            cerrar.setActionCommand("close");
167 3213 jorpiell
        }
168
        return cerrar;
169 3566 jorpiell
    }
170
171
/**
172
 *
173
 *
174
 */
175
    public void setDefaultButtonListeners() {
176 3213 jorpiell
        getCloseButton().addActionListener(this);
177 4713 cesar
        getControlsPanel().getTable().getColumn(Messages.getText("resourceShowColumn")).setCellRenderer(new ButtonRenderer());
178
        getControlsPanel().getTable().getColumn(Messages.getText("resourceShowColumn")).setCellEditor(new ButtonEditor(new JCheckBox(),resources,this));
179 3213 jorpiell
180 3566 jorpiell
    }
181
182
/**
183
 *
184
 *
185
 *
186
 * @param e
187
 */
188
    public void actionPerformed(ActionEvent e) {
189 3213 jorpiell
        //Cerrar
190 3463 jorpiell
        if (e.getActionCommand() == "close") {
191 3213 jorpiell
           closeButtonActionPerformed();
192
        }
193
        System.out.println(e.getActionCommand());
194
195 3566 jorpiell
    }
196
197
/**
198
 *
199
 *
200
 *
201
 * @param resource
202
 */
203
    public void resourceButtonActionPerformed(Resource resource) {
204 3213 jorpiell
        System.out.println(resource.getLinkage() + " no se puede cargar sin usar gvSIG");
205 3566 jorpiell
    }
206
207
/**
208
 *
209
 *
210
 */
211
    public void closeButtonActionPerformed() {
212 3213 jorpiell
       parent.setVisible(false);
213 3566 jorpiell
    }
214 3213 jorpiell
215 3566 jorpiell
/**
216
 *
217
 *
218
 *
219
 * @param parent The parent to set.
220
 */
221
    public void setParent(JFrame parent) {
222 3213 jorpiell
        this.parent = parent;
223 3566 jorpiell
    }
224 3213 jorpiell
 }