public int compare(Object a, Object b) { return PropertySheetSorter.this.compare( (IPropertySheetEntry) a, (IPropertySheetEntry) b); } });
/** * Sets the sorter for this viewer. * <p> * The default sorter sorts categories and entries alphabetically. * A viewer update needs to be triggered after the sorter has changed. * </p> * @param sorter the sorter to set (<code>null</code> will reset to the * default sorter) * @since 3.1 */ public void setSorter(PropertySheetSorter sorter) { if (null == sorter) { sorter = new PropertySheetSorter(); } this.sorter = sorter; }
/** * Returns a negative, zero, or positive number depending on whether the * first element is less than, equal to, or greater than the second element. * <p> * The default implementation of this method uses the collator to * compare the strings. Subclasses may override. * </p> * * @param categoryA * the first element * @param categoryB * the second element * @return a negative number if the first element is less than the second * element; the value <code>0</code> if the first element is equal * to the second element; and a positive number if the first element * is greater than the second element */ public int compareCategories(String categoryA, String categoryB) { return getCollator().compare(categoryA, categoryB); }
/** * Returns a sorted list of <code>IPropertySheetEntry</code> entries. * * @param unsortedEntries * unsorted list of <code>IPropertySheetEntry</code> * @return a sorted list of the specified entries */ private List getSortedEntries(List unsortedEntries) { IPropertySheetEntry[] propertySheetEntries = (IPropertySheetEntry[]) unsortedEntries .toArray(new IPropertySheetEntry[unsortedEntries.size()]); sorter.sort(propertySheetEntries); return Arrays.asList(propertySheetEntries); }
/** * Sorts the given categories in-place, modifying the given array. * * @param categories * the categories to sort */ void sort(PropertySheetCategory[] categories) { Arrays.sort(categories, (a, b) -> PropertySheetSorter.this.compareCategories(a.getCategoryName(), b.getCategoryName())); } }
/** * Returns a sorted list of <code>IPropertySheetEntry</code> entries. * * @param unsortedEntries * unsorted list of <code>IPropertySheetEntry</code> * @return a sorted list of the specified entries */ private List getSortedEntries(List unsortedEntries) { IPropertySheetEntry[] propertySheetEntries = (IPropertySheetEntry[]) unsortedEntries .toArray(new IPropertySheetEntry[unsortedEntries.size()]); sorter.sort(propertySheetEntries); return Arrays.asList(propertySheetEntries); }
public int compare(Object a, Object b) { return PropertySheetSorter.this.compareCategories( ((PropertySheetCategory) a).getCategoryName(), ((PropertySheetCategory) b).getCategoryName()); } });
@Override public int compare(Object a, Object b) { return PropertySheetSorter.this.compare( (IPropertySheetEntry) a, (IPropertySheetEntry) b); } });
/** * Returns a sorted list of <code>IPropertySheetEntry</code> entries. * * @param unsortedEntries * unsorted list of <code>IPropertySheetEntry</code> * @return a sorted list of the specified entries */ private List<IPropertySheetEntry> getSortedEntries(List<IPropertySheetEntry> unsortedEntries) { IPropertySheetEntry[] propertySheetEntries = unsortedEntries .toArray(new IPropertySheetEntry[unsortedEntries.size()]); sorter.sort(propertySheetEntries); return Arrays.asList(propertySheetEntries); }
/** * Returns a negative, zero, or positive number depending on whether the * first element is less than, equal to, or greater than the second element. * <p> * The default implementation of this method uses the collator to * compare the strings. Subclasses may override. * </p> * * @param categoryA * the first element * @param categoryB * the second element * @return a negative number if the first element is less than the second * element; the value <code>0</code> if the first element is equal * to the second element; and a positive number if the first element * is greater than the second element */ public int compareCategories(String categoryA, String categoryB) { return getCollator().compare(categoryA, categoryB); }
@Override public int compare(Object a, Object b) { return PropertySheetSorter.this.compareCategories( ((PropertySheetCategory) a).getCategoryName(), ((PropertySheetCategory) b).getCategoryName()); } });
/** * Sets the sorter for this viewer. * <p> * The default sorter sorts categories and entries alphabetically. * A viewer update needs to be triggered after the sorter has changed. * </p> * @param sorter the sorter to set (<code>null</code> will reset to the * default sorter) * @since 3.1 */ public void setSorter(PropertySheetSorter sorter) { if (null == sorter) { sorter = new PropertySheetSorter(); } this.sorter = sorter; }
/** * Sorts the given elements in-place, modifying the given array. * <p> * The default implementation of this method uses the java.util.Arrays#sort * algorithm on the given array, calling <code>compare</code> to compare * elements. * </p> * <p> * Subclasses may reimplement this method to provide a more optimized * implementation. * </p> * * @param entries * the elements to sort */ public void sort(IPropertySheetEntry[] entries) { Arrays.sort(entries, (a, b) -> PropertySheetSorter.this.compare(a, b)); }
sorter.sort(categoryArray); categories = categoryArray;
/** * Returns a negative, zero, or positive number depending on whether the * first element is less than, equal to, or greater than the second element. * <p> * The default implementation of this method uses the collator to * compare the strings. Subclasses may override. * </p> * * @param categoryA * the first element * @param categoryB * the second element * @return a negative number if the first element is less than the second * element; the value <code>0</code> if the first element is equal * to the second element; and a positive number if the first element * is greater than the second element */ public int compareCategories(String categoryA, String categoryB) { return getCollator().compare(categoryA, categoryB); }
/** * Sets the sorter for this viewer. * <p> * The default sorter sorts categories and entries alphabetically. * A viewer update needs to be triggered after the sorter has changed. * </p> * @param sorter the sorter to set (<code>null</code> will reset to the * default sorter) * @since 3.1 */ public void setSorter(PropertySheetSorter sorter) { if (null == sorter) { sorter = new PropertySheetSorter(); } this.sorter = sorter; }
@Override public int compare ( final IPropertySheetEntry entryA, final IPropertySheetEntry entryB ) { final int sortKeyA = getSortKey ( entryA ); final int sortKeyB = getSortKey ( entryB ); final int result = Integer.compare ( sortKeyA, sortKeyB ); if ( result == 0 ) { return super.compare ( entryA, entryB ); } else { return result; } }
sorter.sort(categoryArray); categories = categoryArray;
/** * Returns a negative, zero, or positive number depending on whether the * first element is less than, equal to, or greater than the second element. * <p> * The default implementation of this method uses the collator to * compare the display names. Subclasses may override. * </p> * * @param entryA * the first element * @param entryB * the second element * @return a negative number if the first element is less than the second * element; the value <code>0</code> if the first element is equal * to the second element; and a positive number if the first element * is greater than the second element */ public int compare(IPropertySheetEntry entryA, IPropertySheetEntry entryB) { return getCollator().compare(entryA.getDisplayName(), entryB.getDisplayName()); }
sorter.sort(categoryArray); categories = categoryArray;