Package com.iizix.prop.ui.mlist
Class MLSwitch
java.lang.Object
com.iizix.prop.ui.mlist.MLItem
com.iizix.prop.ui.mlist.MLSwitch
- All Implemented Interfaces:
IContentData<MLItemProp>
,ICustomDataProvider
,IMLArrowActionListener
The switch list item class.
The switch has a text on leading/trailing sides and a description. On the trailing side, a switch is shown.
The trailing text can be left adjusted after the leading text that may have a fixed width in order to have an additional column of text.
The selection state is independent of other components, support for third state exists.
An optional description text can be added to the bottom of the list item.
- Author:
- Christopher Mindus
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Property name: trailing align opposite "ao".static final String
Property name: display trailing arrow "arrow".static final String
Property name: shape "shape".static final String
Property name: switch state, same asIUICheck2Component.PN_CHECKED
"checked".static final String
Property name: trailing text "tt".static final String
Property name: trailing text virtual column reference "V_tt".Fields inherited from class com.iizix.prop.ui.mlist.MLItem
FIRST_COLUMN_INDEX, PN_ACTION, PN_ANIMATION, PN_DESCRIPTION, PN_ICON, PN_ICON_MARGINS, PN_LEADING_TEXT, PN_LEADING_WIDTH, PN_LEADING_WRAP, PN_V_DESCRIPTION, PN_V_LEADING_TEXT, PN_VS_FOCUS
Constructor Summary
Method Summary
Modifier and TypeMethodDescriptionboolean
addListener
(IMLArrowActionListener listener) Adds an action listener for the arrow.boolean
addListener
(IMLSwitchStateListener listener) Adds a switch listener for the arrow.protected int
Returns the column index for the description.protected int
Returns the column index for the leading text.protected String
Returns the IntProp property name used to set the selection to.int
getShape()
Gets the switch shape.Gets the trailing text for the list item.getType()
Returns the type.protected String[]
Returns the property names for which the
must be called.from(PropCnr,MLItemProp)
void
initialize
(MLItemProp item) Initializes the item property from the content data.boolean
Returns if the trailing arrow is displayed or not.boolean
Returns if the trailing text is aligned to the opposite side, i.e.boolean
isTrailingTextOppositeAligned
(boolean opposite) Sets if the trailing text is aligned to the opposite side, i.e.void
onArrowInvoked
(MLItem item) Called when the arrow action is invoked.void
refreshFromVS
(int[] columns) Refreshes contents from VirtualSpace.boolean
removeListener
(IMLArrowActionListener listener) Removes an action listener for the arrow.boolean
removeListener
(IMLSwitchStateListener listener) Removes a switch listener for the arrow.boolean
setArrowDisplayed
(boolean on) Sets if the trailing arrow should be displayed or not.boolean
setShape
(int shape) Sets the switch shape.boolean
setTrailingText
(KString text) Sets the trailing text for the list item.Methods inherited from class com.iizix.prop.ui.mlist.MLItem
addMappings, doBooleanSelectionOnly, forbiddenGetCustomDataMap, getContextMenu, getGroup, getIcon, getIconMargins, getItemProp, getLeadingText, getLeadingTextWrap, getLeadingWidth, getSelectionState, getVSRow, hasActionSupport, isEnabled, isReadOnly, isSelected, isVisible, setActionSupport, setContextMenu, setDescription, setEnabled, setIcon, setIconMargins, setIconPadding, setLeadingText, setLeadingTextEllipsis, setLeadingTextSingleLine, setLeadingTextWrap, setLeadingTextWrap, setLeadingWidth, setReadOnly, setSelected, setSelection, setSelectionInternal, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.iizix.prop.ICustomDataProvider
getCustomData, putCustomData, putCustomDataIfAbsent
Field Details
PN_SHAPE
Property name: shape "shape".- See Also:
PN_TRAILING_TEXT
Property name: trailing text "tt".- See Also:
PN_V_TRAILING_TEXT
Property name: trailing text virtual column reference "V_tt".- See Also:
PN_ALIGN_OPPOSITE
Property name: trailing align opposite "ao".- See Also:
PN_ARROW
Property name: display trailing arrow "arrow".- See Also:
PN_SWITCH_STATE
Property name: switch state, same asIUICheck2Component.PN_CHECKED
"checked".- See Also:
Constructor Details
MLSwitch
public MLSwitch(boolean state) Creates a new switch list item.- Parameters:
state
- The switch state.
Method Details
getSelectionPropName
Returns the IntProp property name used to set the selection to.- Overrides:
getSelectionPropName
in classMLItem
- Returns:
- The selection property name "checked".
getType
Returns the type.getLeadingTextColumn
protected int getLeadingTextColumn()Returns the column index for the leading text. Types supporting description text must override this method.- Specified by:
getLeadingTextColumn
in classMLItem
- Returns:
- The column index, or -1 for none.
getDescriptionColumn
protected int getDescriptionColumn()Returns the column index for the description. Types supporting description text must override this method.- Specified by:
getDescriptionColumn
in classMLItem
- Returns:
- The column index = 3.
refreshFromVS
public void refreshFromVS(int[] columns) Refreshes contents from VirtualSpace.- Specified by:
refreshFromVS
in interfaceIContentData<MLItemProp>
- Specified by:
refreshFromVS
in classMLItem
- Parameters:
columns
- The connected table columns indicies, -1 for none.
initialize
Initializes the item property from the content data. Each list item must implement this method to provider initialization of its own and call
.initialize(MLItemProp)
- Specified by:
initialize
in interfaceIContentData<MLItemProp>
- Parameters:
item
- The item.
getUpdatePropertyNames
Returns the property names for which the
must be called.from(PropCnr,MLItemProp)
- Returns:
- The array of update properties, never null.
getShape
public int getShape()Gets the switch shape.- Returns:
- The shape:
- 0 = default,
- 1 = square,
- 2 = round (normal knob),
- 3 = round (large knob),
- 4 = arc (normal knob),
- 5 = arc (wide knob)
setShape
public boolean setShape(int shape) Sets the switch shape.- Parameters:
shape
- The new shape (0-5) as:- 0 = default,
- 1 = square,
- 2 = round (normal knob),
- 3 = round (large knob),
- 4 = arc (normal knob),
- 5 = arc (wide knob)
- Returns:
- true for changed, false for no change.
getTrailingText
Gets the trailing text for the list item.- Returns:
- The text, or null if none is set.
setTrailingText
Sets the trailing text for the list item.- Parameters:
text
- The new text, or null for none.- Returns:
- true for changed, false for no change.
isTrailingTextOppositeAligned
public boolean isTrailingTextOppositeAligned()Returns if the trailing text is aligned to the opposite side, i.e. leading instead of trailing.- Returns:
- true if trailing text is aligned to leading side, false for aligned to the trailing side.
isTrailingTextOppositeAligned
public boolean isTrailingTextOppositeAligned(boolean opposite) Sets if the trailing text is aligned to the opposite side, i.e. leading instead of trailing.- Parameters:
opposite
- Alignment flag: true if trailing text is aligned to leading side, false for aligned to the trailing side.- Returns:
- true for changed, false for no change.
isArrowDisplayed
public boolean isArrowDisplayed()Returns if the trailing arrow is displayed or not.- Returns:
- true to display arrow, false not to display arrow.
setArrowDisplayed
public boolean setArrowDisplayed(boolean on) Sets if the trailing arrow should be displayed or not.- Parameters:
on
- The display flag: true to display arrow, false not to display arrow.- Returns:
- true for changed, false for no change.
addListener
Adds a switch listener for the arrow. Calling this method multiple times with the same listener will have no effect (but to return false). Adds a new listener. Calling this method multiple times with the same listener will have no effect (but to return false).- Parameters:
listener
- The listener to add.- Returns:
- true if the listener was added, false otherwise.
- Throws:
NullPointerException
- If the listener isnull
.
removeListener
Removes a switch listener for the arrow.- Parameters:
listener
- The listener to remove.- Returns:
- true if listener is successfully removed, false otherwise.
addListener
Adds an action listener for the arrow. Calling this method multiple times with the same listener will have no effect (but to return false).- Parameters:
listener
- The listener to add.- Returns:
- true if the listener was added, false otherwise.
- Throws:
NullPointerException
- If the listener isnull
.
removeListener
Removes an action listener for the arrow.- Parameters:
listener
- The listener to remove.- Returns:
- true if listener is successfully removed, false otherwise.
onArrowInvoked
Called when the arrow action is invoked. By default, this method will invoke all potential arrow action listeners. A subclass might override this method instead of adding a listener. This subclass should then call thesuper.onArrowInvoked(item)
method in case listeners are added by others.- Specified by:
onArrowInvoked
in interfaceIMLArrowActionListener
- Parameters:
item
- "this" item.