01: /*
02: *******************************************************************************
03: * Copyright (C) 2004, International Business Machines Corporation and *
04: * others. All Rights Reserved. *
05: *******************************************************************************
06: */
07:
08: package com.ibm.icu.dev.tool.ime.translit;
09:
10: import java.awt.Image;
11: import java.awt.im.spi.InputMethod;
12: import java.awt.im.spi.InputMethodDescriptor;
13: import java.util.Locale;
14: import java.util.ResourceBundle;
15: import java.util.MissingResourceException;
16:
17: /**
18: * The TransliteratorInputMethodDescriptor class is used to identify this package
19: * as an input method editor.
20: */
21:
22: public class TransliteratorInputMethodDescriptor implements
23: InputMethodDescriptor {
24:
25: private ResourceBundle rb = null;
26:
27: /**
28: * Creates the Transliterator IME this is automatically callled by the
29: * JVM when the Transliterator IME is selected from the input method list.
30: *
31: * @return InputMethod The Transliterator IME object.
32: */
33: public InputMethod createInputMethod() throws Exception {
34: return new TransliteratorInputMethod();
35: }
36:
37: /**
38: * Get the list of locales that this IME supports.
39: *
40: * @return Locale[] This will always have one locale. By default
41: * we just return the current locale. Therefore
42: * the Transliterator IME works in all locales.
43: */
44: // use the current active locale
45: public Locale[] getAvailableLocales() {
46: return new Locale[] { Locale.getDefault() };
47: }
48:
49: /**
50: * The Transliterator IME does not support dynamic locales. The Transliterator
51: * IME's functionality does not depend upon any locale.
52: *
53: * @return boolean This will always be false.
54: */
55: public boolean hasDynamicLocaleList() {
56: return false;
57: }
58:
59: /**
60: * Obtain the localized name of the Transliterator IME
61: *
62: * @param inputLocale the requested input method locale
63: * @param displayLanguage The requested translation of the Transliterator IME
64: * @return the localized name for the Transliterator IME
65: */
66: public String getInputMethodDisplayName(Locale inputLocale,
67: Locale displayLanguage) {
68: String name = null;
69:
70: try {
71: rb = ResourceBundle.getBundle(
72: "com.ibm.icu.dev.tool.ime.translit.Transliterator",
73: displayLanguage);
74: name = rb.getString("name");
75: } catch (MissingResourceException m) {
76: // use a hardcoded value
77: name = "Transliterator";
78: }
79: return name;
80: }
81:
82: /**
83: * Get the icon for the Transliterator IME. This is not supported.
84: *
85: * @param inputLocale (This is ignored).
86: *
87: * @return Image This will always be null.
88: */
89: public Image getInputMethodIcon(Locale inputLocale) {
90: return null;
91: }
92: }
|