Package java.awt.im.spi

Examples of java.awt.im.spi.InputMethodDescriptor


                if (!(item instanceof IMSubmenu)) {
                    // skip all non-menu elements, such as separators
                    continue;
                }
                IMSubmenu subMenu = (IMSubmenu) item;
                InputMethodDescriptor desc = subMenu.getDesc();
                if (desc == null) {
                    continue;
                }
                if (desc.hasDynamicLocaleList()) {                   
                    subMenu.removeAll();
                    subMenu.addLocales();
                }
                subMenu.checkItems();
                i++;
View Full Code Here


    abstract void addMenuItem(Object targetMenu, String label, String command,
                              String currentSelection);

    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);
View Full Code Here

        // 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);
                }
View Full Code Here

                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);
                    }
View Full Code Here

     * the user's Preferences tree in accordance with the given locale.
     *
     * @param inputMethodLocator input method locator to remember.
     */
    private synchronized void putPreferredInputMethod(InputMethodLocator locator) {
        InputMethodDescriptor descriptor = locator.getDescriptor();
        Locale preferredLocale = locator.getLocale();

        if (preferredLocale == null) {
            // check available locales of the input method
            try {
                Locale[] availableLocales = descriptor.getAvailableLocales();
                if (availableLocales.length == 1) {
                    preferredLocale = availableLocales[0];
                } else {
                    // there is no way to know which locale is the preferred one, so do nothing.
                    return;
                }
            } catch (AWTException ae) {
                // do nothing here, either.
                return;
            }
        }

        // for regions that have only one language, we need to regard
        // "xx_YY" as "xx" when putting the preference into tree
        if (preferredLocale.equals(Locale.JAPAN)) {
            preferredLocale = Locale.JAPANESE;
        }
        if (preferredLocale.equals(Locale.KOREA)) {
            preferredLocale = Locale.KOREAN;
        }
        if (preferredLocale.equals(new Locale("th", "TH"))) {
            preferredLocale = new Locale("th");
        }

        // obtain node
        String path = preferredIMNode + "/" + createLocalePath(preferredLocale);

        // write in the preference tree
        writePreferredInputMethod(path, descriptor.getClass().getName());
        preferredLocatorCache.put(preferredLocale.toString().intern(),
            locator.deriveLocator(preferredLocale));

        return;
    }
View Full Code Here

     * @throws Exception
     */
    private InputMethod getIMInstance(Iterator<InputMethodDescriptor> descriptors,
                                      Locale locale) throws Exception {
        while (descriptors.hasNext()) {
            InputMethodDescriptor desc = descriptors.next();
            Locale[] locs = desc.getAvailableLocales();
            for (Locale element : locs) {
                if (locale.equals(element)) {
                    return getIMInstance(desc);
                }
            }
View Full Code Here

                addIM(it);
            }
        }

        private void addIM(Iterator<InputMethodDescriptor> it) {
            InputMethodDescriptor desc = it.next();
            IMSubmenu subMenu = new IMSubmenu(desc);
            add(subMenu);
        }
View Full Code Here

                if (!(item instanceof IMSubmenu)) {
                    // skip all non-menu elements, such as separators
                    continue;
                }
                IMSubmenu subMenu = (IMSubmenu) item;
                InputMethodDescriptor desc = subMenu.getDesc();
                if (desc == null) {
                    continue;
                }
                if (desc.hasDynamicLocaleList()) {                   
                    subMenu.removeAll();
                    subMenu.addLocales();
                }
                subMenu.checkItems();
                i++;
View Full Code Here

     * @throws Exception
     */
    private InputMethod getIMInstance(Iterator<InputMethodDescriptor> descriptors,
                                      Locale locale) throws Exception {
        while (descriptors.hasNext()) {
            InputMethodDescriptor desc = descriptors.next();
            Locale[] locs = desc.getAvailableLocales();
            for (Locale element : locs) {
                if (locale.equals(element)) {
                    return getIMInstance(desc);
                }
            }
View Full Code Here

                addIM(it);
            }
        }

        private void addIM(Iterator<InputMethodDescriptor> it) {
            InputMethodDescriptor desc = it.next();
            IMSubmenu subMenu = new IMSubmenu(desc);
            add(subMenu);
        }
View Full Code Here

TOP

Related Classes of java.awt.im.spi.InputMethodDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.