1 15 package org.apache.tapestry.workbench.localization; 16 17 import java.util.ArrayList ; 18 import java.util.List ; 19 import java.util.Locale ; 20 21 import org.apache.tapestry.form.IPropertySelectionModel; 22 23 26 27 public class LocaleModel implements IPropertySelectionModel 28 { 29 private Locale locale; 30 31 private List locales = new ArrayList (); 32 33 public LocaleModel(Locale locale) 34 { 35 this.locale = locale; 36 } 37 38 public void add(Locale locale) 39 { 40 locales.add(locale); 41 } 42 43 private Locale get(int index) 44 { 45 return (Locale ) locales.get(index); 46 } 47 48 public String getLabel(int index) 49 { 50 return get(index).getDisplayName(locale); 51 } 52 53 public int getOptionCount() 54 { 55 return locales.size(); 56 } 57 58 public Object getOption(int index) 59 { 60 return locales.get(index); 61 } 62 63 66 67 public String getValue(int index) 68 { 69 return Integer.toString(index); 70 } 71 72 public Object translateValue(String value) 73 { 74 int index = Integer.parseInt(value); 75 76 return locales.get(index); 77 } 78 } | Popular Tags |