Class AutoCompleteDescWindow

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, HyperlinkListener, RootPaneContainer, DescWindowCallback

class AutoCompleteDescWindow extends JWindow implements HyperlinkListener, DescWindowCallback
The optional "description" window that describes the currently selected item in the auto-completion window.
Version:
1.0
  • Field Details

    • ac

      private AutoCompletion ac
      The parent AutoCompletion instance.
    • descArea

      private JEditorPane descArea
      Renders the HTML description.
    • scrollPane

      private JScrollPane scrollPane
      The scroll pane that descArea is in.
    • descWindowNavBar

      private JToolBar descWindowNavBar
      The toolbar with "back" and "forward" buttons.
    • backAction

      private Action backAction
      Action that goes to the previous description displayed.
    • forwardAction

      private Action forwardAction
      Action that goes to the next description displayed.
    • history

      History of descriptions displayed.
    • historyPos

      private int historyPos
      The current position in history.
    • timer

      private 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

      The action that listens for the timer to fire.
    • bundle

      private 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 for Completions that may be slow to compute their summary text.
      See Also:
    • MSG

      private static final String MSG
      The resource bundle name.
      See Also:
    • FLAT_LAF_BORDER_PREFIX

      private static final String FLAT_LAF_BORDER_PREFIX
      See Also:
  • Constructor Details

    • AutoCompleteDescWindow

      AutoCompleteDescWindow(Window owner, AutoCompletion ac)
      Constructor.
      Parameters:
      owner - The parent window.
      ac - The parent auto-completion.
  • Method Details

    • 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 Border getReplacementForFlatLafBorder(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 String getString(String key)
      Returns the localized message for the specified key.
      Parameters:
      key - The key.
      Returns:
      The localized message.
    • getToolTipBorder

      private static Border getToolTipBorder()
    • hyperlinkUpdate

      public void hyperlinkUpdate(HyperlinkEvent e)
      Called when a hyperlink is clicked.
      Specified by:
      hyperlinkUpdate in interface HyperlinkListener
      Parameters:
      e - The event.
    • isFlatLafBorder

      private static boolean isFlatLafBorder(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, 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, or null 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, String anchor, boolean addToHistory)
    • setVisible

      public void setVisible(boolean visible)
      Overrides:
      setVisible in class Window
    • showSummaryFor

      public void showSummaryFor(Completion completion, String anchor)
      Callback for custom ExternalURLHandlers.
      Specified by:
      showSummaryFor in interface DescWindowCallback
      Parameters:
      completion - The completion to display.
      anchor - The anchor in the HTML to jump to, or null if none.
    • updateUI

      public void updateUI()
      Called by the parent completion popup window the LookAndFeel is updated.