src/share/classes/sun/awt/im/InputContext.java

Print this page




 370     private void activateInputMethod(boolean updateCompositionArea) {
 371         // call hideWindows() if this input context uses a different
 372         // input method than the previously activated one
 373         if (inputMethodWindowContext != null && inputMethodWindowContext != this &&
 374                 inputMethodWindowContext.inputMethodLocator != null &&
 375                 !inputMethodWindowContext.inputMethodLocator.sameInputMethod(inputMethodLocator) &&
 376                 inputMethodWindowContext.inputMethod != null) {
 377             inputMethodWindowContext.inputMethod.hideWindows();
 378         }
 379         inputMethodWindowContext = this;
 380 
 381         if (inputMethod != null) {
 382             if (previousInputMethod != inputMethod &&
 383                     previousInputMethod instanceof InputMethodAdapter) {
 384                 // let the host adapter pass through the input events for the
 385                 // new input method
 386                 ((InputMethodAdapter) previousInputMethod).stopListening();
 387             }
 388             previousInputMethod = null;
 389 
 390             if (log.isLoggable(PlatformLogger.FINE)) {
 391                 log.fine("Current client component " + currentClientComponent);
 392             }
 393             if (inputMethod instanceof InputMethodAdapter) {
 394                 ((InputMethodAdapter) inputMethod).setClientComponent(currentClientComponent);
 395             }
 396             inputMethod.activate();
 397             isInputMethodActive = true;
 398 
 399             if (perInputMethodState != null) {
 400                 Boolean state = perInputMethodState.remove(inputMethod);
 401                 if (state != null) {
 402                     clientWindowNotificationEnabled = state.booleanValue();
 403                 }
 404             }
 405             if (clientWindowNotificationEnabled) {
 406                 if (!addedClientWindowListeners()) {
 407                     addClientWindowListeners();
 408                 }
 409                 synchronized(this) {
 410                     if (clientWindowListened != null) {


 870 
 871             // if the instance has been created, then it means either
 872             // setLocale() or setInputMethodContext() failed.
 873             if (inputMethodInstance != null) {
 874                 inputMethodInstance = null;
 875             }
 876         } catch (LinkageError e) {
 877             logCreationFailed(e);
 878 
 879             // same as above
 880             inputMethodCreationFailed = true;
 881         }
 882         ((InputMethodContext) this).setInputMethodSupportsBelowTheSpot(
 883                 (!(inputMethodInstance instanceof InputMethodAdapter)) ||
 884                 ((InputMethodAdapter) inputMethodInstance).supportsBelowTheSpot());
 885         return inputMethodInstance;
 886     }
 887 
 888     private void logCreationFailed(Throwable throwable) {
 889         PlatformLogger logger = PlatformLogger.getLogger("sun.awt.im");
 890         if (logger.isLoggable(PlatformLogger.CONFIG)) {
 891             String errorTextFormat = Toolkit.getProperty("AWT.InputMethodCreationFailed",
 892                                                          "Could not create {0}. Reason: {1}");
 893             Object[] args =
 894                 {inputMethodLocator.getDescriptor().getInputMethodDisplayName(null, Locale.getDefault()),
 895                  throwable.getLocalizedMessage()};
 896             MessageFormat mf = new MessageFormat(errorTextFormat);
 897             logger.config(mf.format(args));
 898         }
 899     }
 900 
 901     InputMethodLocator getInputMethodLocator() {
 902         if (inputMethod != null) {
 903             return inputMethodLocator.deriveLocator(inputMethod.getLocale());
 904         }
 905         return inputMethodLocator;
 906     }
 907 
 908     /**
 909      * @see java.awt.im.InputContext#endComposition
 910      */




 370     private void activateInputMethod(boolean updateCompositionArea) {
 371         // call hideWindows() if this input context uses a different
 372         // input method than the previously activated one
 373         if (inputMethodWindowContext != null && inputMethodWindowContext != this &&
 374                 inputMethodWindowContext.inputMethodLocator != null &&
 375                 !inputMethodWindowContext.inputMethodLocator.sameInputMethod(inputMethodLocator) &&
 376                 inputMethodWindowContext.inputMethod != null) {
 377             inputMethodWindowContext.inputMethod.hideWindows();
 378         }
 379         inputMethodWindowContext = this;
 380 
 381         if (inputMethod != null) {
 382             if (previousInputMethod != inputMethod &&
 383                     previousInputMethod instanceof InputMethodAdapter) {
 384                 // let the host adapter pass through the input events for the
 385                 // new input method
 386                 ((InputMethodAdapter) previousInputMethod).stopListening();
 387             }
 388             previousInputMethod = null;
 389 
 390             if (log.isLoggable(PlatformLogger.Level.FINE)) {
 391                 log.fine("Current client component " + currentClientComponent);
 392             }
 393             if (inputMethod instanceof InputMethodAdapter) {
 394                 ((InputMethodAdapter) inputMethod).setClientComponent(currentClientComponent);
 395             }
 396             inputMethod.activate();
 397             isInputMethodActive = true;
 398 
 399             if (perInputMethodState != null) {
 400                 Boolean state = perInputMethodState.remove(inputMethod);
 401                 if (state != null) {
 402                     clientWindowNotificationEnabled = state.booleanValue();
 403                 }
 404             }
 405             if (clientWindowNotificationEnabled) {
 406                 if (!addedClientWindowListeners()) {
 407                     addClientWindowListeners();
 408                 }
 409                 synchronized(this) {
 410                     if (clientWindowListened != null) {


 870 
 871             // if the instance has been created, then it means either
 872             // setLocale() or setInputMethodContext() failed.
 873             if (inputMethodInstance != null) {
 874                 inputMethodInstance = null;
 875             }
 876         } catch (LinkageError e) {
 877             logCreationFailed(e);
 878 
 879             // same as above
 880             inputMethodCreationFailed = true;
 881         }
 882         ((InputMethodContext) this).setInputMethodSupportsBelowTheSpot(
 883                 (!(inputMethodInstance instanceof InputMethodAdapter)) ||
 884                 ((InputMethodAdapter) inputMethodInstance).supportsBelowTheSpot());
 885         return inputMethodInstance;
 886     }
 887 
 888     private void logCreationFailed(Throwable throwable) {
 889         PlatformLogger logger = PlatformLogger.getLogger("sun.awt.im");
 890         if (logger.isLoggable(PlatformLogger.Level.CONFIG)) {
 891             String errorTextFormat = Toolkit.getProperty("AWT.InputMethodCreationFailed",
 892                                                          "Could not create {0}. Reason: {1}");
 893             Object[] args =
 894                 {inputMethodLocator.getDescriptor().getInputMethodDisplayName(null, Locale.getDefault()),
 895                  throwable.getLocalizedMessage()};
 896             MessageFormat mf = new MessageFormat(errorTextFormat);
 897             logger.config(mf.format(args));
 898         }
 899     }
 900 
 901     InputMethodLocator getInputMethodLocator() {
 902         if (inputMethod != null) {
 903             return inputMethodLocator.deriveLocator(inputMethod.getLocale());
 904         }
 905         return inputMethodLocator;
 906     }
 907 
 908     /**
 909      * @see java.awt.im.InputContext#endComposition
 910      */