home *** CD-ROM | disk | FTP | other *** search
/ BUG 15 / BUGCD1998_06.ISO / aplic / jbuilder / jsamples.z / LocaleChooserSelectedLocalesEditor.java < prev    next >
Encoding:
Java Source  |  1997-07-30  |  2.1 KB  |  65 lines

  1. package borland.samples.intl.beans;
  2.  
  3. import java.util.*;
  4.  
  5. public class LocaleChooserSelectedLocalesEditor extends LocaleChooserMultipleLocaleSelector {
  6.  
  7.   public LocaleChooserSelectedLocalesEditor() {
  8.     localeChooser.setAllowMultiSelect(true);
  9.     localeChooser.setTitle(resourceBundle.getString("none_selected"));
  10.   }
  11.  
  12.   public String getJavaInitializationString() {
  13.     Locale [] selectedLocales = localeChooser.getSelectedLocales();
  14.  
  15.     if ((selectedLocales.length == 0) ||
  16.         ((selectedLocales.length == 1) &&
  17.      (selectedLocales[0].equals(LocaleChooser.TITLE_LOCALE)))) {
  18.       System.out.println(this.getClass().getName() + ".getJavaInitializationString(): NO_LOCALES");
  19.       return "LocaleChooser.NO_LOCALES";
  20.     }
  21.     return super.getJavaInitializationString();
  22.   }
  23.  
  24.   public void setValue(Object o) {
  25.     try {
  26.       Locale [] localeChoices = (Locale []) ((Locale []) o).clone();
  27.       if ((localeChoices.length == 0) ||
  28.       ((localeChoices.length == 1) &&
  29.        (localeChoices[0].equals(LocaleChooser.NULL_LOCALE)))) {
  30.     System.out.println(this.getClass().getName() + ".setValue(): NO_LOCALES");
  31.     localeChooser.setSelectedLocales(new Locale [] { LocaleChooser.TITLE_LOCALE });
  32.       } else {
  33.     super.setValue(o);
  34.       }
  35.     } catch (Exception e) {
  36.       e.printStackTrace();
  37.     }
  38.   }
  39.  
  40.   public Object getValue() {
  41.     Locale [] selectedLocales = localeChooser.getSelectedLocales();
  42.     if ((selectedLocales.length == 0) ||
  43.         ((selectedLocales.length == 1) &&
  44.      (selectedLocales[0].equals(LocaleChooser.TITLE_LOCALE)))) {
  45.       System.out.println(this.getClass().getName() + ".getValue(): NO_LOCALES");
  46.       return LocaleChooser.NO_LOCALES;
  47.     }
  48.     return super.getValue();
  49.   }
  50.  
  51.   public String getAsText() {
  52.     Locale [] selectedLocales = localeChooser.getSelectedLocales();
  53.  
  54.     if ((selectedLocales.length == 0) ||
  55.         ((selectedLocales.length == 1) &&
  56.      (selectedLocales[0].equals(LocaleChooser.TITLE_LOCALE)))) {
  57.       System.out.println(this.getClass().getName() + ".getAsText(): none_selected");
  58.       return resourceBundle.getString("none_selected");
  59.     }
  60.     return super.getAsText();
  61.   }
  62.  
  63. }
  64.  
  65.