LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.view.win.swing.component
Class LyJAutoCompletionViewer

java.lang.Object
  extended by leon.view.win.swing.component.LyJAutoCompletionViewer
All Implemented Interfaces:
LySelectionListener

public class LyJAutoCompletionViewer
extends java.lang.Object
implements LySelectionListener

This class implements an auto-completion system for text components.


Field Summary
static java.lang.String __VERSION
           
static java.lang.String BEAN_KEY_EVENT
           
static java.lang.String EMPTY_VALUE
          Value used to store empty values in the auto-completion list.
static long KEY_PRESSED_TIMER
          Timer used to send keyboard events (in milliseconds).
 
Constructor Summary
LyJAutoCompletionViewer(javax.swing.text.JTextComponent text, javax.swing.JButton button, java.lang.String[] internalValues, java.lang.String[] displayedValues, java.lang.String[] displayedShortValues, boolean automaticCompletion, int nMax, LyEnvironment environment)
          Constructor.
 
Method Summary
 void addValue(java.lang.String internalValue, java.lang.String displayedValue, java.lang.String displayedShortValue, int pos)
          Adds a value to the list of values used for auto-completion.
 boolean componentIsMine(java.awt.Component c)
          This method test Component c is member of this class
 java.lang.String getDisplayedShortValue(java.lang.String internalValue)
          Returns the displayed short value corresponding to a given internal value.
 java.lang.String[] getDisplayedShortValues()
          Returns the list of displayed short values for auto-completion.
 java.lang.String getDisplayedValue(java.lang.String internalValue)
          Returns the displayed value corresponding to a given internal value.
 java.lang.String[] getDisplayedValues()
          Returns the list of displayed values for auto-completion.
 LyJListComponent getListField()
          Returns the list component associated with this auto-completion viewer.
 int getSelectedIndex()
          Returns the index of selected value.
 java.lang.String getSelectedValue()
          Returns the internal selected value if any.
 javax.swing.text.JTextComponent getTextField()
          Returns the text component associated with this auto-completion viewer.
 void hideWindow()
          Hides the completion window.
 boolean isWindowVisible()
          Indicates whether the completion window is visible or not.
 void removeValue(java.lang.String internalValue)
          Removes a value from the list of values used for auto-completion.
 void removeValueAt(int pos)
          Removes a value from the list of values used for auto-completion.
 void selectionPerformed(LySelectionEvent selectionEvent)
          Implementation of the LySelectionListener interface.
 void setActionListener(LyActionListener actionListener)
          Sets the action listener to be used.
 void setCurrentText(java.lang.String currentText, int startIndex, int endIndex)
          Set the value of the currently typed
 void setLocation(int x, int y)
          Set the popup menu location
 void setMutli(boolean isMulti)
          Set if the popup menu is for a multilines text on not
 void setPopupWidth(int popupWidth)
          Sets the fixed width of the popup.
 void setShowOnKeyType(boolean show)
          indicate whether the autocompletion list is shown when keys are typed
 void setTextValue(int index, boolean notify)
          Sets the value of the text component.
 void setValues(int nMax, java.lang.String[] internalValues, java.lang.String[] displayedValues, java.lang.String[] displayedShortValues)
          Set the list of values used for auto-completion.
 void setValues(java.lang.String[] internalValues, java.lang.String[] displayedValues, java.lang.String[] displayedShortValues)
          Set the list of values used for auto-completion.
 boolean wasEnterPressed()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values

EMPTY_VALUE

public static final java.lang.String EMPTY_VALUE
Value used to store empty values in the auto-completion list.

See Also:
Constant Field Values

KEY_PRESSED_TIMER

public static long KEY_PRESSED_TIMER
Timer used to send keyboard events (in milliseconds).


BEAN_KEY_EVENT

public static final java.lang.String BEAN_KEY_EVENT
See Also:
Constant Field Values
Constructor Detail

LyJAutoCompletionViewer

public LyJAutoCompletionViewer(javax.swing.text.JTextComponent text,
                               javax.swing.JButton button,
                               java.lang.String[] internalValues,
                               java.lang.String[] displayedValues,
                               java.lang.String[] displayedShortValues,
                               boolean automaticCompletion,
                               int nMax,
                               LyEnvironment environment)
Constructor.

Parameters:
text - text component used for auto-completion
button - button component used to open / close auto-completion window
internalValues - list of internal values used for auto-completion
displayedValues - list of displayed values used for auto-completion
displayedValues - list of displayed short values used for auto-completion
automaticCompletion - indicates whether text value is updated automatically when focus is lost
nMax - maximum number of values displayed in the auto-completion list
environment - current environment
Method Detail

setValues

public void setValues(java.lang.String[] internalValues,
                      java.lang.String[] displayedValues,
                      java.lang.String[] displayedShortValues)
Set the list of values used for auto-completion.

Parameters:
internalValues - the new list of internal values for auto-completion.
displayedValues - the new list of displayed values for auto-completion.
displayedShortValues - the new list of displayed short values for auto-completion.

setShowOnKeyType

public void setShowOnKeyType(boolean show)
indicate whether the autocompletion list is shown when keys are typed

Parameters:
show - if true, the completion list is shown when keys are typed

setValues

public void setValues(int nMax,
                      java.lang.String[] internalValues,
                      java.lang.String[] displayedValues,
                      java.lang.String[] displayedShortValues)
Set the list of values used for auto-completion.

Parameters:
nMax - max values displayed
internalValues - the new list of internal values for auto-completion.
displayedValues - the new list of displayed values for auto-completion.
displayedShortValues - the new list of displayed short values for auto-completion.

addValue

public void addValue(java.lang.String internalValue,
                     java.lang.String displayedValue,
                     java.lang.String displayedShortValue,
                     int pos)
Adds a value to the list of values used for auto-completion.

Parameters:
internalValue - the new internal value to be added.
displayedValue - the new displayed value to be added.
displayedShortValue - the new displayed short value to be added.
pos - the position of the value to be added.

removeValue

public void removeValue(java.lang.String internalValue)
Removes a value from the list of values used for auto-completion.

Parameters:
internalValue - the internal value to be removed.

removeValueAt

public void removeValueAt(int pos)
Removes a value from the list of values used for auto-completion.

Parameters:
pos - the position of the value to be removed.

getSelectedIndex

public int getSelectedIndex()
Returns the index of selected value.

Returns:
the index of selected value, or -1 if no value was selected.

getSelectedValue

public java.lang.String getSelectedValue()
Returns the internal selected value if any.

Returns:
the internal value that has been selected if any, null otherwise.

getDisplayedValue

public java.lang.String getDisplayedValue(java.lang.String internalValue)
Returns the displayed value corresponding to a given internal value.

Parameters:
internalValue - the internal value to be used to retrieve displayed value.
Returns:
the displayed value corresponding to the given internal value or null if no internal value was found for given internal value.

getDisplayedShortValue

public java.lang.String getDisplayedShortValue(java.lang.String internalValue)
Returns the displayed short value corresponding to a given internal value.

Parameters:
internalValue - the internal value to be used to retrieve displayed value.
Returns:
the displayed short value corresponding to the given internal value or null if no internal value was found for given internal value.

componentIsMine

public boolean componentIsMine(java.awt.Component c)
This method test Component c is member of this class

Parameters:
c - Component to test
Returns:
boolean true if given component is member of current completion viewer

getDisplayedValues

public java.lang.String[] getDisplayedValues()
Returns the list of displayed values for auto-completion.

Returns:
the list of displayed values for auto-completion.

getDisplayedShortValues

public java.lang.String[] getDisplayedShortValues()
Returns the list of displayed short values for auto-completion.

Returns:
the list of displayed short values for auto-completion.

getTextField

public javax.swing.text.JTextComponent getTextField()
Returns the text component associated with this auto-completion viewer.

Returns:
the text component associated with this auto-completion viewer.

getListField

public LyJListComponent getListField()
Returns the list component associated with this auto-completion viewer.

Returns:
the list component associated with this auto-completion viewer.

setCurrentText

public void setCurrentText(java.lang.String currentText,
                           int startIndex,
                           int endIndex)
Set the value of the currently typed

Parameters:
currentText - text value
startIndex - start index in the text component
endIndex - end index in the text component

selectionPerformed

public void selectionPerformed(LySelectionEvent selectionEvent)
Implementation of the LySelectionListener interface.

Specified by:
selectionPerformed in interface LySelectionListener
Parameters:
selectionEvent - description of the selection which has occured

setLocation

public void setLocation(int x,
                        int y)
Set the popup menu location

Parameters:
x - x coordinate
y - y coordinate

setMutli

public void setMutli(boolean isMulti)
Set if the popup menu is for a multilines text on not

Parameters:
isMulti -

setTextValue

public void setTextValue(int index,
                         boolean notify)
Sets the value of the text component.

Parameters:
index - the index of the new text value to be set.
notify - indicates if action listener must be notified.

setActionListener

public void setActionListener(LyActionListener actionListener)
Sets the action listener to be used.

Parameters:
actionListener - the new action listener that must be notified when changing text value.

setPopupWidth

public void setPopupWidth(int popupWidth)
Sets the fixed width of the popup.

Parameters:
popupWidth - the fixed width of the popup.

hideWindow

public void hideWindow()
Hides the completion window.


isWindowVisible

public boolean isWindowVisible()
Indicates whether the completion window is visible or not.

Returns:
true if the completion window is visible, false otherwise.

wasEnterPressed

public boolean wasEnterPressed()

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com