private void activateIM(InputMethod im) { Component c; im.activate(); if ((nativeIM != null) && (im != nativeIM)) { // when Java IM is active // native input method editor must be // explicitly disabled nativeIM.disableIME(); } IMManager.setLastActiveIMC(this); c = getClient(); if (c != null) { c.getInputMethodRequests(); } }
@Override public boolean selectInputMethod(Locale locale) { if ((inputMethod != null) && inputMethod.setLocale(locale)) { return true; } // first // take last user-selected IM for locale InputMethod newIM = localeIM.get(locale); // if not found search through IM descriptors // and take already created instance if exists // or create, store new IM instance in descriptor->instance map if (newIM == null) { try { newIM = getIMInstance(IMManager.getIMDescriptors().iterator(), locale); } catch (Exception e) { // ignore exceptions - just return false } } return switchToIM(locale, newIM); }
public void enableClientWindowNotification(InputMethod inputMethod, boolean enable) { if (enable) { notifyIM.add(inputMethod); if (client != null) { notifyClientWindowChange(IMManager.getWindow(client).getBounds()); } else { pendingClientNotify = true; } } else { notifyIM.remove(inputMethod); } }
/** * @see java.awt.im.InputContext#reconvert * @since 1.3 * @exception UnsupportedOperationException when input method is null */ public synchronized void reconvert() { InputMethod inputMethod = getInputMethod(); if (inputMethod == null) { throw new UnsupportedOperationException(); } inputMethod.reconvert(); }
/** * @see java.awt.im.InputContext#getInputMethodControlObject */ public synchronized Object getInputMethodControlObject() { InputMethod inputMethod = getInputMethod(); if (inputMethod != null) { return inputMethod.getControlObject(); } else { return null; } }
/** * @see java.awt.im.InputContext#setCompositionEnabled(boolean) * @exception UnsupportedOperationException when input method is null */ public void setCompositionEnabled(boolean enable) { InputMethod inputMethod = getInputMethod(); if (inputMethod == null) { throw new UnsupportedOperationException(); } inputMethod.setCompositionEnabled(enable); }
/** * @see java.awt.im.InputContext#isCompositionEnabled * @exception UnsupportedOperationException when input method is null */ public boolean isCompositionEnabled() { InputMethod inputMethod = getInputMethod(); if (inputMethod == null) { throw new UnsupportedOperationException(); } return inputMethod.isCompositionEnabled(); }
/** * @return a string with information about the current input method. * @exception UnsupportedOperationException when input method is null */ public String getInputMethodInfo() { InputMethod inputMethod = getInputMethod(); if (inputMethod == null) { throw new UnsupportedOperationException("Null input method"); } String inputMethodInfo = null; if (inputMethod instanceof InputMethodAdapter) { // returns the information about the host native input method. inputMethodInfo = ((InputMethodAdapter)inputMethod). getNativeInputMethodInfo(); } // extracts the information from the InputMethodDescriptor // associated with the current java input method. if (inputMethodInfo == null && inputMethodLocator != null) { inputMethodInfo = inputMethodLocator.getDescriptor(). getInputMethodDisplayName(getLocale(), SunToolkit. getStartupLocale()); } if (inputMethodInfo != null && !inputMethodInfo.equals("")) { return inputMethodInfo; } // do our best to return something useful. return inputMethod.toString() + "-" + inputMethod.getLocale().toString(); }
private synchronized InputMethod getInputMethod() { if (inputMethod != null) { return inputMethod; } if (inputMethodCreationFailed) { return null; } inputMethod = getInputMethodInstance(); return inputMethod; }
/** * @see java.awt.im.spi.InputMethodContext#enableClientWindowNotification */ synchronized void enableClientWindowNotification(InputMethod requester, boolean enable) { // in case this request is not from the current input method, // store the request and handle it when this requesting input // method becomes the current one. if (requester != inputMethod) { if (perInputMethodState == null) { perInputMethodState = new HashMap<>(5); } perInputMethodState.put(requester, Boolean.valueOf(enable)); return; } if (clientWindowNotificationEnabled != enable) { clientWindowLocation = null; clientWindowNotificationEnabled = enable; } if (clientWindowNotificationEnabled) { if (!addedClientWindowListeners()) { addClientWindowListeners(); } if (clientWindowListened != null) { clientWindowLocation = null; notifyClientWindowChange(clientWindowListened); } } else { if (addedClientWindowListeners()) { removeClientWindowListeners(); } } }