Statistics
| Revision:

root / trunk / libraries / libUI / src / org / gvsig / gui / beans / comboBoxItemsSeeker / ComboBoxItemsSeekerConfigurableModel.java @ 6816

History | View | Annotate | Download (19.2 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.TreeSet;
7
import java.util.Vector;
8

    
9
import javax.swing.DefaultComboBoxModel;
10

    
11
import org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel.BinaryRankOfItemsSearch;
12

    
13

    
14
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
15
 *
16
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
17
 *
18
 * This program is free software; you can redistribute it and/or
19
 * modify it under the terms of the GNU General Public License
20
 * as published by the Free Software Foundation; either version 2
21
 * of the License, or (at your option) any later version.
22
 *
23
 * This program is distributed in the hope that it will be useful,
24
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
 * GNU General Public License for more details.
27
 *
28
 * You should have received a copy of the GNU General Public License
29
 * along with this program; if not, write to the Free Software
30
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
31
 *
32
 * For more information, contact:
33
 *
34
 *  Generalitat Valenciana
35
 *   Conselleria d'Infraestructures i Transport
36
 *   Av. Blasco Ib??ez, 50
37
 *   46010 VALENCIA
38
 *   SPAIN
39
 *
40
 *      +34 963862235
41
 *   gvsig@gva.es
42
 *      www.gvsig.gva.es
43
 *
44
 *    or
45
 *
46
 *   IVER T.I. S.A
47
 *   Salamanca 50
48
 *   46005 Valencia
49
 *   Spain
50
 *
51
 *   +34 963163400
52
 *   dac@iver.es
53
 */
54

    
55
/** VERSI?N EN DESARROLLO
56
 *  COMENTAR Y REVISAR
57
 * Se consideran los datos que contiene DefaultComboBoxModel como los que se tomar?n para devolver datos a no ser que sea para actualizar la lista
58
 *    de la vista, que en cuyo caso se tendr? en cuenta la configuraci?n del comportamiento y atributos internos.
59
 *    
60
 * ESTA VERSI?N FUNCIONA CON ITEMS REPETIDOS Y SIN HABERLOS
61
 *  (PARA EL CASO QUE LOS ITEMS NO EST?N REPETIDOS IR? PEOR QUE 'ComboBoxSingularItemsSeekerConfigurableModel')
62
 *  
63
 * ESTA SIN NING?N TESTEO!!!
64
 *  
65
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
66
 */
67
public class ComboBoxItemsSeekerConfigurableModel extends AbstractDefaultComboBoxItemsSeekerConfigurableModel implements java.io.Serializable {
68
        
69
        // INNER MODEL STRUCTURES
70
        private Vector itemsShowed;
71
        // END INNER MODEL STRUCTURES
72
        
73
        // OTHER FLAGS
74
        protected boolean thisIsAComboBoxItemsSeekerConfigurableModelClassInialized=false; // To distinguish the class which invokes some methods of this class
75
        private boolean itemsShowedIsOrdered;
76
        // END OTHER FLAGS
77

    
78
        
79
        /**
80
         * 
81
         */
82
        public ComboBoxItemsSeekerConfigurableModel() {
83
                super();
84
                // TODO Auto-generated constructor stub
85
        }
86

    
87
        /**
88
         * @param items
89
         * @throws Exception
90
         */
91
        public ComboBoxItemsSeekerConfigurableModel(Object[] items) {
92

    
93
//        public ComboBoxItemsSeekerConfigurableModel(Object[] items) throws Exception {
94
                super(items);
95
                // TODO Auto-generated constructor stub
96
                
97
                this.itemsShowed.addAll(Arrays.asList(items));
98
                
99
//                if (!this.itemsShowed.addAll(Arrays.asList(items)))
100
//                        throw new Exception();
101
        }
102

    
103
        /**
104
         * @param objects
105
         * @throws Exception
106
         */
107
        public ComboBoxItemsSeekerConfigurableModel(Vector objects) {
108
                super(objects);
109
                // TODO Auto-generated constructor stub
110
                
111
                this.itemsShowed.addAll(objects);
112
                
113
//                if (!this.itemsShowed.addAll(objects))
114
//                        throw new Exception();
115
        }
116
        
117
        /*
118
         * (non-Javadoc)
119
         * @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#initialize()
120
         */
121
        protected void initialize() {
122
                super.initialize();
123
                logger.debug("Se ejecuta el initialize del hijo");
124

    
125
                thisIsAComboBoxItemsSeekerConfigurableModelClassInialized = true;
126
                this.itemsShowed = new Vector();
127
                itemsShowedIsOrdered = false;
128
        }
129
        
130
        
131
        ////// REIMPLEMENTATION OF SOME METHODS OF "DefaultComboBoxModel" TO ADAPT THE BEHAVIOR OF THIS MODEL //////
132
        
133
        /* (non-Javadoc)
134
         * @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#addElement(java.lang.Object)
135
         */
136
        public void addElement(Object anObject) {
137
                // TODO Auto-generated method stub
138
                super.addElementToParent(anObject); // this adds the element and selects by default the first item added
139
                
140
                // Add the item also in the inner attribute
141
                this.itemsShowed.add(anObject);
142

    
143
                this.reset();
144
                
145
                itemsShowedIsOrdered = false;
146
        }
147
        
148
        /* (non-Javadoc)
149
         * @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#getElementAt(int)
150
         */
151
        public Object getElementAt(int index) {
152
                // TODO Auto-generated method stub
153
                
154
                if (!this.thisIsAComboBoxItemsSeekerConfigurableModelClassInialized)
155
                        return super.getParentElementAt(index);
156
                
157
                if (!itemsShowedIsOrdered)
158
                        this.sortItemsShowedVector();
159
                
160
                if (this.startView) // At the beginning shows all items
161
                {                        
162
                        switch(this.getStartBehavior())
163
                        {
164
                                case MAINTAIN_ORIGINAL_POSITION_START :                                
165
                                        return super.getParentElementAt(index);
166
//                                        break;
167
                                case ORDERED_START :
168
                                        // If the items aren't sorted -> sort them!
169
//                                        if (!this.allItemsAreSorted)
170
//                                                this.sortItemsCopy();
171
                                        if ((!this.itemsInTheArray) || (this.stateAllItems != STATE_ITEMS_ARE_ORDERED))
172
                                                this.setItemsCopyToArray();
173
                                        
174
                                        // Return the item at that position
175
                                        return this.itemsSearchesShow[index];
176
//                                        return this.itemsShowedDisordered.[index];
177
//                                        break;
178
                                case DISORDERED_START :
179
                                        
180
                                        if (!this.itemsInTheArray)
181
                                                this.setItemsCopyToArray();
182
                                        
183
                                        // If the items aren't disordered -> sort them!
184
                                        if (this.stateAllItems != STATE_ITEMS_ARE_DISORDERED)
185
                                                this.disorderItemsCopy();
186

    
187
                                        // Return the item at that position
188
                                        return this.itemsSearchesShow[index];
189
//                                        return this.itemsShowedDisordered[index];
190
//                                        break;
191
                                default:
192
                                        // If error configuration -> it gives back an empty object for not to produce more errors 
193
                                        return new Object();
194
                        }
195
                }
196
                else
197
                {                        
198
                        switch(this.getSearchBehavior())
199
                        {
200
                                case MAINTAIN_ORIGINAL_POSITION_ALL_ITEMS_SEARCH :
201
                                        return super.getParentElementAt(index);
202
//                                                break;
203
                                case ORDERED_ALL_ITEMS_SEARCH :
204
                                        if ((!this.itemsInTheArray) || (this.stateAllItems != STATE_ITEMS_ARE_ORDERED))
205
                                                this.setItemsCopyToArray();
206

    
207
//                                                this.setItemsCopyToArray();
208

    
209
                                        // If the items aren't sorted -> sort them!
210
//                                        if (!this.allItemsAreSorted)
211
//                                                this.sortItemsCopy();
212
                                        
213
                                        // Return the item at that position
214
                                //        return this.iterator.next();        
215
                                        return this.itemsSearchesShow[index];
216
//                                        return this.itemsShowedDisordered[index];
217
//                                                break;
218
                                case DISORDERED_ALL_ITEMS_SEARCH :
219
                                        if (!this.itemsInTheArray)
220
                                                this.setItemsCopyToArray();
221

    
222
                                        // If the items aren't sorted -> sort them!
223
                                        if (this.stateAllItems != STATE_ITEMS_ARE_DISORDERED)
224
                                                this.disorderItemsCopy();
225

    
226
                                        // Return the item at that position
227
                                //        return this.iterator.next();
228
                                        return this.itemsSearchesShow[index];
229
//                                        return this.itemsShowedDisordered[index];
230
                                        
231
//                                                break;
232
                                case MAINTAIN_ORIGINAL_POSITION_DYNAMIC_SEARCH : case ORDERED_DYNAMIC_SEARCH : case DISORDERED_DYNAMIC_SEARCH :
233
                                        if (!this.itemsInTheArray)
234
                                                this.setItemsCopyToArray();
235

    
236
                                        if (!this.dynamicSearchDone)
237
                                                seekDynamicItems();
238
                                        
239
                                        return this.itemsSearchesShow[index];
240
//                                                break;
241
                                default:
242
                                        // If error configuration -> it gives back an empty object for not to produce more errors 
243
                                        return new Object();
244
                        }
245
                }                
246
        }
247

    
248
        /* (non-Javadoc)
249
         * @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#getIndexOf(java.lang.Object)
250
         */
251
        public int getIndexOf(Object anObject) {
252
                // TODO Auto-generated method stub
253
                
254
                if (!this.thisIsAComboBoxItemsSeekerConfigurableModelClassInialized)
255
                        return super.getParentIndexOf(anObject);
256
                
257
                if (!itemsShowedIsOrdered)
258
                        this.sortItemsShowedVector();
259
                
260
                if (!this.itemsInTheArray)
261
                {
262
                        if (this.startView) // At the beginning shows all items
263
                        {                        
264
                                switch(this.getStartBehavior())
265
                                {
266
                                        case MAINTAIN_ORIGINAL_POSITION_START : // Do nothing        
267
                                                break;
268
                                        case ORDERED_START :
269
                                                this.setItemsCopyToArray();
270
                                                break;
271
                                        case DISORDERED_START :
272
                                                if (!this.itemsInTheArray)
273
                                                        this.setItemsCopyToArray();
274
                                                
275
                                                // If the items aren't disordered -> sort them!
276
                                                if (this.stateAllItems != STATE_ITEMS_ARE_DISORDERED)
277
                                                        this.disorderItemsCopy();
278

    
279
                                                break;
280
                                        default:
281
                                                // If error configuration -> it gives back -1 for not to produce more errors 
282
                                                return -1;
283
                                }
284
                        }
285
                        else
286
                        {                        
287
                                switch(this.getSearchBehavior())
288
                                {
289
                                        case MAINTAIN_ORIGINAL_POSITION_ALL_ITEMS_SEARCH : // Do nothing        
290
                                                break;
291
                                        case ORDERED_ALL_ITEMS_SEARCH :
292
                                                if ((!this.itemsInTheArray) || (this.stateAllItems != STATE_ITEMS_ARE_ORDERED))
293
                                                        this.setItemsCopyToArray();
294
                                                break;
295
                                        case DISORDERED_ALL_ITEMS_SEARCH :
296
                                                if (!this.itemsInTheArray)
297
                                                        this.setItemsCopyToArray();
298

    
299
                                                // If the items aren't disordered -> sort them!
300
                                                if (this.stateAllItems != STATE_ITEMS_ARE_DISORDERED)
301
                                                        this.disorderItemsCopy();
302

    
303
                                                break;
304
                                        case MAINTAIN_ORIGINAL_POSITION_DYNAMIC_SEARCH : case ORDERED_DYNAMIC_SEARCH : case DISORDERED_DYNAMIC_SEARCH :
305
                                                if (!this.itemsInTheArray)
306
                                                        this.setItemsCopyToArray();
307

    
308
                                                if (!this.dynamicSearchDone)
309
                                                        seekDynamicItems();
310
                                                
311
                                                break;
312
                                        default:
313
                                                // If error configuration -> it gives back -1 for not to produce more errors 
314
                                                return -1;
315
                                }
316
                        }                
317
                        
318
                }
319
//                        this.setItemsCopyToArray();
320

    
321
                //if (this.alphanumericSortedSearches)
322
                        //return this.itemsShowedVector.indexOf(anObject);
323
                
324
                if (((this.startView) && (this.getStartBehavior() == MAINTAIN_ORIGINAL_POSITION_START)) || ((!this.startView) && (this.getSearchBehavior() == MAINTAIN_ORIGINAL_POSITION_ALL_ITEMS_SEARCH)))
325
                        return super.getParentIndexOf(anObject); //this.itemsShowed.indexOf(anObject);
326
                else
327
                        return (Arrays.asList(this.itemsSearchesShow)).indexOf(anObject);
328

    
329
        }
330

    
331
        /* (non-Javadoc)
332
         * @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#getSize()
333
         */
334
        public int getSize() {
335
                // TODO Auto-generated method stub
336
                
337
                if (!this.thisIsAComboBoxItemsSeekerConfigurableModelClassInialized)
338
                        return super.getParentSize();
339
                
340
                if (!itemsShowedIsOrdered)
341
                        this.sortItemsShowedVector();
342
                
343
                if (this.startView)
344
                        return this.itemsShowed.size();                        
345
                
346
                switch(this.getSearchBehavior())
347
                {
348
                        case MAINTAIN_ORIGINAL_POSITION_ALL_ITEMS_SEARCH: case ORDERED_ALL_ITEMS_SEARCH: case DISORDERED_ALL_ITEMS_SEARCH:
349
                                return this.itemsShowed.size();
350
//                                        break;
351
                        case MAINTAIN_ORIGINAL_POSITION_DYNAMIC_SEARCH:
352
                                if (!this.dynamicSearchDone)
353
                                        seekDynamicItems();
354

    
355
                                return this.itemsSearchesShow.length;
356
//                                        break;
357
                        case ORDERED_DYNAMIC_SEARCH:
358
                                if (!this.dynamicSearchDone)
359
                                        seekDynamicItems();
360

    
361
                                return this.itemsSearchesShow.length;
362
//                                        break;
363
                        case DISORDERED_DYNAMIC_SEARCH:
364
                                if (!this.dynamicSearchDone)
365
                                        seekDynamicItems();
366

    
367
                                return this.itemsSearchesShow.length;
368
//                                        break;
369
                        default:
370
                                // If error configuration -> it gives back 0 for not to produce more errors 
371
                                return 0; // HACER
372
                }
373
        }
374

    
375
        /* (non-Javadoc)
376
         * @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#insertElementAt(java.lang.Object, int)
377
         */
378
        public void insertElementAt(Object anObject, int index) {
379
                // TODO Auto-generated method stub
380
                super.insertToParentElementAt(anObject, index);
381
                
382
                // Add the item also in the inner attribute
383
                this.itemsShowed.add(anObject);
384

    
385
                this.reset();
386
                
387
                itemsShowedIsOrdered = false;
388
        }
389

    
390
        /* (non-Javadoc)
391
         * @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#removeAllElements()
392
         */
393
        public void removeAllElements() {
394
                // TODO Auto-generated method stub
395
                super.removeAllElementsOfParent();
396
                
397
                // Also empty the inner attribute
398
                itemsShowed.clear();                
399
                
400
                this.reset();
401
                
402
                itemsShowedIsOrdered = false;
403
        }
404

    
405
        /* (non-Javadoc)
406
         * @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#removeElement(java.lang.Object)
407
         */
408
        public void removeElement(Object anObject) {
409
                // TODO Auto-generated method stub
410
                super.removeParentElement(anObject);
411
                
412
                // Remove the object also in the inner attribute
413
                itemsShowed.remove(anObject);
414
                
415
                this.reset();
416
                
417
                itemsShowedIsOrdered = false;
418
        }
419

    
420
        /* (non-Javadoc)
421
         * @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#removeElementAt(int)
422
         */
423
        public void removeElementAt(int index) {
424
                // TODO Auto-generated method stub
425
                Object obj = new Object();
426
                
427
                obj = super.getParentElementAt(index);
428
                super.removeParentElementAt(index);
429
                
430
                // Remove the object also in the inner attribute
431
                itemsShowed.remove(obj);
432
                
433
                // If this model has to return the elements sorted
434
//                if ((this.getStartBehavior() == this.ORDERED_START) || (this.getSearchBehavior() == this.ORDERED_ALL_ITEMS_SEARCH) || (this.getSearchBehavior() == this.ORDERED_DYNAMIC_SEARCH))
435
//                //if (this.alphanumericSortedSearches)
436
//                        this.allItemsAreSorted = false;
437
                
438
                this.reset();
439
                
440
                itemsShowedIsOrdered = false;
441
        }
442

    
443
        ////// END REIMPLEMENTATION OF SOME METHODS OF "DefaultComboBoxModel" TO ADAPT THE BEHAVIOR OF THIS MODEL //////        
444
        
445
        ////// OTHER METHODS //////
446
        
447
        /*
448
         * 
449
         */
450
        public Vector getParentAllData()
451
        {
452
                Vector data = new Vector();
453
                int size;
454
                logger.debug("Parent size: " + super.getParentSize());
455
                logger.debug("ItemsShowed size: " + this.itemsShowed.size());
456
                
457
                // Caso de model que no permite items repetidos con items repetidos
458
                if (this.itemsShowed.size() < super.getParentSize())
459
                        size = super.getParentSize();
460
                else
461
                        size = this.itemsShowed.size();
462
                
463
                for (int i = 0; i < size; i++)
464
                        data.add(super.getParentElementAt(i));
465
                
466
                return data;
467
        }
468
        
469
        /* (non-Javadoc)
470
         * @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#disorderItemsCopy()
471
         */
472
        protected void disorderItemsCopy() {
473
                // TODO Auto-generated method stub
474
                if (this.getSearchBehavior() == DISORDERED_DYNAMIC_SEARCH)
475
                        Collections.shuffle(Arrays.asList(this.itemsSearchesShow)); // Disorder the items to show
476
                else
477
                {
478
//                if ((!this.maintainPositionItems) && (!this.alphanumericSortedSearches))                        
479
//                {
480
                        this.itemsSearchesShow = this.itemsShowed.toArray();
481
                        Collections.shuffle(Arrays.asList(this.itemsSearchesShow)); // Disorder the items
482
                }
483
                
484
                this.stateAllItems = STATE_ITEMS_ARE_DISORDERED;
485
//                this.allItemsAreDisordered = true;
486
//                }
487
        }
488

    
489
        /* (non-Javadoc)
490
         * @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#getDynamicItemsSearch(org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel.BinaryRankOfItemsSearch, int, int)
491
         */
492
        protected void getDynamicItemsSearch(BinaryRankOfItemsSearch search, int lowIndex, int hightIndex) {
493
                // TODO Auto-generated method stub
494
                int lowIndexSubSet2;
495
                int hightIndexSubSet2;
496
//                int lastIndex;
497
                List aux;
498

    
499
                if (isCaseSensitive())
500
                {
501
                        if (lowIndex <= hightIndex)
502
                        {
503
                                if (hightIndex == (itemsSearchesShow.length - 1))
504
                                {
505
                                        aux = new Vector(hightIndex - lowIndex + 1 , 1); // Parameters: Initial Capacity and 1 -> capacity increment
506
                                        aux.addAll(Arrays.asList((this.itemsShowed.subList(lowIndex, hightIndex)).toArray()));
507
                                        aux.add(this.itemsSearchesShow[hightIndex]);
508
                                        this.itemsSearchesShow = aux.toArray();
509
                                }
510
                                else
511
                                        this.itemsSearchesShow = (this.itemsShowed.subList(lowIndex, hightIndex+1)).toArray();
512
                        }
513
                        else // Any items match their start with the written text
514
                                this.itemsSearchesShow = new Object[0];
515
                }
516
                else
517
                {
518
                        lowIndexSubSet2 = search.getLowIndexSecondSubSet();
519
                        hightIndexSubSet2 = search.getHightIndexSecondSubSet();
520
                        
521
                        // If any element has been found
522
                        if ((lowIndex > hightIndex) && (lowIndexSubSet2 > hightIndexSubSet2))
523
                        {
524
                                this.itemsSearchesShow = new Object[0];
525
                                return;
526
                        }
527

    
528
                        aux = new Vector();
529
                        
530
                        // Second Subset (Uppercases are first)
531
                        if (lowIndexSubSet2 <= hightIndexSubSet2)
532
                        {
533
                                if ((lowIndex != lowIndexSubSet2) && (hightIndex != hightIndexSubSet2))
534
                                {
535
                                        aux.addAll(Arrays.asList((this.itemsShowed.subList(lowIndexSubSet2, hightIndexSubSet2)).toArray()));
536
                                        aux.add(this.itemsSearchesShow[hightIndexSubSet2]);
537
                                }
538
                        }
539
        
540
                        // First Subset (Uppercases are first)
541
                        if (lowIndex <= hightIndex)
542
                        {
543
                                aux.addAll(Arrays.asList((this.itemsShowed.subList(lowIndex, hightIndex)).toArray()));
544
                                aux.add(this.itemsSearchesShow[hightIndex]);
545
                        }
546
                        
547
                        this.itemsSearchesShow = aux.toArray();
548
                }                
549
        }
550

    
551

    
552
        /* (non-Javadoc)
553
         * @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#seekDynamicItems()
554
         */
555
        protected void seekDynamicItems() {
556
                // TODO Auto-generated method stub
557
                int lowIndex;
558
                int hightIndex;
559
                
560
                // If doesn't have to seek items -> finish
561
                if (this.writtenText.compareTo("") == 0)
562
                        return;
563
                
564
                if (this.dynamicSearches) // Puede que sobre este if
565
                {                        
566
                        // Get a sorted copy of all items
567
                        this.itemsSearchesShow = this.itemsShowed.toArray();
568
                        
569
                        // Do the search of the rank
570
                        BinaryRankOfItemsSearch search = new BinaryRankOfItemsSearch();
571
                        search.binaryRankSearch();
572
                                                
573
                        // To obtain the range of items to showing
574
                        lowIndex = search.getLowIndex();
575
                        hightIndex = search.getHightIndex();                         
576
                        
577
                        this.dynamicSearchDone = true;
578
                        
579
                        // Get the items
580
                        switch(this.getSearchBehavior())
581
                        {
582
                                case MAINTAIN_ORIGINAL_POSITION_DYNAMIC_SEARCH: // If maintain original position // REVISAR y HACER                                        
583
                                        int numberOfItems = hightIndex - lowIndex;
584
                                        
585
                                        this.getDynamicItemsSearch(search, lowIndex, hightIndex);
586
                                        
587
                                        if (numberOfItems > 0)
588
                                        {                                                
589
                                                int positions[] = new int[numberOfItems];
590
                                                
591
                                                int positionArrayIndex = 0;
592
                                                
593
                                                // Gets the items ordered
594
                                                this.getDynamicItemsSearch(search, lowIndex, hightIndex);
595
                                                
596
                                                // Gets the position of the items in the original position
597
                                                for (int i = lowIndex; i < hightIndex; i++)
598
                                                {
599
                                                        positions[positionArrayIndex] = super.getParentIndexOf(this.itemsSearchesShow[i]);
600
                                                        positionArrayIndex ++;
601
                                                }
602
                                                Arrays.sort(positions);
603
                                                
604
                                                this.itemsSearchesShow = new Object[numberOfItems]; // Remove the array
605
                
606
                                                // Get the items at the original position
607
                                                for (int i = 0; i < numberOfItems; i++)
608
                                                        this.itemsSearchesShow[i] = super.getParentElementAt(positions[i]);        
609
                                        }
610
                                        break;
611
                                case ORDERED_DYNAMIC_SEARCH: // If ordered                        
612
                                        
613
                                        this.getDynamicItemsSearch(search, lowIndex, hightIndex);
614
                                        
615
                                        break;
616
                                case DISORDERED_DYNAMIC_SEARCH: // If disordered //HACER                                
617

    
618
                                        this.getDynamicItemsSearch(search, lowIndex, hightIndex);
619
                                        this.disorderItemsCopy();
620
                        }                        
621
                }
622
        }
623

    
624
        /* (non-Javadoc)
625
         * @see org.gvsig.gui.beans.comboBoxItemsSeeker.AbstractDefaultComboBoxItemsSeekerConfigurableModel#setItemsCopyToArray()
626
         */
627
        protected void setItemsCopyToArray() {
628
                // TODO Auto-generated method stub
629
                this.itemsSearchesShow = null;
630
                this.itemsSearchesShow = this.itemsShowed.toArray();
631
                this.itemsInTheArray = true;
632
                this.stateAllItems = STATE_ITEMS_ARE_ORDERED;
633
        }
634

    
635
        private void sortItemsShowedVector() {
636
                Collections.sort(this.itemsShowed);
637
                itemsShowedIsOrdered = true;
638
        }
639
        ////// END OTHER METHODS //////
640
}