)
{
String mappedIconName = getSkinResourceMappedKey(iconName);
Icon rtlIcon = null;
Icon defaultRTLIcon = null;
Skin skin = getSkin();
if (mappedIconName != null)
{
if (getLocaleContext().isRightToLeft() &&
(!mappedIconName.endsWith(StyleUtils.RTL_CSS_SUFFIX)))
{
// append :rtl to the mappedIconName. If no icon with that name,
// default to getting the icon with the original mappedIconName.
String rtlIconName = mappedIconName+StyleUtils.RTL_CSS_SUFFIX;
// @todo I could optimize this a bit by having a method on SkinExtension
// which doesn't create a NullIcon when the icon is not found, if I
// know I want to set it to something else anyway.
rtlIcon = skin.getIcon(rtlIconName);
if (rtlIcon == null)
{
// we want :rtl icons to default to regular icons, not a NullIcon,
// which is what the Skin does.
// Couldn't find rtl icon, so default it to the regular icon
defaultRTLIcon = skin.getIcon(mappedIconName);
if (defaultRTLIcon != null)
{
// cache regular icon so we don't need to get it again!
skin.registerIcon(rtlIconName, defaultRTLIcon);
}
}
return (rtlIcon != null) ? rtlIcon : defaultRTLIcon;
}
else
{
// no rtl icon
return skin.getIcon(mappedIconName);
}
}
else