svn-gvsig-desktop / trunk / applications / appCatalogYNomenclatorClient / src / es / gva / cit / gazetteer / ui / showResults / ShowResultsPanel.java @ 3613
History | View | Annotate | Download (9.66 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.gazetteer.ui.showResults; |
43 |
import es.gva.cit.catalogClient.traductor.ITranslator; |
44 |
import es.gva.cit.catalogClient.traductor.Translator; |
45 |
import es.gva.cit.gazetteer.querys.Feature; |
46 |
import java.awt.FlowLayout; |
47 |
import javax.swing.BoxLayout; |
48 |
import javax.swing.DefaultListModel; |
49 |
import javax.swing.JButton; |
50 |
import javax.swing.JLabel; |
51 |
import javax.swing.JList; |
52 |
import javax.swing.JPanel; |
53 |
import javax.swing.JScrollPane; |
54 |
|
55 |
/**
|
56 |
*
|
57 |
*
|
58 |
*
|
59 |
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
60 |
*/
|
61 |
public class ShowResultsPanel extends JPanel { |
62 |
/**
|
63 |
* <p></p>
|
64 |
*
|
65 |
*
|
66 |
*
|
67 |
* @poseidon-type es.gva.cit.gazetteer.querys.Feature
|
68 |
*/
|
69 |
public java.util.Collection features = new java.util.ArrayList(); |
70 |
/**
|
71 |
*
|
72 |
*
|
73 |
*/
|
74 |
private JPanel descriptionPanel = null; |
75 |
/**
|
76 |
*
|
77 |
*
|
78 |
*/
|
79 |
private JPanel linksPanel = null; |
80 |
/**
|
81 |
*
|
82 |
*
|
83 |
*/
|
84 |
private JButton mapButton = null; |
85 |
// @jve:decl-index=0:
|
86 |
/**
|
87 |
*
|
88 |
*
|
89 |
*/
|
90 |
private JScrollPane descriptionScroll = null; |
91 |
// @jve:decl-index=0:
|
92 |
/**
|
93 |
*
|
94 |
*
|
95 |
*/
|
96 |
private JLabel jLabel1 = null; |
97 |
/**
|
98 |
*
|
99 |
*
|
100 |
*/
|
101 |
private JPanel nextLastPanel = null; |
102 |
/**
|
103 |
*
|
104 |
*
|
105 |
*/
|
106 |
private JButton lastButton = null; |
107 |
/**
|
108 |
*
|
109 |
*
|
110 |
*/
|
111 |
private JLabel textLabel = null; |
112 |
/**
|
113 |
*
|
114 |
*
|
115 |
*/
|
116 |
private JButton nextButton = null; |
117 |
|
118 |
/**
|
119 |
*
|
120 |
*
|
121 |
*/
|
122 |
private int numPages; |
123 |
/**
|
124 |
*
|
125 |
*
|
126 |
*/
|
127 |
private JButton closeButton = null; |
128 |
/**
|
129 |
*
|
130 |
*
|
131 |
*/
|
132 |
private DefaultListModel listModel = null; |
133 |
/**
|
134 |
*
|
135 |
*
|
136 |
*/
|
137 |
private JList descriptionList = null; |
138 |
/**
|
139 |
*
|
140 |
*
|
141 |
*/
|
142 |
private ITranslator translator = null; |
143 |
|
144 |
/**
|
145 |
*
|
146 |
*
|
147 |
*
|
148 |
* @param features
|
149 |
* @param numPages
|
150 |
* @param recordsByPage
|
151 |
* @param translator
|
152 |
*/
|
153 |
public ShowResultsPanel(Feature[] features, int numPages, int recordsByPage, ITranslator translator) { |
154 |
super();
|
155 |
setFeatures(features); |
156 |
this.numPages = numPages;
|
157 |
this.translator = translator;
|
158 |
initialize(recordsByPage); |
159 |
} |
160 |
|
161 |
/**
|
162 |
* This method initializes this
|
163 |
*
|
164 |
*
|
165 |
* @param recordsByPage
|
166 |
*/
|
167 |
private void initialize(int recordsByPage) { |
168 |
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
169 |
this.setSize(465, 230); |
170 |
this.setPreferredSize(new java.awt.Dimension(465,230)); |
171 |
this.add(getNextLastPanel(), null); |
172 |
this.add(getDescriptionPanel(), null); |
173 |
this.add(getLinksPanel(), null); |
174 |
actualizaLabel(1,recordsByPage);
|
175 |
|
176 |
} |
177 |
|
178 |
/**
|
179 |
* It loads the feature list
|
180 |
*
|
181 |
*
|
182 |
* @param first
|
183 |
* @param last
|
184 |
*/
|
185 |
private void loadList(int first, int last) { |
186 |
if (features.size() < last)
|
187 |
last = features.size() - 1;
|
188 |
|
189 |
listModel.removeAllElements(); |
190 |
|
191 |
int index = 0; |
192 |
for (int i=first ; i<=last ; i++) |
193 |
if (i < features.size()){
|
194 |
listModel.add(index,getAllFeatures()[i]); |
195 |
index++; |
196 |
} |
197 |
} |
198 |
|
199 |
/**
|
200 |
* Actualiza el valor de la cadena de taexto que muestra los resultados
|
201 |
*
|
202 |
*
|
203 |
* @param number Registro actual
|
204 |
* @param recordsByPage
|
205 |
*/
|
206 |
public void actualizaLabel(int number, int recordsByPage) { |
207 |
textLabel.setText(Translator.getText(translator,"results") +
|
208 |
": "+String.valueOf(features.size()) + |
209 |
". " +
|
210 |
Translator.getText(translator,"page") + " " + |
211 |
String.valueOf(number) + " " + |
212 |
Translator.getText(translator,"of") + " " + |
213 |
" " +
|
214 |
String.valueOf(this.numPages)); |
215 |
loadList((number * recordsByPage) - recordsByPage,(number * recordsByPage)-1);
|
216 |
} |
217 |
|
218 |
/**
|
219 |
*
|
220 |
*
|
221 |
*
|
222 |
* @param mapButton The mapButton to set.
|
223 |
*/
|
224 |
public void setMapButton(JButton mapButton) { |
225 |
this.mapButton = mapButton;
|
226 |
} |
227 |
|
228 |
/**
|
229 |
* This method initializes jPanel
|
230 |
*
|
231 |
*
|
232 |
* @return javax.swing.JPanel
|
233 |
*/
|
234 |
private JPanel getDescriptionPanel() { |
235 |
if (descriptionPanel == null) { |
236 |
jLabel1 = new JLabel(); |
237 |
descriptionPanel = new JPanel(); |
238 |
descriptionPanel.setLayout(new FlowLayout()); |
239 |
descriptionPanel.setPreferredSize(new java.awt.Dimension(400,155)); |
240 |
jLabel1.setText("");
|
241 |
jLabel1.setPreferredSize(new java.awt.Dimension(40, 0)); |
242 |
descriptionPanel.add(getDescriptionScroll(), null);
|
243 |
|
244 |
} |
245 |
return descriptionPanel;
|
246 |
} |
247 |
|
248 |
/**
|
249 |
* This method initializes jPanel
|
250 |
*
|
251 |
*
|
252 |
* @return javax.swing.JPanel
|
253 |
*/
|
254 |
private JPanel getLinksPanel() { |
255 |
if (linksPanel == null) { |
256 |
linksPanel = new JPanel(); |
257 |
linksPanel.add(getMapButton(), null);
|
258 |
linksPanel.add(getCloseButton(), null);
|
259 |
} |
260 |
return linksPanel;
|
261 |
} |
262 |
|
263 |
/**
|
264 |
* This method initializes jButton 1
|
265 |
*
|
266 |
*
|
267 |
* @return javax.swing.JButton
|
268 |
*/
|
269 |
public JButton getMapButton() { |
270 |
if (mapButton == null) { |
271 |
mapButton = new JButton(); |
272 |
mapButton.setText(Translator.getText(translator,"localize"));
|
273 |
mapButton.setActionCommand("localize");
|
274 |
mapButton.setPreferredSize(new java.awt.Dimension(102, 26)); |
275 |
} |
276 |
return mapButton;
|
277 |
} |
278 |
|
279 |
/**
|
280 |
* This method initializes jScrollPane
|
281 |
*
|
282 |
*
|
283 |
* @return javax.swing.JScrollPane
|
284 |
*/
|
285 |
public JScrollPane getDescriptionScroll() { |
286 |
if (descriptionScroll == null) { |
287 |
descriptionScroll = new JScrollPane(); |
288 |
descriptionScroll.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
289 |
descriptionScroll.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
290 |
descriptionScroll.setPreferredSize(new java.awt.Dimension(400,150)); |
291 |
descriptionScroll.setViewportView(getDescriptionList()); |
292 |
} |
293 |
return descriptionScroll;
|
294 |
} |
295 |
|
296 |
/**
|
297 |
* This method initializes jPanel2
|
298 |
*
|
299 |
*
|
300 |
* @return javax.swing.JPanel
|
301 |
*/
|
302 |
private JPanel getNextLastPanel() { |
303 |
if (nextLastPanel == null) { |
304 |
textLabel = new JLabel(); |
305 |
nextLastPanel = new JPanel(); |
306 |
textLabel.setText("JLabel");
|
307 |
nextLastPanel.add(getLastButton(), null);
|
308 |
nextLastPanel.add(textLabel, null);
|
309 |
nextLastPanel.add(getNextButton(), null);
|
310 |
} |
311 |
return nextLastPanel;
|
312 |
} |
313 |
|
314 |
/**
|
315 |
* This method initializes jButton
|
316 |
*
|
317 |
*
|
318 |
* @return javax.swing.JButton
|
319 |
*/
|
320 |
public JButton getLastButton() { |
321 |
if (lastButton == null) { |
322 |
lastButton = new JButton(); |
323 |
lastButton.setText(Translator.getText(translator,"last"));
|
324 |
lastButton.setActionCommand("last");
|
325 |
lastButton.setEnabled(false);
|
326 |
} |
327 |
return lastButton;
|
328 |
} |
329 |
|
330 |
/**
|
331 |
* This method initializes jButton
|
332 |
*
|
333 |
*
|
334 |
* @return javax.swing.JButton
|
335 |
*/
|
336 |
public JButton getNextButton() { |
337 |
if (nextButton == null) { |
338 |
nextButton = new JButton(); |
339 |
nextButton.setText(Translator.getText(translator,"next"));
|
340 |
nextButton.setActionCommand("next");
|
341 |
if (this.numPages < 2) { |
342 |
nextButton.setEnabled(false);
|
343 |
} |
344 |
} |
345 |
return nextButton;
|
346 |
} |
347 |
|
348 |
/**
|
349 |
* This method initializes jButton
|
350 |
*
|
351 |
*
|
352 |
* @return javax.swing.JButton
|
353 |
*/
|
354 |
public JButton getCloseButton() { |
355 |
if (closeButton == null) { |
356 |
closeButton = new JButton(); |
357 |
closeButton.setText(Translator.getText(translator,"close"));
|
358 |
closeButton.setActionCommand("close");
|
359 |
closeButton.setPreferredSize(new java.awt.Dimension(102,26)); |
360 |
} |
361 |
return closeButton;
|
362 |
} |
363 |
|
364 |
/**
|
365 |
* This method initializes jList
|
366 |
*
|
367 |
*
|
368 |
* @return javax.swing.JList
|
369 |
*/
|
370 |
private JList getDescriptionList() { |
371 |
if (descriptionList == null) { |
372 |
listModel = new DefaultListModel(); |
373 |
descriptionList = new JList(listModel); |
374 |
} |
375 |
return descriptionList;
|
376 |
} |
377 |
|
378 |
/**
|
379 |
*
|
380 |
*
|
381 |
*
|
382 |
* @return
|
383 |
*/
|
384 |
public Feature getFeature() {
|
385 |
if (descriptionList.getSelectedIndex() == -1) |
386 |
return null; |
387 |
return (Feature) listModel.getElementAt(descriptionList.getSelectedIndex());
|
388 |
} |
389 |
|
390 |
/**
|
391 |
*
|
392 |
*
|
393 |
*
|
394 |
* @return
|
395 |
*/
|
396 |
public Feature[] getAllFeatures() { |
397 |
Feature[] aux = new Feature[features.size()]; |
398 |
for (int i=0 ; i<aux.length ; i++){ |
399 |
aux[i] = (Feature)features.toArray()[i]; |
400 |
} |
401 |
return aux;
|
402 |
} |
403 |
|
404 |
/**
|
405 |
*
|
406 |
*
|
407 |
*
|
408 |
* @param features
|
409 |
*/
|
410 |
public void setFeatures(Feature[] features) { |
411 |
this.features = new java.util.ArrayList(); |
412 |
for (int i=0 ; i<features.length ; i++){ |
413 |
this.features.add(features[i]);
|
414 |
} |
415 |
} |
416 |
} |
417 |
// @jve:decl-index=0:visual-constraint="107,10"
|