1 // 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html#License 3 /* 4 ******************************************************************************* 5 * Copyright (C) 2004, International Business Machines Corporation and * 6 * others. All Rights Reserved. * 7 ******************************************************************************* 8 */ 9 10 package com.ibm.icu.dev.tool.ime.indic; 11 12 import java.awt.Image; 13 import java.awt.im.spi.InputMethod; 14 import java.awt.im.spi.InputMethodDescriptor; 15 import java.util.Locale; 16 import java.util.ResourceBundle; 17 18 public abstract class IndicIMDescriptor implements InputMethodDescriptor { 19 private final Locale locale; 20 private final String name; 21 22 protected IndicIMDescriptor(Locale locale, String name) { 23 this.locale = locale; 24 this.name = name; 25 } 26 27 protected abstract IndicInputMethodImpl getImpl(); 28 29 public Locale[] getAvailableLocales() { 30 return new Locale[] { locale }; 31 } 32 33 public boolean hasDynamicLocaleList() { 34 return false; 35 } 36 37 public synchronized String getInputMethodDisplayName(Locale inputLocale, Locale displayLanguage) { 38 try { 39 ResourceBundle rb = ResourceBundle.getBundle("com.ibm.icu.dev.tool.ime.indic.DisplayNames", 40 displayLanguage); 41 return rb.getString("DisplayName." + name); 42 } 43 catch (Throwable t) { 44 return name; 45 } 46 } 47 48 public Image getInputMethodIcon(Locale inputLocale) { 49 return null; 50 } 51 52 public InputMethod createInputMethod() throws Exception { 53 return new IndicInputMethod(locale, getImpl()); 54 } 55 56 public String toString() { 57 return name; 58 } 59 } 60