Search in sources :

Example 1 with InputMethod

use of java.awt.im.spi.InputMethod in project jdk8u_jdk by JetBrains.

the class InputContext method setCompositionEnabled.

/**
     * @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);
}
Also used : InputMethod(java.awt.im.spi.InputMethod)

Example 2 with InputMethod

use of java.awt.im.spi.InputMethod in project jdk8u_jdk by JetBrains.

the class InputContext method getInputMethodInstance.

/**
     * Returns an instance of the input method described by
     * the current input method locator. This may be an input
     * method that was previously used and switched out of,
     * or a new instance. The locale, character subsets, and
     * input method context of the input method are set.
     *
     * The inputMethodCreationFailed field is set to true if the
     * instantiation failed.
     *
     * @return an InputMethod instance
     * @see java.awt.im.spi.InputMethod#setInputMethodContext
     * @see java.awt.im.spi.InputMethod#setLocale
     * @see java.awt.im.spi.InputMethod#setCharacterSubsets
     */
private InputMethod getInputMethodInstance() {
    InputMethodLocator locator = inputMethodLocator;
    if (locator == null) {
        inputMethodCreationFailed = true;
        return null;
    }
    Locale locale = locator.getLocale();
    InputMethod inputMethodInstance = null;
    // see whether we have a previously used input method
    if (usedInputMethods != null) {
        inputMethodInstance = usedInputMethods.remove(locator.deriveLocator(null));
        if (inputMethodInstance != null) {
            if (locale != null) {
                inputMethodInstance.setLocale(locale);
            }
            inputMethodInstance.setCharacterSubsets(characterSubsets);
            Boolean state = perInputMethodState.remove(inputMethodInstance);
            if (state != null) {
                enableClientWindowNotification(inputMethodInstance, state.booleanValue());
            }
            ((InputMethodContext) this).setInputMethodSupportsBelowTheSpot((!(inputMethodInstance instanceof InputMethodAdapter)) || ((InputMethodAdapter) inputMethodInstance).supportsBelowTheSpot());
            return inputMethodInstance;
        }
    }
    // need to create new instance
    try {
        inputMethodInstance = locator.getDescriptor().createInputMethod();
        if (locale != null) {
            inputMethodInstance.setLocale(locale);
        }
        inputMethodInstance.setInputMethodContext((InputMethodContext) this);
        inputMethodInstance.setCharacterSubsets(characterSubsets);
    } catch (Exception e) {
        logCreationFailed(e);
        // there are a number of bad things that can happen while creating
        // the input method. In any case, we just continue without an
        // input method.
        inputMethodCreationFailed = true;
        // setLocale() or setInputMethodContext() failed.
        if (inputMethodInstance != null) {
            inputMethodInstance = null;
        }
    } catch (LinkageError e) {
        logCreationFailed(e);
        // same as above
        inputMethodCreationFailed = true;
    }
    ((InputMethodContext) this).setInputMethodSupportsBelowTheSpot((!(inputMethodInstance instanceof InputMethodAdapter)) || ((InputMethodAdapter) inputMethodInstance).supportsBelowTheSpot());
    return inputMethodInstance;
}
Also used : Locale(java.util.Locale) InputMethod(java.awt.im.spi.InputMethod) BackingStoreException(java.util.prefs.BackingStoreException)

Example 3 with InputMethod

use of java.awt.im.spi.InputMethod in project jdk8u_jdk by JetBrains.

the class InputContext method reconvert.

/**
     * @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();
}
Also used : InputMethod(java.awt.im.spi.InputMethod)

Example 4 with InputMethod

use of java.awt.im.spi.InputMethod in project jdk8u_jdk by JetBrains.

the class InputContext method dispatchEvent.

/**
     * @see java.awt.im.InputContext#dispatchEvent
     */
@SuppressWarnings("fallthrough")
public void dispatchEvent(AWTEvent event) {
    if (event instanceof InputMethodEvent) {
        return;
    }
    // This is a workaround.  Should be removed after 4452384 is fixed.
    if (event instanceof FocusEvent) {
        Component opposite = ((FocusEvent) event).getOppositeComponent();
        if ((opposite != null) && (getComponentWindow(opposite) instanceof InputMethodWindow) && (opposite.getInputContext() == this)) {
            return;
        }
    }
    InputMethod inputMethod = getInputMethod();
    int id = event.getID();
    switch(id) {
        case FocusEvent.FOCUS_GAINED:
            focusGained((Component) event.getSource());
            break;
        case FocusEvent.FOCUS_LOST:
            focusLost((Component) event.getSource(), ((FocusEvent) event).isTemporary());
            break;
        case KeyEvent.KEY_PRESSED:
            if (checkInputMethodSelectionKey((KeyEvent) event)) {
                // pop up the input method selection menu
                InputMethodManager.getInstance().notifyChangeRequestByHotKey((Component) event.getSource());
                break;
            }
        default:
            if ((inputMethod != null) && (event instanceof InputEvent)) {
                inputMethod.dispatchEvent(event);
            }
    }
}
Also used : InputMethod(java.awt.im.spi.InputMethod) InputMethodEvent(java.awt.event.InputMethodEvent) InputEvent(java.awt.event.InputEvent) Component(java.awt.Component) FocusEvent(java.awt.event.FocusEvent)

Example 5 with InputMethod

use of java.awt.im.spi.InputMethod in project jdk8u_jdk by JetBrains.

the class InputContext method getInputMethodInfo.

/**
     * @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();
    }
    // 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();
}
Also used : InputMethod(java.awt.im.spi.InputMethod)

Aggregations

InputMethod (java.awt.im.spi.InputMethod)5 Component (java.awt.Component)1 FocusEvent (java.awt.event.FocusEvent)1 InputEvent (java.awt.event.InputEvent)1 InputMethodEvent (java.awt.event.InputMethodEvent)1 Locale (java.util.Locale)1 BackingStoreException (java.util.prefs.BackingStoreException)1