|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2009 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2010 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 3267-3316
Link Here
|
| 3267 |
} |
3267 |
} |
| 3268 |
|
3268 |
|
| 3269 |
/** |
3269 |
/** |
| 3270 |
* Compares items using camel case method. |
|
|
| 3271 |
*/ |
| 3272 |
private class CamelCaseComparator implements Comparator { |
| 3273 |
|
| 3274 |
/* |
| 3275 |
* (non-Javadoc) |
| 3276 |
* |
| 3277 |
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) |
| 3278 |
*/ |
| 3279 |
public int compare(Object o1, Object o2) { |
| 3280 |
|
| 3281 |
int leftCategory = getCamelCaseCategory(o1); |
| 3282 |
int rightCategory = getCamelCaseCategory(o2); |
| 3283 |
if (leftCategory < rightCategory) |
| 3284 |
return -1; |
| 3285 |
if (leftCategory > rightCategory) |
| 3286 |
return +1; |
| 3287 |
|
| 3288 |
return getItemsComparator().compare(o1, o2); |
| 3289 |
} |
| 3290 |
|
| 3291 |
private int getCamelCaseCategory(Object item) { |
| 3292 |
if (filter == null) |
| 3293 |
return 0; |
| 3294 |
if (!filter.isCamelCasePattern()) |
| 3295 |
return 0; |
| 3296 |
return filter.matchesRawNamePattern(item) ? 0 : 1; |
| 3297 |
} |
| 3298 |
} |
| 3299 |
|
| 3300 |
/** |
| 3301 |
* Compares items according to the history. |
3270 |
* Compares items according to the history. |
| 3302 |
*/ |
3271 |
*/ |
| 3303 |
private class HistoryComparator implements Comparator { |
3272 |
private class HistoryComparator implements Comparator { |
| 3304 |
|
3273 |
|
| 3305 |
private CamelCaseComparator camelCaseComparator; |
|
|
| 3306 |
|
| 3307 |
/** |
| 3308 |
* |
| 3309 |
*/ |
| 3310 |
public HistoryComparator() { |
| 3311 |
this.camelCaseComparator = new CamelCaseComparator(); |
| 3312 |
} |
| 3313 |
|
| 3314 |
/* |
3274 |
/* |
| 3315 |
* (non-Javadoc) |
3275 |
* (non-Javadoc) |
| 3316 |
* |
3276 |
* |
|
Lines 3319-3325
Link Here
|
| 3319 |
public int compare(Object o1, Object o2) { |
3279 |
public int compare(Object o1, Object o2) { |
| 3320 |
if ((isHistoryElement(o1) && isHistoryElement(o2)) |
3280 |
if ((isHistoryElement(o1) && isHistoryElement(o2)) |
| 3321 |
|| (!isHistoryElement(o1) && !isHistoryElement(o2))) |
3281 |
|| (!isHistoryElement(o1) && !isHistoryElement(o2))) |
| 3322 |
return this.camelCaseComparator.compare(o1, o2); |
3282 |
return getItemsComparator().compare(o1, o2); |
| 3323 |
|
3283 |
|
| 3324 |
if (isHistoryElement(o1)) |
3284 |
if (isHistoryElement(o1)) |
| 3325 |
return -2; |
3285 |
return -2; |