Statistics
| Revision:

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

History | View | Annotate | Download (5.32 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.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 3213 jorpiell
import java.awt.Dimension;
49
import java.awt.FlowLayout;
50
import java.awt.event.ActionEvent;
51
import java.awt.event.ActionListener;
52 3566 jorpiell
import java.util.Collection;
53 3213 jorpiell
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 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
/**
97
 *
98
 *
99
 */
100 3789 jorpiell
    protected ITranslator translator = null;
101 3213 jorpiell
102 3566 jorpiell
/**
103
 *
104
 *
105
 */
106
    private java.util.Collection resources = new java.util.ArrayList();
107 3213 jorpiell
108 3566 jorpiell
/**
109
 * This method initializes
110
 *
111
 *
112
 * @param resources
113
 * @param translator
114
 */
115
    public  ChooseResourceDialogPanel(Collection resources, ITranslator translator) {
116 3463 jorpiell
117 3213 jorpiell
        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 3566 jorpiell
    }
130 3213 jorpiell
131 3566 jorpiell
/**
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 3213 jorpiell
        }
143 3566 jorpiell
        return controlsPanel;
144
    }
145 3213 jorpiell
146 3566 jorpiell
/**
147
 *
148
 *
149
 *
150
 * @return
151
 */
152
    public JPanel getButtonPanel() {
153 3213 jorpiell
        if (buttonsPanel == null) {
154 4392 jorpiell
            FlowLayout flowLayout = new FlowLayout();
155
            flowLayout.setAlignment(FlowLayout.RIGHT);
156
                buttonsPanel = new JPanel(flowLayout);
157 3213 jorpiell
            buttonsPanel.add(getCloseButton());
158
        }
159
        return buttonsPanel;
160 3566 jorpiell
    }
161
162
/**
163
 *
164
 *
165
 *
166
 * @return
167
 */
168
    public JButton getCloseButton() {
169 3213 jorpiell
        if (cerrar == null) {
170 3463 jorpiell
            cerrar = new JButton(Translator.getText(translator,"close"));
171 4392 jorpiell
            cerrar.setPreferredSize(new Dimension(80, 23));
172 3463 jorpiell
            cerrar.setActionCommand("close");
173 3213 jorpiell
        }
174
        return cerrar;
175 3566 jorpiell
    }
176
177
/**
178
 *
179
 *
180
 */
181
    public void setDefaultButtonListeners() {
182 3213 jorpiell
        getCloseButton().addActionListener(this);
183
        getControlsPanel().getTable().getColumn(Translator.getText(translator,"resourceShowColumn")).setCellRenderer(new ButtonRenderer());
184
        getControlsPanel().getTable().getColumn(Translator.getText(translator,"resourceShowColumn")).setCellEditor(new ButtonEditor(new JCheckBox(),resources,this));
185
186 3566 jorpiell
    }
187
188
/**
189
 *
190
 *
191
 *
192
 * @param e
193
 */
194
    public void actionPerformed(ActionEvent e) {
195 3213 jorpiell
        //Cerrar
196 3463 jorpiell
        if (e.getActionCommand() == "close") {
197 3213 jorpiell
           closeButtonActionPerformed();
198
        }
199
        System.out.println(e.getActionCommand());
200
201 3566 jorpiell
    }
202
203
/**
204
 *
205
 *
206
 *
207
 * @param resource
208
 */
209
    public void resourceButtonActionPerformed(Resource resource) {
210 3213 jorpiell
        System.out.println(resource.getLinkage() + " no se puede cargar sin usar gvSIG");
211 3566 jorpiell
    }
212
213
/**
214
 *
215
 *
216
 */
217
    public void closeButtonActionPerformed() {
218 3213 jorpiell
       parent.setVisible(false);
219 3566 jorpiell
    }
220 3213 jorpiell
221 3566 jorpiell
/**
222
 *
223
 *
224
 *
225
 * @param parent The parent to set.
226
 */
227
    public void setParent(JFrame parent) {
228 3213 jorpiell
        this.parent = parent;
229 3566 jorpiell
    }
230 3213 jorpiell
 }