public class AutoCompleteDocument extends Object implements Document
Modifier and Type | Class and Description |
---|---|
private class |
AutoCompleteDocument.Handler |
private static class |
AutoCompleteDocument.LookupResult |
Modifier and Type | Field and Description |
---|---|
(package private) AbstractAutoCompleteAdaptor |
adaptor
The adaptor that is used to find and select items.
|
protected Document |
delegate |
private static Comparator<String> |
EQUALS |
private static Comparator<String> |
EQUALS_IGNORE_CASE |
private AutoCompleteDocument.Handler |
handler |
(package private) boolean |
selecting
Flag to indicate if adaptor.setSelectedItem has been called.
|
private static Comparator<String> |
STARTS_WITH |
private static Comparator<String> |
STARTS_WITH_IGNORE_CASE |
protected boolean |
strictMatching
true, if only items from the adaptors's list can be entered
false, otherwise (selected item might not be in the adaptors's list)
|
(package private) ObjectToStringConverter |
stringConverter |
StreamDescriptionProperty, TitleProperty
Constructor and Description |
---|
AutoCompleteDocument(AbstractAutoCompleteAdaptor adaptor,
boolean strictMatching)
Creates a new AutoCompleteDocument for the given AbstractAutoCompleteAdaptor.
|
AutoCompleteDocument(AbstractAutoCompleteAdaptor adaptor,
boolean strictMatching,
ObjectToStringConverter stringConverter)
Creates a new AutoCompleteDocument for the given AbstractAutoCompleteAdaptor.
|
AutoCompleteDocument(AbstractAutoCompleteAdaptor adaptor,
boolean strictMatching,
ObjectToStringConverter stringConverter,
Document delegate)
Creates a new AutoCompleteDocument for the given AbstractAutoCompleteAdaptor.
|
Modifier and Type | Method and Description |
---|---|
void |
addDocumentListener(DocumentListener listener) |
void |
addUndoableEditListener(UndoableEditListener listener) |
protected Document |
createDefaultDocument()
Creates the default backing document when no delegate is passed to this
document.
|
Position |
createPosition(int offs) |
Element |
getDefaultRootElement() |
Position |
getEndPosition() |
int |
getLength() |
Object |
getProperty(Object key) |
Element[] |
getRootElements() |
Position |
getStartPosition() |
String |
getText(int offset,
int length) |
void |
getText(int offset,
int length,
Segment txt) |
void |
insertString(int offs,
String str,
AttributeSet a) |
boolean |
isStrictMatching()
Returns if only items from the adaptor's list should be allowed to be entered.
|
private AutoCompleteDocument.LookupResult |
lookupItem(String pattern)
Searches for an item that matches the given pattern.
|
private AutoCompleteDocument.LookupResult |
lookupItem(String pattern,
Comparator<String> comparator) |
private AutoCompleteDocument.LookupResult |
lookupOneItem(Object item,
String pattern,
Comparator<String> comparator) |
void |
putProperty(Object key,
Object value) |
void |
remove(int offs,
int len) |
void |
removeDocumentListener(DocumentListener listener) |
void |
removeUndoableEditListener(UndoableEditListener listener) |
void |
render(Runnable r) |
private void |
setSelectedItem(Object item,
String itemAsString)
Selects the given item using the AbstractAutoCompleteAdaptor.
|
private void |
setText(String text)
Sets the text of this AutoCompleteDocument to the given text.
|
protected boolean strictMatching
boolean selecting
AbstractAutoCompleteAdaptor adaptor
ObjectToStringConverter stringConverter
private final AutoCompleteDocument.Handler handler
private static final Comparator<String> EQUALS_IGNORE_CASE
private static final Comparator<String> STARTS_WITH_IGNORE_CASE
private static final Comparator<String> EQUALS
private static final Comparator<String> STARTS_WITH
public AutoCompleteDocument(AbstractAutoCompleteAdaptor adaptor, boolean strictMatching, ObjectToStringConverter stringConverter, Document delegate)
adaptor
- The adaptor that will be used to find and select matching
items.strictMatching
- true, if only items from the adaptor's list should
be allowed to be enteredstringConverter
- the converter used to transform items to stringsdelegate
- the Document
delegate backing this documentpublic AutoCompleteDocument(AbstractAutoCompleteAdaptor adaptor, boolean strictMatching, ObjectToStringConverter stringConverter)
adaptor
- The adaptor that will be used to find and select matching
items.strictMatching
- true, if only items from the adaptor's list should
be allowed to be enteredstringConverter
- the converter used to transform items to stringspublic AutoCompleteDocument(AbstractAutoCompleteAdaptor adaptor, boolean strictMatching)
strictMatching
- true, if only items from the adaptor's list should
be allowed to be enteredadaptor
- The adaptor that will be used to find and select matching
items.protected Document createDefaultDocument()
public void remove(int offs, int len) throws BadLocationException
remove
in interface Document
BadLocationException
public void insertString(int offs, String str, AttributeSet a) throws BadLocationException
insertString
in interface Document
BadLocationException
private void setText(String text)
text
- the text that will be set for this documentprivate void setSelectedItem(Object item, String itemAsString)
itemAsString
- string representation of the item to be selecteditem
- the item that is to be selectedprivate AutoCompleteDocument.LookupResult lookupItem(String pattern)
pattern
- the pattern that should be matchednull
if no item matchesprivate AutoCompleteDocument.LookupResult lookupOneItem(Object item, String pattern, Comparator<String> comparator)
private AutoCompleteDocument.LookupResult lookupItem(String pattern, Comparator<String> comparator)
public void addDocumentListener(DocumentListener listener)
addDocumentListener
in interface Document
public void addUndoableEditListener(UndoableEditListener listener)
addUndoableEditListener
in interface Document
public Position createPosition(int offs) throws BadLocationException
createPosition
in interface Document
BadLocationException
public Element getDefaultRootElement()
getDefaultRootElement
in interface Document
public Position getEndPosition()
getEndPosition
in interface Document
public Object getProperty(Object key)
getProperty
in interface Document
public Element[] getRootElements()
getRootElements
in interface Document
public Position getStartPosition()
getStartPosition
in interface Document
public String getText(int offset, int length) throws BadLocationException
getText
in interface Document
BadLocationException
public void getText(int offset, int length, Segment txt) throws BadLocationException
getText
in interface Document
BadLocationException
public void putProperty(Object key, Object value)
putProperty
in interface Document
public void removeDocumentListener(DocumentListener listener)
removeDocumentListener
in interface Document
public void removeUndoableEditListener(UndoableEditListener listener)
removeUndoableEditListener
in interface Document
public boolean isStrictMatching()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses