svn-gvsig-desktop / tags / Root_v06 / applications / appCatalogYNomenclatorClient / src / es / gva / cit / catalogClient / ui / chooseResource / ChooseResourceDialogPanel.java @ 4811
History | View | Annotate | Download (5.32 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 a 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 |
protected 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 |
FlowLayout flowLayout = new FlowLayout(); |
155 |
flowLayout.setAlignment(FlowLayout.RIGHT);
|
156 |
buttonsPanel = new JPanel(flowLayout); |
157 |
buttonsPanel.add(getCloseButton()); |
158 |
} |
159 |
return buttonsPanel;
|
160 |
} |
161 |
|
162 |
/**
|
163 |
*
|
164 |
*
|
165 |
*
|
166 |
* @return
|
167 |
*/
|
168 |
public JButton getCloseButton() { |
169 |
if (cerrar == null) { |
170 |
cerrar = new JButton(Translator.getText(translator,"close")); |
171 |
cerrar.setPreferredSize(new Dimension(80, 23)); |
172 |
cerrar.setActionCommand("close");
|
173 |
} |
174 |
return cerrar;
|
175 |
} |
176 |
|
177 |
/**
|
178 |
*
|
179 |
*
|
180 |
*/
|
181 |
public void setDefaultButtonListeners() { |
182 |
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 |
} |
187 |
|
188 |
/**
|
189 |
*
|
190 |
*
|
191 |
*
|
192 |
* @param e
|
193 |
*/
|
194 |
public void actionPerformed(ActionEvent e) { |
195 |
//Cerrar
|
196 |
if (e.getActionCommand() == "close") { |
197 |
closeButtonActionPerformed(); |
198 |
} |
199 |
System.out.println(e.getActionCommand());
|
200 |
|
201 |
} |
202 |
|
203 |
/**
|
204 |
*
|
205 |
*
|
206 |
*
|
207 |
* @param resource
|
208 |
*/
|
209 |
public void resourceButtonActionPerformed(Resource resource) { |
210 |
System.out.println(resource.getLinkage() + " no se puede cargar sin usar gvSIG"); |
211 |
} |
212 |
|
213 |
/**
|
214 |
*
|
215 |
*
|
216 |
*/
|
217 |
public void closeButtonActionPerformed() { |
218 |
parent.setVisible(false);
|
219 |
} |
220 |
|
221 |
/**
|
222 |
*
|
223 |
*
|
224 |
*
|
225 |
* @param parent The parent to set.
|
226 |
*/
|
227 |
public void setParent(JFrame parent) { |
228 |
this.parent = parent;
|
229 |
} |
230 |
} |