You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by tv...@apache.org on 2009/09/30 17:50:16 UTC

svn commit: r820312 - /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java

Author: tvolkert
Date: Wed Sep 30 15:50:16 2009
New Revision: 820312

URL: http://svn.apache.org/viewvc?rev=820312&view=rev
Log:
Made TableViewDateCellRenderer support rendering of long values, interpreted as epoch time values

Modified:
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java?rev=820312&r1=820311&r2=820312&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java Wed Sep 30 15:50:16 2009
@@ -57,9 +57,9 @@
         boolean rowSelected, boolean rowHighlighted, boolean rowDisabled) {
         renderStyles(tableView, rowSelected, rowDisabled);
 
-        if (value != null) {
-            String formattedDate = null;
+        String formattedDate = null;
 
+        if (value != null) {
             // Get the row and cell data
             if (columnName != null) {
                 Dictionary<String, Object> rowData;
@@ -71,15 +71,19 @@
 
                 Object cellData = rowData.get(columnName);
 
-                if (cellData instanceof Date) {
-                    formattedDate = dateFormat.format((Date)cellData);
-                } else {
-                    System.err.println("Data for \"" + columnName + "\" is not an instance of "
-                        + Date.class.getName());
+                if (cellData != null) {
+                    if (cellData instanceof Date) {
+                        formattedDate = dateFormat.format((Date)cellData);
+                    } else if (cellData instanceof Long) {
+                        formattedDate = dateFormat.format(new Date((Long)cellData));
+                    } else {
+                        System.err.println("Data for \"" + columnName + "\" is not an instance of "
+                            + Date.class.getName());
+                    }
                 }
             }
-
-            setText(formattedDate);
         }
+
+        setText(formattedDate);
     }
 }



Re: svn commit: r820312 - /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java

Posted by Sandro Martini <sa...@gmail.com>.
Hi to all,
this small patch has been committed.

Now, someone has (already) a working sample with test data ?
Tell me, so if wanted I can try to add some Calendars ...

Bye,
Sandro

Re: svn commit: r820312 - /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java

Posted by Sandro Martini <sa...@gmail.com>.
Ok, received.
Thanks the same.

I'll do the patch tomorrow.

Sandro

Re: svn commit: r820312 - /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java

Posted by Todd Volkert <tv...@gmail.com>.
No, I think that's a different beast. Renderers inherently are built to
support certain types of custom data, so adding knowledge of Calendar to the
date cell renderer makes sense.  JSONSerializer, however, is built to
support the basic JSON data types (number, string, map, list, boolean).  The
user wishing to serialize a Date out to JSONSerializer should have to
convert the date to its millisecond representation (or better yet, just deal
in milliseconds as their data model in the first place -- this is what I do
in my apps).  Date should get no more special treatment in JSONSerializer as
any other non-JSON data type class.

-T

On Wed, Sep 30, 2009 at 12:20 PM, Sandro Martini
<sa...@gmail.com>wrote:

> Hi Todd,
> Ok, I can do the patch (but tomorrow) ... as you note in last weeks
> I'm very busy at work, and I'm doing little things on Pivot, sigh ...
>
> Or if you have time, do it for me, no problem.
> If tomorrow I didn't see the commit, I'll do it ...
>
>
> And a last thing, similar but on JSONSerializer  ... if I remember
> well, in the JSON format there isn't support for Date / Timestamps,
> and in out JSONSerializer we don't support Date objects (nor
> Calendar).
> So, what do you think on add athing like upper in this discussion, for
> example converting them to a long when writing ? The problem in this
> case would be when reading, so not fully solved.
> Or if we could do this inside a catch, or register a user-defined
> callback for these cases but we could add too much complexity here.
>
> What do you think ?
>
>
> Byeeee
>

Re: svn commit: r820312 - /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java

Posted by Sandro Martini <sa...@gmail.com>.
Hi Todd,
Ok, I can do the patch (but tomorrow) ... as you note in last weeks
I'm very busy at work, and I'm doing little things on Pivot, sigh ...

Or if you have time, do it for me, no problem.
If tomorrow I didn't see the commit, I'll do it ...


And a last thing, similar but on JSONSerializer  ... if I remember
well, in the JSON format there isn't support for Date / Timestamps,
and in out JSONSerializer we don't support Date objects (nor
Calendar).
So, what do you think on add athing like upper in this discussion, for
example converting them to a long when writing ? The problem in this
case would be when reading, so not fully solved.
Or if we could do this inside a catch, or register a user-defined
callback for these cases but we could add too much complexity here.

What do you think ?


Byeeee

Re: svn commit: r820312 - /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java

Posted by Todd Volkert <tv...@gmail.com>.
Just searched the archives - it was
http://mail-archives.apache.org/mod_mbox/incubator-pivot-dev/200908.mbox/%3C6B378467-D979-4AA9-8D80-3064634E9FD9@mac.com%3E

I missed this suggestion the first time - making this renderer support
Calendar instances would be trivial and would seem to make sense.  It'd just
add call dateFormat.format(calendar.getTime()).  Sandro, you wanna make the
change?

-T

On Wed, Sep 30, 2009 at 12:06 PM, Greg Brown <gk...@mac.com> wrote:

> I don't remember that suggestion specifically - can you remind us what it
> was?
>
>
> On Sep 30, 2009, at 12:05 PM, Sandro Martini wrote:
>
>  Hi to all,
>> some time ago i wrote on supporting here also another common class:
>> Calendar ... but was rejected.
>>
>> What do you think ?
>>
>> Bye
>>
>
>

Re: svn commit: r820312 - /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java

Posted by Greg Brown <gk...@mac.com>.
I don't remember that suggestion specifically - can you remind us what  
it was?

On Sep 30, 2009, at 12:05 PM, Sandro Martini wrote:

> Hi to all,
> some time ago i wrote on supporting here also another common class:
> Calendar ... but was rejected.
>
> What do you think ?
>
> Bye


Re: svn commit: r820312 - /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewDateCellRenderer.java

Posted by Sandro Martini <sa...@gmail.com>.
Hi to all,
some time ago i wrote on supporting here also another common class:
Calendar ... but was rejected.

What do you think ?

Bye