root / trunk / libraries / libUI / src / org / gvsig / gui / beans / comboBoxItemsSeeker / ComboBoxItemsSeekerConfigurableModel.java @ 7964
History | View | Annotate | Download (17.7 KB)
1 |
package org.gvsig.gui.beans.comboBoxItemsSeeker; |
---|---|
2 |
|
3 |
import java.util.Arrays; |
4 |
import java.util.Collections; |
5 |
import java.util.List; |
6 |
import java.util.Vector; |
7 |
|
8 |
|
9 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
10 |
*
|
11 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
12 |
*
|
13 |
* This program is free software; you can redistribute it and/or
|
14 |
* modify it under the terms of the GNU General Public License
|
15 |
* as published by the Free Software Foundation; either version 2
|
16 |
* of the License, or (at your option) any later version.
|
17 |
*
|
18 |
* This program is distributed in the hope that it will be useful,
|
19 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21 |
* GNU General Public License for more details.
|
22 |
*
|
23 |
* You should have received a copy of the GNU General Public License
|
24 |
* along with this program; if not, write to the Free Software
|
25 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
26 |
*
|
27 |
* For more information, contact:
|
28 |
*
|
29 |
* Generalitat Valenciana
|
30 |
* Conselleria d'Infraestructures i Transport
|
31 |
* Av. Blasco Ib??ez, 50
|
32 |
* 46010 VALENCIA
|
33 |
* SPAIN
|
34 |
*
|
35 |
* +34 963862235
|
36 |
* gvsig@gva.es
|
37 |
* www.gvsig.gva.es
|
38 |
*
|
39 |
* or
|
40 |
*
|
41 |
* IVER T.I. S.A
|
42 |
* Salamanca 50
|
43 |
* 46005 Valencia
|
44 |
* Spain
|
45 |
*
|
46 |
* +34 963163400
|
47 |
* dac@iver.es
|
48 |
*/
|
49 |
|
50 |
/**
|
51 |
* This class inherits of 'AbstractDefaultComboBoxItemsSeekerConfigurableModel' and can be used with repeated items or not. If there aren't
|
52 |
* repeated items this model works worse than 'ComboBoxSingularItemsSeekerConfigurableModel', and it's recommended use it.
|
53 |
* It's probably that this model work slow, more when more items had.
|
54 |
*
|
55 |
* Limitations: This model works slowly if has a lot of items, and if no item is repeated works much worse than using 'ComboBoxSingularItemsSeekerConfigurableModel':
|
56 |
* needs more time.
|
57 |
*
|
58 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
59 |
*/
|
60 |
public class ComboBoxItemsSeekerConfigurableModel extends AbstractDefaultComboBoxItemsSeekerConfigurableModel implements java.io.Serializable { |
61 |
private static final long serialVersionUID = -4551182962607749953L; |
62 |
|
63 |
// INNER MODEL STRUCTURES
|
64 |
private Vector itemsShowed; |
65 |
// END INNER MODEL STRUCTURES
|
66 |
|
67 |
// OTHER FLAGS
|
68 |
protected boolean thisIsAComboBoxItemsSeekerConfigurableModelClassInialized=false; // To distinguish the class which invokes some methods of this class |
69 |
private boolean itemsShowedIsOrdered; |
70 |
// END OTHER FLAGS
|
71 |
|
72 |
|
73 |
/**
|
74 |
* Default constructor without parameters
|
75 |
*
|
76 |
* @see AbstractDefaultComboBoxItemsSeekerConfigurableModel#AbstractDefaultComboBoxItemsSeekerConfigurableModel()
|
77 |
*/
|
78 |
public ComboBoxItemsSeekerConfigurableModel() {
|
79 |
super();
|
80 |
this.initialize();
|
81 |
} |
82 |
|
83 |
/**
|
84 |
* Default constructor with an array as a parameter
|
85 |
*
|
86 |
* @see AbstractDefaultComboBoxItemsSeekerConfigurableModel#AbstractDefaultComboBoxItemsSeekerConfigurableModel(Object[])
|
87 |
*/
|
88 |
public ComboBoxItemsSeekerConfigurableModel(Object[] items) { |
89 |
super(items);
|
90 |
this.initialize();
|
91 |
this.itemsShowed.addAll(Arrays.asList(items)); |
92 |
} |
93 |
|
94 |
/**
|
95 |
* Default constructor with a Vector as a parameter
|
96 |
*
|
97 |
* @see AbstractDefaultComboBoxItemsSeekerConfigurableModel#AbstractDefaultComboBoxItemsSeekerConfigurableModel(Vector)
|
98 |
*/
|
99 |
public ComboBoxItemsSeekerConfigurableModel(Vector objects) { |
100 |
super(objects);
|
101 |
this.initialize();
|
102 |
this.itemsShowed.addAll(objects);
|
103 |
} |
104 |
|
105 |
/*
|
106 |
* (non-Javadoc)
|
107 |
* @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#initialize()
|
108 |
*/
|
109 |
protected void initialize() { |
110 |
super.initialize();
|
111 |
logger.debug("Se ejecuta el initialize del hijo");
|
112 |
|
113 |
thisIsAComboBoxItemsSeekerConfigurableModelClassInialized = true;
|
114 |
this.itemsShowed = new Vector(); |
115 |
itemsShowedIsOrdered = false;
|
116 |
} |
117 |
|
118 |
|
119 |
////// REIMPLEMENTATION OF SOME METHODS OF "DefaultComboBoxModel" TO ADAPT THE BEHAVIOR OF THIS MODEL //////
|
120 |
|
121 |
/*
|
122 |
* (non-Javadoc)
|
123 |
* @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#addElement(java.lang.Object)
|
124 |
*/
|
125 |
public void addElement(Object anObject) { |
126 |
super.addElementToParent(anObject); // this adds the element and selects by default the first item added |
127 |
|
128 |
// Add the item also in the inner attribute
|
129 |
this.itemsShowed.add(anObject);
|
130 |
this.reset();
|
131 |
|
132 |
itemsShowedIsOrdered = false;
|
133 |
} |
134 |
|
135 |
/*
|
136 |
* (non-Javadoc)
|
137 |
* @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#getElementAt(int)
|
138 |
*/
|
139 |
public Object getElementAt(int index) { |
140 |
if (!this.thisIsAComboBoxItemsSeekerConfigurableModelClassInialized) |
141 |
return super.getParentElementAt(index); |
142 |
|
143 |
if (!itemsShowedIsOrdered)
|
144 |
this.sortItemsShowedVector();
|
145 |
|
146 |
if (this.startState) // At the beginning shows all items |
147 |
{ |
148 |
switch(this.getStartBehavior()) |
149 |
{ |
150 |
case MAINTAIN_ORIGINAL_POSITION_START :
|
151 |
return super.getParentElementAt(index); |
152 |
case ORDERED_START :
|
153 |
if ((!this.itemsInTheArray) || (this.stateAllItems != STATE_ITEMS_ARE_ORDERED)) |
154 |
this.setItemsCopyToArray();
|
155 |
|
156 |
// Return the item at that position
|
157 |
return this.itemsSearchesShow[index]; |
158 |
case DISORDERED_START :
|
159 |
if (!this.itemsInTheArray) |
160 |
this.setItemsCopyToArray();
|
161 |
|
162 |
// If the items aren't disordered -> sort them!
|
163 |
if (this.stateAllItems != STATE_ITEMS_ARE_DISORDERED) |
164 |
this.disorderItemsCopy();
|
165 |
|
166 |
// Return the item at that position
|
167 |
return this.itemsSearchesShow[index]; |
168 |
default:
|
169 |
// If error configuration -> it gives back an empty object for not to produce more errors
|
170 |
return new Object(); |
171 |
} |
172 |
} |
173 |
else
|
174 |
{ |
175 |
switch(this.getSearchBehavior()) |
176 |
{ |
177 |
case MAINTAIN_ORIGINAL_POSITION_ALL_ITEMS_SEARCH :
|
178 |
return super.getParentElementAt(index); |
179 |
case ORDERED_ALL_ITEMS_SEARCH :
|
180 |
if ((!this.itemsInTheArray) || (this.stateAllItems != STATE_ITEMS_ARE_ORDERED)) |
181 |
this.setItemsCopyToArray();
|
182 |
return this.itemsSearchesShow[index]; |
183 |
case DISORDERED_ALL_ITEMS_SEARCH :
|
184 |
if (!this.itemsInTheArray) |
185 |
this.setItemsCopyToArray();
|
186 |
|
187 |
// If the items aren't sorted -> sort them!
|
188 |
if (this.stateAllItems != STATE_ITEMS_ARE_DISORDERED) |
189 |
this.disorderItemsCopy();
|
190 |
|
191 |
return this.itemsSearchesShow[index]; |
192 |
case MAINTAIN_ORIGINAL_POSITION_DYNAMIC_SEARCH : case ORDERED_DYNAMIC_SEARCH : case DISORDERED_DYNAMIC_SEARCH : |
193 |
if (!this.itemsInTheArray) |
194 |
this.setItemsCopyToArray();
|
195 |
|
196 |
if (!this.dynamicSearchDone) |
197 |
seekDynamicItems(); |
198 |
|
199 |
return this.itemsSearchesShow[index]; |
200 |
default:
|
201 |
// If error configuration -> it gives back an empty object for not to produce more errors
|
202 |
return new Object(); |
203 |
} |
204 |
} |
205 |
} |
206 |
|
207 |
/*
|
208 |
* (non-Javadoc)
|
209 |
* @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#getIndexOf(java.lang.Object)
|
210 |
*/
|
211 |
public int getIndexOf(Object anObject) { |
212 |
if (!this.thisIsAComboBoxItemsSeekerConfigurableModelClassInialized) |
213 |
return super.getParentIndexOf(anObject); |
214 |
|
215 |
if (!itemsShowedIsOrdered)
|
216 |
this.sortItemsShowedVector();
|
217 |
|
218 |
if (!this.itemsInTheArray) |
219 |
{ |
220 |
if (this.startState) // At the beginning shows all items |
221 |
{ |
222 |
switch(this.getStartBehavior()) |
223 |
{ |
224 |
case MAINTAIN_ORIGINAL_POSITION_START : // Do nothing |
225 |
break;
|
226 |
case ORDERED_START :
|
227 |
this.setItemsCopyToArray();
|
228 |
break;
|
229 |
case DISORDERED_START :
|
230 |
if (!this.itemsInTheArray) |
231 |
this.setItemsCopyToArray();
|
232 |
|
233 |
// If the items aren't disordered -> sort them!
|
234 |
if (this.stateAllItems != STATE_ITEMS_ARE_DISORDERED) |
235 |
this.disorderItemsCopy();
|
236 |
|
237 |
break;
|
238 |
default:
|
239 |
// If error configuration -> it gives back -1 for not to produce more errors
|
240 |
return -1; |
241 |
} |
242 |
} |
243 |
else
|
244 |
{ |
245 |
switch(this.getSearchBehavior()) |
246 |
{ |
247 |
case MAINTAIN_ORIGINAL_POSITION_ALL_ITEMS_SEARCH : // Do nothing |
248 |
break;
|
249 |
case ORDERED_ALL_ITEMS_SEARCH :
|
250 |
if ((!this.itemsInTheArray) || (this.stateAllItems != STATE_ITEMS_ARE_ORDERED)) |
251 |
this.setItemsCopyToArray();
|
252 |
break;
|
253 |
case DISORDERED_ALL_ITEMS_SEARCH :
|
254 |
if (!this.itemsInTheArray) |
255 |
this.setItemsCopyToArray();
|
256 |
|
257 |
// If the items aren't disordered -> sort them!
|
258 |
if (this.stateAllItems != STATE_ITEMS_ARE_DISORDERED) |
259 |
this.disorderItemsCopy();
|
260 |
|
261 |
break;
|
262 |
case MAINTAIN_ORIGINAL_POSITION_DYNAMIC_SEARCH : case ORDERED_DYNAMIC_SEARCH : case DISORDERED_DYNAMIC_SEARCH : |
263 |
if (!this.itemsInTheArray) |
264 |
this.setItemsCopyToArray();
|
265 |
|
266 |
if (!this.dynamicSearchDone) |
267 |
seekDynamicItems(); |
268 |
|
269 |
break;
|
270 |
default:
|
271 |
// If error configuration -> it gives back -1 for not to produce more errors
|
272 |
return -1; |
273 |
} |
274 |
} |
275 |
|
276 |
} |
277 |
|
278 |
if (((this.startState) && (this.getStartBehavior() == MAINTAIN_ORIGINAL_POSITION_START)) || ((!this.startState) && (this.getSearchBehavior() == MAINTAIN_ORIGINAL_POSITION_ALL_ITEMS_SEARCH))) |
279 |
return super.getParentIndexOf(anObject); //this.itemsShowed.indexOf(anObject); |
280 |
else
|
281 |
return (Arrays.asList(this.itemsSearchesShow)).indexOf(anObject); |
282 |
|
283 |
} |
284 |
|
285 |
/*
|
286 |
* (non-Javadoc)
|
287 |
* @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#getSize()
|
288 |
*/
|
289 |
public int getSize() { |
290 |
if (!this.thisIsAComboBoxItemsSeekerConfigurableModelClassInialized) |
291 |
return super.getParentSize(); |
292 |
|
293 |
if (!itemsShowedIsOrdered)
|
294 |
this.sortItemsShowedVector();
|
295 |
|
296 |
if (this.startState) |
297 |
return this.itemsShowed.size(); |
298 |
|
299 |
switch(this.getSearchBehavior()) |
300 |
{ |
301 |
case MAINTAIN_ORIGINAL_POSITION_ALL_ITEMS_SEARCH: case ORDERED_ALL_ITEMS_SEARCH: case DISORDERED_ALL_ITEMS_SEARCH: |
302 |
return this.itemsShowed.size(); |
303 |
case MAINTAIN_ORIGINAL_POSITION_DYNAMIC_SEARCH: case ORDERED_DYNAMIC_SEARCH: case DISORDERED_DYNAMIC_SEARCH: |
304 |
if (!this.itemsInTheArray) |
305 |
this.setItemsCopyToArray();
|
306 |
|
307 |
if (!this.dynamicSearchDone) |
308 |
seekDynamicItems(); |
309 |
|
310 |
return this.itemsSearchesShow.length; |
311 |
// case ORDERED_DYNAMIC_SEARCH:
|
312 |
// if (!this.dynamicSearchDone)
|
313 |
// seekDynamicItems();
|
314 |
//
|
315 |
// return this.itemsSearchesShow.length;
|
316 |
// case DISORDERED_DYNAMIC_SEARCH:
|
317 |
// if (!this.dynamicSearchDone)
|
318 |
// seekDynamicItems();
|
319 |
//
|
320 |
// return this.itemsSearchesShow.length;
|
321 |
default:
|
322 |
// If error configuration -> it gives back 0 for not to produce more errors
|
323 |
return 0; |
324 |
} |
325 |
} |
326 |
|
327 |
/*
|
328 |
* (non-Javadoc)
|
329 |
* @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#insertElementAt(java.lang.Object, int)
|
330 |
*/
|
331 |
public void insertElementAt(Object anObject, int index) { |
332 |
super.insertToParentElementAt(anObject, index);
|
333 |
|
334 |
// Add the item also in the inner attribute
|
335 |
this.itemsShowed.add(anObject);
|
336 |
|
337 |
this.reset();
|
338 |
|
339 |
itemsShowedIsOrdered = false;
|
340 |
} |
341 |
|
342 |
/*
|
343 |
* (non-Javadoc)
|
344 |
* @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#removeAllElements()
|
345 |
*/
|
346 |
public void removeAllElements() { |
347 |
super.removeAllElementsOfParent();
|
348 |
|
349 |
// Also empty the inner attribute
|
350 |
itemsShowed.clear(); |
351 |
|
352 |
this.reset();
|
353 |
|
354 |
itemsShowedIsOrdered = false;
|
355 |
} |
356 |
|
357 |
/*
|
358 |
* (non-Javadoc)
|
359 |
* @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#removeElement(java.lang.Object)
|
360 |
*/
|
361 |
public void removeElement(Object anObject) { |
362 |
super.removeParentElement(anObject);
|
363 |
|
364 |
// Remove the object also in the inner attribute
|
365 |
itemsShowed.remove(anObject); |
366 |
|
367 |
this.reset();
|
368 |
|
369 |
itemsShowedIsOrdered = false;
|
370 |
} |
371 |
|
372 |
/*
|
373 |
* (non-Javadoc)
|
374 |
* @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#removeElementAt(int)
|
375 |
*/
|
376 |
public void removeElementAt(int index) { |
377 |
Object obj = new Object(); |
378 |
|
379 |
obj = super.getParentElementAt(index);
|
380 |
super.removeParentElementAt(index);
|
381 |
|
382 |
// Remove the object also in the inner attribute
|
383 |
itemsShowed.remove(obj); |
384 |
|
385 |
this.reset();
|
386 |
|
387 |
itemsShowedIsOrdered = false;
|
388 |
} |
389 |
|
390 |
////// END REIMPLEMENTATION OF SOME METHODS OF "DefaultComboBoxModel" TO ADAPT THE BEHAVIOR OF THIS MODEL //////
|
391 |
|
392 |
|
393 |
|
394 |
////// OTHER METHODS //////
|
395 |
|
396 |
/*
|
397 |
* (non-Javadoc)
|
398 |
* @see AbstractDefaultComboBoxItemsSeekerConfigurableModel#getParentAllData()
|
399 |
*/
|
400 |
public Vector getParentAllData() |
401 |
{ |
402 |
Vector data = new Vector(); |
403 |
int size;
|
404 |
logger.debug("Parent size: " + super.getParentSize()); |
405 |
logger.debug("ItemsShowed size: " + this.itemsShowed.size()); |
406 |
|
407 |
// Caso de model que no permite items repetidos con items repetidos
|
408 |
if (this.itemsShowed.size() < super.getParentSize()) |
409 |
size = super.getParentSize();
|
410 |
else
|
411 |
size = this.itemsShowed.size();
|
412 |
|
413 |
for (int i = 0; i < size; i++) |
414 |
data.add(super.getParentElementAt(i));
|
415 |
|
416 |
return data;
|
417 |
} |
418 |
|
419 |
/*
|
420 |
* (non-Javadoc)
|
421 |
* @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#disorderItemsCopy()
|
422 |
*/
|
423 |
protected void disorderItemsCopy() { |
424 |
if (this.getSearchBehavior() == DISORDERED_DYNAMIC_SEARCH) |
425 |
Collections.shuffle(Arrays.asList(this.itemsSearchesShow)); // Disorder the items to show |
426 |
else
|
427 |
{ |
428 |
this.itemsSearchesShow = this.itemsShowed.toArray(); |
429 |
Collections.shuffle(Arrays.asList(this.itemsSearchesShow)); // Disorder the items |
430 |
} |
431 |
|
432 |
this.stateAllItems = STATE_ITEMS_ARE_DISORDERED;
|
433 |
} |
434 |
|
435 |
/*
|
436 |
* (non-Javadoc)
|
437 |
* @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#getDynamicItemsSearch(org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel.BinaryRankOfItemsSearch, int, int)
|
438 |
*/
|
439 |
protected void getDynamicItemsSearch(BinaryRankOfItemsSeek search, int lowIndex, int hightIndex) { |
440 |
int lowIndexSubSet2;
|
441 |
int hightIndexSubSet2;
|
442 |
List aux;
|
443 |
|
444 |
if (isCaseSensitive_Flag())
|
445 |
{ |
446 |
if (lowIndex <= hightIndex)
|
447 |
{ |
448 |
if (hightIndex == (itemsSearchesShow.length - 1)) |
449 |
{ |
450 |
aux = new Vector(hightIndex - lowIndex + 1 , 1); // Parameters: Initial Capacity and 1 -> capacity increment |
451 |
aux.addAll(Arrays.asList((this.itemsShowed.subList(lowIndex, hightIndex)).toArray())); |
452 |
aux.add(this.itemsSearchesShow[hightIndex]);
|
453 |
this.itemsSearchesShow = aux.toArray();
|
454 |
} |
455 |
else
|
456 |
this.itemsSearchesShow = (this.itemsShowed.subList(lowIndex, hightIndex+1)).toArray(); |
457 |
} |
458 |
else // Any items match their start with the written text |
459 |
this.itemsSearchesShow = new Object[0]; |
460 |
} |
461 |
else
|
462 |
{ |
463 |
lowIndexSubSet2 = search.getLowIndexSecondSubSet(); |
464 |
hightIndexSubSet2 = search.getHightIndexSecondSubSet(); |
465 |
|
466 |
// If any element has been found
|
467 |
if ((lowIndex > hightIndex) && (lowIndexSubSet2 > hightIndexSubSet2))
|
468 |
{ |
469 |
this.itemsSearchesShow = new Object[0]; |
470 |
return;
|
471 |
} |
472 |
|
473 |
aux = new Vector(); |
474 |
|
475 |
// Second Subset (Uppercases are first)
|
476 |
if (lowIndexSubSet2 <= hightIndexSubSet2)
|
477 |
{ |
478 |
if ((lowIndex != lowIndexSubSet2) && (hightIndex != hightIndexSubSet2))
|
479 |
{ |
480 |
aux.addAll(Arrays.asList((this.itemsShowed.subList(lowIndexSubSet2, hightIndexSubSet2)).toArray())); |
481 |
aux.add(this.itemsSearchesShow[hightIndexSubSet2]);
|
482 |
} |
483 |
} |
484 |
|
485 |
// First Subset (Uppercases are first)
|
486 |
if (lowIndex <= hightIndex)
|
487 |
{ |
488 |
aux.addAll(Arrays.asList((this.itemsShowed.subList(lowIndex, hightIndex)).toArray())); |
489 |
aux.add(this.itemsSearchesShow[hightIndex]);
|
490 |
} |
491 |
|
492 |
this.itemsSearchesShow = aux.toArray();
|
493 |
} |
494 |
} |
495 |
|
496 |
|
497 |
/*
|
498 |
* (non-Javadoc)
|
499 |
* @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#seekDynamicItems()
|
500 |
*/
|
501 |
protected void seekDynamicItems() { |
502 |
int lowIndex;
|
503 |
int hightIndex;
|
504 |
|
505 |
// If doesn't have to seek items -> finish
|
506 |
if (this.writtenText.compareTo("") == 0) |
507 |
return;
|
508 |
|
509 |
if (isDynamicSearch()) // Puede que sobre este if |
510 |
{ |
511 |
// Get a sorted copy of all items
|
512 |
this.itemsSearchesShow = this.itemsShowed.toArray(); |
513 |
|
514 |
// Do the search of the rank
|
515 |
BinaryRankOfItemsSeek search = new BinaryRankOfItemsSeek();
|
516 |
search.binaryRankSeek(); |
517 |
|
518 |
// To obtain the range of items to showing
|
519 |
lowIndex = search.getLowIndex(); |
520 |
hightIndex = search.getHightIndex(); |
521 |
|
522 |
this.dynamicSearchDone = true; |
523 |
|
524 |
// Get the items
|
525 |
switch(this.getSearchBehavior()) |
526 |
{ |
527 |
case MAINTAIN_ORIGINAL_POSITION_DYNAMIC_SEARCH: // If maintain original position // REVISAR y HACER |
528 |
int numberOfItems = hightIndex - lowIndex;
|
529 |
|
530 |
this.getDynamicItemsSearch(search, lowIndex, hightIndex);
|
531 |
|
532 |
if (numberOfItems > 0) |
533 |
{ |
534 |
int positions[] = new int[numberOfItems]; |
535 |
|
536 |
int positionArrayIndex = 0; |
537 |
|
538 |
// Gets the items ordered
|
539 |
this.getDynamicItemsSearch(search, lowIndex, hightIndex);
|
540 |
|
541 |
// Gets the position of the items in the original position
|
542 |
for (int i = lowIndex; i < hightIndex; i++) |
543 |
{ |
544 |
positions[positionArrayIndex] = super.getParentIndexOf(this.itemsSearchesShow[i]); |
545 |
positionArrayIndex ++; |
546 |
} |
547 |
Arrays.sort(positions);
|
548 |
|
549 |
this.itemsSearchesShow = new Object[numberOfItems]; // Remove the array |
550 |
|
551 |
// Get the items at the original position
|
552 |
for (int i = 0; i < numberOfItems; i++) |
553 |
this.itemsSearchesShow[i] = super.getParentElementAt(positions[i]); |
554 |
} |
555 |
break;
|
556 |
case ORDERED_DYNAMIC_SEARCH: // If ordered |
557 |
|
558 |
this.getDynamicItemsSearch(search, lowIndex, hightIndex);
|
559 |
|
560 |
break;
|
561 |
case DISORDERED_DYNAMIC_SEARCH: // If disordered |
562 |
|
563 |
this.getDynamicItemsSearch(search, lowIndex, hightIndex);
|
564 |
this.disorderItemsCopy();
|
565 |
} |
566 |
} |
567 |
} |
568 |
|
569 |
/*
|
570 |
* (non-Javadoc)
|
571 |
* @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#setItemsCopyToArray()
|
572 |
*/
|
573 |
protected void setItemsCopyToArray() { |
574 |
this.itemsSearchesShow = null; |
575 |
this.itemsSearchesShow = this.itemsShowed.toArray(); |
576 |
this.itemsInTheArray = true; |
577 |
this.stateAllItems = STATE_ITEMS_ARE_ORDERED;
|
578 |
} |
579 |
|
580 |
/**
|
581 |
* Orders the attibute 'itemsShowed'
|
582 |
*/
|
583 |
private void sortItemsShowedVector() { |
584 |
Collections.sort(this.itemsShowed); |
585 |
itemsShowedIsOrdered = true;
|
586 |
} |
587 |
////// END OTHER METHODS //////
|
588 |
} |