if (im != null && im.setLocale(locale))
{
recent.put(locale, im);
return true;
}
InputMethod next = recent.get(locale);
if (next != null)
for (int i = 0, limit = descriptors.size(); i < limit; i++)
{
InputMethodDescriptor d = descriptors.get(i);
Locale[] list;
try
{
list = d.getAvailableLocales();
}
catch (AWTException ignored)
{
continue;
}
for (int j = list.length; --j >= 0; )
if (locale.equals(list[j]))
{
try
{
next = d.createInputMethod();
recent.put(locale, next);
}
catch (Exception ignored)
{
continue;
}
}
}
if (next == null)
return false;
// XXX I'm not sure if this does all the necessary steps in the switch.
if (im != null)
{
try
{
next.setCompositionEnabled(im.isCompositionEnabled());
}
catch (UnsupportedOperationException ignored)
{
}
im.endComposition();