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