de.enough.polish.ui
Class FilteredChoiceGroup

java.lang.Object
  extended by javax.microedition.lcdui.Item
      extended by javax.microedition.lcdui.CustomItem
          extended by de.enough.polish.ui.FakeCustomItem
              extended by de.enough.polish.ui.FakeStringCustomItem
                  extended by de.enough.polish.ui.FilteredChoiceGroup
All Implemented Interfaces:
javax.microedition.lcdui.Choice, javax.microedition.lcdui.CommandListener

public class FilteredChoiceGroup
extends FakeStringCustomItem
implements javax.microedition.lcdui.Choice, javax.microedition.lcdui.CommandListener

Displays the currently selected item(s) and opens up a new FilteredList for selecting an element.

Copyright Enough Software 2007 - 2008

 history
        Jun 26, 2007 - rob creation
 

Author:
Robert Virkus, j2mepolish@enough.de
See Also:
FilteredList

Field Summary
static int EXCLUSIVE
          Only a single option can be selected
static int IMPLICIT
          Only a single option can be selected - it is selected automatically when pressing FIRE.
static int MULTIPLE
          Several values can be selected
 
Fields inherited from class de.enough.polish.ui.FakeStringCustomItem
bitMapFont, bitMapFontViewer, clipText, font, text, textColor, textEffect, textHorizontalAdjustment, textLines, textVerticalAdjustment, useSingleLine, xOffset
 
Fields inherited from class de.enough.polish.ui.FakeCustomItem
_bbField, _bbFieldAdded, appearanceMode, background, backgroundHeight, backgroundWidth, backgroundYOffset, border, borderWidth, BUTTON, colSpan, commands, contentHeight, contentWidth, contentX, contentY, cssSelector, defaultCommand, focusedStyle, HORIZONTAL, HYPERLINK, includeLabel, INTERACTIVE, internalHeight, internalWidth, internalX, internalY, isFocused, isInitialized, isInvisible, isLayoutCenter, isLayoutExpand, isLayoutRight, isPressed, isShown, isStyleInitialised, itemCommandListener, itemHeight, itemWidth, label, labelStyle, layout, LAYOUT_2, LAYOUT_BOTTOM, LAYOUT_CENTER, LAYOUT_DEFAULT, LAYOUT_EXPAND, LAYOUT_LEFT, LAYOUT_NEWLINE_AFTER, LAYOUT_NEWLINE_BEFORE, LAYOUT_RIGHT, LAYOUT_SHRINK, LAYOUT_TOP, LAYOUT_VCENTER, LAYOUT_VEXPAND, LAYOUT_VSHRINK, marginBottom, marginLeft, marginRight, marginTop, maximumHeight, maximumWidth, minimumHeight, minimumWidth, NO_POSITION_SET, paddingBottom, paddingHorizontal, paddingLeft, paddingRight, paddingTop, paddingVertical, parent, PLAIN, preferredHeight, preferredWidth, preserveViewType, relativeX, relativeY, rowSpan, screen, style, TRANSPARENT, VERTICAL, view
 
Fields inherited from class javax.microedition.lcdui.CustomItem
KEY_PRESS, KEY_RELEASE, KEY_REPEAT, NONE, POINTER_DRAG, POINTER_PRESS, POINTER_RELEASE, TRAVERSE_HORIZONTAL, TRAVERSE_VERTICAL
 
Fields inherited from interface javax.microedition.lcdui.Choice
POPUP, TEXT_WRAP_DEFAULT, TEXT_WRAP_OFF, TEXT_WRAP_ON
 
Constructor Summary
FilteredChoiceGroup(java.lang.String label, java.lang.String nullText, int listType)
          Creates a new FilteredChoiceGroup.
FilteredChoiceGroup(java.lang.String label, java.lang.String nullText, int listType, Style style)
          Creates a new FilteredChoiceGroup.
 
Method Summary
 int append(ChoiceItem item)
          Appends an item to this group.
 int append(java.lang.String stringPart, javax.microedition.lcdui.Image imagePart)
           
 int append(java.lang.String stringPart, javax.microedition.lcdui.Image imagePart, Style itemStyle)
          Appends an item to this group.
 void commandAction(javax.microedition.lcdui.Command cmd, javax.microedition.lcdui.Displayable disp)
           
 void delete(int elementNum)
           
 void deleteAll()
           
 java.lang.String getDelimiter()
          Retrieves the delimiter for separating text entries of a MULTIPLE FilteredChoiceGroup
 int getFitPolicy()
           
 javax.microedition.lcdui.Font getFont(int elementNum)
           
 javax.microedition.lcdui.Image getImage(int elementNum)
           
 int getSelectedFlags(boolean[] selectedArray_return)
           
 int getSelectedIndex()
           
 java.lang.String getString(int elementNum)
           
protected  boolean handleKeyReleased(int keyCode, int gameAction)
          Handles the key-released event.
 void insert(int elementNum, java.lang.String stringPart, javax.microedition.lcdui.Image imagePart)
           
 void insert(int elementNum, java.lang.String stringPart, javax.microedition.lcdui.Image imagePart, Style elementStyle)
          Inserts an element with an attached style definition
 boolean isSelected(int elementNum)
           
 void resetFilter()
          Resets the filter text to null.
 void set(int elementNum, java.lang.String stringPart, javax.microedition.lcdui.Image imagePart)
           
 void set(int elementNum, java.lang.String stringPart, javax.microedition.lcdui.Image imagePart, Style elementStyle)
          Sets an item at the specified index
 void setDelimiter(java.lang.String delimiter)
          Sets the delimiter for separating text entries of a MULTIPLE FilteredChoiceGroup - the default is ", "
 void setFitPolicy(int fitPolicy)
           
 void setFont(int elementNum, javax.microedition.lcdui.Font font)
           
 void setSelectedFlags(boolean[] selectedArray)
           
 void setSelectedIndex(int elementNum, boolean selected)
           
 void setStyle(Style style)
          Sets the style of this item.
 void showFilteredList(javax.microedition.lcdui.Display display)
          Shows the filtered list.
 int size()
           
 
Methods inherited from class de.enough.polish.ui.FakeStringCustomItem
animate, createCssSelector, defocus, getFont, getText, hideNotify, initContent, paintContent, releaseResources, setFont, setText, setText, showNotify, toString
 
Methods inherited from class de.enough.polish.ui.FakeCustomItem
addCommand, addCommand, addCommands, addRelativeToBackgroundRegion, addRelativeToContentRegion, animate, containsCommand, focus, getAbsoluteX, getAbsoluteY, getAppearanceMode, getAttribute, getAttributes, getBackgroundHeight, getBackgroundWidth, getBackgroundX, getBackgroundY, getContentHeight, getContentWidth, getContentX, getContentY, getDefaultCommand, getFocusedStyle, getItemAt, getItemCommandListener, getItemHeight, getItemStateListener, getItemWidth, getLabel, getLabelItem, getLayout, getMinContentHeight, getMinContentWidth, getMinimumHeight, getMinimumWidth, getParent, getPrefContentHeight, getPrefContentWidth, getPreferredHeight, getPreferredWidth, getScreen, getStyle, handleCommand, handleKeyPressed, handleKeyRepeated, handlePointerPressed, handlePointerReleased, init, initStyle, isInContentArea, isInItemArea, isVisible, notifyItemPressedEnd, notifyItemPressedStart, notifyStateChanged, paint, paint, paintBackground, paintBackgroundAndBorder, paintBorder, removeCommand, repaintFully, requestInit, setAppearanceMode, setAttribute, setDefaultCommand, setItemCommandListener, setItemCommandListener, setItemStateListener, setLabel, setLayout, setPreferredSize, setVisible, show, showCommands
 
Methods inherited from class javax.microedition.lcdui.CustomItem
getGameAction, getInteractionModes, invalidate, keyPressed, keyReleased, keyRepeated, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, sizeChanged, traverse, traverseOut
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EXCLUSIVE

public static final int EXCLUSIVE
Only a single option can be selected

See Also:
Constant Field Values

MULTIPLE

public static final int MULTIPLE
Several values can be selected

See Also:
Constant Field Values

IMPLICIT

public static final int IMPLICIT
Only a single option can be selected - it is selected automatically when pressing FIRE.

See Also:
Constant Field Values
Constructor Detail

FilteredChoiceGroup

public FilteredChoiceGroup(java.lang.String label,
                           java.lang.String nullText,
                           int listType)
Creates a new FilteredChoiceGroup.

Parameters:
label - the label of the group
nullText - the text that should be displayed when no item has been selected
listType - the type of the list, e.g. Choice.MULTIPLE, Choice.EXCLUSIVE or Choice.IMPLICIT

FilteredChoiceGroup

public FilteredChoiceGroup(java.lang.String label,
                           java.lang.String nullText,
                           int listType,
                           Style style)
Creates a new FilteredChoiceGroup.

Parameters:
label - the label of the group
nullText - the text that should be displayed when no item has been selected
listType - the type of the list, e.g. Choice.MULTIPLE, Choice.EXCLUSIVE or Choice.IMPLICIT
style - the style of this group
Method Detail

append

public int append(java.lang.String stringPart,
                  javax.microedition.lcdui.Image imagePart)
Specified by:
append in interface javax.microedition.lcdui.Choice

append

public int append(java.lang.String stringPart,
                  javax.microedition.lcdui.Image imagePart,
                  Style itemStyle)
Appends an item to this group.

Parameters:
stringPart - the string part of the element to be added
imagePart - the image part of the element to be added, or null if there is no image part
itemStyle - the style for the new list element.
Returns:
the assigned index of the element
Throws:
java.lang.NullPointerException - if stringPart is null

append

public int append(ChoiceItem item)
Appends an item to this group.

Parameters:
item - the choice item to be added
Returns:
the assigned index of the element
Throws:
java.lang.NullPointerException - if item is null

delete

public void delete(int elementNum)
Specified by:
delete in interface javax.microedition.lcdui.Choice

deleteAll

public void deleteAll()
Specified by:
deleteAll in interface javax.microedition.lcdui.Choice

getFitPolicy

public int getFitPolicy()
Specified by:
getFitPolicy in interface javax.microedition.lcdui.Choice

getFont

public javax.microedition.lcdui.Font getFont(int elementNum)
Specified by:
getFont in interface javax.microedition.lcdui.Choice

getImage

public javax.microedition.lcdui.Image getImage(int elementNum)
Specified by:
getImage in interface javax.microedition.lcdui.Choice

getSelectedFlags

public int getSelectedFlags(boolean[] selectedArray_return)
Specified by:
getSelectedFlags in interface javax.microedition.lcdui.Choice

getSelectedIndex

public int getSelectedIndex()
Specified by:
getSelectedIndex in interface javax.microedition.lcdui.Choice

getString

public java.lang.String getString(int elementNum)
Specified by:
getString in interface javax.microedition.lcdui.Choice

insert

public void insert(int elementNum,
                   java.lang.String stringPart,
                   javax.microedition.lcdui.Image imagePart)
Specified by:
insert in interface javax.microedition.lcdui.Choice

insert

public void insert(int elementNum,
                   java.lang.String stringPart,
                   javax.microedition.lcdui.Image imagePart,
                   Style elementStyle)
Inserts an element with an attached style definition

Parameters:
elementNum - the index at which the element is added
stringPart - the text
imagePart - the optional image
elementStyle - the associated style

isSelected

public boolean isSelected(int elementNum)
Specified by:
isSelected in interface javax.microedition.lcdui.Choice

set

public void set(int elementNum,
                java.lang.String stringPart,
                javax.microedition.lcdui.Image imagePart)
Specified by:
set in interface javax.microedition.lcdui.Choice

set

public void set(int elementNum,
                java.lang.String stringPart,
                javax.microedition.lcdui.Image imagePart,
                Style elementStyle)
Sets an item at the specified index

Parameters:
elementNum - the element index
stringPart - the text
imagePart - the image
elementStyle - the associated style

setFitPolicy

public void setFitPolicy(int fitPolicy)
Specified by:
setFitPolicy in interface javax.microedition.lcdui.Choice

setFont

public void setFont(int elementNum,
                    javax.microedition.lcdui.Font font)
Specified by:
setFont in interface javax.microedition.lcdui.Choice

setSelectedFlags

public void setSelectedFlags(boolean[] selectedArray)
Specified by:
setSelectedFlags in interface javax.microedition.lcdui.Choice

setSelectedIndex

public void setSelectedIndex(int elementNum,
                             boolean selected)
Specified by:
setSelectedIndex in interface javax.microedition.lcdui.Choice

size

public int size()
Specified by:
size in interface javax.microedition.lcdui.Choice

handleKeyReleased

protected boolean handleKeyReleased(int keyCode,
                                    int gameAction)
Description copied from class: FakeCustomItem
Handles the key-released event. Please note, that implementation should first try to handle the given key-code, before the game-action is processed. The default does nothing.

Overrides:
handleKeyReleased in class FakeCustomItem
Parameters:
keyCode - the code of the pressed key, e.g. Canvas.KEY_NUM2
gameAction - the corresponding game-action, e.g. Canvas.UP
Returns:
true when the key has been handled / recognized
See Also:
FakeCustomItem.handleKeyPressed(int, int)

commandAction

public void commandAction(javax.microedition.lcdui.Command cmd,
                          javax.microedition.lcdui.Displayable disp)
Specified by:
commandAction in interface javax.microedition.lcdui.CommandListener

resetFilter

public void resetFilter()
Resets the filter text to null.


showFilteredList

public void showFilteredList(javax.microedition.lcdui.Display display)
Shows the filtered list.

Parameters:
display - the display

setStyle

public void setStyle(Style style)
Description copied from class: FakeCustomItem
Sets the style of this item.

Overrides:
setStyle in class FakeStringCustomItem
Parameters:
style - the new style for this item.

getDelimiter

public java.lang.String getDelimiter()
Retrieves the delimiter for separating text entries of a MULTIPLE FilteredChoiceGroup

Returns:
the delimiter

setDelimiter

public void setDelimiter(java.lang.String delimiter)
Sets the delimiter for separating text entries of a MULTIPLE FilteredChoiceGroup - the default is ", "

Parameters:
delimiter - the delimiter to set