Print this page
rev 5696 : 6336885: RFE: Locale Data Deployment Enhancements
4609153: Provide locale data for Indic locales
5104387: Support for gl_ES locale (galician language)
6337471: desktop/system locale preferences support
7056139: (cal) SPI support for locale-dependent Calendar parameters
7058206: Provide CalendarData SPI for week params and display field value names
7073852: Support multiple scripts for digits and decimal symbols per locale
7079560: [Fmt-Da] Context dependent month names support in SimpleDateFormat
7171324: getAvailableLocales() of locale sensitive services should return the actual availability of locales
7151414: (cal) Support calendar type identification
7168528: LocaleServiceProvider needs to be aware of Locale extensions
7171372: (cal) locale's default Calendar should be created if unknown calendar is specified
Summary: JEP 127: Improve Locale Data Packaging and Adopt Unicode CLDR Data (part 1 w/o packaging changes. by Naoto Sato and Masayoshi Okutsu)

Split Close
Expand all
Collapse all
          --- old/src/share/classes/javax/swing/JSpinner.java
          +++ new/src/share/classes/javax/swing/JSpinner.java
   1    1  /*
   2      - * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
        2 + * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
   3    3   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4    4   *
   5    5   * This code is free software; you can redistribute it and/or modify it
   6    6   * under the terms of the GNU General Public License version 2 only, as
   7    7   * published by the Free Software Foundation.  Oracle designates this
   8    8   * particular file as subject to the "Classpath" exception as provided
   9    9   * by Oracle in the LICENSE file that accompanied this code.
  10   10   *
  11   11   * This code is distributed in the hope that it will be useful, but WITHOUT
  12   12   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
↓ open down ↓ 16 lines elided ↑ open up ↑
  29   29  import java.awt.event.*;
  30   30  
  31   31  import javax.swing.event.*;
  32   32  import javax.swing.text.*;
  33   33  import javax.swing.plaf.SpinnerUI;
  34   34  
  35   35  import java.util.*;
  36   36  import java.beans.*;
  37   37  import java.text.*;
  38   38  import java.io.*;
  39      -import java.util.HashMap;
  40      -import sun.util.resources.LocaleData;
       39 +import java.text.spi.DateFormatProvider;
       40 +import java.text.spi.NumberFormatProvider;
  41   41  
  42   42  import javax.accessibility.*;
       43 +import sun.util.locale.provider.LocaleProviderAdapter;
       44 +import sun.util.locale.provider.LocaleResources;
       45 +import sun.util.locale.provider.LocaleServiceProviderPool;
  43   46  
  44   47  
  45   48  /**
  46   49   * A single line input field that lets the user select a
  47   50   * number or an object value from an ordered sequence. Spinners typically
  48   51   * provide a pair of tiny arrow buttons for stepping through the elements
  49   52   * of the sequence. The keyboard up/down arrow keys also cycle through the
  50   53   * elements. The user may also be allowed to type a (legal) value directly
  51   54   * into the spinner. Although combo boxes provide similar functionality,
  52   55   * spinners are sometimes preferred because they don't require a drop down list
↓ open down ↓ 886 lines elided ↑ open up ↑
 939  942       * <code>minimum</code> and <code>maximum</code> properties
 940  943       * are mapped to the <code>SpinnerDateModel</code>.
 941  944       * @since 1.4
 942  945       */
 943  946      // PENDING(hmuller): more example javadoc
 944  947      public static class DateEditor extends DefaultEditor
 945  948      {
 946  949          // This is here until SimpleDateFormat gets a constructor that
 947  950          // takes a Locale: 4923525
 948  951          private static String getDefaultPattern(Locale loc) {
 949      -            ResourceBundle r = LocaleData.getDateFormatData(loc);
 950      -            String[] dateTimePatterns = r.getStringArray("DateTimePatterns");
 951      -            Object[] dateTimeArgs = {dateTimePatterns[DateFormat.SHORT],
 952      -                                     dateTimePatterns[DateFormat.SHORT + 4]};
 953      -            return MessageFormat.format(dateTimePatterns[8], dateTimeArgs);
      952 +            LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
      953 +            LocaleResources lr = adapter.getLocaleResources(loc);
      954 +            if (lr == null) {
      955 +                lr = LocaleProviderAdapter.forJRE().getLocaleResources(loc);
      956 +            }
      957 +            return lr.getDateTimePattern(DateFormat.SHORT, DateFormat.SHORT, null);
 954  958          }
 955  959  
 956  960          /**
 957  961           * Construct a <code>JSpinner</code> editor that supports displaying
 958  962           * and editing the value of a <code>SpinnerDateModel</code>
 959  963           * with a <code>JFormattedTextField</code>.  <code>This</code>
 960  964           * <code>DateEditor</code> becomes both a <code>ChangeListener</code>
 961  965           * on the spinners model and a <code>PropertyChangeListener</code>
 962  966           * on the new <code>JFormattedTextField</code>.
 963  967           *
↓ open down ↓ 154 lines elided ↑ open up ↑
1118 1122       * are mapped to the <code>SpinnerNumberModel</code>.
1119 1123       * @since 1.4
1120 1124       */
1121 1125      // PENDING(hmuller): more example javadoc
1122 1126      public static class NumberEditor extends DefaultEditor
1123 1127      {
1124 1128          // This is here until DecimalFormat gets a constructor that
1125 1129          // takes a Locale: 4923525
1126 1130          private static String getDefaultPattern(Locale locale) {
1127 1131              // Get the pattern for the default locale.
1128      -            ResourceBundle rb = LocaleData.getNumberFormatData(locale);
1129      -            String[] all = rb.getStringArray("NumberPatterns");
     1132 +            LocaleProviderAdapter adapter;
     1133 +            adapter = LocaleProviderAdapter.getAdapter(NumberFormatProvider.class,
     1134 +                                                       locale);
     1135 +            LocaleResources lr = adapter.getLocaleResources(locale);
     1136 +            if (lr == null) {
     1137 +                lr = LocaleProviderAdapter.forJRE().getLocaleResources(locale);
     1138 +            }
     1139 +            String[] all = lr.getNumberPatterns();
1130 1140              return all[0];
1131 1141          }
1132 1142  
1133 1143          /**
1134 1144           * Construct a <code>JSpinner</code> editor that supports displaying
1135 1145           * and editing the value of a <code>SpinnerNumberModel</code>
1136 1146           * with a <code>JFormattedTextField</code>.  <code>This</code>
1137 1147           * <code>NumberEditor</code> becomes both a <code>ChangeListener</code>
1138 1148           * on the spinner and a <code>PropertyChangeListener</code>
1139 1149           * on the new <code>JFormattedTextField</code>.
↓ open down ↓ 894 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX