Lines 11-26
Link Here
|
11 |
|
11 |
|
12 |
package org.eclipse.ui.views.properties; |
12 |
package org.eclipse.ui.views.properties; |
13 |
|
13 |
|
14 |
import java.text.Collator; |
|
|
15 |
import java.util.ArrayList; |
14 |
import java.util.ArrayList; |
16 |
import java.util.Arrays; |
15 |
import java.util.Arrays; |
17 |
import java.util.Collections; |
16 |
import java.util.Collection; |
18 |
import java.util.Comparator; |
|
|
19 |
import java.util.HashMap; |
17 |
import java.util.HashMap; |
20 |
import java.util.HashSet; |
18 |
import java.util.HashSet; |
21 |
import java.util.Iterator; |
19 |
import java.util.Iterator; |
22 |
import java.util.List; |
20 |
import java.util.List; |
23 |
import java.util.Locale; |
|
|
24 |
import java.util.Map; |
21 |
import java.util.Map; |
25 |
import java.util.Set; |
22 |
import java.util.Set; |
26 |
|
23 |
|
Lines 105-110
Link Here
|
105 |
|
102 |
|
106 |
// Cell editor activation listeners |
103 |
// Cell editor activation listeners |
107 |
private ListenerList activationListeners = new ListenerList(3); |
104 |
private ListenerList activationListeners = new ListenerList(3); |
|
|
105 |
|
106 |
// the property sheet sorter |
107 |
private PropertySheetSorter sorter = new PropertySheetSorter(); |
108 |
|
108 |
|
109 |
/** |
109 |
/** |
110 |
* Creates a property sheet viewer on a newly-created tree control |
110 |
* Creates a property sheet viewer on a newly-created tree control |
Lines 491-497
Link Here
|
491 |
} |
491 |
} |
492 |
|
492 |
|
493 |
/** |
493 |
/** |
494 |
* Returns the children of the given category or entry |
494 |
* Returns the sorted children of the given category or entry |
495 |
* |
495 |
* |
496 |
* @param node a category or entry |
496 |
* @param node a category or entry |
497 |
* @return the children of the given category or entry |
497 |
* @return the children of the given category or entry |
Lines 536-543
Link Here
|
536 |
return Arrays.asList(categories); |
536 |
return Arrays.asList(categories); |
537 |
} |
537 |
} |
538 |
|
538 |
|
539 |
// return the filtered child entries |
539 |
// return the sorted & filtered child entries |
540 |
return getFilteredEntries(entry.getChildEntries()); |
540 |
return getSortedEntries(getFilteredEntries(entry.getChildEntries())); |
541 |
} |
541 |
} |
542 |
|
542 |
|
543 |
/** |
543 |
/** |
Lines 549-555
Link Here
|
549 |
* <code>IPropertySheetEntry</code>) |
549 |
* <code>IPropertySheetEntry</code>) |
550 |
*/ |
550 |
*/ |
551 |
private List getChildren(PropertySheetCategory category) { |
551 |
private List getChildren(PropertySheetCategory category) { |
552 |
return getFilteredEntries(category.getChildEntries()); |
552 |
return getSortedEntries(getFilteredEntries(category.getChildEntries())); |
553 |
} |
553 |
} |
554 |
|
554 |
|
555 |
/* |
555 |
/* |
Lines 589-601
Link Here
|
589 |
} |
589 |
} |
590 |
return filteredEntries; |
590 |
return filteredEntries; |
591 |
} |
591 |
} |
|
|
592 |
|
593 |
/** |
594 |
* Returns a sorted list of <code>IPropertySheetEntry</code> entries. |
595 |
* |
596 |
* @param unsortedEntries |
597 |
* unsorted list of <code>IPropertySheetEntry</code> |
598 |
* @return a sorted list of the specified entries |
599 |
*/ |
600 |
private List getSortedEntries(List unsortedEntries) { |
601 |
IPropertySheetEntry[] propertySheetEntries = (IPropertySheetEntry[]) unsortedEntries |
602 |
.toArray(new IPropertySheetEntry[unsortedEntries.size()]); |
603 |
sorter.sort(propertySheetEntries); |
604 |
return Arrays.asList(propertySheetEntries); |
605 |
} |
606 |
|
592 |
|
607 |
|
593 |
/** |
608 |
/** |
594 |
* The <code>PropertySheetViewer</code> implementation of this method |
609 |
* The <code>PropertySheetViewer</code> implementation of this method |
595 |
* declared on <code>IInputProvider</code> returns the objects for which |
610 |
* declared on <code>IInputProvider</code> returns the objects for which |
596 |
* the viewer is currently showing properties. It returns an |
611 |
* the viewer is currently showing properties. It returns an |
597 |
* <code>Object[]</code> or <code>null</code>. |
612 |
* <code>Object[]</code> or <code>null</code>. |
598 |
*/ |
613 |
*/ |
599 |
public Object getInput() { |
614 |
public Object getInput() { |
600 |
return input; |
615 |
return input; |
601 |
} |
616 |
} |
Lines 910-915
Link Here
|
910 |
} |
925 |
} |
911 |
|
926 |
|
912 |
/** |
927 |
/** |
|
|
928 |
* Sets the sorter for this viewer. |
929 |
* <p> |
930 |
* The default sorter sorts categories and entries alphabetically. |
931 |
* A viewer update needs to be triggered after the sorter has changed. |
932 |
* </p> |
933 |
* @param sorter the sorter to set (<code>null</code> will reset to the |
934 |
* default sorter) |
935 |
*/ |
936 |
public void setSorter(PropertySheetSorter sorter) { |
937 |
if (null == sorter) |
938 |
sorter = new PropertySheetSorter(); |
939 |
this.sorter = sorter; |
940 |
} |
941 |
|
942 |
/** |
913 |
* Sets the status line manager this view will use to show messages. |
943 |
* Sets the status line manager this view will use to show messages. |
914 |
* |
944 |
* |
915 |
* @param manager |
945 |
* @param manager |
Lines 997-1021
Link Here
|
997 |
categoryCache.put(MISCELLANEOUS_CATEGORY_NAME, misc); |
1027 |
categoryCache.put(MISCELLANEOUS_CATEGORY_NAME, misc); |
998 |
|
1028 |
|
999 |
// Sort the categories |
1029 |
// Sort the categories |
1000 |
List list = new ArrayList(categoryCache.values()); |
1030 |
Collection categoryCacheValues = categoryCache.values(); |
1001 |
for (int i = 0; i < categoriesToRemove.size(); i++) |
1031 |
categories = (PropertySheetCategory[]) categoryCacheValues |
1002 |
list.remove(categoriesToRemove.get(i)); |
1032 |
.toArray(new PropertySheetCategory[categoryCacheValues.size()]); |
1003 |
Collections.sort(list, new Comparator() { |
1033 |
sorter.sort(categories); |
1004 |
Collator coll = Collator.getInstance(Locale.getDefault()); |
|
|
1005 |
|
1006 |
public int compare(Object a, Object b) { |
1007 |
PropertySheetCategory c1, c2; |
1008 |
String dname1, dname2; |
1009 |
c1 = (PropertySheetCategory) a; |
1010 |
dname1 = c1.getCategoryName(); |
1011 |
c2 = (PropertySheetCategory) b; |
1012 |
dname2 = c2.getCategoryName(); |
1013 |
return coll.compare(dname1, dname2); |
1014 |
} |
1015 |
}); |
1016 |
|
1017 |
categories = (PropertySheetCategory[]) list |
1018 |
.toArray(new PropertySheetCategory[list.size()]); |
1019 |
} |
1034 |
} |
1020 |
|
1035 |
|
1021 |
/** |
1036 |
/** |