1 /* 2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 27 package sun.awt.windows; 28 29 import java.awt.Image; 30 import java.awt.Toolkit; 31 import java.awt.im.spi.InputMethod; 32 import java.awt.im.spi.InputMethodDescriptor; 33 import java.util.Locale; 34 35 /** 36 * Provides sufficient information about an input method 37 * to enable selection and loading of that input method. 38 * The input method itself is only loaded when it is actually used. 39 * 40 * @since 1.3 41 */ 42 43 final class WInputMethodDescriptor implements InputMethodDescriptor { 44 45 /** 46 * @see java.awt.im.spi.InputMethodDescriptor#getAvailableLocales 47 */ 48 @Override 49 public Locale[] getAvailableLocales() { 50 // returns a copy of internal list for public API 51 Locale[] locales = getAvailableLocalesInternal(); 52 Locale[] tmp = new Locale[locales.length]; 53 System.arraycopy(locales, 0, tmp, 0, locales.length); 54 return tmp; 55 } 56 57 static Locale[] getAvailableLocalesInternal() { 58 return getNativeAvailableLocales(); 59 } 60 61 /** 62 * @see java.awt.im.spi.InputMethodDescriptor#hasDynamicLocaleList 63 */ 64 @Override 65 public boolean hasDynamicLocaleList() { 66 return true; 67 } 68 69 /** 70 * @see java.awt.im.spi.InputMethodDescriptor#getInputMethodDisplayName 71 */ 72 @Override 73 public synchronized String getInputMethodDisplayName(Locale inputLocale, Locale displayLanguage) { 74 // We ignore the input locale. 75 // When displaying for the default locale, rely on the localized AWT properties; 76 // for any other locale, fall back to English. 77 String name = "System Input Methods"; 78 if (Locale.getDefault().equals(displayLanguage)) { 79 name = Toolkit.getProperty("AWT.HostInputMethodDisplayName", name); 80 } 81 return name; 82 } 83 84 /** 85 * @see java.awt.im.spi.InputMethodDescriptor#getInputMethodIcon 86 */ 87 @Override 88 public Image getInputMethodIcon(Locale inputLocale) { 89 return null; 90 } 91 92 /** 93 * @see java.awt.im.spi.InputMethodDescriptor#createInputMethod 94 */ 95 @Override 96 public InputMethod createInputMethod() throws Exception { 97 return new WInputMethod(); 98 } 99 100 private static native Locale[] getNativeAvailableLocales(); 101 }