Revision 6613

View differences:

trunk/libraries/libUI/src-test/org/gvsig/gui/beans/comboBoxItemsSeeker/TestJComboBoxItemsSeekerDynamic.java
111 111
			jCBSD.setShowAllItems(true);
112 112
			//jCBSD.setShowAllItems(false);		
113 113
			
114
			// Test a configuration of behavior of the JComboBoxSearcheableDynamic
115
			//JComboBoxSearcheableDynamic jCBSD = new JComboBoxSearcheableDynamic(true, true, false, true);
116
	
117
			// Test a configuration of behavior of the JComboBoxSearcheableDynamic
118
			//JComboBoxSearcheableDynamic jCBSD = new JComboBoxSearcheableDynamic(true, false, false, false);
119
		
120
			// Test a configuration of behavior of the JComboBoxSearcheableDynamic
121
			//JComboBoxSearcheableDynamic jCBSD = new JComboBoxSearcheableDynamic(true, false, false, true);
122
	
123
			// Test a configuration of behavior of the JComboBoxSearcheableDynamic		
124
			//JComboBoxSearcheableDynamic jCBSD = new JComboBoxSearcheableDynamic(false, true, true, true);
114
			// Test a configuration of behavior of the start of JComboBoxSearcheableDynamic
115
			jCBSD.setStartBehavior(ComboBoxItemsSeekerDynamicModel.MAINTAIN_ORIGINAL_POSITION_START);
116
//			jCBSD.setStartBehavior(ComboBoxItemsSeekerDynamicModel.ORDERED_START);
117
//			jCBSD.setStartBehavior(ComboBoxItemsSeekerDynamicModel.DISORDERED_START);
118
//
119
//			jCBSD.setStartBehavior(ComboBoxItemsSeekerDynamicModel.ORDERED_ALL_ITEMS_SEARCH); // Test error configuration
125 120
			
126
			// Test a configuration of behavior of the JComboBoxSearcheableDynamic
127
			//JComboBoxSearcheableDynamic jCBSD = new JComboBoxSearcheableDynamic(false, true, true, false);
121
			// Test a configuration of behavior of the start of JComboBoxSearcheableDynamic
122
//			jCBSD.setSearchBehavior(ComboBoxItemsSeekerDynamicModel.MAINTAIN_ORIGINAL_POSITION_ALL_ITEMS_SEARCH);
123
//			jCBSD.setSearchBehavior(ComboBoxItemsSeekerDynamicModel.ORDERED_ALL_ITEMS_SEARCH);
124
//			jCBSD.setSearchBehavior(ComboBoxItemsSeekerDynamicModel.DISORDERED_ALL_ITEMS_SEARCH);
125
//
126
//			jCBSD.setSearchBehavior(ComboBoxItemsSeekerDynamicModel.MAINTAIN_ORIGINAL_POSITION_DYNAMIC_SEARCH);
127
//			jCBSD.setSearchBehavior(ComboBoxItemsSeekerDynamicModel.ORDERED_DYNAMIC_SEARCH);
128
//			jCBSD.setSearchBehavior(ComboBoxItemsSeekerDynamicModel.DISORDERED_DYNAMIC_SEARCH);
129
//			
130
//			jCBSD.setStartBehavior(ComboBoxItemsSeekerDynamicModel.ORDERED_START); // Test error configuration
131

  
128 132
			
129
			// Test a configuration of behavior of the JComboBoxSearcheableDynamic
130
			//JComboBoxSearcheableDynamic jCBSD = new JComboBoxSearcheableDynamic(false, false, true, true);
131
			
132
			// Test a configuration of behavior of the JComboBoxSearcheableDynamic
133
			//JComboBoxSearcheableDynamic jCBSD = new JComboBoxSearcheableDynamic(false, false, true, false);
134
	
135
			// Test a configuration of behavior of the JComboBoxSearcheableDynamic
136
			//JComboBoxSearcheableDynamic jCBSD = new JComboBoxSearcheableDynamic(false, false, false, true);
137
	
138
			// Test a configuration of behavior of the JComboBoxSearcheableDynamic
139
			//JComboBoxSearcheableDynamic jCBSD = new JComboBoxSearcheableDynamic(false, false, false, false);
140
			
141 133
			// If the flags configuration is ok -> test the component
142 134
			if (jCBSD.testFlagsConfigurationOK())
143 135
			{
trunk/libraries/libUI/src/org/gvsig/gui/beans/comboBoxItemsSeeker/ComboBoxItemsSeekerDynamicModel.java
62 62
	// INNER MODEL STRUCTURES
63 63
	private Set itemsShowed;
64 64
	private Object itemsShowedSortedOrDisordered[];
65
	private String writtenText;
66 65
//	private String writtenString = "";
67 66
	// END INNER MODEL STRUCTURES
68 67
	
69 68
	// CONTANTS FOR CONFIGURE THE BEHAVIOR
70
	public final int ORIGINAL_POSITION_ALL = 0;
71
	public final int SORTED_ALL = 1;
72
	public final int DISORDERED_ALL = 2;
69
	public static final int MAINTAIN_ORIGINAL_POSITION_START = 0;
70
	public static final int ORDERED_START = 1;
71
	public static final int DISORDERED_START = 2;
73 72

  
74
	public final int ORIGINAL_POSITION_SEARCH = 0;
75
	public final int SORTED_SEARCH = 1;
76
	public final int DISORDERED_SEARCH = 2;
73
	public static final int MAINTAIN_ORIGINAL_POSITION_ALL_ITEMS_SEARCH = 3;
74
	public static final int ORDERED_ALL_ITEMS_SEARCH = 4;
75
	public static final int DISORDERED_ALL_ITEMS_SEARCH = 5;
76
	public static final int MAINTAIN_ORIGINAL_POSITION_DYNAMIC_SEARCH = 6;
77
	public static final int ORDERED_DYNAMIC_SEARCH = 7;
78
	public static final int DISORDERED_DYNAMIC_SEARCH = 8;
79

  
77 80
	// END CONTANTS FOR CONFIGURE THE BEHAVIOR
78 81
	
79 82
	// CONFIGURATION FLAGS (Voy a Cambiar algunas!!!!)
80
	private boolean maintainPositionItems;	
81
	private boolean alphanumericSortedSearches;
82
	private boolean allAlphanumericSorted;
83
//	private boolean maintainPositionItems;	
84
//	private boolean alphanumericSortedSearches;
85
//	private boolean allAlphanumericSorted;
86
	private int startBehavior;
87
	private int searchBehavior;
83 88
	private boolean keySensitive;
84 89
	private boolean showAllItems;
85 90
//	(With the default value)
......
88 93
//	private boolean allAlphanumericSorted  = true;
89 94
//	private boolean keySensitive = false;
90 95
//	private boolean showAllItems = true; //false;;
91
	// END FLAGS	
96
	// END FLAGS	//		this.maintainPositionItems = true;		
97
//	this.alphanumericSortedSearches = true;
98
//	this.allAlphanumericSorted = false;
92 99

  
100

  
93 101
	// OTHER FLAGS
102
	private boolean startView;
94 103
	private boolean allItemsAreSorted;
95 104
	private boolean allItemsAreDisordered;
96
	private boolean thisIsAComboBoxItemsSeekerDynamicModelClass; // To distinguish the class which invokes some methods of this class
105
	private boolean thisIsAComboBoxItemsSeekerDynamicModelClass; // To distinguish the class which invokes some methods of this class	
97 106
	// END OTHER FLAGS
98 107

  
108
	// ATTRIBUTES FOR DYNAMIC CASES
109
	private int highIndex;
110
	private int lowIndex;
111
	private String writtenText;
112
	// END ATTRIBUTES FOR DYNAMIC CASES
113
	
99 114
	/**
100 115
	 * Default Constructor without parameters.
101 116
	 * Constructs an empty ComboBoxItemsSeekerDynamicModel object.          
......
140 155
//		this.currentString = "";
141 156
		this.writtenText = "";
142 157
		this.setDefaultBehaviorFlagsConfiguration();
158
		this.startView = true;
143 159
		this.allItemsAreSorted = false;
144 160
		this.allItemsAreDisordered = false;
145 161
		this.itemsShowed = new HashSet();
......
150 166
	 */
151 167
	private void setDefaultBehaviorFlagsConfiguration() {
152 168
		// Set the default values of the flags
153
		this.maintainPositionItems = true;		
154
		this.alphanumericSortedSearches = true;
155
		this.allAlphanumericSorted = false;
169
//		this.maintainPositionItems = true;		
170
//		this.alphanumericSortedSearches = true;
171
//		this.allAlphanumericSorted = false;
172
		this.startBehavior = this.MAINTAIN_ORIGINAL_POSITION_START;
173
		this.searchBehavior = this.ORDERED_ALL_ITEMS_SEARCH; //this.ORDERED_DYNAMIC_SEARCH;
156 174
		this.keySensitive = false;
157 175
		this.showAllItems = true; //false;	
158 176
	}
......
186 204
	 * @return boolean True if the configuration of the flags is oks, false if not
187 205
	 */
188 206
	public boolean testFlagsConfigurationOK() {
189
		if ((maintainPositionItems == allAlphanumericSorted) && (maintainPositionItems == true))
207
//		if ((maintainPositionItems == allAlphanumericSorted) && (maintainPositionItems == true))
208
//			return false;
209
//		
210
//		if ((maintainPositionItems == false) && (allAlphanumericSorted == true) && (alphanumericSortedSearches == false))
211
//			return false;
212
		
213
		if ((this.startBehavior < 0) || (this.startBehavior > 2))
190 214
			return false;
191 215
		
192
		if ((maintainPositionItems == false) && (allAlphanumericSorted == true) && (alphanumericSortedSearches == false))
216
		if ((this.searchBehavior < 3) || (this.searchBehavior > 8))
193 217
			return false;
194 218
		
195 219
//		if ((showAllItems == true) && (maintainPositionItems == false))
......
198 222
		return true;
199 223
	}
200 224

  
201
	/**
202
	 * Gets the flag of the configuration of the policy for maintain the position of the items of this component 
203
	 * (true -> maintains the position of the items, false -> don't maintains the position of the items)
204
	 * 
205
	 * @return boolean The value of the flag
206
	 */
207
	public boolean isMaintainPositionItems() {
208
		return maintainPositionItems;
225
	public int getStartBehavior() {
226
		return this.startBehavior;
209 227
	}
210 228
	
211
	/**
212
	 * Sets the flag of the configuration of the policy for maintain the position of the items of this component 
213
	 * (true -> maintains the position of the items, false -> don't maintains the position of the items)
214
	 * 
215
	 * @param boolean The value of the flag
216
	 */
217
	public void setMaintainPositionItems(boolean maintain_Position_Items) {
218
		this.maintainPositionItems = maintain_Position_Items;
229
	public void setStartBehavior(int start_Behavior) {
230
		this.startBehavior = start_Behavior;
219 231
	}
220
	
221
	/**
222
	 * Gets the flag of the configuration of the alphanumericSortedSearches flag of this component 
223
	 * (true -> all items showed when we write on the textfield will be showed in alphanumeric ordenation; false -> they don't have to be in alphanumeric ordenation)
224
	 * 
225
	 * @return boolean The value of the flag
226
	 */
227
	public boolean isAlphanumericSortedSearches() {
228
		return alphanumericSortedSearches;
232

  
233
	public int getSearchBehavior() {
234
		return this.searchBehavior;
229 235
	}
230
	
231
	/**
232
	 * Sets the flag of the configuration of the alphanumericSortedSearches flag of this component 
233
	 * (true -> all items showed when we write on the textfield will be showed in alphanumeric ordenation; false -> they don't have to be in alphanumeric ordenation)
234
	 * 
235
	 * @param boolean The value of the flag
236
	 */
237
	public void setAlphanumericSortedSearches(boolean alphanumeric_Sorted_Searches) {
238
		this.alphanumericSortedSearches = alphanumeric_Sorted_Searches;
239
		
240
//		if (!testFlagsConfigurationOK())
241
//			JOptionPane.showMessageDialog(this, PluginServices.getText(this, "error_message_JComboBoxSearcheableDynamic"), PluginServices.getText(this, "exportJOP2Title"), JOptionPane.ERROR_MESSAGE);
242
//
243
//		if (alphanumericSortedSearches)
244
//		{
245
//			notRemovedItems = new HashSet();
246
//			
247
//			for (int i=0; i < this.getItemCount(); i++)
248
//				notRemovedItems.add(this.getItemAt(i));
249
//		}
250
//		else
251
//			notRemovedItems.clear();
252 236

  
237
	public void setSearchBehavior(int search_Behavior) {
238
		this.searchBehavior = search_Behavior;
253 239
	}
254
	
240

  
255 241
	/**
256
	 * Gets the flag of the configuration of the allAlphanumericSorted flag of this component 
257
	 * (true -> all items showed will be in alphanumeric ordenation; false -> they don't have to be in alphanumeric ordenation)
258
	 * 
259
	 * @return boolean The value of the flag
260
	 */
261
	public boolean isAllAlphanumericSorted() {
262
		return allAlphanumericSorted;
263
	}
264
	
265
	/**
266
	 * Sets the flag of the configuration of the allAlphanumericSorted flag of this component 
267
	 * (true -> all items showed will be in alphanumeric ordenation; false -> they don't have to be in alphanumeric ordenation)
268
	 * 
269
	 * @param boolean The value of the flag
270
	 */
271
	public void setAllAlphanumericSorted(boolean all_Alphanumeric_Sorted) {
272
		this.allAlphanumericSorted = all_Alphanumeric_Sorted;
273
		
274
		// If all_Alphanumeric_Sorted = true -> alphanumeric_Sorted_Searches = true
275
		setAlphanumericSortedSearches(this.alphanumericSortedSearches | this.allAlphanumericSorted);
276
		
277
//		if (allAlphanumericSorted)
278
//		
279
	}
280
	
281
	/**
282 242
	 * Gets the flag of the configuration of the keySensitive flag of this component 
283 243
	 * (true -> discriminates capital letters from small letters ,false -> don't discriminates capital letters from small letters)
284 244
	 * 
......
330 290
	 * @see javax.swing.DefaultComboBoxModel#getSize()
331 291
	 */
332 292
	public int getSize() {
333
		// TENGO DUDAS DE ESTE ALGORITMO
334
		if (thisIsAComboBoxItemsSeekerDynamicModelClass == true)
293
		if (thisIsAComboBoxItemsSeekerDynamicModelClass)
335 294
		{
336
//			System.out.println("ENTRA AQUI ComboBoxItemsSeekerDynamicModel");
337
			if (this.showAllItems)
338
				return this.itemsShowed.size();
339
			else
295
			if (this.startView)
296
				return this.itemsShowed.size();			
297
			
298
			switch(this.getSearchBehavior())
340 299
			{
341
				// HAcerlo
342
//				System.out.println("ENTRA AQUI");
343
				return 0;
300
				case MAINTAIN_ORIGINAL_POSITION_ALL_ITEMS_SEARCH: case ORDERED_ALL_ITEMS_SEARCH: case DISORDERED_ALL_ITEMS_SEARCH:
301
					return this.itemsShowed.size();
302
//					break;
303
				case MAINTAIN_ORIGINAL_POSITION_DYNAMIC_SEARCH:
304
					return 0; // HACER
305
//					break;
306
				case ORDERED_DYNAMIC_SEARCH:
307
					return 0; // HACER
308
//					break;
309
				case DISORDERED_DYNAMIC_SEARCH:
310
					return 0; // HACER
311
//					break;
312
				default:
313
					// If error configuration -> it gives back 0 for not to produce more errors 
314
					return 0; // HACER
344 315
			}
345 316
		}
346 317
		else
347
		{
348
			// If the class which is this object instance is 'javax.swing.DefaultComboBoxModel'
349
//			System.out.println("ENTRA AQUI DEFAULTCOMBOBOXMODEL");
350 318
			return super.getSize();
351
		}
352 319
	}
353 320

  
354 321
	/*
......
356 323
	 * @see javax.swing.ListModel#getElementAt(int)
357 324
	 */
358 325
	public Object getElementAt(int index) {
359
		if (this.showAllItems)
360
		{
361

  
362
			// Primero considerar el mostrar todos al comienzo
363
			
364
			
365
			
366
			// Caso de las b?squedas
367
			
368
			// If the items have to be showed in ascending order
369
			if (this.alphanumericSortedSearches)
326
		
327
		if (this.startView) // At the beginning shows all items
328
		{			
329
			switch(this.getStartBehavior())
370 330
			{
371
				// If the items aren't sorted -> sort them!
372
				if (!this.allItemsAreSorted)
373
					this.sortItemsCopy();
374
				
375
				// Return the item at that position
376
				return this.itemsShowedSortedOrDisordered[index];
377
			}
378
			else
379
			{
380
				if (this.maintainPositionItems)
331
				case MAINTAIN_ORIGINAL_POSITION_START :					
381 332
					return super.getElementAt(index);
382
				else
383
				{
333
//					break;
334
				case ORDERED_START :
384 335
					// If the items aren't sorted -> sort them!
336
					if (!this.allItemsAreSorted)
337
						this.sortItemsCopy();
338
					
339
					// Return the item at that position
340
					return this.itemsShowedSortedOrDisordered[index];
341
//					break;
342
				case DISORDERED_START :
343
					// If the items aren't sorted -> sort them!
385 344
					if (!this.allItemsAreDisordered)
386 345
						this.disorderItemsCopy();
387
//					System.out.println("BBB");
346

  
388 347
					// Return the item at that position
389 348
					return this.itemsShowedSortedOrDisordered[index];
390
				}
349
//					break;
350
				default:
351
					// If error configuration -> it gives back an empty object for not to produce more errors 
352
					return new Object();
391 353
			}
392 354
		}
393 355
		else
394
		{
395
			// HAcerlo
396
			return new Object();
356
		{			
357
			switch(this.getSearchBehavior())
358
			{
359
				case MAINTAIN_ORIGINAL_POSITION_ALL_ITEMS_SEARCH :
360
					return super.getElementAt(index);
361
//						break;
362
				case ORDERED_ALL_ITEMS_SEARCH :
363
					// If the items aren't sorted -> sort them!
364
					if (!this.allItemsAreSorted)
365
						this.sortItemsCopy();
366
					
367
					// Return the item at that position
368
					return this.itemsShowedSortedOrDisordered[index];
369
//						break;
370
				case DISORDERED_ALL_ITEMS_SEARCH :
371
					// If the items aren't sorted -> sort them!
372
					if (!this.allItemsAreDisordered)
373
						this.disorderItemsCopy();
374

  
375
					// Return the item at that position
376
					return this.itemsShowedSortedOrDisordered[index];
377
//						break;
378
				case MAINTAIN_ORIGINAL_POSITION_DYNAMIC_SEARCH :
379
					if (!this.allItemsAreSorted)
380
						this.sortItemsCopy();
381
					
382
					return new Object(); // HACER
383
//						break;
384
				case ORDERED_DYNAMIC_SEARCH :
385
					if (!this.allItemsAreSorted)
386
						this.sortItemsCopy();
387
					
388
					return new Object(); // HACER
389
//						break;
390
				case DISORDERED_DYNAMIC_SEARCH :
391
					if (!this.allItemsAreSorted)
392
						this.sortItemsCopy();
393
					
394
					return new Object(); // HACER
395
//						break;
396
				default:
397
					// If error configuration -> it gives back an empty object for not to produce more errors 
398
					return new Object();
399
			}
397 400
		}		
398 401
	}
399 402

  
......
408 411
		this.itemsShowed.add(anObject);
409 412
		
410 413
		// If this model has to return the elements sorted
411
		if (this.alphanumericSortedSearches)
414
		if ((this.getStartBehavior() == this.ORDERED_START) || (this.getSearchBehavior() == this.ORDERED_ALL_ITEMS_SEARCH) || (this.getSearchBehavior() == this.ORDERED_DYNAMIC_SEARCH))
415
		//if (this.alphanumericSortedSearches)
412 416
			this.allItemsAreSorted = false;
413
		
414
		// If elements have to be disordered
415
		if ((!this.maintainPositionItems) && (!this.alphanumericSortedSearches))
416
			this.allItemsAreDisordered = false;
417
		else
418
		{
419
			// If elements have to be disordered
420
			if ((this.getStartBehavior() == this.DISORDERED_START) || (this.getSearchBehavior() == this.DISORDERED_ALL_ITEMS_SEARCH) || (this.getSearchBehavior() == this.DISORDERED_DYNAMIC_SEARCH))
421
			//if ((!this.maintainPositionItems) && (!this.alphanumericSortedSearches))
422
				this.allItemsAreDisordered = false;
423
		}
417 424
	 }
418 425

  
419 426
	/*
......
447 454
		this.itemsShowed.add(anObject);
448 455

  
449 456
		// If this model has to return the elements sorted
450
		if (this.alphanumericSortedSearches)
457
		if ((this.getStartBehavior() == this.ORDERED_START) || (this.getSearchBehavior() == this.ORDERED_ALL_ITEMS_SEARCH) || (this.getSearchBehavior() == this.ORDERED_DYNAMIC_SEARCH))
458
		//if (this.alphanumericSortedSearches)
451 459
			this.allItemsAreSorted = false;
452 460
		
453 461
		// If elements have to be disordered
454
		if ((!this.maintainPositionItems) && (!this.alphanumericSortedSearches))
462
		if ((this.getStartBehavior() == this.DISORDERED_START) || (this.getSearchBehavior() == this.DISORDERED_ALL_ITEMS_SEARCH) || (this.getSearchBehavior() == this.DISORDERED_DYNAMIC_SEARCH))
463
		//if ((!this.maintainPositionItems) && (!this.alphanumericSortedSearches))
455 464
			this.allItemsAreDisordered = false;
456 465
	}
457 466
    
......
466 475
		itemsShowed.clear();		
467 476

  
468 477
		// If this model has to return the elements sorted
469
		if (this.alphanumericSortedSearches)
478
		if ((this.getStartBehavior() == this.ORDERED_START) || (this.getSearchBehavior() == this.ORDERED_ALL_ITEMS_SEARCH) || (this.getSearchBehavior() == this.ORDERED_DYNAMIC_SEARCH))
479
		//if (this.alphanumericSortedSearches)
470 480
			this.allItemsAreSorted = false;
471 481
		
472 482
		// If elements have to be disordered
473
		if ((!this.maintainPositionItems) && (!this.alphanumericSortedSearches))
483
		if ((this.getStartBehavior() == this.DISORDERED_START) || (this.getSearchBehavior() == this.DISORDERED_ALL_ITEMS_SEARCH) || (this.getSearchBehavior() == this.DISORDERED_DYNAMIC_SEARCH))
484
		//if ((!this.maintainPositionItems) && (!this.alphanumericSortedSearches))
474 485
			this.allItemsAreDisordered = false;
475 486
	}
476 487
    
......
485 496
		itemsShowed.remove(anObject);
486 497
		
487 498
		// If this model has to return the elements sorted
488
		if (this.alphanumericSortedSearches)
499
		if ((this.getStartBehavior() == this.ORDERED_START) || (this.getSearchBehavior() == this.ORDERED_ALL_ITEMS_SEARCH) || (this.getSearchBehavior() == this.ORDERED_DYNAMIC_SEARCH))
500
		//if (this.alphanumericSortedSearches)
489 501
			this.allItemsAreSorted = false;
490 502
		
491 503
		// If elements have to be disordered
492
		if ((!this.maintainPositionItems) && (!this.alphanumericSortedSearches))
504
		if ((this.getStartBehavior() == this.DISORDERED_START) || (this.getSearchBehavior() == this.DISORDERED_ALL_ITEMS_SEARCH) || (this.getSearchBehavior() == this.DISORDERED_DYNAMIC_SEARCH))
505
		//if ((!this.maintainPositionItems) && (!this.alphanumericSortedSearches))
493 506
			this.allItemsAreDisordered = false;
494 507
	}
495 508
    
......
507 520
		itemsShowed.remove(obj);
508 521
		
509 522
		// If this model has to return the elements sorted
510
		if (this.alphanumericSortedSearches)
523
		if ((this.getStartBehavior() == this.ORDERED_START) || (this.getSearchBehavior() == this.ORDERED_ALL_ITEMS_SEARCH) || (this.getSearchBehavior() == this.ORDERED_DYNAMIC_SEARCH))
524
		//if (this.alphanumericSortedSearches)
511 525
			this.allItemsAreSorted = false;
512 526
		
513 527
		// If elements have to be disordered
514
		if ((!this.maintainPositionItems) && (!this.alphanumericSortedSearches))
528
		if ((this.getStartBehavior() == this.DISORDERED_START) || (this.getSearchBehavior() == this.DISORDERED_ALL_ITEMS_SEARCH) || (this.getSearchBehavior() == this.DISORDERED_DYNAMIC_SEARCH))
529
		//if ((!this.maintainPositionItems) && (!this.alphanumericSortedSearches))
515 530
			this.allItemsAreDisordered = false;
516 531
	}
517 532
    
518
//	/*
519
//	 *  (non-Javadoc)
520
//	 * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
521
//	 */
522
//	public void setSelectedItem(Object anObject) {
523
//		super.setSelectedItem(anObject);
524
//	}
525
//	
526
//	////// END REIMPLEMENTATION OF METHODS OF "DefaultComboBoxModel" TO ADAPT THE BEHAVIOR OF THIS MODEL //////	
527
//
528
//
529
//	/**
530
//	 * @param currentString 
531
//	 */
532
//	public void setCurrentString(String currentString) {
533
//		this.currentString = currentString;
534
//		
535
//		System.out.println("SetCurrentString-> CurrentString: '" + this.currentString + "'");
536
////		Vector v = new Vector();		
537
//		
538
//		//Refrescar el modelo
539
//		
540
////		for (int i=0 ; i< super.getSize() ; i++){
541
////			String obj = super.getElementAt(i).toString();
542
////			if (currentString.equals("")){
543
////				v.add(super.getElementAt(i));
544
////			}else if (obj.indexOf(currentString) == 0){
545
////				v.add(super.getElementAt(i));
546
////			}
547
////		}		
548
//	}
549
	
550
//	/**
551
//	 * 
552
//	 * @return
553
//	 */
554
//	public String getCurrentString() {
555
//		System.out.println("GetCurrentString-> CurrentString: '" + this.currentString + "'");
556
//		return this.currentString;
557
//	}
558
	
559
	
560 533
	/**
561 534
	 * 
562 535
	 */
......
564 537
//		System.out.println("Entrada: " + writtenString);
565 538
		writtenText = text;
566 539
		
567
		if ((!this.maintainPositionItems) && (!this.alphanumericSortedSearches))
568
			this.disorderItemsCopy();
540
		
541
//		if (text.compareTo("") == 0)
542
//		{
543
//			this.startShow = true;
544
			
545
			if (this.getStartBehavior() == this.DISORDERED_START)
546
				this.disorderItemsCopy();
547
//		}
548
//		else
549
//			this.startShow = false;
550
		
551
//		if ((text.compareTo("") == 0) && (this.getStartBehavior() == this.DISORDERED_START))
552
//			this.disorderItemsCopy();
553
		
554
//		if ((!this.maintainPositionItems) && (!this.alphanumericSortedSearches))
555
//			this.disorderItemsCopy();
569 556
	}
570 557
	
558
	public void setStartViewFlag(boolean flagValue) {
559
		this.startView = flagValue;
560
	}
561
	
571 562
	/**
572 563
	 * This method sort the items of this component and store them on a array
573 564
	 */
574 565
	private void sortItemsCopy() {
575
		if (this.alphanumericSortedSearches)
576
		{
566
		//if ((this.getStartBehavior() == this.ORDERED_START) || (this.getSearchBehavior() == this.ORDERED_SEARCH))
567
//		if (this.alphanumericSortedSearches)
568
//		{
577 569
			this.itemsShowedSortedOrDisordered = this.itemsShowed.toArray();
578 570
			Arrays.sort(this.itemsShowedSortedOrDisordered);
579 571
			this.allItemsAreSorted = true;
580
		}
572
//		}
581 573
	}
582 574
	
583 575
	/**
584 576
	 * This method gets the items of this component disordered and store them on a array
585 577
	 */
586 578
	private void disorderItemsCopy() {
587
		if ((!this.maintainPositionItems) && (!this.alphanumericSortedSearches))			
588
		{
579
//		if ((!this.maintainPositionItems) && (!this.alphanumericSortedSearches))			
580
//		{
589 581
			this.itemsShowedSortedOrDisordered = this.itemsShowed.toArray();
590 582
			Collections.shuffle(Arrays.asList(this.itemsShowedSortedOrDisordered)); // Disorder the items
591 583
			this.allItemsAreDisordered = true;
592
		}
584
//		}
593 585
	}	
594 586
}
trunk/libraries/libUI/src/org/gvsig/gui/beans/comboBoxItemsSeeker/JComboBoxItemsSeekerDynamic.java
35 35
import javax.swing.text.JTextComponent;
36 36
import javax.swing.text.PlainDocument;
37 37

  
38
import org.gvsig.gui.beans.comboBoxItemsSeeker.JComboBoxItemsSeekerDynamic;
39 38
import org.gvsig.gui.beans.comboBoxItemsSeeker.ComboBoxItemsSeekerDynamicModel;
40 39

  
41 40

  
......
149 148
	private int lastSelectedIndex;
150 149
	
151 150
	// pueDE QUE TB. SOBRE
152
//	private int num = 0;
151
	private int num = 0;
153 152
//	private JTextField txtField;
154 153
	
155 154
	// Reference to the ui
......
206 205
	 * @param boolean (true -> all items showed will be in alphanumeric ordenation; false -> they don't have to be in alphanumeric ordenation)
207 206
	 * @param boolean (true -> discriminates capital letters from small letters; false -> don't discriminates capital letters from small letters)
208 207
	 */
209
	public JComboBoxItemsSeekerDynamic(boolean maintain_Position_Items, boolean alphanumeric_Sorted_Searches, boolean all_Alphanumeric_Sorted, boolean key_Sensitive)	{
208
	public JComboBoxItemsSeekerDynamic(int start_Behavior, int search_Behavior, boolean key_Sensitive)	{
210 209
		// Invokes to the parent class constructor		
211 210
		super();	
212 211

  
......
214 213
		this.initialize();
215 214
		
216 215
		// Sets the options selected by the user
217
		this.model.setMaintainPositionItems(maintain_Position_Items);
218
		this.model.setAllAlphanumericSorted(all_Alphanumeric_Sorted);
219
		this.model.setAlphanumericSortedSearches(alphanumeric_Sorted_Searches);
216
//		this.model.setMaintainPositionItems(maintain_Position_Items);
217
//		this.model.setAllAlphanumericSorted(all_Alphanumeric_Sorted);
218
//		this.model.setAlphanumericSortedSearches(alphanumeric_Sorted_Searches);
219
		this.model.setStartBehavior(start_Behavior);
220
		this.model.setStartBehavior(search_Behavior);
220 221
		this.model.setKeySensitive(key_Sensitive);
221 222
		this.model.setShowAllItems(false);
222 223
		this.onlyOneColor = false;
223 224
		this.completeMatchedItem = true;
224
		this.useBeep = false; //true;
225
		this.useBeep = true;
225 226
		
226 227
		if (!testFlagsConfigurationOK())
227 228
			JOptionPane.showMessageDialog(this, PluginServices.getText(this, "error_message_JComboBoxSearcheableDynamic"), PluginServices.getText(this, "exportJOP2Title"), JOptionPane.ERROR_MESSAGE);
......
242 243
  	 * @param boolean (completeMatchedItem (explicar))
243 244
  	 * @param boolean (useBeep (explicar))
244 245
	 */
245
	public JComboBoxItemsSeekerDynamic(boolean maintain_Position_Items, boolean alphanumeric_Sorted_Searches, boolean all_Alphanumeric_Sorted, boolean key_Sensitive, boolean only_One_Color, boolean show_All_Items, boolean complete_Matched_Item, boolean use_Beep) {
246
	public JComboBoxItemsSeekerDynamic(int start_Behavior, int search_Behavior, boolean key_Sensitive, boolean only_One_Color, boolean show_All_Items, boolean complete_Matched_Item, boolean use_Beep) {
246 247
		// Invokes to the parent class constructor		
247 248
		super();	
248 249

  
......
250 251
		this.initialize();
251 252
		
252 253
		// Sets the options selected by the user
253
		this.model.setMaintainPositionItems(maintain_Position_Items);
254
		this.model.setAllAlphanumericSorted(all_Alphanumeric_Sorted);
255
		this.model.setAlphanumericSortedSearches(alphanumeric_Sorted_Searches);
254
//		this.model.setMaintainPositionItems(maintain_Position_Items);
255
//		this.model.setAllAlphanumericSorted(all_Alphanumeric_Sorted);
256
//		this.model.setAlphanumericSortedSearches(alphanumeric_Sorted_Searches);
257
		this.model.setStartBehavior(start_Behavior);
258
		this.model.setStartBehavior(search_Behavior);
256 259
		this.model.setKeySensitive(key_Sensitive);
257 260
		this.model.setShowAllItems(show_All_Items);
258 261
		this.onlyOneColor = only_One_Color;
......
320 323
				// TODO Auto-generated method stub
321 324
//				System.out.println("NUM: " + num + " DocumentListener->changedUpdate");
322 325
//				num++;
326
//				if (!isOnlyOneColor())
327
//					document.lookupItem(document.getText(0, document.getLength()));
323 328
			}
324 329

  
325 330
			public void insertUpdate(DocumentEvent arg0) {
......
337 342
				else
338 343
					upOrDownKeyPressed = false;
339 344
				//model.setWrittenString(writtenString);
345
				
346
				// If we insert characters by default if we use two color -> set color red ; and if the item would match in the lookUp algorithm of the PlainDocumentSeeker
347
				//    text will be on black color
348
		        if (!isOnlyOneColor())
349
		        	editor.getEditorComponent().setForeground(Color.RED);
350

  
340 351
			}
341 352

  
342 353
			public void removeUpdate(DocumentEvent arg0) {
343 354
				// TODO Auto-generated method stub
344 355
//				System.out.println("NUM: " + num + " DocumentListener->removeUpdate");
345 356
//				num++;
357
				
358
				// If we remove characters by default if we use two color -> set color red ; and if the item would match in the lookUp algorithm of the PlainDocumentSeeker
359
				//    text will be on black color
360
		        if (!isOnlyOneColor())
361
		        	editor.getEditorComponent().setForeground(Color.RED);
362
		        
363
//		        try {
364
//					System.out.println("TEXTO ->" + document.getText(0, document.getLength()) + "<-");
365
//				} catch (BadLocationException e) {
366
//					// TODO Auto-generated catch block
367
//					e.printStackTrace();
368
//				}
369
//				
370
//				try {
371
//					if (document.getText(0, document.getLength()).compareTo("") == 0)
372
//					{
373
//						System.out.println("ESVACIO");						
374
//					}
375
//				} catch (BadLocationException e) {
376
//					// TODO Auto-generated catch block
377
//					e.printStackTrace();
378
//				}
379
		        
380

  
381
//				if (!isOnlyOneColor())
382
//				{
383
//					if (getSelectedItem() != null)
384
//					{
385
//						getSelectedItem()
386
//					}
387
//					
388
//				}
389
//				try {
390
//					System.out.println("ESCRITO ESTA: ->" + document.getText(0, document.getLength()) + "<-");
391
//					
392
//					if (!isOnlyOneColor())
393
//						document.lookupItem(document.getText(0, document.getLength()));
394
//				} catch (BadLocationException e) {
395
//					// TODO Auto-generated catch block
396
//					e.printStackTrace();
397
//				}
398
				
399
//		        if (!isOnlyOneColor())
400
//		        	editor.getEditorComponent().setForeground(Color.RED);
401

  
402
				
346 403
			}			
347 404
		};
348 405
	}
......
399 456
		
400 457
		// Defines and add a Document listener for changes on the document of the editor of this component
401 458
		document.addDocumentListener(this.documentListener);
402

  
403 459
	}
404 460
	
405 461
	
......
498 554
//						String currentString = model.getCurrentString();
499 555
//						if (currentString.length() > 0)
500 556
//							model.setCurrentString(currentString.substring(0,model.getCurrentString().length()-1));
501
						
557
					
502 558
						hitBackspace=true;
503 559
						hitBackspaceOnSelection=editor.getSelectionStart()!=editor.getSelectionEnd();
504 560
						break;
......
506 562
					case KeyEvent.VK_DELETE : // supr key in spanish keyboard
507 563
						// Do nothing -> use the default behavior
508 564
						//ke.consume();
565
						
566
//						try {
567
//							System.out.println("ESCRITO ESTA:->" + document.getText(0, document.getLength()) + "<-");
568
//							
569
//							// Updates the document color
570
//							if (!isOnlyOneColor())
571
//								document.lookupItem(document.getText(0, document.getLength()));
572
//							
573
//						} catch (BadLocationException e) {
574
//							// TODO Auto-generated catch block
575
//							e.printStackTrace();
576
//						}
577

  
578
						
509 579
						break;
510 580
					case KeyEvent.VK_DOWN :
511 581
					    // If the key (typed, pressed and) released has been the Down Key -> when there isn't any text (item of the list) selected, select the first
......
581 651
						break;
582 652
					case KeyEvent.VK_ESCAPE :
583 653
						// Reset to the beginning behavior
654
						model.setStartViewFlag(true);						
584 655
						setSelectedIndex(0);
585 656
						highlightCompletedText(0);
586 657
						break;
587 658

  
588 659
					default:
589
						//System.out.println("Key Pressed:" + ke.getKeyCode());
590
						 if (editor.getText().trim().equalsIgnoreCase("")) {
591
							// If the current string in the JTextField of the Editor is an empty string -> hide the popup list and the reset the index
592
							lastSelectedIndex = -1;
593
							setSelectedIndex(lastSelectedIndex);
594
							hidePopup();
595
						 }
596
						
597
						
598
						
599
//					// If the key (typed, pressed and) released has been the TAB Key -> try to complete the current selected item from the list and hide the popup list
600
//
601
//					// If there isn't any item selected and there are items, select and show the first item
602
//					if (this.getModel().getSize() > 0)
603
//					{
604
//						if (!showAllItems)
605
//						{
606
//							int numItems = this.getItemCount();
607
//							
608
//							if (alphanumericSortedSearches)
609
//							{
610
//								for (int i=1; i < numItems; i++)
611
//								{
612
//									removedItems.add(this.getModel().getElementAt(1));
613
//									notRemovedItems.remove(this.getModel().getElementAt(1));
614
//									this.removeItemAt(1);
615
//								}
616
//							}
617
//							else
618
//							{
619
//								for (int i=1; i < numItems; i++)
620
//								{
621
//									removedItems.add(this.getModel().getElementAt(1));
622
//									this.removeItemAt(1);
623
//								}							
624
//							}
625
//						
626
//							// Show a item
627
//							this.setSelectedIndex(0);
628
//						}
629
//					}
630
						// A?ADIR LOS CASOS DE TECLA-ESCAPE; y ??
631
//				} else if (ke.getKeyChar() == KeyEvent.VK_ESCAPE) {
632
//					// If the key (typed, pressed and) released has been the Escape Key -> hide the popup list and empty the JTextField			
633
//					this.hidePopup();
634
//					
635
//					if ((!maintainPositionItems) && (!allAlphanumericSorted))
636
//					{
637
//						if (removedItems.size() > 0)
638
//						{
639
//							Iterator it = removedItems.iterator();
640
//							
641
//							while(it.hasNext())
642
//								super.addItem(it.next());
643
//							
644
//							removedItems.clear();
645
//						}
646
//					}
647
//					else
648
//						this.setModel(getCopyOfModel());
649
//
650
//					txtField.setText("");
651
//					txtField.setForeground(Color.BLACK);
652
//					lastSelectedItem = -1;
653
//					this.setSelectedIndex(lastSelectedItem);
654
//
655
//				
656
//
657
						//				    } else if (txtField.getText().trim().equalsIgnoreCase("")) {
658
//						// If the current string in the JTextField of the Editor is an empty string -> hide the popup list and the reset the index
659
//				    	lastSelectedItem = -1;
660
//						this.setSelectedIndex(lastSelectedItem);
661
//						this.hidePopup();						
662
			//	default: // Alphanumeric and simbols keys
663
						// Add the new character written
664
//						model.setCurrentString(model.getCurrentString().concat(String.valueOf(ke.getKeyChar())));
660
//						System.out.println("Key Pressed:" + ke.getKeyCode());
661
//						 if (editor.getText().trim().equalsIgnoreCase("")) {
662
//							// If the current string in the JTextField of the Editor is an empty string -> hide the popup list and the reset the index
663
////							lastSelectedIndex = -1;
664
////							setSelectedIndex(lastSelectedIndex);
665
//							hidePopup();
666
//						 }
667
//						 else // If the user has written someting -> search mode
668
							 model.setStartViewFlag(false);
665 669
                }
666 670
            }
667 671
		};
......
878 882
	 * 
879 883
	 * @return boolean The value of the flag
880 884
	 */
881
	public boolean isMaintainPositionItems() {
882
		return this.model.isMaintainPositionItems();
883
	}
884
	
885
	/**
886
	 * Sets the flag of the configuration of the policy for maintain the position of the items of this component 
887
	 * (true -> maintains the position of the items, false -> don't maintains the position of the items)
888
	 * 
889
	 * @param boolean The value of the flag
890
	 */
891
	public void setMaintainPositionItems(boolean maintain_Position_Items) {
892
		this.model.setMaintainPositionItems(maintain_Position_Items);
885
//	public boolean isMaintainPositionItems() {
886
//		return this.model.isMaintainPositionItems();
887
//	}
888
//	
889
//	/**
890
//	 * Sets the flag of the configuration of the policy for maintain the position of the items of this component 
891
//	 * (true -> maintains the position of the items, false -> don't maintains the position of the items)
892
//	 * 
893
//	 * @param boolean The value of the flag
894
//	 */
895
//	public void setMaintainPositionItems(boolean maintain_Position_Items) {
896
//		this.model.setMaintainPositionItems(maintain_Position_Items);
897
//
898
//		if (!this.model.testFlagsConfigurationOK())
899
//			JOptionPane.showMessageDialog(this, PluginServices.getText(this, "error_message_JComboBoxSearcheableDynamic"), PluginServices.getText(this, "exportJOP2Title"), JOptionPane.ERROR_MESSAGE);
900
//	}
901
//	
902
//	/**
903
//	 * Gets the flag of the configuration of the alphanumericSortedSearches flag of this component 
904
//	 * (true -> all items showed when we write on the textfield will be showed in alphanumeric ordenation; false -> they don't have to be in alphanumeric ordenation)
905
//	 * 
906
//	 * @return boolean The value of the flag
907
//	 */
908
//	public boolean isAlphanumericSortedSearches() {
909
//		return this.model.isAlphanumericSortedSearches();
910
//	}
911
//	
912
//	/**
913
//	 * Sets the flag of the configuration of the alphanumericSortedSearches flag of this component 
914
//	 * (true -> all items showed when we write on the textfield will be showed in alphanumeric ordenation; false -> they don't have to be in alphanumeric ordenation)
915
//	 * 
916
//	 * @param boolean The value of the flag
917
//	 */
918
//	public void setAlphanumericSortedSearches(boolean alphanumeric_Sorted_Searches) {
919
//		this.model.setAlphanumericSortedSearches(alphanumeric_Sorted_Searches);
920
//		
921
//		if (!this.model.testFlagsConfigurationOK())
922
//			JOptionPane.showMessageDialog(this, PluginServices.getText(this, "error_message_JComboBoxSearcheableDynamic"), PluginServices.getText(this, "exportJOP2Title"), JOptionPane.ERROR_MESSAGE);
923
//
924
////		if (this.model.isAlphanumericSortedSearches())
925
////		{
926
////			notRemovedItems = new HashSet();
927
////			
928
////			for (int i=0; i < this.getItemCount(); i++)
929
////				notRemovedItems.add(this.getItemAt(i));
930
////		}
931
////		else
932
////			notRemovedItems.clear();
933
//
934
//	}
935
//	
936
//	/**
937
//	 * Gets the flag of the configuration of the allAlphanumericSorted flag of this component 
938
//	 * (true -> all items showed will be in alphanumeric ordenation; false -> they don't have to be in alphanumeric ordenation)
939
//	 * 
940
//	 * @return boolean The value of the flag
941
//	 */
942
//	public boolean isAllAlphanumericSorted() {
943
//		return this.model.isAllAlphanumericSorted();
944
//	}
945
//	
946
//	/**
947
//	 * Sets the flag of the configuration of the allAlphanumericSorted flag of this component 
948
//	 * (true -> all items showed will be in alphanumeric ordenation; false -> they don't have to be in alphanumeric ordenation)
949
//	 * 
950
//	 * @param boolean The value of the flag
951
//	 */
952
//	public void setAllAlphanumericSorted(boolean all_Alphanumeric_Sorted) {
953
//		this.model.setAllAlphanumericSorted(all_Alphanumeric_Sorted);
954
//		
955
////		if (allAlphanumericSorted)
956
//		
957
//		if (!this.model.testFlagsConfigurationOK())
958
//			JOptionPane.showMessageDialog(this, PluginServices.getText(this, "error_message_JComboBoxSearcheableDynamic"), PluginServices.getText(this, "exportJOP2Title"), JOptionPane.ERROR_MESSAGE);
959
//	}
893 960

  
894
		if (!this.model.testFlagsConfigurationOK())
895
			JOptionPane.showMessageDialog(this, PluginServices.getText(this, "error_message_JComboBoxSearcheableDynamic"), PluginServices.getText(this, "exportJOP2Title"), JOptionPane.ERROR_MESSAGE);
961
	public int getStartBehavior() {
962
		return this.model.getStartBehavior();
896 963
	}
897 964
	
898
	/**
899
	 * Gets the flag of the configuration of the alphanumericSortedSearches flag of this component 
900
	 * (true -> all items showed when we write on the textfield will be showed in alphanumeric ordenation; false -> they don't have to be in alphanumeric ordenation)
901
	 * 
902
	 * @return boolean The value of the flag
903
	 */
904
	public boolean isAlphanumericSortedSearches() {
905
		return this.model.isAlphanumericSortedSearches();
906
	}
907
	
908
	/**
909
	 * Sets the flag of the configuration of the alphanumericSortedSearches flag of this component 
910
	 * (true -> all items showed when we write on the textfield will be showed in alphanumeric ordenation; false -> they don't have to be in alphanumeric ordenation)
911
	 * 
912
	 * @param boolean The value of the flag
913
	 */
914
	public void setAlphanumericSortedSearches(boolean alphanumeric_Sorted_Searches) {
915
		this.model.setAlphanumericSortedSearches(alphanumeric_Sorted_Searches);
965
	public void setStartBehavior(int start_Behavior) {
966
		this.model.setStartBehavior(start_Behavior);
916 967
		
917 968
		if (!this.model.testFlagsConfigurationOK())
918 969
			JOptionPane.showMessageDialog(this, PluginServices.getText(this, "error_message_JComboBoxSearcheableDynamic"), PluginServices.getText(this, "exportJOP2Title"), JOptionPane.ERROR_MESSAGE);
970
	}
919 971

  
920
//		if (this.model.isAlphanumericSortedSearches())
921
//		{
922
//			notRemovedItems = new HashSet();
923
//			
924
//			for (int i=0; i < this.getItemCount(); i++)
925
//				notRemovedItems.add(this.getItemAt(i));
926
//		}
927
//		else
928
//			notRemovedItems.clear();
972
	public int getSearchBehavior() {
973
		return this.model.getSearchBehavior();
974
	}
929 975

  
930
	}
931
	
932
	/**
933
	 * Gets the flag of the configuration of the allAlphanumericSorted flag of this component 
934
	 * (true -> all items showed will be in alphanumeric ordenation; false -> they don't have to be in alphanumeric ordenation)
935
	 * 
936
	 * @return boolean The value of the flag
937
	 */
938
	public boolean isAllAlphanumericSorted() {
939
		return this.model.isAllAlphanumericSorted();
940
	}
941
	
942
	/**
943
	 * Sets the flag of the configuration of the allAlphanumericSorted flag of this component 
944
	 * (true -> all items showed will be in alphanumeric ordenation; false -> they don't have to be in alphanumeric ordenation)
945
	 * 
946
	 * @param boolean The value of the flag
947
	 */
948
	public void setAllAlphanumericSorted(boolean all_Alphanumeric_Sorted) {
949
		this.model.setAllAlphanumericSorted(all_Alphanumeric_Sorted);
976
	public void setSearchBehavior(int search_Behavior) {
977
		this.model.setSearchBehavior(search_Behavior);
950 978
		
951
//		if (allAlphanumericSorted)
952
		
953 979
		if (!this.model.testFlagsConfigurationOK())
954 980
			JOptionPane.showMessageDialog(this, PluginServices.getText(this, "error_message_JComboBoxSearcheableDynamic"), PluginServices.getText(this, "exportJOP2Title"), JOptionPane.ERROR_MESSAGE);
955 981
	}
982

  
956 983
	
957 984
	/**
958 985
	 * Gets the flag of the configuration of the keySensitive flag of this component 
......
1159 1186
	    private Object lookupItem(String pattern) {
1160 1187
	    	
1161 1188
	    	// Reset the color to the default
1162
	    	editor.getEditorComponent().setForeground(Color.BLACK);
1189
//	    	editor.getEditorComponent().setForeground(Color.BLACK);
1163 1190
	    	
1191
	        // If no item starts with the pattern => return null and set the text written on red color if it's allowed	        
1192
	    	
1164 1193
	        Object selectedItem = model.getSelectedItem();
1165 1194
	        
1166 1195
	        // only search for a different item if the currently selected does not match
1167 1196
	        if ((selectedItem != null) && (startsWithIgnoreCase(selectedItem.toString(), pattern)))
1168 1197
	        {
1198
	        	editor.getEditorComponent().setForeground(Color.BLACK);
1169 1199
	            return selectedItem;
1170 1200
	        }
1171 1201
	        else
......
1178 1208
	                // current item starts with the pattern?
1179 1209
	                if ((currentItem != null) && (startsWithIgnoreCase(currentItem.toString(), pattern)))
1180 1210
	                {
1211
	                	editor.getEditorComponent().setForeground(Color.BLACK);
1181 1212
	                    return currentItem;
1182 1213
	                }
1183 1214
	            }
1184 1215
	        }	        
1185 1216
	          
1186
	        // If no item starts with the pattern => return null and set the text written on red color if it's allowed	        
1187
	        if (!isOnlyOneColor())
1188
	        	editor.getEditorComponent().setForeground(Color.RED);
1189 1217
	        
1190 1218
	        return null;
1191 1219
	    }

Also available in: Unified diff