1 /* 2 * Copyright (c) 1998, 2003, 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; 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.security.AccessController; 34 import java.util.Locale; 35 import sun.awt.SunToolkit; 36 import sun.security.action.GetPropertyAction; 37 38 /** 39 * Provides sufficient information about an input method 40 * to enable selection and loading of that input method. 41 * The input method itself is only loaded when it is actually used. 42 * 43 * @since JDK1.3 44 */ 45 46 public abstract class X11InputMethodDescriptor implements InputMethodDescriptor { 47 48 private static Locale locale; 49 X11InputMethodDescriptor()50 public X11InputMethodDescriptor() { 51 locale = getSupportedLocale(); 52 } 53 54 /** 55 * @see java.awt.im.spi.InputMethodDescriptor#getAvailableLocales 56 */ getAvailableLocales()57 public Locale[] getAvailableLocales() { 58 Locale[] locales = {locale}; 59 return locales; 60 } 61 62 /** 63 * @see java.awt.im.spi.InputMethodDescriptor#hasDynamicLocaleList 64 */ hasDynamicLocaleList()65 public boolean hasDynamicLocaleList() { 66 return false; 67 } 68 69 /** 70 * @see java.awt.im.spi.InputMethodDescriptor#getInputMethodDisplayName 71 */ getInputMethodDisplayName(Locale inputLocale, Locale displayLanguage)72 public synchronized String getInputMethodDisplayName(Locale inputLocale, Locale displayLanguage) { 73 // We ignore the input locale. 74 // When displaying for the default locale, rely on the localized AWT properties; 75 // for any other locale, fall back to English. 76 String name = "System Input Methods"; 77 if (Locale.getDefault().equals(displayLanguage)) { 78 name = Toolkit.getProperty("AWT.HostInputMethodDisplayName", name); 79 } 80 return name; 81 } 82 83 /** 84 * @see java.awt.im.spi.InputMethodDescriptor#getInputMethodIcon 85 */ getInputMethodIcon(Locale inputLocale)86 public Image getInputMethodIcon(Locale inputLocale) { 87 return null; 88 } 89 90 /** 91 * @see java.awt.im.spi.InputMethodDescriptor#createInputMethod 92 */ createInputMethod()93 public abstract InputMethod createInputMethod() throws Exception; 94 95 /** 96 * returns supported locale. Currently this method returns the locale in which 97 * the VM is started since Solaris doesn't provide a way to determine the login locale. 98 */ getSupportedLocale()99 static Locale getSupportedLocale() { 100 return SunToolkit.getStartupLocale(); 101 } 102 } 103