77 private InputMethodLocator inputMethodLocator; |
77 private InputMethodLocator inputMethodLocator; |
78 private InputMethod inputMethod; |
78 private InputMethod inputMethod; |
79 private boolean inputMethodCreationFailed; |
79 private boolean inputMethodCreationFailed; |
80 |
80 |
81 // holding bin for previously used input method instances, but not the current one |
81 // holding bin for previously used input method instances, but not the current one |
82 private HashMap usedInputMethods; |
82 private HashMap<InputMethodLocator, InputMethod> usedInputMethods; |
83 |
83 |
84 // the current client component is kept until the user focusses on a different |
84 // the current client component is kept until the user focusses on a different |
85 // client component served by the same input context. When that happens, we call |
85 // client component served by the same input context. When that happens, we call |
86 // endComposition so that text doesn't jump from one component to another. |
86 // endComposition so that text doesn't jump from one component to another. |
87 private Component currentClientComponent; |
87 private Component currentClientComponent; |
104 // client window to which this input context is listening |
104 // client window to which this input context is listening |
105 private Window clientWindowListened; |
105 private Window clientWindowListened; |
106 // cache location notification |
106 // cache location notification |
107 private Rectangle clientWindowLocation = null; |
107 private Rectangle clientWindowLocation = null; |
108 // holding the state of clientWindowNotificationEnabled of only non-current input methods |
108 // holding the state of clientWindowNotificationEnabled of only non-current input methods |
109 private HashMap perInputMethodState; |
109 private HashMap<InputMethod, Boolean> perInputMethodState; |
110 |
110 |
111 // Input Method selection hot key stuff |
111 // Input Method selection hot key stuff |
112 private static AWTKeyStroke inputMethodSelectionKey; |
112 private static AWTKeyStroke inputMethodSelectionKey; |
113 private static boolean inputMethodSelectionKeyInitialized = false; |
113 private static boolean inputMethodSelectionKeyInitialized = false; |
114 private static final String inputMethodSelectionKeyPath = "/java/awt/im/selectionKey"; |
114 private static final String inputMethodSelectionKeyPath = "/java/awt/im/selectionKey"; |
392 } |
393 } |
393 inputMethod.activate(); |
394 inputMethod.activate(); |
394 isInputMethodActive = true; |
395 isInputMethodActive = true; |
395 |
396 |
396 if (perInputMethodState != null) { |
397 if (perInputMethodState != null) { |
397 Boolean state = (Boolean) perInputMethodState.remove(inputMethod); |
398 Boolean state = perInputMethodState.remove(inputMethod); |
398 if (state != null) { |
399 if (state != null) { |
399 clientWindowNotificationEnabled = state.booleanValue(); |
400 clientWindowNotificationEnabled = state.booleanValue(); |
400 } |
401 } |
401 } |
402 } |
402 if (clientWindowNotificationEnabled) { |
403 if (clientWindowNotificationEnabled) { |
547 } |
548 } |
548 savedLocale = inputMethod.getLocale(); |
549 savedLocale = inputMethod.getLocale(); |
549 |
550 |
550 // keep the input method instance around for future use |
551 // keep the input method instance around for future use |
551 if (usedInputMethods == null) { |
552 if (usedInputMethods == null) { |
552 usedInputMethods = new HashMap(5); |
553 usedInputMethods = new HashMap<>(5); |
553 } |
554 } |
554 if (perInputMethodState == null) { |
555 if (perInputMethodState == null) { |
555 perInputMethodState = new HashMap(5); |
556 perInputMethodState = new HashMap<>(5); |
556 } |
557 } |
557 usedInputMethods.put(inputMethodLocator.deriveLocator(null), inputMethod); |
558 usedInputMethods.put(inputMethodLocator.deriveLocator(null), inputMethod); |
558 perInputMethodState.put(inputMethod, |
559 perInputMethodState.put(inputMethod, |
559 Boolean.valueOf(clientWindowNotificationEnabled)); |
560 Boolean.valueOf(clientWindowNotificationEnabled)); |
560 enableClientWindowNotification(inputMethod, false); |
561 enableClientWindowNotification(inputMethod, false); |
687 |
688 |
688 inputMethod = null; |
689 inputMethod = null; |
689 } |
690 } |
690 inputMethodLocator = null; |
691 inputMethodLocator = null; |
691 if (usedInputMethods != null && !usedInputMethods.isEmpty()) { |
692 if (usedInputMethods != null && !usedInputMethods.isEmpty()) { |
692 Iterator iterator = usedInputMethods.values().iterator(); |
693 Iterator<InputMethod> iterator = usedInputMethods.values().iterator(); |
693 usedInputMethods = null; |
694 usedInputMethods = null; |
694 while (iterator.hasNext()) { |
695 while (iterator.hasNext()) { |
695 ((InputMethod) iterator.next()).dispose(); |
696 iterator.next().dispose(); |
696 } |
697 } |
697 } |
698 } |
698 |
699 |
699 // cleanup client window notification variables |
700 // cleanup client window notification variables |
700 clientWindowNotificationEnabled = false; |
701 clientWindowNotificationEnabled = false; |
828 Locale locale = locator.getLocale(); |
829 Locale locale = locator.getLocale(); |
829 InputMethod inputMethodInstance = null; |
830 InputMethod inputMethodInstance = null; |
830 |
831 |
831 // see whether we have a previously used input method |
832 // see whether we have a previously used input method |
832 if (usedInputMethods != null) { |
833 if (usedInputMethods != null) { |
833 inputMethodInstance = (InputMethod) usedInputMethods.remove(locator.deriveLocator(null)); |
834 inputMethodInstance = usedInputMethods.remove(locator.deriveLocator(null)); |
834 if (inputMethodInstance != null) { |
835 if (inputMethodInstance != null) { |
835 if (locale != null) { |
836 if (locale != null) { |
836 inputMethodInstance.setLocale(locale); |
837 inputMethodInstance.setLocale(locale); |
837 } |
838 } |
838 inputMethodInstance.setCharacterSubsets(characterSubsets); |
839 inputMethodInstance.setCharacterSubsets(characterSubsets); |
839 Boolean state = (Boolean) perInputMethodState.remove(inputMethodInstance); |
840 Boolean state = perInputMethodState.remove(inputMethodInstance); |
840 if (state != null) { |
841 if (state != null) { |
841 enableClientWindowNotification(inputMethodInstance, state.booleanValue()); |
842 enableClientWindowNotification(inputMethodInstance, state.booleanValue()); |
842 } |
843 } |
843 ((InputMethodContext) this).setInputMethodSupportsBelowTheSpot( |
844 ((InputMethodContext) this).setInputMethodSupportsBelowTheSpot( |
844 (!(inputMethodInstance instanceof InputMethodAdapter)) || |
845 (!(inputMethodInstance instanceof InputMethodAdapter)) || |
917 // in case this request is not from the current input method, |
918 // in case this request is not from the current input method, |
918 // store the request and handle it when this requesting input |
919 // store the request and handle it when this requesting input |
919 // method becomes the current one. |
920 // method becomes the current one. |
920 if (requester != inputMethod) { |
921 if (requester != inputMethod) { |
921 if (perInputMethodState == null) { |
922 if (perInputMethodState == null) { |
922 perInputMethodState = new HashMap(5); |
923 perInputMethodState = new HashMap<>(5); |
923 } |
924 } |
924 perInputMethodState.put(requester, Boolean.valueOf(enable)); |
925 perInputMethodState.put(requester, Boolean.valueOf(enable)); |
925 return; |
926 return; |
926 } |
927 } |
927 |
928 |
1027 |
1028 |
1028 /** |
1029 /** |
1029 * Initializes the input method selection key definition in preference trees |
1030 * Initializes the input method selection key definition in preference trees |
1030 */ |
1031 */ |
1031 private void initializeInputMethodSelectionKey() { |
1032 private void initializeInputMethodSelectionKey() { |
1032 AccessController.doPrivileged(new PrivilegedAction() { |
1033 AccessController.doPrivileged(new PrivilegedAction<Object>() { |
1033 public Object run() { |
1034 public Object run() { |
1034 // Look in user's tree |
1035 // Look in user's tree |
1035 Preferences root = Preferences.userRoot(); |
1036 Preferences root = Preferences.userRoot(); |
1036 inputMethodSelectionKey = getInputMethodSelectionKeyStroke(root); |
1037 inputMethodSelectionKey = getInputMethodSelectionKeyStroke(root); |
1037 |
1038 |