Package org.fife.ui.autocomplete
Class AutoCompleteDescWindow
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Window
-
- javax.swing.JWindow
-
- org.fife.ui.autocomplete.AutoCompleteDescWindow
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,java.util.EventListener
,javax.accessibility.Accessible
,javax.swing.event.HyperlinkListener
,javax.swing.RootPaneContainer
,DescWindowCallback
class AutoCompleteDescWindow extends javax.swing.JWindow implements javax.swing.event.HyperlinkListener, DescWindowCallback
The optional "description" window that describes the currently selected item in the auto-completion window.- Version:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
AutoCompleteDescWindow.HistoryEntry
A completion and its cached summary text.private class
AutoCompleteDescWindow.TimerAction
Action that actually updates the summary text displayed.(package private) class
AutoCompleteDescWindow.ToolBarBackAction
Action that moves to the previous description displayed.(package private) class
AutoCompleteDescWindow.ToolBarForwardAction
Action that moves to the previous description displayed.-
Nested classes/interfaces inherited from class javax.swing.JWindow
javax.swing.JWindow.AccessibleJWindow
-
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
-
-
Field Summary
Fields Modifier and Type Field Description private AutoCompletion
ac
The parent AutoCompletion instance.private javax.swing.Action
backAction
Action that goes to the previous description displayed.private java.util.ResourceBundle
bundle
The resource bundle for this window.private javax.swing.JEditorPane
descArea
Renders the HTML description.private javax.swing.JToolBar
descWindowNavBar
The toolbar with "back" and "forward" buttons.private static java.lang.String
FLAT_LAF_BORDER_PREFIX
private javax.swing.Action
forwardAction
Action that goes to the next description displayed.private java.util.List<AutoCompleteDescWindow.HistoryEntry>
history
History of descriptions displayed.private int
historyPos
The current position inhistory
.private static int
INITIAL_TIMER_DELAY
The amount of time to wait after the user changes the selected completion to refresh the description.private static java.lang.String
MSG
The resource bundle name.private javax.swing.JScrollPane
scrollPane
The scroll pane thatdescArea
is in.private javax.swing.Timer
timer
Provides a slight delay between asking to set a description and actually displaying it, so that if the user is scrolling quickly through completions, those with slow-to-calculate summaries won't bog down the scrolling.private AutoCompleteDescWindow.TimerAction
timerAction
The action that listens for the timer to fire.-
Fields inherited from class javax.swing.JWindow
accessibleContext, rootPane, rootPaneCheckingEnabled
-
-
Constructor Summary
Constructors Constructor Description AutoCompleteDescWindow(java.awt.Window owner, AutoCompletion ac)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addToHistory(AutoCompleteDescWindow.HistoryEntry historyItem)
Sets the currently displayed description and updates the history.private void
clearHistory()
Clears the history of viewed descriptions.private void
clearHistoryAfterCurrentPos()
Makes the current history page the last one in the history.boolean
copy()
Copies from the description text area, if it is visible and there is a selection.private static javax.swing.border.Border
getReplacementForFlatLafBorder(javax.swing.border.Border border)
FlatLaf adds insets to tool tips, and for some themes (usually light ones) also uses a line border, whereas for other themes (usually dark ones) there is no line border.private java.lang.String
getString(java.lang.String key)
Returns the localized message for the specified key.private static javax.swing.border.Border
getToolTipBorder()
void
hyperlinkUpdate(javax.swing.event.HyperlinkEvent e)
Called when a hyperlink is clicked.private static boolean
isFlatLafBorder(javax.swing.border.Border border)
private void
setActionStates()
Enables or disables the back and forward actions as appropriate.void
setDescriptionFor(Completion item)
Sets the description displayed in this window.protected void
setDescriptionFor(Completion item, boolean addToHistory)
Sets the description displayed in this window.protected void
setDescriptionFor(Completion item, java.lang.String anchor, boolean addToHistory)
Sets the description displayed in this window.private void
setDisplayedDesc(Completion completion, java.lang.String anchor, boolean addToHistory)
void
setVisible(boolean visible)
void
showSummaryFor(Completion completion, java.lang.String anchor)
Callback for customExternalURLHandler
s.void
updateUI()
Called by the parent completion popup window the LookAndFeel is updated.-
Methods inherited from class javax.swing.JWindow
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getGraphics, getLayeredPane, getRootPane, getTransferHandler, isRootPaneCheckingEnabled, paramString, remove, repaint, setContentPane, setGlassPane, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update, windowInit
-
Methods inherited from class java.awt.Window
addNotify, addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBackground, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setOpacity, setShape, setSize, setSize, setType, show, toBack, toFront
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
ac
private AutoCompletion ac
The parent AutoCompletion instance.
-
descArea
private javax.swing.JEditorPane descArea
Renders the HTML description.
-
scrollPane
private javax.swing.JScrollPane scrollPane
The scroll pane thatdescArea
is in.
-
descWindowNavBar
private javax.swing.JToolBar descWindowNavBar
The toolbar with "back" and "forward" buttons.
-
backAction
private javax.swing.Action backAction
Action that goes to the previous description displayed.
-
forwardAction
private javax.swing.Action forwardAction
Action that goes to the next description displayed.
-
history
private java.util.List<AutoCompleteDescWindow.HistoryEntry> history
History of descriptions displayed.
-
historyPos
private int historyPos
The current position inhistory
.
-
timer
private javax.swing.Timer timer
Provides a slight delay between asking to set a description and actually displaying it, so that if the user is scrolling quickly through completions, those with slow-to-calculate summaries won't bog down the scrolling.
-
timerAction
private AutoCompleteDescWindow.TimerAction timerAction
The action that listens for the timer to fire.
-
bundle
private java.util.ResourceBundle bundle
The resource bundle for this window.
-
INITIAL_TIMER_DELAY
private static final int INITIAL_TIMER_DELAY
The amount of time to wait after the user changes the selected completion to refresh the description. This delay is in place to help performance forCompletion
s that may be slow to compute their summary text.- See Also:
- Constant Field Values
-
MSG
private static final java.lang.String MSG
The resource bundle name.- See Also:
- Constant Field Values
-
FLAT_LAF_BORDER_PREFIX
private static final java.lang.String FLAT_LAF_BORDER_PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AutoCompleteDescWindow
AutoCompleteDescWindow(java.awt.Window owner, AutoCompletion ac)
Constructor.- Parameters:
owner
- The parent window.ac
- The parent auto-completion.
-
-
Method Detail
-
addToHistory
private void addToHistory(AutoCompleteDescWindow.HistoryEntry historyItem)
Sets the currently displayed description and updates the history.- Parameters:
historyItem
- The item to add to the history.
-
clearHistory
private void clearHistory()
Clears the history of viewed descriptions.
-
clearHistoryAfterCurrentPos
private void clearHistoryAfterCurrentPos()
Makes the current history page the last one in the history.
-
copy
public boolean copy()
Copies from the description text area, if it is visible and there is a selection.- Returns:
- Whether a copy occurred.
-
getReplacementForFlatLafBorder
private static javax.swing.border.Border getReplacementForFlatLafBorder(javax.swing.border.Border border)
FlatLaf adds insets to tool tips, and for some themes (usually light ones) also uses a line border, whereas for other themes (usually dark ones) there is no line border. We need to ensure our border has no insets so our draggable bottom component looks good, but we'd like to preserve the color of the line border, if any. This method allows us to do so without a compile-time dependency on flatlaf.- Parameters:
border
- The default tool tip border for the current Look and Feel.- Returns:
- The border to use for this window.
-
getString
private java.lang.String getString(java.lang.String key)
Returns the localized message for the specified key.- Parameters:
key
- The key.- Returns:
- The localized message.
-
getToolTipBorder
private static javax.swing.border.Border getToolTipBorder()
-
hyperlinkUpdate
public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e)
Called when a hyperlink is clicked.- Specified by:
hyperlinkUpdate
in interfacejavax.swing.event.HyperlinkListener
- Parameters:
e
- The event.
-
isFlatLafBorder
private static boolean isFlatLafBorder(javax.swing.border.Border border)
-
setActionStates
private void setActionStates()
Enables or disables the back and forward actions as appropriate.
-
setDescriptionFor
public void setDescriptionFor(Completion item)
Sets the description displayed in this window. This clears the history.- Parameters:
item
- The item whose description you want to display.
-
setDescriptionFor
protected void setDescriptionFor(Completion item, boolean addToHistory)
Sets the description displayed in this window.- Parameters:
item
- The item whose description you want to display.addToHistory
- Whether to add this page to the page history (as opposed to clearing it and starting anew).
-
setDescriptionFor
protected void setDescriptionFor(Completion item, java.lang.String anchor, boolean addToHistory)
Sets the description displayed in this window.- Parameters:
item
- The item whose description you want to display.anchor
- The anchor to jump to, ornull
if none.addToHistory
- Whether to add this page to the page history (as opposed to clearing it and starting anew).
-
setDisplayedDesc
private void setDisplayedDesc(Completion completion, java.lang.String anchor, boolean addToHistory)
-
setVisible
public void setVisible(boolean visible)
- Overrides:
setVisible
in classjava.awt.Window
-
showSummaryFor
public void showSummaryFor(Completion completion, java.lang.String anchor)
Callback for customExternalURLHandler
s.- Specified by:
showSummaryFor
in interfaceDescWindowCallback
- Parameters:
completion
- The completion to display.anchor
- The anchor in the HTML to jump to, ornull
if none.
-
updateUI
public void updateUI()
Called by the parent completion popup window the LookAndFeel is updated.
-
-