001: /*
002: * Copyright 1998-2003 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package sun.awt;
027:
028: import java.awt.Image;
029: import java.awt.Toolkit;
030: import java.awt.im.spi.InputMethod;
031: import java.awt.im.spi.InputMethodDescriptor;
032: import java.security.AccessController;
033: import java.util.Locale;
034: import sun.awt.SunToolkit;
035: import sun.security.action.GetPropertyAction;
036:
037: /**
038: * Provides sufficient information about an input method
039: * to enable selection and loading of that input method.
040: * The input method itself is only loaded when it is actually used.
041: *
042: * @since JDK1.3
043: */
044:
045: public abstract class X11InputMethodDescriptor implements
046: InputMethodDescriptor {
047:
048: private static Locale locale;
049:
050: public X11InputMethodDescriptor() {
051: locale = getSupportedLocale();
052: }
053:
054: /**
055: * @see java.awt.im.spi.InputMethodDescriptor#getAvailableLocales
056: */
057: public Locale[] getAvailableLocales() {
058: Locale[] locales = { locale };
059: return locales;
060: }
061:
062: /**
063: * @see java.awt.im.spi.InputMethodDescriptor#hasDynamicLocaleList
064: */
065: public boolean hasDynamicLocaleList() {
066: return false;
067: }
068:
069: /**
070: * @see java.awt.im.spi.InputMethodDescriptor#getInputMethodDisplayName
071: */
072: public synchronized String getInputMethodDisplayName(
073: Locale inputLocale, Locale displayLanguage) {
074: // We ignore the input locale.
075: // When displaying for the default locale, rely on the localized AWT properties;
076: // for any other locale, fall back to English.
077: String name = "System Input Methods";
078: if (Locale.getDefault().equals(displayLanguage)) {
079: name = Toolkit.getProperty(
080: "AWT.HostInputMethodDisplayName", name);
081: }
082: return name;
083: }
084:
085: /**
086: * @see java.awt.im.spi.InputMethodDescriptor#getInputMethodIcon
087: */
088: public Image getInputMethodIcon(Locale inputLocale) {
089: return null;
090: }
091:
092: /**
093: * @see java.awt.im.spi.InputMethodDescriptor#createInputMethod
094: */
095: public abstract InputMethod createInputMethod() throws Exception;
096:
097: /**
098: * returns supported locale. Currently this method returns the locale in which
099: * the VM is started since Solaris doesn't provide a way to determine the login locale.
100: */
101: static Locale getSupportedLocale() {
102: return SunToolkit.getStartupLocale();
103: }
104: }
|