Daniel Kurka has uploaded a new change for review.

  https://gwt-review.googlesource.com/3617


Change subject: Make DateCell use non deprecated DateTimeFormat
......................................................................

Make DateCell use non deprecated DateTimeFormat

fixes issue 8201

Change-Id: I4fe3065313a019ef5c97427e925d45dadc6ef434
---
M user/src/com/google/gwt/cell/client/DateCell.java
1 file changed, 103 insertions(+), 6 deletions(-)



diff --git a/user/src/com/google/gwt/cell/client/DateCell.java b/user/src/com/google/gwt/cell/client/DateCell.java
index b187bab..3192d9b 100644
--- a/user/src/com/google/gwt/cell/client/DateCell.java
+++ b/user/src/com/google/gwt/cell/client/DateCell.java
@@ -16,7 +16,6 @@
 package com.google.gwt.cell.client;

 import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
 import com.google.gwt.i18n.client.TimeZone;
 import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
 import com.google.gwt.text.shared.SafeHtmlRenderer;
@@ -35,12 +34,17 @@

   private final TimeZone timeZone;

+  private final com.google.gwt.i18n.shared.DateTimeFormat sharedFormat;
+
+  private final com.google.gwt.i18n.shared.TimeZone timeZoneShared;
+
   /**
    * Construct a new {@link DateCell} using the format
* {@link PredefinedFormat#DATE_FULL} and a {@link SimpleSafeHtmlRenderer}.
    */
   public DateCell() {
-    this(DateTimeFormat.getFormat(PredefinedFormat.DATE_FULL),
+    this(com.google.gwt.i18n.shared.DateTimeFormat.getFormat(
+ com.google.gwt.i18n.shared.DateTimeFormat.PredefinedFormat.DATE_FULL),
         SimpleSafeHtmlRenderer.getInstance(), null);
   }

@@ -52,7 +56,9 @@
    *          formatted date as HTML
    */
   public DateCell(SafeHtmlRenderer<String> renderer) {
- this(DateTimeFormat.getFormat(PredefinedFormat.DATE_FULL), renderer, null);
+    this(com.google.gwt.i18n.shared.DateTimeFormat.getFormat(
+ com.google.gwt.i18n.shared.DateTimeFormat.PredefinedFormat.DATE_FULL),
+      renderer, null);
   }

   /**
@@ -60,7 +66,11 @@
    * {@link SimpleSafeHtmlRenderer}.
    *
    * @param format the {@link DateTimeFormat} used to render the date
+   *
+   * @deprecated use
+   * {@link DateCell#DateCell(com.google.gwt.i18n.shared.DateTimeFormat)}
    */
+  @Deprecated
   public DateCell(DateTimeFormat format) {
     this(format, SimpleSafeHtmlRenderer.getInstance(), null);
   }
@@ -72,7 +82,11 @@
    * @param format the {@link DateTimeFormat} used to render the date
    * @param renderer a non-null {@link SafeHtmlRenderer} used to render the
    *          formatted date
+   *
+   * @deprecated use
+ * {@link DateCell#DateCell(com.google.gwt.i18n.shared.DateTimeFormat, SafeHtmlRenderer)}
    */
+  @Deprecated
public DateCell(DateTimeFormat format, SafeHtmlRenderer<String> renderer) {
     this(format, renderer, null);
   }
@@ -81,11 +95,15 @@
* Construct a new {@link DateCell} using the specified format and time zone.
    *
    * @param format the {@link DateTimeFormat} used to render the date
- * @param timezone the {@link TimeZone} used to render the date, or null to + * @param timeZone the {@link TimeZone} used to render the date, or null to * use the default behavior for the local time zone and the rendered
    *          date. See {@link DateTimeFormat#format(Date)} and
    *          {@link Date#getTimezoneOffset()}
+   *
+   * @deprecated use
+ * {@link DateCell#DateCell(com.google.gwt.i18n.shared.DateTimeFormat, com.google.gwt.i18n.shared.TimeZone)}
    */
+  @Deprecated
   public DateCell(DateTimeFormat format, TimeZone timeZone) {
     this(format, SimpleSafeHtmlRenderer.getInstance(), timeZone);
   }
@@ -97,11 +115,15 @@
    * @param format the {@link DateTimeFormat} used to render the date
    * @param renderer a non-null {@link SafeHtmlRenderer} used to render the
    *          formatted date
- * @param timezone the {@link TimeZone} used to render the date, or null to + * @param timeZone the {@link TimeZone} used to render the date, or null to * use the default behavior for the local time zone and the rendered
    *          date. See {@link DateTimeFormat#format(Date)} and
    *          {@link Date#getTimezoneOffset()}
+   *
+   * @deprecated use
+ * {@link DateCell#DateCell(com.google.gwt.i18n.shared.DateTimeFormat, SafeHtmlRenderer, com.google.gwt.i18n.shared.TimeZone)}
    */
+  @Deprecated
   public DateCell(DateTimeFormat format, SafeHtmlRenderer<String> renderer,
       TimeZone timeZone) {
     if (format == null) {
@@ -111,14 +133,89 @@
       throw new IllegalArgumentException("renderer == null");
     }
     this.format = format;
+    this.sharedFormat = null;
     this.renderer = renderer;
     this.timeZone = timeZone;
+    this.timeZoneShared = null;
+  }
+
+  /**
+   * Construct a new {@link DateCell} using the specified format and a
+   * {@link SimpleSafeHtmlRenderer}.
+   *
+   * @param format the {@link com.google.gwt.i18n.shared.DateTimeFormat}
+   *          used to render the date
+   */
+  public DateCell(com.google.gwt.i18n.shared.DateTimeFormat format) {
+    this(format, SimpleSafeHtmlRenderer.getInstance(), null);
+  }
+
+  /**
+ * Construct a new {@link DateCell} using the specified format and the given
+   * {@link SafeHtmlRenderer}.
+   *
+   * @param format the {@link com.google.gwt.i18n.shared.DateTimeFormat}
+   *          used to render the date
+   * @param renderer a non-null {@link SafeHtmlRenderer} used to render the
+   *          formatted date
+   */
+ public DateCell(com.google.gwt.i18n.shared.DateTimeFormat format, SafeHtmlRenderer<String> renderer) {
+    this(format, renderer, null);
+  }
+
+  /**
+ * Construct a new {@link DateCell} using the specified format and time zone.
+   *
+   * @param format the {@link com.google.gwt.i18n.shared.DateTimeFormat}
+   *          used to render the date
+   * @param timeZone the {@link com.google.gwt.i18n.shared.TimeZone}
+   *          used to render the date, or null to
+ * use the default behavior for the local time zone and the rendered
+   *          date. See {@link DateTimeFormat#format(Date)} and
+   *          {@link Date#getTimezoneOffset()}
+   */
+  public DateCell(com.google.gwt.i18n.shared.DateTimeFormat format,
+      com.google.gwt.i18n.shared.TimeZone timeZone) {
+    this(format, SimpleSafeHtmlRenderer.getInstance(), timeZone);
+  }
+
+  /**
+   * Construct a new {@link DateCell} using the specified format, the given
+   * {@link SafeHtmlRenderer}, and the specified time zone.
+   *
+   * @param format the {@link com.google.gwt.i18n.shared.DateTimeFormat}
+   *          used to render the date
+   * @param renderer a non-null {@link SafeHtmlRenderer} used to render the
+   *          formatted date
+   * @param timeZone the {@link com.google.gwt.i18n.shared.TimeZone}
+   *          used to render the date, or null to
+ * use the default behavior for the local time zone and the rendered
+   *          date. See {@link DateTimeFormat#format(Date)} and
+   *          {@link Date#getTimezoneOffset()}
+   */
+ public DateCell(com.google.gwt.i18n.shared.DateTimeFormat format, SafeHtmlRenderer<String> renderer,
+      com.google.gwt.i18n.shared.TimeZone timeZone) {
+    if (format == null) {
+      throw new IllegalArgumentException("format == null");
+    }
+    if (renderer == null) {
+      throw new IllegalArgumentException("renderer == null");
+    }
+    this.format = null;
+    this.sharedFormat = format;
+    this.renderer = renderer;
+    this.timeZone = null;
+    this.timeZoneShared = timeZone;
   }

   @Override
   public void render(Context context, Date value, SafeHtmlBuilder sb) {
     if (value != null) {
-      sb.append(renderer.render(format.format(value, timeZone)));
+      if (sharedFormat != null) {
+ sb.append(renderer.render(sharedFormat.format(value, timeZoneShared)));
+      } else {
+        sb.append(renderer.render(format.format(value, timeZone)));
+      }
     }
   }
 }

--
To view, visit https://gwt-review.googlesource.com/3617
To unsubscribe, visit https://gwt-review.googlesource.com/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4fe3065313a019ef5c97427e925d45dadc6ef434
Gerrit-PatchSet: 1
Gerrit-Project: gwt
Gerrit-Branch: master
Gerrit-Owner: Daniel Kurka <[email protected]>

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
--- You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to