502
503 // search at parent's node
504 nodePath = nodePath.substring(0, nodePath.lastIndexOf('/'));
505 }
506
507 return null;
508 }
509
510 private String readPreferredInputMethod(String nodePath) {
511 if ((userRoot == null) || (nodePath == null)) {
512 return null;
513 }
514
515 return userRoot.node(nodePath).get(descriptorKey, null);
516 }
517
518 /**
519 * Writes the preferred input method descriptor class name into
520 * the user's Preferences tree in accordance with the given locale.
521 *
522 * @param inputMethodLocator input method locator to remember.
523 */
524 private synchronized void putPreferredInputMethod(InputMethodLocator locator) {
525 InputMethodDescriptor descriptor = locator.getDescriptor();
526 Locale preferredLocale = locator.getLocale();
527
528 if (preferredLocale == null) {
529 // check available locales of the input method
530 try {
531 Locale[] availableLocales = descriptor.getAvailableLocales();
532 if (availableLocales.length == 1) {
533 preferredLocale = availableLocales[0];
534 } else {
535 // there is no way to know which locale is the preferred one, so do nothing.
536 return;
537 }
538 } catch (AWTException ae) {
539 // do nothing here, either.
540 return;
541 }
542 }
|
502
503 // search at parent's node
504 nodePath = nodePath.substring(0, nodePath.lastIndexOf('/'));
505 }
506
507 return null;
508 }
509
510 private String readPreferredInputMethod(String nodePath) {
511 if ((userRoot == null) || (nodePath == null)) {
512 return null;
513 }
514
515 return userRoot.node(nodePath).get(descriptorKey, null);
516 }
517
518 /**
519 * Writes the preferred input method descriptor class name into
520 * the user's Preferences tree in accordance with the given locale.
521 *
522 * @param locator input method locator to remember.
523 */
524 private synchronized void putPreferredInputMethod(InputMethodLocator locator) {
525 InputMethodDescriptor descriptor = locator.getDescriptor();
526 Locale preferredLocale = locator.getLocale();
527
528 if (preferredLocale == null) {
529 // check available locales of the input method
530 try {
531 Locale[] availableLocales = descriptor.getAvailableLocales();
532 if (availableLocales.length == 1) {
533 preferredLocale = availableLocales[0];
534 } else {
535 // there is no way to know which locale is the preferred one, so do nothing.
536 return;
537 }
538 } catch (AWTException ae) {
539 // do nothing here, either.
540 return;
541 }
542 }
|