java.awt.im.spi.InputMethodDescriptor Java Examples

The following examples show how to use java.awt.im.spi.InputMethodDescriptor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExecutableInputMethodManager.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
ExecutableInputMethodManager() {

        // set up host adapter locator
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        try {
            if (toolkit instanceof InputMethodSupport) {
                InputMethodDescriptor hostAdapterDescriptor =
                    ((InputMethodSupport)toolkit)
                    .getInputMethodAdapterDescriptor();
                if (hostAdapterDescriptor != null) {
                    hostAdapterLocator = new InputMethodLocator(hostAdapterDescriptor, null, null);
                }
            }
        } catch (AWTException e) {
            // if we can't get a descriptor, we'll just have to do without native input methods
        }

        javaInputMethodLocatorList = new Vector<InputMethodLocator>();
        initializeInputMethodLocatorList();
    }
 
Example #2
Source File: ExecutableInputMethodManager.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
ExecutableInputMethodManager() {

        // set up host adapter locator
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        try {
            if (toolkit instanceof InputMethodSupport) {
                InputMethodDescriptor hostAdapterDescriptor =
                    ((InputMethodSupport)toolkit)
                    .getInputMethodAdapterDescriptor();
                if (hostAdapterDescriptor != null) {
                    hostAdapterLocator = new InputMethodLocator(hostAdapterDescriptor, null, null);
                }
            }
        } catch (AWTException e) {
            // if we can't get a descriptor, we'll just have to do without native input methods
        }

        javaInputMethodLocatorList = new Vector<InputMethodLocator>();
        initializeInputMethodLocatorList();
    }
 
Example #3
Source File: ExecutableInputMethodManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
ExecutableInputMethodManager() {

        // set up host adapter locator
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        try {
            if (toolkit instanceof InputMethodSupport) {
                InputMethodDescriptor hostAdapterDescriptor =
                    ((InputMethodSupport)toolkit)
                    .getInputMethodAdapterDescriptor();
                if (hostAdapterDescriptor != null) {
                    hostAdapterLocator = new InputMethodLocator(hostAdapterDescriptor, null, null);
                }
            }
        } catch (AWTException e) {
            // if we can't get a descriptor, we'll just have to do without native input methods
        }

        javaInputMethodLocatorList = new Vector<InputMethodLocator>();
        initializeInputMethodLocatorList();
    }
 
Example #4
Source File: ExecutableInputMethodManager.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
ExecutableInputMethodManager() {

        // set up host adapter locator
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        try {
            if (toolkit instanceof InputMethodSupport) {
                InputMethodDescriptor hostAdapterDescriptor =
                    ((InputMethodSupport)toolkit)
                    .getInputMethodAdapterDescriptor();
                if (hostAdapterDescriptor != null) {
                    hostAdapterLocator = new InputMethodLocator(hostAdapterDescriptor, null, null);
                }
            }
        } catch (AWTException e) {
            // if we can't get a descriptor, we'll just have to do without native input methods
        }

        javaInputMethodLocatorList = new Vector<InputMethodLocator>();
        initializeInputMethodLocatorList();
    }
 
Example #5
Source File: ExecutableInputMethodManager.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void initializeInputMethodLocatorList() {
    synchronized (javaInputMethodLocatorList) {
        javaInputMethodLocatorList.clear();
        try {
            AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                public Object run() {
                    for (InputMethodDescriptor descriptor :
                        ServiceLoader.loadInstalled(InputMethodDescriptor.class)) {
                        ClassLoader cl = descriptor.getClass().getClassLoader();
                        javaInputMethodLocatorList.add(new InputMethodLocator(descriptor, cl, null));
                    }
                    return null;
                }
            });
        }  catch (PrivilegedActionException e) {
            e.printStackTrace();
        }
        javaInputMethodCount = javaInputMethodLocatorList.size();
    }

    if (hasMultipleInputMethods()) {
        // initialize preferences
        if (userRoot == null) {
            userRoot = getUserRoot();
        }
    } else {
        // indicate to clients not to offer the menu
        triggerMenuString = null;
    }
}
 
Example #6
Source File: ExecutableInputMethodManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void initializeInputMethodLocatorList() {
    synchronized (javaInputMethodLocatorList) {
        javaInputMethodLocatorList.clear();
        try {
            AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                public Object run() {
                    for (InputMethodDescriptor descriptor :
                        ServiceLoader.loadInstalled(InputMethodDescriptor.class)) {
                        ClassLoader cl = descriptor.getClass().getClassLoader();
                        javaInputMethodLocatorList.add(new InputMethodLocator(descriptor, cl, null));
                    }
                    return null;
                }
            });
        }  catch (PrivilegedActionException e) {
            e.printStackTrace();
        }
        javaInputMethodCount = javaInputMethodLocatorList.size();
    }

    if (hasMultipleInputMethods()) {
        // initialize preferences
        if (userRoot == null) {
            userRoot = getUserRoot();
        }
    } else {
        // indicate to clients not to offer the menu
        triggerMenuString = null;
    }
}
 
Example #7
Source File: InputMethodLocator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
InputMethodLocator(InputMethodDescriptor descriptor, ClassLoader loader, Locale locale) {
    if (descriptor == null) {
        throw new NullPointerException("descriptor can't be null");
    }
    this.descriptor = descriptor;
    this.loader = loader;
    this.locale = locale;
}
 
Example #8
Source File: InputMethodLocator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
InputMethodLocator(InputMethodDescriptor descriptor, ClassLoader loader, Locale locale) {
    if (descriptor == null) {
        throw new NullPointerException("descriptor can't be null");
    }
    this.descriptor = descriptor;
    this.loader = loader;
    this.locale = locale;
}
 
Example #9
Source File: InputMethodLocator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
InputMethodLocator(InputMethodDescriptor descriptor, ClassLoader loader, Locale locale) {
    if (descriptor == null) {
        throw new NullPointerException("descriptor can't be null");
    }
    this.descriptor = descriptor;
    this.loader = loader;
    this.locale = locale;
}
 
Example #10
Source File: ExecutableInputMethodManager.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void initializeInputMethodLocatorList() {
    synchronized (javaInputMethodLocatorList) {
        javaInputMethodLocatorList.clear();
        try {
            AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                public Object run() {
                    for (InputMethodDescriptor descriptor :
                        ServiceLoader.loadInstalled(InputMethodDescriptor.class)) {
                        ClassLoader cl = descriptor.getClass().getClassLoader();
                        javaInputMethodLocatorList.add(new InputMethodLocator(descriptor, cl, null));
                    }
                    return null;
                }
            });
        }  catch (PrivilegedActionException e) {
            e.printStackTrace();
        }
        javaInputMethodCount = javaInputMethodLocatorList.size();
    }

    if (hasMultipleInputMethods()) {
        // initialize preferences
        if (userRoot == null) {
            userRoot = getUserRoot();
        }
    } else {
        // indicate to clients not to offer the menu
        triggerMenuString = null;
    }
}
 
Example #11
Source File: ExecutableInputMethodManager.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void initializeInputMethodLocatorList() {
    synchronized (javaInputMethodLocatorList) {
        javaInputMethodLocatorList.clear();
        try {
            AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                public Object run() {
                    for (InputMethodDescriptor descriptor :
                        ServiceLoader.loadInstalled(InputMethodDescriptor.class)) {
                        ClassLoader cl = descriptor.getClass().getClassLoader();
                        javaInputMethodLocatorList.add(new InputMethodLocator(descriptor, cl, null));
                    }
                    return null;
                }
            });
        }  catch (PrivilegedActionException e) {
            e.printStackTrace();
        }
        javaInputMethodCount = javaInputMethodLocatorList.size();
    }

    if (hasMultipleInputMethods()) {
        // initialize preferences
        if (userRoot == null) {
            userRoot = getUserRoot();
        }
    } else {
        // indicate to clients not to offer the menu
        triggerMenuString = null;
    }
}
 
Example #12
Source File: InputMethodLocator.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
InputMethodLocator(InputMethodDescriptor descriptor, ClassLoader loader, Locale locale) {
    if (descriptor == null) {
        throw new NullPointerException("descriptor can't be null");
    }
    this.descriptor = descriptor;
    this.loader = loader;
    this.locale = locale;
}
 
Example #13
Source File: ExecutableInputMethodManager.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void initializeInputMethodLocatorList() {
    synchronized (javaInputMethodLocatorList) {
        javaInputMethodLocatorList.clear();
        try {
            AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                public Object run() {
                    for (InputMethodDescriptor descriptor :
                        ServiceLoader.loadInstalled(InputMethodDescriptor.class)) {
                        ClassLoader cl = descriptor.getClass().getClassLoader();
                        javaInputMethodLocatorList.add(new InputMethodLocator(descriptor, cl, null));
                    }
                    return null;
                }
            });
        }  catch (PrivilegedActionException e) {
            e.printStackTrace();
        }
        javaInputMethodCount = javaInputMethodLocatorList.size();
    }

    if (hasMultipleInputMethods()) {
        // initialize preferences
        if (userRoot == null) {
            userRoot = getUserRoot();
        }
    } else {
        // indicate to clients not to offer the menu
        triggerMenuString = null;
    }
}
 
Example #14
Source File: InputMethodLocator.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
InputMethodLocator(InputMethodDescriptor descriptor, ClassLoader loader, Locale locale) {
    if (descriptor == null) {
        throw new NullPointerException("descriptor can't be null");
    }
    this.descriptor = descriptor;
    this.loader = loader;
    this.locale = locale;
}
 
Example #15
Source File: InputMethodLocator.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
InputMethodLocator(InputMethodDescriptor descriptor, ClassLoader loader, Locale locale) {
    if (descriptor == null) {
        throw new NullPointerException("descriptor can't be null");
    }
    this.descriptor = descriptor;
    this.loader = loader;
    this.locale = locale;
}
 
Example #16
Source File: InputMethodPopupMenu.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
void addOneInputMethodToMenu(InputMethodLocator locator, String currentSelection) {
    InputMethodDescriptor descriptor = locator.getDescriptor();
    String label = descriptor.getInputMethodDisplayName(null, Locale.getDefault());
    String command = locator.getActionCommandString();
    Locale[] locales = null;
    int localeCount;
    try {
        locales = descriptor.getAvailableLocales();
        localeCount = locales.length;
    } catch (AWTException e) {
        // ??? should have better error handling -
        // tell user what happened, then remove this input method from the list.
        // For the time being, just show it disabled.
        localeCount = 0;
    }
    if (localeCount == 0) {
        // could be IIIMP adapter which has lost its connection
        addMenuItem(label, null, currentSelection);
    } else if (localeCount == 1) {
        if (descriptor.hasDynamicLocaleList()) {
            // try to make sure that what the user sees and what
            // we eventually select is consistent even if the locale
            // list changes in the meantime
            label = descriptor.getInputMethodDisplayName(locales[0], Locale.getDefault());
            command = locator.deriveLocator(locales[0]).getActionCommandString();
        }
        addMenuItem(label, command, currentSelection);
    } else {
        Object submenu = createSubmenu(label);
        add(submenu);
        for (int j = 0; j < localeCount; j++) {
            Locale locale = locales[j];
            String subLabel = getLocaleName(locale);
            String subCommand = locator.deriveLocator(locale).getActionCommandString();
            addMenuItem(submenu, subLabel, subCommand, currentSelection);
        }
    }
}
 
Example #17
Source File: LWCToolkit.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public InputMethodDescriptor getInputMethodAdapterDescriptor() {
    if (sInputMethodDescriptor == null)
        sInputMethodDescriptor = new CInputMethodDescriptor();

    return sInputMethodDescriptor;
}
 
Example #18
Source File: ExecutableInputMethodManager.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void initializeInputMethodLocatorList() {
    synchronized (javaInputMethodLocatorList) {
        javaInputMethodLocatorList.clear();
        try {
            AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                public Object run() {
                    for (InputMethodDescriptor descriptor :
                        ServiceLoader.load(InputMethodDescriptor.class,
                                           ClassLoader.getSystemClassLoader())) {
                        ClassLoader cl = descriptor.getClass().getClassLoader();
                        javaInputMethodLocatorList.add(new InputMethodLocator(descriptor, cl, null));
                    }
                    return null;
                }
            });
        }  catch (PrivilegedActionException e) {
            e.printStackTrace();
        }
        javaInputMethodCount = javaInputMethodLocatorList.size();
    }

    if (hasMultipleInputMethods()) {
        // initialize preferences
        if (userRoot == null) {
            userRoot = getUserRoot();
        }
    } else {
        // indicate to clients not to offer the menu
        triggerMenuString = null;
    }
}
 
Example #19
Source File: InputMethodPopupMenu.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
void addOneInputMethodToMenu(InputMethodLocator locator, String currentSelection) {
    InputMethodDescriptor descriptor = locator.getDescriptor();
    String label = descriptor.getInputMethodDisplayName(null, Locale.getDefault());
    String command = locator.getActionCommandString();
    Locale[] locales = null;
    int localeCount;
    try {
        locales = descriptor.getAvailableLocales();
        localeCount = locales.length;
    } catch (AWTException e) {
        // ??? should have better error handling -
        // tell user what happened, then remove this input method from the list.
        // For the time being, just show it disabled.
        localeCount = 0;
    }
    if (localeCount == 0) {
        // could be IIIMP adapter which has lost its connection
        addMenuItem(label, null, currentSelection);
    } else if (localeCount == 1) {
        if (descriptor.hasDynamicLocaleList()) {
            // try to make sure that what the user sees and what
            // we eventually select is consistent even if the locale
            // list changes in the meantime
            label = descriptor.getInputMethodDisplayName(locales[0], Locale.getDefault());
            command = locator.deriveLocator(locales[0]).getActionCommandString();
        }
        addMenuItem(label, command, currentSelection);
    } else {
        Object submenu = createSubmenu(label);
        add(submenu);
        for (int j = 0; j < localeCount; j++) {
            Locale locale = locales[j];
            String subLabel = getLocaleName(locale);
            String subCommand = locator.deriveLocator(locale).getActionCommandString();
            addMenuItem(submenu, subLabel, subCommand, currentSelection);
        }
    }
}
 
Example #20
Source File: ExecutableInputMethodManager.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void initializeInputMethodLocatorList() {
    synchronized (javaInputMethodLocatorList) {
        javaInputMethodLocatorList.clear();
        try {
            AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                public Object run() {
                    for (InputMethodDescriptor descriptor :
                        ServiceLoader.loadInstalled(InputMethodDescriptor.class)) {
                        ClassLoader cl = descriptor.getClass().getClassLoader();
                        javaInputMethodLocatorList.add(new InputMethodLocator(descriptor, cl, null));
                    }
                    return null;
                }
            });
        }  catch (PrivilegedActionException e) {
            e.printStackTrace();
        }
        javaInputMethodCount = javaInputMethodLocatorList.size();
    }

    if (hasMultipleInputMethods()) {
        // initialize preferences
        if (userRoot == null) {
            userRoot = getUserRoot();
        }
    } else {
        // indicate to clients not to offer the menu
        triggerMenuString = null;
    }
}
 
Example #21
Source File: InputMethodPopupMenu.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
void addOneInputMethodToMenu(InputMethodLocator locator, String currentSelection) {
    InputMethodDescriptor descriptor = locator.getDescriptor();
    String label = descriptor.getInputMethodDisplayName(null, Locale.getDefault());
    String command = locator.getActionCommandString();
    Locale[] locales = null;
    int localeCount;
    try {
        locales = descriptor.getAvailableLocales();
        localeCount = locales.length;
    } catch (AWTException e) {
        // ??? should have better error handling -
        // tell user what happened, then remove this input method from the list.
        // For the time being, just show it disabled.
        localeCount = 0;
    }
    if (localeCount == 0) {
        // could be IIIMP adapter which has lost its connection
        addMenuItem(label, null, currentSelection);
    } else if (localeCount == 1) {
        if (descriptor.hasDynamicLocaleList()) {
            // try to make sure that what the user sees and what
            // we eventually select is consistent even if the locale
            // list changes in the meantime
            label = descriptor.getInputMethodDisplayName(locales[0], Locale.getDefault());
            command = locator.deriveLocator(locales[0]).getActionCommandString();
        }
        addMenuItem(label, command, currentSelection);
    } else {
        Object submenu = createSubmenu(label);
        add(submenu);
        for (int j = 0; j < localeCount; j++) {
            Locale locale = locales[j];
            String subLabel = getLocaleName(locale);
            String subCommand = locator.deriveLocator(locale).getActionCommandString();
            addMenuItem(submenu, subLabel, subCommand, currentSelection);
        }
    }
}
 
Example #22
Source File: InputMethodPopupMenu.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
void addOneInputMethodToMenu(InputMethodLocator locator, String currentSelection) {
    InputMethodDescriptor descriptor = locator.getDescriptor();
    String label = descriptor.getInputMethodDisplayName(null, Locale.getDefault());
    String command = locator.getActionCommandString();
    Locale[] locales = null;
    int localeCount;
    try {
        locales = descriptor.getAvailableLocales();
        localeCount = locales.length;
    } catch (AWTException e) {
        // ??? should have better error handling -
        // tell user what happened, then remove this input method from the list.
        // For the time being, just show it disabled.
        localeCount = 0;
    }
    if (localeCount == 0) {
        // could be IIIMP adapter which has lost its connection
        addMenuItem(label, null, currentSelection);
    } else if (localeCount == 1) {
        if (descriptor.hasDynamicLocaleList()) {
            // try to make sure that what the user sees and what
            // we eventually select is consistent even if the locale
            // list changes in the meantime
            label = descriptor.getInputMethodDisplayName(locales[0], Locale.getDefault());
            command = locator.deriveLocator(locales[0]).getActionCommandString();
        }
        addMenuItem(label, command, currentSelection);
    } else {
        Object submenu = createSubmenu(label);
        add(submenu);
        for (int j = 0; j < localeCount; j++) {
            Locale locale = locales[j];
            String subLabel = getLocaleName(locale);
            String subCommand = locator.deriveLocator(locale).getActionCommandString();
            addMenuItem(submenu, subLabel, subCommand, currentSelection);
        }
    }
}
 
Example #23
Source File: LWCToolkit.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public InputMethodDescriptor getInputMethodAdapterDescriptor() {
    if (sInputMethodDescriptor == null)
        sInputMethodDescriptor = new CInputMethodDescriptor();

    return sInputMethodDescriptor;
}
 
Example #24
Source File: InputMethodPopupMenu.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
void addOneInputMethodToMenu(InputMethodLocator locator, String currentSelection) {
    InputMethodDescriptor descriptor = locator.getDescriptor();
    String label = descriptor.getInputMethodDisplayName(null, Locale.getDefault());
    String command = locator.getActionCommandString();
    Locale[] locales = null;
    int localeCount;
    try {
        locales = descriptor.getAvailableLocales();
        localeCount = locales.length;
    } catch (AWTException e) {
        // ??? should have better error handling -
        // tell user what happened, then remove this input method from the list.
        // For the time being, just show it disabled.
        localeCount = 0;
    }
    if (localeCount == 0) {
        // could be IIIMP adapter which has lost its connection
        addMenuItem(label, null, currentSelection);
    } else if (localeCount == 1) {
        if (descriptor.hasDynamicLocaleList()) {
            // try to make sure that what the user sees and what
            // we eventually select is consistent even if the locale
            // list changes in the meantime
            label = descriptor.getInputMethodDisplayName(locales[0], Locale.getDefault());
            command = locator.deriveLocator(locales[0]).getActionCommandString();
        }
        addMenuItem(label, command, currentSelection);
    } else {
        Object submenu = createSubmenu(label);
        add(submenu);
        for (int j = 0; j < localeCount; j++) {
            Locale locale = locales[j];
            String subLabel = getLocaleName(locale);
            String subCommand = locator.deriveLocator(locale).getActionCommandString();
            addMenuItem(submenu, subLabel, subCommand, currentSelection);
        }
    }
}
 
Example #25
Source File: InputMethodPopupMenu.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
void addOneInputMethodToMenu(InputMethodLocator locator, String currentSelection) {
    InputMethodDescriptor descriptor = locator.getDescriptor();
    String label = descriptor.getInputMethodDisplayName(null, Locale.getDefault());
    String command = locator.getActionCommandString();
    Locale[] locales = null;
    int localeCount;
    try {
        locales = descriptor.getAvailableLocales();
        localeCount = locales.length;
    } catch (AWTException e) {
        // ??? should have better error handling -
        // tell user what happened, then remove this input method from the list.
        // For the time being, just show it disabled.
        localeCount = 0;
    }
    if (localeCount == 0) {
        // could be IIIMP adapter which has lost its connection
        addMenuItem(label, null, currentSelection);
    } else if (localeCount == 1) {
        if (descriptor.hasDynamicLocaleList()) {
            // try to make sure that what the user sees and what
            // we eventually select is consistent even if the locale
            // list changes in the meantime
            label = descriptor.getInputMethodDisplayName(locales[0], Locale.getDefault());
            command = locator.deriveLocator(locales[0]).getActionCommandString();
        }
        addMenuItem(label, command, currentSelection);
    } else {
        Object submenu = createSubmenu(label);
        add(submenu);
        for (int j = 0; j < localeCount; j++) {
            Locale locale = locales[j];
            String subLabel = getLocaleName(locale);
            String subCommand = locator.deriveLocator(locale).getActionCommandString();
            addMenuItem(submenu, subLabel, subCommand, currentSelection);
        }
    }
}
 
Example #26
Source File: LWCToolkit.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public InputMethodDescriptor getInputMethodAdapterDescriptor() {
    if (sInputMethodDescriptor == null)
        sInputMethodDescriptor = new CInputMethodDescriptor();

    return sInputMethodDescriptor;
}
 
Example #27
Source File: ExecutableInputMethodManager.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void initializeInputMethodLocatorList() {
    synchronized (javaInputMethodLocatorList) {
        javaInputMethodLocatorList.clear();
        try {
            AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                public Object run() {
                    for (InputMethodDescriptor descriptor :
                        ServiceLoader.loadInstalled(InputMethodDescriptor.class)) {
                        ClassLoader cl = descriptor.getClass().getClassLoader();
                        javaInputMethodLocatorList.add(new InputMethodLocator(descriptor, cl, null));
                    }
                    return null;
                }
            });
        }  catch (PrivilegedActionException e) {
            e.printStackTrace();
        }
        javaInputMethodCount = javaInputMethodLocatorList.size();
    }

    if (hasMultipleInputMethods()) {
        // initialize preferences
        if (userRoot == null) {
            userRoot = getUserRoot();
        }
    } else {
        // indicate to clients not to offer the menu
        triggerMenuString = null;
    }
}
 
Example #28
Source File: InputMethodLocator.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
InputMethodLocator(InputMethodDescriptor descriptor, ClassLoader loader, Locale locale) {
    if (descriptor == null) {
        throw new NullPointerException("descriptor can't be null");
    }
    this.descriptor = descriptor;
    this.loader = loader;
    this.locale = locale;
}
 
Example #29
Source File: ExecutableInputMethodManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns a InputMethodLocator object that the
 * user prefers for the given locale.
 *
 * @param locale Locale for which the user prefers the input method.
 */
private synchronized InputMethodLocator getPreferredInputMethod(Locale locale) {
    InputMethodLocator preferredLocator = null;

    if (!hasMultipleInputMethods()) {
        // No need to look for a preferred Java input method
        return null;
    }

    // look for the cached preference first.
    preferredLocator = preferredLocatorCache.get(locale.toString().intern());
    if (preferredLocator != null) {
        return preferredLocator;
    }

    // look for the preference in the user preference tree
    String nodePath = findPreferredInputMethodNode(locale);
    String descriptorName = readPreferredInputMethod(nodePath);
    Locale advertised;

    // get the locator object
    if (descriptorName != null) {
        // check for the host adapter first
        if (hostAdapterLocator != null &&
            hostAdapterLocator.getDescriptor().getClass().getName().equals(descriptorName)) {
            advertised = getAdvertisedLocale(hostAdapterLocator, locale);
            if (advertised != null) {
                preferredLocator = hostAdapterLocator.deriveLocator(advertised);
                preferredLocatorCache.put(locale.toString().intern(), preferredLocator);
            }
            return preferredLocator;
        }
        // look for Java input methods
        for (int i = 0; i < javaInputMethodLocatorList.size(); i++) {
            InputMethodLocator locator = javaInputMethodLocatorList.get(i);
            InputMethodDescriptor descriptor = locator.getDescriptor();
            if (descriptor.getClass().getName().equals(descriptorName)) {
                advertised = getAdvertisedLocale(locator, locale);
                if (advertised != null) {
                    preferredLocator = locator.deriveLocator(advertised);
                    preferredLocatorCache.put(locale.toString().intern(), preferredLocator);
                }
                return preferredLocator;
            }
        }

        // maybe preferred input method information is bogus.
        writePreferredInputMethod(nodePath, null);
    }

    return null;
}
 
Example #30
Source File: HToolkit.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public InputMethodDescriptor getInputMethodAdapterDescriptor()
    throws AWTException
{
    return (InputMethodDescriptor)null;
}