Class AutoCompletionList
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList
-
- All Implemented Interfaces:
Serializable
,TableModel
public class AutoCompletionList extends AbstractTableModel
AutoCompletionList manages a graphical list ofAutoCompletionItem
s. The list is sorted, items with higher priority first, then according to lexicographic order on the value of theAutoCompletionItem
. AutoCompletionList maintains two views on the list ofAutoCompletionItem
s.- the bare, unfiltered view which includes all items
- a filtered view, which includes only items which match a current filter expression
AbstractTableModel
which serves the list of filtered items to aJTable
.- Since:
- 1762
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private String
filter
the filter expressionprivate ArrayList<AutoCompletionItem>
filtered
the filtered list of AutoCompletionItemsprivate AutoCompletionSet
list
the bare list of AutoCompletionItems-
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
-
Constructor Summary
Constructors Constructor Description AutoCompletionList()
constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Collection<String> values, AutoCompletionPriority priority)
adds a list of strings to this list.void
add(Collection<AutoCompletionItem> collection)
adds a collection ofAutoCompletionItem
to this list.void
add(AutoCompletionItem item)
adds anAutoCompletionItem
to the list.void
add(AutoCompletionList other)
adds anotherAutoCompletionList
to this list.void
addUserInput(Collection<String> values)
Adds values that have been entered by the user.void
applyFilter(String filter)
applies a filter expression to the list ofAutoCompletionItem
s.void
clear()
removes all elements from the auto completion listvoid
clearFilter()
clears the current filterboolean
contains(String value)
checks whether an item with the given value is already in the list.boolean
contains(AutoCompletionItem item)
checks whether a specific item is already in the list.protected void
filter()
int
getColumnCount()
String
getFilter()
Returns the current filter expression.AutoCompletionItem
getFilteredItemAt(int idx)
replies the idx-th item from the list of filtered itemsint
getFilteredSize()
replies the number of filtered itemsint
getRowCount()
(package private) AutoCompletionSet
getSet()
(package private) Set<AutoCompletionItem>
getUnmodifiableSet()
Object
getValueAt(int rowIndex, int columnIndex)
void
remove(String key)
removes the auto completion item with keykey
-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
-
-
-
-
Field Detail
-
list
private final transient AutoCompletionSet list
the bare list of AutoCompletionItems
-
filtered
private final transient ArrayList<AutoCompletionItem> filtered
the filtered list of AutoCompletionItems
-
-
Constructor Detail
-
AutoCompletionList
public AutoCompletionList()
constructor
-
-
Method Detail
-
applyFilter
public void applyFilter(String filter)
applies a filter expression to the list ofAutoCompletionItem
s. The matching criterion is a case insensitive substring match.- Parameters:
filter
- the filter expression; must not be null- Throws:
IllegalArgumentException
- if filter is null
-
clearFilter
public void clearFilter()
clears the current filter
-
getFilter
public String getFilter()
Returns the current filter expression.- Returns:
- the current filter expression; null, if no filter expression is set
-
add
public void add(AutoCompletionItem item)
adds anAutoCompletionItem
to the list. Only adds the item if it is not null and if not in the list yet.- Parameters:
item
- the item- Since:
- 12859
-
add
public void add(AutoCompletionList other)
adds anotherAutoCompletionList
to this list. An item is only added it is not null and if it does not exist in the list yet.- Parameters:
other
- another auto completion list; must not be null- Throws:
IllegalArgumentException
- if other is null
-
add
public void add(Collection<AutoCompletionItem> collection)
adds a collection ofAutoCompletionItem
to this list. An item is only added it is not null and if it does not exist in the list yet.- Parameters:
collection
- auto completion collection; must not be null- Throws:
IllegalArgumentException
- if other is null- Since:
- 12859
-
add
public void add(Collection<String> values, AutoCompletionPriority priority)
adds a list of strings to this list. Only strings which are not null and which do not exist yet in the list are added.- Parameters:
values
- a list of strings to addpriority
- the priority to use- Since:
- 12859
-
addUserInput
public void addUserInput(Collection<String> values)
Adds values that have been entered by the user.- Parameters:
values
- values that have been entered by the user
-
contains
public boolean contains(AutoCompletionItem item)
checks whether a specific item is already in the list. Matches for the the value and the priority of the item- Parameters:
item
- the item to check- Returns:
- true, if item is in the list; false, otherwise
- Since:
- 12859
-
contains
public boolean contains(String value)
checks whether an item with the given value is already in the list. Ignores priority of the items.- Parameters:
value
- the value of an auto completion item- Returns:
- true, if value is in the list; false, otherwise
-
remove
public void remove(String key)
removes the auto completion item with keykey
- Parameters:
key
- the key
-
filter
protected void filter()
-
getFilteredSize
public int getFilteredSize()
replies the number of filtered items- Returns:
- the number of filtered items
-
getFilteredItemAt
public AutoCompletionItem getFilteredItemAt(int idx)
replies the idx-th item from the list of filtered items- Parameters:
idx
- the index; must be in the range 0 <= idx <getFilteredSize()
- Returns:
- the item
- Throws:
IndexOutOfBoundsException
- if idx is out of bounds- Since:
- 12859
-
getSet
AutoCompletionSet getSet()
-
getUnmodifiableSet
Set<AutoCompletionItem> getUnmodifiableSet()
-
clear
public void clear()
removes all elements from the auto completion list
-
getColumnCount
public int getColumnCount()
-
getRowCount
public int getRowCount()
-
getValueAt
public Object getValueAt(int rowIndex, int columnIndex)
-
-