Class AbstractListIntelliHints

  • All Implemented Interfaces:
    IntelliHints
    Direct Known Subclasses:
    FileIntelliHints, ListDataIntelliHints

    public abstract class AbstractListIntelliHints
    extends AbstractIntelliHints
    AbstractListIntelliHints extends AbstractIntelliHints and further implement most of the methods in interface IntelliHints. In this class, it assumes the hints can be represented as a JList, so it used JList in the hints popup.
    Author:
    Santhosh Kumar T - santhosh@in.fiorano.com, JIDE Software, Inc.
    • Field Detail

      • _keyStrokes

        protected javax.swing.KeyStroke[] _keyStrokes
    • Constructor Detail

      • AbstractListIntelliHints

        public AbstractListIntelliHints​(javax.swing.text.JTextComponent textComponent)
        Creates a Completion for JTextComponent
        Parameters:
        textComponent -
    • Method Detail

      • createHintsComponent

        public javax.swing.JComponent createHintsComponent()
        Description copied from interface: IntelliHints
        Creates the component which contains hints. At this moment, the content should be empty. Following call IntelliHints.updateHints(Object, boolean) will update the content.
        Returns:
        the component which will be used to display the hints.
      • createList

        protected javax.swing.JList createList()
        Creates the list to display the hints. By default, we create a JList using the code below.
         return new JList() {
             public int getVisibleRowCount() {
                 int size = getModel().getSize();
                 return size < super.getVisibleRowCount() ? size : super.getVisibleRowCount();
             }
         

        public Dimension getPreferredScrollableViewportSize() { if (getModel().getSize() == 0) { return new Dimension(0, 0); } else { return super.getPreferredScrollableViewportSize(); } } };

        Returns:
        the list.
      • getList

        protected javax.swing.JList getList()
        Gets the list.
        Returns:
        the list.
      • setListData

        protected void setListData​(java.lang.Object[] objects)
        Sets the list data.
        Parameters:
        objects -
      • setListData

        protected void setListData​(java.util.Vector<?> objects)
        Sets the list data.
        Parameters:
        objects -
      • getSelectedHint

        public java.lang.Object getSelectedHint()
        Description copied from interface: IntelliHints
        Gets the selected value. This value will be used to complete the text component.
        Returns:
        the selected value.
      • getDelegateComponent

        public javax.swing.JComponent getDelegateComponent()
        Description copied from class: AbstractIntelliHints
        Gets the delegate component in the hint popup.
        Specified by:
        getDelegateComponent in class AbstractIntelliHints
        Returns:
        the component that will receive the keystrokes that are delegated to hint popup.
      • getDelegateKeyStrokes

        public javax.swing.KeyStroke[] getDelegateKeyStrokes()
        Gets the delegate keystrokes. Since we know the hints popup is a JList, we return eight keystrokes so that they can be delegate to the JList. Those keystrokes are DOWN, UP, PAGE_DOWN, PAGE_UP, HOME and END.
        Specified by:
        getDelegateKeyStrokes in class AbstractIntelliHints
        Returns:
        the keystrokes that will be delegated to the JList when hints popup is visible.