42 import java.awt.im.spi.InputMethodDescriptor; 43 import java.lang.reflect.InvocationTargetException; 44 import java.security.AccessController; 45 import java.security.PrivilegedAction; 46 import java.security.PrivilegedActionException; 47 import java.security.PrivilegedExceptionAction; 48 import java.util.Hashtable; 49 import java.util.Iterator; 50 import java.util.Locale; 51 import java.util.ServiceLoader; 52 import java.util.Vector; 53 import java.util.Set; 54 import java.util.prefs.BackingStoreException; 55 import java.util.prefs.Preferences; 56 import sun.awt.InputMethodSupport; 57 import sun.awt.SunToolkit; 58 import sun.misc.InnocuousThread; 59 import sun.misc.ManagedLocalsThread; 60 61 /** 62 * <code>InputMethodManager</code> is an abstract class that manages the input 63 * method environment of JVM. There is only one <code>InputMethodManager</code> 64 * instance in JVM that is executed under a separate daemon thread. 65 * <code>InputMethodManager</code> performs the following: 66 * <UL> 67 * <LI> 68 * Keeps track of the current input context.</LI> 69 * 70 * <LI> 71 * Provides a user interface to switch input methods and notifies the current 72 * input context about changes made from the user interface.</LI> 73 * </UL> 74 * 75 * The mechanism for supporting input method switch is as follows. (Note that 76 * this may change in future releases.) 77 * 78 * <UL> 79 * <LI> 80 * One way is to use platform-dependent window manager's menu (known as the <I>Window 81 * menu </I>in Motif and the <I>System menu</I> or <I>Control menu</I> in 82 * Win32) on each window which is popped up by clicking the left top box of 83 * a window (known as <I>Window menu button</I> in Motif and <I>System menu 84 * button</I> in Win32). This happens to be common in both Motif and Win32.</LI> 85 * 86 * <LI> 87 * When more than one input method descriptor can be found or the only input 88 * method descriptor found supports multiple locales, a menu item 89 * is added to the window (manager) menu. This item label is obtained invoking 90 * <code>getTriggerMenuString()</code>. If null is returned by this method, it 91 * means that there is only input method or none in the environment. Frame and Dialog 92 * invoke this method.</LI> 93 * 94 * <LI> 95 * This menu item means a trigger switch to the user to pop up a selection 96 * menu.</LI> 97 * 98 * <LI> 99 * When the menu item of the window (manager) menu has been selected by the 100 * user, Frame/Dialog invokes <code>notifyChangeRequest()</code> to notify 101 * <code>InputMethodManager</code> that the user wants to switch input methods.</LI> 102 * 103 * <LI> 104 * <code>InputMethodManager</code> displays a pop-up menu to choose an input method.</LI> 105 * 106 * <LI> 107 * <code>InputMethodManager</code> notifies the current <code>InputContext</code> of 108 * the selected <code>InputMethod</code>.</LI> 109 * </UL> 110 * 111 * <UL> 112 * <LI> 113 * The other way is to use user-defined hot key combination to show the pop-up menu to 114 * choose an input method. This is useful for the platforms which do not provide a 115 * way to add a menu item in the window (manager) menu.</LI> 116 * 117 * <LI> 118 * When the hot key combination is typed by the user, the component which has the input 119 * focus invokes <code>notifyChangeRequestByHotKey()</code> to notify 120 * <code>InputMethodManager</code> that the user wants to switch input methods.</LI> 121 * 122 * <LI> 123 * This results in a popup menu and notification to the current input context, 124 * as above.</LI> 125 * </UL> 126 * 127 * @see java.awt.im.spi.InputMethod 128 * @see sun.awt.im.InputContext 129 * @see sun.awt.im.InputMethodAdapter 130 * @author JavaSoft International 131 */ 132 133 public abstract class InputMethodManager { 134 135 /** 136 * InputMethodManager thread name 137 */ 138 private static final String threadName = "AWT-InputMethodManager"; 139 140 /** | 42 import java.awt.im.spi.InputMethodDescriptor; 43 import java.lang.reflect.InvocationTargetException; 44 import java.security.AccessController; 45 import java.security.PrivilegedAction; 46 import java.security.PrivilegedActionException; 47 import java.security.PrivilegedExceptionAction; 48 import java.util.Hashtable; 49 import java.util.Iterator; 50 import java.util.Locale; 51 import java.util.ServiceLoader; 52 import java.util.Vector; 53 import java.util.Set; 54 import java.util.prefs.BackingStoreException; 55 import java.util.prefs.Preferences; 56 import sun.awt.InputMethodSupport; 57 import sun.awt.SunToolkit; 58 import sun.misc.InnocuousThread; 59 import sun.misc.ManagedLocalsThread; 60 61 /** 62 * {@code InputMethodManager} is an abstract class that manages the input 63 * method environment of JVM. There is only one {@code InputMethodManager} 64 * instance in JVM that is executed under a separate daemon thread. 65 * {@code InputMethodManager} performs the following: 66 * <UL> 67 * <LI> 68 * Keeps track of the current input context.</LI> 69 * 70 * <LI> 71 * Provides a user interface to switch input methods and notifies the current 72 * input context about changes made from the user interface.</LI> 73 * </UL> 74 * 75 * The mechanism for supporting input method switch is as follows. (Note that 76 * this may change in future releases.) 77 * 78 * <UL> 79 * <LI> 80 * One way is to use platform-dependent window manager's menu (known as the <I>Window 81 * menu </I>in Motif and the <I>System menu</I> or <I>Control menu</I> in 82 * Win32) on each window which is popped up by clicking the left top box of 83 * a window (known as <I>Window menu button</I> in Motif and <I>System menu 84 * button</I> in Win32). This happens to be common in both Motif and Win32.</LI> 85 * 86 * <LI> 87 * When more than one input method descriptor can be found or the only input 88 * method descriptor found supports multiple locales, a menu item 89 * is added to the window (manager) menu. This item label is obtained invoking 90 * {@code getTriggerMenuString()}. If null is returned by this method, it 91 * means that there is only input method or none in the environment. Frame and Dialog 92 * invoke this method.</LI> 93 * 94 * <LI> 95 * This menu item means a trigger switch to the user to pop up a selection 96 * menu.</LI> 97 * 98 * <LI> 99 * When the menu item of the window (manager) menu has been selected by the 100 * user, Frame/Dialog invokes {@code notifyChangeRequest()} to notify 101 * {@code InputMethodManager} that the user wants to switch input methods.</LI> 102 * 103 * <LI> 104 * {@code InputMethodManager} displays a pop-up menu to choose an input method.</LI> 105 * 106 * <LI> 107 * {@code InputMethodManager} notifies the current {@code InputContext} of 108 * the selected {@code InputMethod}.</LI> 109 * </UL> 110 * 111 * <UL> 112 * <LI> 113 * The other way is to use user-defined hot key combination to show the pop-up menu to 114 * choose an input method. This is useful for the platforms which do not provide a 115 * way to add a menu item in the window (manager) menu.</LI> 116 * 117 * <LI> 118 * When the hot key combination is typed by the user, the component which has the input 119 * focus invokes {@code notifyChangeRequestByHotKey()} to notify 120 * {@code InputMethodManager} that the user wants to switch input methods.</LI> 121 * 122 * <LI> 123 * This results in a popup menu and notification to the current input context, 124 * as above.</LI> 125 * </UL> 126 * 127 * @see java.awt.im.spi.InputMethod 128 * @see sun.awt.im.InputContext 129 * @see sun.awt.im.InputMethodAdapter 130 * @author JavaSoft International 131 */ 132 133 public abstract class InputMethodManager { 134 135 /** 136 * InputMethodManager thread name 137 */ 138 private static final String threadName = "AWT-InputMethodManager"; 139 140 /** |