|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jidesoft.hints.AbstractIntelliHints
public abstract class AbstractIntelliHints
AbstractIntelliHints
is an abstract implementation of IntelliHints
. It covers
functions such as showing the hint popup at the correct position, delegating keystrokes, updating and selecting hint.
The only thing that is left out to subclasses is the creation of the hint popup.
Field Summary |
---|
Fields inherited from interface com.jidesoft.hints.IntelliHints |
---|
CLIENT_PROPERTY_INTELLI_HINTS |
Constructor Summary | |
---|---|
AbstractIntelliHints(JTextComponent textComponent)
Creates an IntelliHints object for a given JTextComponent. |
Method Summary | |
---|---|
void |
acceptHint(Object selected)
After user has selected a item in the hints popup, this method will update JTextComponent accordingly to accept the hint. |
void |
addShowHintsKeyStroke(KeyStroke keyStroke)
Adds a new key stroke to show hints popup. |
protected JidePopup |
createPopup()
|
KeyStroke[] |
getAllShowHintsKeyStrokes()
Gets all key strokes that will show hints popup. |
protected int |
getCaretPositionForPopup()
Gets the caret position which is used as the anchor point to display the popup. |
protected Rectangle |
getCaretRectangleForPopup(int caretPosition)
Gets the caret rectangle where caret is displayed. |
protected Object |
getContext()
Gets the context for hints. |
protected abstract JComponent |
getDelegateComponent()
Gets the delegate component in the hint popup. |
protected abstract KeyStroke[] |
getDelegateKeyStrokes()
Gets the delegate keystrokes. |
static IntelliHints |
getIntelliHints(JComponent component)
Gets the IntelliHints object if it was installed on the component before. |
int |
getShowHintsDelay()
Gets the delay after the key is pressed to show hints. |
protected KeyStroke |
getShowHintsKeyStroke()
Gets the keystroke that will trigger the hint popup. |
JTextComponent |
getTextComponent()
|
protected void |
hideHintsPopup()
Hides the hints popup. |
boolean |
isAutoPopup()
Returns whether the hints popup is automatically displayed. |
boolean |
isFollowCaret()
Should the hints popup follows the caret. |
boolean |
isHintsPopupVisible()
Checks if the hints popup is visible. |
protected boolean |
isMultilineTextComponent()
Returns whether this IntelliHints' JTextComponent supports single-line text or multi-line text. |
void |
removeShowHintsKeyStroke(KeyStroke keyStroke)
Removes a key stroke from the list to show hints popup. |
void |
setAutoPopup(boolean autoPopup)
Sets whether the popup should be displayed automatically. |
void |
setFollowCaret(boolean followCaret)
Sets the position of the hints popup. |
void |
setHintsEnabled(boolean enabled)
Enables or disables the hints popup. |
void |
setShowHintsDelay(int showHintsDelay)
Sets the delay after the key is pressed to show hints. |
void |
showHints()
Shows the hints popup which contains the hints. |
protected void |
showHintsPopup()
This method will call showHints() if and only if the text component is enabled and has focus. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.jidesoft.hints.IntelliHints |
---|
createHintsComponent, getSelectedHint, updateHints |
Constructor Detail |
---|
public AbstractIntelliHints(JTextComponent textComponent)
textComponent
- the text component.Method Detail |
---|
protected JidePopup createPopup()
public JTextComponent getTextComponent()
public void acceptHint(Object selected)
FileIntelliHints
will append the
selected item at the end of the existing text in order to complete a full file path.
acceptHint
in interface IntelliHints
selected
- the hint to be accepted.protected boolean isMultilineTextComponent()
JTextComponent
supports single-line text or multi-line text.
true
if the component supports multiple text lines, false
otherwiseprotected void showHintsPopup()
showHints()
if and only if the text component is enabled and has focus.
public void showHints()
IntelliHints.updateHints(Object)
. Only if it returns
true, the popup will be shown. You can call this method to fore the hints to be displayed.
protected Rectangle getCaretRectangleForPopup(int caretPosition) throws BadLocationException
caretPosition
- the caret position.
BadLocationException
- if the given position does not represent a valid location in the associated
document.protected int getCaretPositionForPopup()
isFollowCaret()
is true, it will return caret position. Otherwise it will return the caret position at the
beginning of the caret line. Subclass can override to return any caret position.
protected Object getContext()
We provide a default context in AbstractIntelliHints. If it's a JTextArea, the context will be the string at the caret line from line beginning to the caret position. If it's a JTextField, the context will be whatever string in the text field. Subclass can always override it to return the context that is appropriate.
protected void hideHintsPopup()
public void setHintsEnabled(boolean enabled)
enabled
- true to enable the hints popup. Otherwise false.public boolean isHintsPopupVisible()
public boolean isFollowCaret()
public void setFollowCaret(boolean followCaret)
followCaret
- true or false.public boolean isAutoPopup()
setAutoPopup(boolean)
public void setAutoPopup(boolean autoPopup)
autoPopup
- true or falseprotected abstract KeyStroke[] getDelegateKeyStrokes()
getDelegateComponent()
.
NOTE: Since this method would be invoked inside the constructor of AbstractIntelliHints, please do not try to
return a field because the field is not initiated yet at this time.
getDelegateComponent()
when hint popup is
shown.protected abstract JComponent getDelegateComponent()
protected KeyStroke getShowHintsKeyStroke()
public int getShowHintsDelay()
setShowHintsDelay(int)
public void setShowHintsDelay(int showHintsDelay)
showHintsDelay
- the delay timepublic void addShowHintsKeyStroke(KeyStroke keyStroke)
keyStroke
- the key strokeremoveShowHintsKeyStroke(javax.swing.KeyStroke)
,
getAllShowHintsKeyStrokes()
public void removeShowHintsKeyStroke(KeyStroke keyStroke)
keyStroke
- the key strokepublic KeyStroke[] getAllShowHintsKeyStrokes()
public static IntelliHints getIntelliHints(JComponent component)
component
- the component that has IntelliHints installed
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |