MenuItem
- the GUI toolkit specific type for menu itemspublic class TextMenuItemSortingStrategy<MenuItem> extends Object implements MenuItemSortingStrategy<MenuItem,IdentityMenuItemSupplierFactory<MenuItem>>
MenuItemSortingStrategy
which sorts the menu items depending on their text using a locale-sensitive comparison. This sorting strategy does not add any separators.Constructor and Description |
---|
TextMenuItemSortingStrategy(Function<MenuItem,String> menuTextExtractor)
Creates a new instance of the class.
|
TextMenuItemSortingStrategy(Function<MenuItem,String> menuTextExtractor,
Collator collator)
Creates a new instance of the class.
|
Modifier and Type | Method and Description |
---|---|
int |
getMenuItemInsertionPoint(List<? extends MenuItemSupplierFactoryEntry<MenuItem,IdentityMenuItemSupplierFactory<MenuItem>>> entryList,
MenuItemSupplierFactoryEntry<MenuItem,IdentityMenuItemSupplierFactory<MenuItem>> entry)
Gets the instertion point of the new menu entry.
|
Optional<Integer> |
getSeparatorInsertionPoint(int index,
List<? extends MenuItemSupplierFactoryEntry<MenuItem,IdentityMenuItemSupplierFactory<MenuItem>>> entryList,
MenuItemSupplierFactoryEntry<MenuItem,IdentityMenuItemSupplierFactory<MenuItem>> entry)
This method will always return an empty
Optional . |
public TextMenuItemSortingStrategy(Function<MenuItem,String> menuTextExtractor)
menuTextExtractor
- the GUI-toolkit specific function which provides the text of a menu itempublic TextMenuItemSortingStrategy(Function<MenuItem,String> menuTextExtractor, Collator collator)
menuTextExtractor
- the GUI-toolkit specific function which provides the text of a menu itemcollator
- the Collator
to use for the locale-sensitive text comparisonpublic int getMenuItemInsertionPoint(List<? extends MenuItemSupplierFactoryEntry<MenuItem,IdentityMenuItemSupplierFactory<MenuItem>>> entryList, MenuItemSupplierFactoryEntry<MenuItem,IdentityMenuItemSupplierFactory<MenuItem>> entry)
getMenuItemInsertionPoint
in interface MenuItemSortingStrategy<MenuItem,IdentityMenuItemSupplierFactory<MenuItem>>
entryList
- the existing menu entriesentry
- the new entrypublic Optional<Integer> getSeparatorInsertionPoint(int index, List<? extends MenuItemSupplierFactoryEntry<MenuItem,IdentityMenuItemSupplierFactory<MenuItem>>> entryList, MenuItemSupplierFactoryEntry<MenuItem,IdentityMenuItemSupplierFactory<MenuItem>> entry)
Optional
.
Gets the instertion point of a new separator. Returns empty if no new separator should be added. This method gets called after MenuItemSortingStrategy.getMenuItemInsertionPoint(java.util.List, org.drombler.acp.core.action.MenuItemSupplierFactoryEntry)
.getSeparatorInsertionPoint
in interface MenuItemSortingStrategy<MenuItem,IdentityMenuItemSupplierFactory<MenuItem>>
index
- the index of the new menu entry which was added to the listentryList
- the existing menu entries including the new menu entryentry
- the new menu entry which was added to the listCopyright © 2012–2017 Drombler. All rights reserved.