|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjavax.swing.text.AbstractDocument
javax.swing.text.PlainDocument
com.gremwell.history.HistoryDocument
public class HistoryDocument
A Document with history and autocomplete. Can be used with various text components to implement autocomplete
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument |
|---|
javax.swing.text.AbstractDocument.AbstractElement, javax.swing.text.AbstractDocument.AttributeContext, javax.swing.text.AbstractDocument.BranchElement, javax.swing.text.AbstractDocument.Content, javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AbstractDocument.ElementEdit, javax.swing.text.AbstractDocument.LeafElement |
| Field Summary |
|---|
| Fields inherited from class javax.swing.text.PlainDocument |
|---|
lineLimitAttribute, tabSizeAttribute |
| Fields inherited from class javax.swing.text.AbstractDocument |
|---|
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName |
| Fields inherited from interface javax.swing.text.Document |
|---|
StreamDescriptionProperty, TitleProperty |
| Constructor Summary | |
|---|---|
HistoryDocument(javax.swing.text.JTextComponent component)
Constructor for document with default history. |
|
HistoryDocument(javax.swing.text.JTextComponent component,
History history)
Constructor using existing history object |
|
HistoryDocument(javax.swing.text.JTextComponent component,
java.lang.String historyKey)
Constructor |
|
| Method Summary | |
|---|---|
void |
addToHistory(java.lang.String str)
This method should be called by the text component that uses this document, or by anything else that handles the input into the text component. |
History |
getHistory()
Returns the History object for this document. |
void |
insertString(int offs,
java.lang.String str,
javax.swing.text.AttributeSet a)
Overrides insertString of the PlainDocument to provide autocompletion Whenever characters are inserted into the document, the typed text is looked up in history and the matching history item is inserted into the document. |
boolean |
isInserting()
This function can be used by complex components to tell if the document is currently inserting autocompleted text. |
void |
setHistory(History history)
Sets the History object for this document |
| Methods inherited from class javax.swing.text.PlainDocument |
|---|
createDefaultRoot, getDefaultRootElement, getParagraphElement, insertUpdate, removeUpdate |
| Methods inherited from class javax.swing.text.AbstractDocument |
|---|
addDocumentListener, addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, remove, removeDocumentListener, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public HistoryDocument(javax.swing.text.JTextComponent component,
java.lang.String historyKey)
component - - the text component that uses this document.key - - History key, may be null. An application can have multiple
autocomplete components each with its own history, or sharing a history.
If separate histories are desired, each component
should have a document with a different key
public HistoryDocument(javax.swing.text.JTextComponent component,
History history)
component - JTextComponent that will be using this documenthistory - History object that will store the input history and provide
autocomplete suggestionsHistorypublic HistoryDocument(javax.swing.text.JTextComponent component)
component - JTextComponent that will use this document| Method Detail |
|---|
public void insertString(int offs,
java.lang.String str,
javax.swing.text.AttributeSet a)
throws javax.swing.text.BadLocationException
insertString in interface javax.swing.text.DocumentinsertString in class javax.swing.text.PlainDocumentoffs - offsetstr - Inserted stringa - Atrribute set
javax.swing.text.BadLocationExceptionpublic void addToHistory(java.lang.String str)
str - public History getHistory()
public void setHistory(History history)
history - History objectpublic boolean isInserting()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||