com.mucommander.ui.autocomplete
Class CompletionType

java.lang.Object
  extended by com.mucommander.ui.autocomplete.CompletionType
Direct Known Subclasses:
EditableComboboxCompletion, OtherTextComponentCompletion, TextFieldCompletion

public abstract class CompletionType
extends java.lang.Object

AutoCompletionType defines the behaviour of the auto-completion, such as: - The key(s) that will open the popup window - When should the documentListener be attached to the text component - etc.. This abstract class contains the common things to all CompleterType implementations.

Author:
Arik Hadas, based on the code of Santhosh Kumar: http://www.jroller.com/santhosh/entry/file_path_autocompletion

Nested Class Summary
protected  class CompletionType.ShowingThread
          ShowingThread is an abstract class for threads that show auto-completion popup window after a given delay.
 
Field Summary
protected  AutocompleterTextComponent autocompletedtextComp
           
protected  javax.swing.event.DocumentListener documentListener
           
protected  javax.swing.JList list
           
protected  javax.swing.JPopupMenu popup
           
protected  int POPUP_DELAY_AFTER_ACCEPTING_LIST_ITEM
           
protected  int POPUP_DELAY_AT_TEXT_DELETION
           
protected  int POPUP_DELAY_AT_TEXT_INSERTION
           
protected  CompletionType.ShowingThread showingThread
           
protected  int VISIBLE_ROW_COUNT
           
 
Constructor Summary
CompletionType(AutocompleterTextComponent comp, Completer completer)
           
 
Method Summary
protected  void acceptListItem(java.lang.String selected)
          The function handles the case when an item of the auto-copmpletion popup was selected.
protected  void createNewShowingThread(int delay)
          createNewShowingThread shows the auto-completion popup window after a non-blocking delay.
protected abstract  void hideAutocompletionPopup()
          Hide the auto-completion popup window.
protected  boolean isItemSelectedAtPopupList()
          Returns true if there is a selected item at the auto-completion popup window.
protected  boolean isPopupListShowing()
          Returns true if the auto-completion popup window is visible.
protected  void selectFirstValue()
          Selects the first item in the list.
protected  void selectLastValue()
          Selects the last item in the list.
protected  void selectNextPage()
          Selects the item at (VISIBLE_ROW_COUNT - 1) places after the currently selected item in the list.
protected  void selectNextPossibleValue()
          Selects the next item in the list.
protected  void selectPreviousPage()
          Selects the item at (VISIBLE_ROW_COUNT - 1) places before the currently selected item in the list.
protected  void selectPreviousPossibleValue()
          Selects the previous item in the list.
protected abstract  void startNewShowingThread(int delay)
          Start a new thread that implement ShowingThread with the given delay.
protected  boolean updateListData(javax.swing.JList list)
          update auto-completion popup's list model depending on the data in text component.
protected  void updateTextComponent(java.lang.String selected)
          user has selected some item from the auto-completion popup list, update text component accordingly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

autocompletedtextComp

protected AutocompleterTextComponent autocompletedtextComp

documentListener

protected javax.swing.event.DocumentListener documentListener

list

protected javax.swing.JList list

popup

protected javax.swing.JPopupMenu popup

showingThread

protected CompletionType.ShowingThread showingThread

VISIBLE_ROW_COUNT

protected final int VISIBLE_ROW_COUNT
See Also:
Constant Field Values

POPUP_DELAY_AT_TEXT_INSERTION

protected final int POPUP_DELAY_AT_TEXT_INSERTION
See Also:
Constant Field Values

POPUP_DELAY_AT_TEXT_DELETION

protected final int POPUP_DELAY_AT_TEXT_DELETION
See Also:
Constant Field Values

POPUP_DELAY_AFTER_ACCEPTING_LIST_ITEM

protected final int POPUP_DELAY_AFTER_ACCEPTING_LIST_ITEM
See Also:
Constant Field Values
Constructor Detail

CompletionType

public CompletionType(AutocompleterTextComponent comp,
                      Completer completer)
Method Detail

startNewShowingThread

protected abstract void startNewShowingThread(int delay)
Start a new thread that implement ShowingThread with the given delay.


hideAutocompletionPopup

protected abstract void hideAutocompletionPopup()
Hide the auto-completion popup window.


updateListData

protected boolean updateListData(javax.swing.JList list)
update auto-completion popup's list model depending on the data in text component.

Parameters:
list - - Auto-completion popup's list.
Returns:
true if the list was updated successfully, false otherwise.

updateTextComponent

protected void updateTextComponent(java.lang.String selected)
user has selected some item from the auto-completion popup list, update text component accordingly.

Parameters:
selected - - The selected item from the auto-completion popup's list.

createNewShowingThread

protected void createNewShowingThread(int delay)
createNewShowingThread shows the auto-completion popup window after a non-blocking delay.

Parameters:
delay - - The requested delay (in miliseconds) until the popup appear.

acceptListItem

protected void acceptListItem(java.lang.String selected)
The function handles the case when an item of the auto-copmpletion popup was selected. it ask the text component to be updated according to the selected item and create a new thread that will open auto-completion popup windos after delay of POPUP_DELAY_AFTER_ACCEPTING_LIST_ITEM seconds.


isPopupListShowing

protected boolean isPopupListShowing()
Returns true if the auto-completion popup window is visible.


isItemSelectedAtPopupList

protected boolean isItemSelectedAtPopupList()
Returns true if there is a selected item at the auto-completion popup window.


selectFirstValue

protected void selectFirstValue()
Selects the first item in the list.


selectLastValue

protected void selectLastValue()
Selects the last item in the list.


selectNextPage

protected void selectNextPage()
Selects the item at (VISIBLE_ROW_COUNT - 1) places after the currently selected item in the list.


selectPreviousPage

protected void selectPreviousPage()
Selects the item at (VISIBLE_ROW_COUNT - 1) places before the currently selected item in the list.


selectNextPossibleValue

protected void selectNextPossibleValue()
Selects the next item in the list. It won't change the selection if the currently selected item is already the last item.


selectPreviousPossibleValue

protected void selectPreviousPossibleValue()
Selects the previous item in the list. It won't change the selection if the currently selected item is already the first item.



This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard