I don't understand how SortedList and TableComparatorChooser work together

View: New views
7 Messages — Rating Filter:   Alert me  

I don't understand how SortedList and TableComparatorChooser work together

by Boomah :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi people. I don't understand how SortedList and TableComparatorChooser work together.

I have objects that get added to a SortedList that represent (via my TableFormat) a row in a table. The SortedList uses this object to sort, and if I just use a standard JTable, whenever an object is added to my list, it gets added to my table in the appropriate position. Everything works exactly as I would expect.

Now I install a TableComparatorChooser on my JTable. If I start my application, I see items being added to the table in the correct position given my SortedList as before. However, if I now click on one of the columns, it sorts not using my SortedList but by using the objects in the column I clicked on. In my case they are all strings and so get sorted using the standard string comparator.

I don't understand why the TableComparatorChooser requires a SortedList if once the user clicks on a column, it gets sorted by the objects it contains. Why isn't it possible to use an EventList?

It feels like I'm missing something obvious, but I think that SortedList and TableComparatorChooser completely work against each other and should be separated.

Have I completely missed the point?

Thanks, Nick.


re: I don't understand how SortedList and TableComparatorChooser work together

by Kevin Day-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
I'm pretty sure that TableComparitorChooser is actually swapping out the comparator on your sorted list.
 
- K
 
 
----------------------- Original Message -----------------------
  
From: Boomah nickdarcy@...
Cc: 
Date: Thu, 30 Apr 2009 10:41:56 -0700 (PDT)
Subject: I don't understand how SortedList and TableComparatorChooser work together
  

Hi people. I don't understand how SortedList and TableComparatorChooser work
together.

I have objects that get added to a SortedList that represent (via my
TableFormat) a row in a table. The SortedList uses this object to sort, and
if I just use a standard JTable, whenever an object is added to my list, it
gets added to my table in the appropriate position. Everything works exactly
as I would expect.

Now I install a TableComparatorChooser on my JTable. If I start my
application, I see items being added to the table in the correct position
given my SortedList as before. However, if I now click on one of the
columns, it sorts not using my SortedList but by using the objects in the
column I clicked on. In my case they are all strings and so get sorted using
the standard string comparator.

I don't understand why the TableComparatorChooser requires a SortedList if
once the user clicks on a column, it gets sorted by th e objects it contains.
Why isn't it possible to use an EventList?

It feels like I'm missing something obvious, but I think that SortedList and
TableComparatorChooser completely work against each other and should be
separated.

Have I completely missed the point?

Thanks, Nick.


--
View this message in context: http://www.nabble.com/I-don%27t-understand-how-SortedList-and-TableComparatorChooser-work-together-tp23321078p23321078.html
Sent from the GlazedLists - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-ma il: users-help@...


--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@...

Re: I don't understand how SortedList and TableComparatorChooser work together

by James Lemieux :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Kevin is correct.

SortedList is a transformation used to create an ordered *view* of any EventList.

TableComparatorChooser is simply a big fancy way to interpret mouse clicks on a column header as a change in the Comparator of a SortedList.

If the original question posed in this Thread is essentially "why don't you just sort data in place, why do you have sorted "views" at all?" that's a really long winded explanation. Some quick but obvious reasons include:

a) what if I want 2 different sorted views of the same data?
b) what if the original order has special meaning to my app, and shouldn't be disturbed?
c) how can I return to the original order after it has been disturbed?

etc.

James

On Thu, Apr 30, 2009 at 11:00 AM, Kevin Day <kevin@...> wrote:
I'm pretty sure that TableComparitorChooser is actually swapping out the comparator on your sorted list.
 
- K
 
 
----------------------- Original Message -----------------------
  
From: Boomah nickdarcy@...
Cc: 
Date: Thu, 30 Apr 2009 10:41:56 -0700 (PDT)
Subject: I don't understand how SortedList and TableComparatorChooser work together
  

Hi people. I don't understand how SortedList and TableComparatorChooser work
together.

I have objects that get added to a SortedList that represent (via my
TableFormat) a row in a table. The SortedList uses this object to sort, and
if I just use a standard JTable, whenever an object is added to my list, it
gets added to my table in the appropriate position. Everything works exactly
as I would expect.

Now I install a TableComparatorChooser on my JTable. If I start my
application, I see items being added to the table in the correct position
given my SortedList as before. However, if I now click on one of the
columns, it sorts not using my SortedList but by using the objects in the
column I clicked on. In my case they are all strings and so get sorted using
the standard string comparator.

I don't understand why the TableComparatorChooser requires a SortedList if
once the user clicks on a column, it gets sorted by th e objects it contains.

Why isn't it possible to use an EventList?

It feels like I'm missing something obvious, but I think that SortedList and
TableComparatorChooser completely work against each other and should be
separated.

Have I completely missed the point?

Thanks, Nick.


--
View this message in context: http://www.nabble.com/I-don%27t-understand-how-SortedList-and-TableComparatorChooser-work-together-tp23321078p23321078.html
Sent from the GlazedLists - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-ma il: users-help@...


--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@...


Re: I don't understand how SortedList and TableComparatorChooser work together

by Boomah :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the answers but I'm still unsure (this is my fault for not explaining properly). Let me try again:

The TableComparatorChooser isn't swapping out the Comparator on my SortedList, it is using the Comparator of whatever my TableFormat returns for that column. This is a field in an object contained in my SortedList. So as soon as I click on a column to sort, the SortedList is no longer used, and could just as easily be replaced by an EventList.

I agree with point c) mentioned below. After I had clicked on a column, I might want to revert back to the order that the SortedList says the table should display data in. I can't figure out how to do this though. It doesn't seem I can deselected a column sorting. Is this possible?

So my main point is this: Why does the method TableComparatorChooser.install take a SortedList when it seems to me that taking an EventList would be just as legitimate.

Thanks for any clarification,

Nick.



James Lemieux wrote:
Kevin is correct.

SortedList is a transformation used to create an ordered *view* of any
EventList.

TableComparatorChooser is simply a big fancy way to interpret mouse clicks
on a column header as a change in the Comparator of a SortedList.

If the original question posed in this Thread is essentially "why don't you
just sort data in place, why do you have sorted "views" at all?" that's a
really long winded explanation. Some quick but obvious reasons include:

a) what if I want 2 different sorted views of the same data?
b) what if the original order has special meaning to my app, and shouldn't
be disturbed?
c) how can I return to the original order after it has been disturbed?

etc.

James

On Thu, Apr 30, 2009 at 11:00 AM, Kevin Day <kevin@trumpetinc.com> wrote:

>  I'm pretty sure that TableComparitorChooser is actually swapping out the
> comparator on your sorted list.
>
> - K
>
>
>  ----------------------- *Original Message* -----------------------
>
> *From:* Boomah <nickdarcy@gmail.com> <nickdarcy@gmail.com>
> *To:* users@glazedlists.dev.java.net
> *Cc:*
> *Date:* Thu, 30 Apr 2009 10:41:56 -0700 (PDT)
> *Subject: I don't understand how SortedList and TableComparatorChooser
> work together*
>
>
> Hi people. I don't understand how SortedList and TableComparatorChooser
> work
> together.
>
> I have objects that get added to a SortedList that represent (via my
> TableFormat) a row in a table. The SortedList uses this object to sort, and
> if I just use a standard JTable, whenever an object is added to my list, it
> gets added to my table in the appropriate position. Everything works
> exactly
> as I would expect.
>
> Now I install a TableComparatorChooser on my JTable. If I start my
> application, I see items being added to the table in the correct position
> given my SortedList as before. However, if I now click on one of the
> columns, it sorts not using my SortedList but by using the objects in the
> column I clicked on. In my case they are all strings and so get sorted
> using
> the standard string comparator.
>
> I don't understand why the TableComparatorChooser requires a SortedList if
> once the user clicks on a column, it gets sorted by th e objects it
> contains.
> Why isn't it possible to use an EventList?
>
> It feels like I'm missing something obvious, but I think that SortedList
> and
> TableComparatorChooser completely work against each other and should be
> separated.
>
> Have I completely missed the point?
>
> Thanks, Nick.
>
>
> --
> View this message in context:
> http://www.nabble.com/I-don%27t-understand-how-SortedList-and-TableComparatorChooser-work-together-tp23321078p23321078.html
> Sent from the GlazedLists - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glazedlists.dev.java.net
> For additional commands, e-ma il: users-help@glazedlists.dev.java.net
>
>
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: users-unsubscribe@glazedlists.dev.java.net For
> additional commands, e-mail: users-help@glazedlists.dev.java.net

Re: I don't understand how SortedList and TableComparatorChooser work together

by James Lemieux :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Nick,

"The TableComparatorChooser isn't swapping out the Comparator on my
SortedList, it is using the Comparator of whatever my TableFormat returns
for that column."

This is a false statement. The Comparator of whatever your TableFormat returns for a column is set as the Comparator of the SortedList. It may be combined with other Comparators (for multi column sorting) and it may be wrapped to reverse its natural sort direction, but ultimately your column Comparators are used as the Comparator on your SortedList. If you're still unconvinced, look at AbstractTableComparatorChooser.rebuildComparator():

    protected void rebuildComparator() {
        final Comparator<E> rebuiltComparator = sortingState.buildComparator();

        // select the new comparator
        sortedList.getReadWriteLock().writeLock().lock();
        try {
            sortedListComparator = rebuiltComparator;
            sortedList.setComparator(rebuiltComparator);
        } finally {
            sortedList.getReadWriteLock().writeLock().unlock();
        }
    }

If you still have questions at this point, post them back and I'll answer them.

James

On Fri, May 1, 2009 at 12:32 AM, Boomah <nickdarcy@...> wrote:

Thanks for the answers but I'm still unsure (this is my fault for not
explaining properly). Let me try again:

The TableComparatorChooser isn't swapping out the Comparator on my
SortedList, it is using the Comparator of whatever my TableFormat returns
for that column. This is a field in an object contained in my SortedList. So
as soon as I click on a column to sort, the SortedList is no longer used,
and could just as easily be replaced by an EventList.

I agree with point c) mentioned below. After I had clicked on a column, I
might want to revert back to the order that the SortedList says the table
should display data in. I can't figure out how to do this though. It doesn't
seem I can deselected a column sorting. Is this possible?

So my main point is this: Why does the method TableComparatorChooser.install
take a SortedList when it seems to me that taking an EventList would be just
as legitimate.

Thanks for any clarification,

Nick.




James Lemieux wrote:
>
> Kevin is correct.
>
> SortedList is a transformation used to create an ordered *view* of any
> EventList.
>
> TableComparatorChooser is simply a big fancy way to interpret mouse clicks
> on a column header as a change in the Comparator of a SortedList.
>
> If the original question posed in this Thread is essentially "why don't
> you
> just sort data in place, why do you have sorted "views" at all?" that's a
> really long winded explanation. Some quick but obvious reasons include:
>
> a) what if I want 2 different sorted views of the same data?
> b) what if the original order has special meaning to my app, and shouldn't
> be disturbed?
> c) how can I return to the original order after it has been disturbed?
>
> etc.
>
> James
>
> On Thu, Apr 30, 2009 at 11:00 AM, Kevin Day <kevin@...> wrote:
>
>>  I'm pretty sure that TableComparitorChooser is actually swapping out the
>> comparator on your sorted list.
>>
>> - K
>>
>>
>>  ----------------------- *Original Message* -----------------------
>>
>> *From:* Boomah <nickdarcy@...> <nickdarcy@...>
>> *To:* users@...
>> *Cc:*
>> *Date:* Thu, 30 Apr 2009 10:41:56 -0700 (PDT)
>> *Subject: I don't understand how SortedList and TableComparatorChooser
>> work together*
>>
>>
>> Hi people. I don't understand how SortedList and TableComparatorChooser
>> work
>> together.
>>
>> I have objects that get added to a SortedList that represent (via my
>> TableFormat) a row in a table. The SortedList uses this object to sort,
>> and
>> if I just use a standard JTable, whenever an object is added to my list,
>> it
>> gets added to my table in the appropriate position. Everything works
>> exactly
>> as I would expect.
>>
>> Now I install a TableComparatorChooser on my JTable. If I start my
>> application, I see items being added to the table in the correct position
>> given my SortedList as before. However, if I now click on one of the
>> columns, it sorts not using my SortedList but by using the objects in the
>> column I clicked on. In my case they are all strings and so get sorted
>> using
>> the standard string comparator.
>>
>> I don't understand why the TableComparatorChooser requires a SortedList
>> if
>> once the user clicks on a column, it gets sorted by th e objects it
>> contains.
>> Why isn't it possible to use an EventList?
>>
>> It feels like I'm missing something obvious, but I think that SortedList
>> and
>> TableComparatorChooser completely work against each other and should be
>> separated.
>>
>> Have I completely missed the point?
>>
>> Thanks, Nick.
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/I-don%27t-understand-how-SortedList-and-TableComparatorChooser-work-together-tp23321078p23321078.html
>> Sent from the GlazedLists - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@...
>> For additional commands, e-ma il: users-help@...
>>
>>
>> --------------------------------------------------------------------- To
>> unsubscribe, e-mail: users-unsubscribe@... For
>> additional commands, e-mail: users-help@...
>
>

--
View this message in context: http://www.nabble.com/I-don%27t-understand-how-SortedList-and-TableComparatorChooser-work-together-tp23321078p23329393.html
Sent from the GlazedLists - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...



Re: I don't understand how SortedList and TableComparatorChooser work together

by Boomah :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for you answer James, this is clear now.

I see that a comparator is added to my sorted list and the comparator wraps my table format!

One final question if you will. Once I've clicked on a column header, I would like to deselect that column header so that my sorted list (and hence JTable view of it) goes back to original sorting behaviour. Does anyone know of a way to do this?

Thanks, Nick.



James Lemieux wrote:
Nick,

"The TableComparatorChooser isn't swapping out the Comparator on my
SortedList, it is using the Comparator of whatever my TableFormat returns
for that column."

This is a false statement. The Comparator of whatever your TableFormat
returns for a column is set as the Comparator of the SortedList. It may be
combined with other Comparators (for multi column sorting) and it may be
wrapped to reverse its natural sort direction, but ultimately your column
Comparators are used as the Comparator on your SortedList. If you're still
unconvinced, look at AbstractTableComparatorChooser.rebuildComparator():

    protected void rebuildComparator() {
        final Comparator<E> rebuiltComparator =
sortingState.buildComparator();

        // select the new comparator
        sortedList.getReadWriteLock().writeLock().lock();
        try {
            sortedListComparator = rebuiltComparator;
            sortedList.setComparator(rebuiltComparator);
        } finally {
            sortedList.getReadWriteLock().writeLock().unlock();
        }
    }

If you still have questions at this point, post them back and I'll answer
them.

James

On Fri, May 1, 2009 at 12:32 AM, Boomah <nickdarcy@gmail.com> wrote:

>
> Thanks for the answers but I'm still unsure (this is my fault for not
> explaining properly). Let me try again:
>
> The TableComparatorChooser isn't swapping out the Comparator on my
> SortedList, it is using the Comparator of whatever my TableFormat returns
> for that column. This is a field in an object contained in my SortedList.
> So
> as soon as I click on a column to sort, the SortedList is no longer used,
> and could just as easily be replaced by an EventList.
>
> I agree with point c) mentioned below. After I had clicked on a column, I
> might want to revert back to the order that the SortedList says the table
> should display data in. I can't figure out how to do this though. It
> doesn't
> seem I can deselected a column sorting. Is this possible?
>
> So my main point is this: Why does the method
> TableComparatorChooser.install
> take a SortedList when it seems to me that taking an EventList would be
> just
> as legitimate.
>
> Thanks for any clarification,
>
> Nick.
>
>
>
>
> James Lemieux wrote:
> >
> > Kevin is correct.
> >
> > SortedList is a transformation used to create an ordered *view* of any
> > EventList.
> >
> > TableComparatorChooser is simply a big fancy way to interpret mouse
> clicks
> > on a column header as a change in the Comparator of a SortedList.
> >
> > If the original question posed in this Thread is essentially "why don't
> > you
> > just sort data in place, why do you have sorted "views" at all?" that's a
> > really long winded explanation. Some quick but obvious reasons include:
> >
> > a) what if I want 2 different sorted views of the same data?
> > b) what if the original order has special meaning to my app, and
> shouldn't
> > be disturbed?
> > c) how can I return to the original order after it has been disturbed?
> >
> > etc.
> >
> > James
> >
> > On Thu, Apr 30, 2009 at 11:00 AM, Kevin Day <kevin@trumpetinc.com>
> wrote:
> >
> >>  I'm pretty sure that TableComparitorChooser is actually swapping out
> the
> >> comparator on your sorted list.
> >>
> >> - K
> >>
> >>
> >>  ----------------------- *Original Message* -----------------------
> >>
> >> *From:* Boomah <nickdarcy@gmail.com> <nickdarcy@gmail.com>
> >> *To:* users@glazedlists.dev.java.net
> >> *Cc:*
> >> *Date:* Thu, 30 Apr 2009 10:41:56 -0700 (PDT)
> >> *Subject: I don't understand how SortedList and TableComparatorChooser
> >> work together*
> >>
> >>
> >> Hi people. I don't understand how SortedList and TableComparatorChooser
> >> work
> >> together.
> >>
> >> I have objects that get added to a SortedList that represent (via my
> >> TableFormat) a row in a table. The SortedList uses this object to sort,
> >> and
> >> if I just use a standard JTable, whenever an object is added to my list,
> >> it
> >> gets added to my table in the appropriate position. Everything works
> >> exactly
> >> as I would expect.
> >>
> >> Now I install a TableComparatorChooser on my JTable. If I start my
> >> application, I see items being added to the table in the correct
> position
> >> given my SortedList as before. However, if I now click on one of the
> >> columns, it sorts not using my SortedList but by using the objects in
> the
> >> column I clicked on. In my case they are all strings and so get sorted
> >> using
> >> the standard string comparator.
> >>
> >> I don't understand why the TableComparatorChooser requires a SortedList
> >> if
> >> once the user clicks on a column, it gets sorted by th e objects it
> >> contains.
> >> Why isn't it possible to use an EventList?
> >>
> >> It feels like I'm missing something obvious, but I think that SortedList
> >> and
> >> TableComparatorChooser completely work against each other and should be
> >> separated.
> >>
> >> Have I completely missed the point?
> >>
> >> Thanks, Nick.
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/I-don%27t-understand-how-SortedList-and-TableComparatorChooser-work-together-tp23321078p23321078.html
> >> Sent from the GlazedLists - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@glazedlists.dev.java.net
> >> For additional commands, e-ma il: users-help@glazedlists.dev.java.net
> >>
> >>
> >> --------------------------------------------------------------------- To
> >> unsubscribe, e-mail: users-unsubscribe@glazedlists.dev.java.net For
> >> additional commands, e-mail: users-help@glazedlists.dev.java.net
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/I-don%27t-understand-how-SortedList-and-TableComparatorChooser-work-together-tp23321078p23329393.html
> Sent from the GlazedLists - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glazedlists.dev.java.net
> For additional commands, e-mail: users-help@glazedlists.dev.java.net
>
>

Re: I don't understand how SortedList and TableComparatorChooser work together

by James Lemieux :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hey Nick,

   The last argument of the TableComparatorChooser's install method is the strategy for interpreting mouse/keyboard input and fiddling with the Comparator. There can be many ways that users want applications to behave in this regard. GL ships some stock strategies, but you may also write your own if it behooves you.

public static <E> TableComparatorChooser<E> install(JTable table, SortedList<E> sortedList, Object strategy)

Of the out-of-the-box strategies, it seems like AbstractTableComparatorChooser.MULTIPLE_COLUMN_MOUSE_WITH_UNDO might be your guy:

     * Sort multiple columns without use of the keyboard.  Single clicks cycle
     * through comparators. Single click on the last comparator of the primary
     * sort column will clear the entire sort (for all columns).
     *
     * <p>This is an improvement over the original sorting strategy provided by
     * Glazed Lists, since it gives a reasonable mechanism for clearing a sort
     * order that is already in place. It's designed to be used with multiple
     * columns and multiple comparators per column.

James

On Mon, May 11, 2009 at 9:44 AM, Boomah <nickdarcy@...> wrote:

Thanks for you answer James, this is clear now.

I see that a comparator is added to my sorted list and the comparator wraps
my table format!

One final question if you will. Once I've clicked on a column header, I
would like to deselect that column header so that my sorted list (and hence
JTable view of it) goes back to original sorting behaviour. Does anyone know
of a way to do this?

Thanks, Nick.




James Lemieux wrote:
>
> Nick,
>
> "The TableComparatorChooser isn't swapping out the Comparator on my
> SortedList, it is using the Comparator of whatever my TableFormat returns
> for that column."
>
> This is a false statement. The Comparator of whatever your TableFormat
> returns for a column is set as the Comparator of the SortedList. It may be
> combined with other Comparators (for multi column sorting) and it may be
> wrapped to reverse its natural sort direction, but ultimately your column
> Comparators are used as the Comparator on your SortedList. If you're still
> unconvinced, look at AbstractTableComparatorChooser.rebuildComparator():
>
>     protected void rebuildComparator() {
>         final Comparator<E> rebuiltComparator =
> sortingState.buildComparator();
>
>         // select the new comparator
>         sortedList.getReadWriteLock().writeLock().lock();
>         try {
>             sortedListComparator = rebuiltComparator;
>             sortedList.setComparator(rebuiltComparator);
>         } finally {
>             sortedList.getReadWriteLock().writeLock().unlock();
>         }
>     }
>
> If you still have questions at this point, post them back and I'll answer
> them.
>
> James
>
> On Fri, May 1, 2009 at 12:32 AM, Boomah <nickdarcy@...> wrote:
>
>>
>> Thanks for the answers but I'm still unsure (this is my fault for not
>> explaining properly). Let me try again:
>>
>> The TableComparatorChooser isn't swapping out the Comparator on my
>> SortedList, it is using the Comparator of whatever my TableFormat returns
>> for that column. This is a field in an object contained in my SortedList.
>> So
>> as soon as I click on a column to sort, the SortedList is no longer used,
>> and could just as easily be replaced by an EventList.
>>
>> I agree with point c) mentioned below. After I had clicked on a column, I
>> might want to revert back to the order that the SortedList says the table
>> should display data in. I can't figure out how to do this though. It
>> doesn't
>> seem I can deselected a column sorting. Is this possible?
>>
>> So my main point is this: Why does the method
>> TableComparatorChooser.install
>> take a SortedList when it seems to me that taking an EventList would be
>> just
>> as legitimate.
>>
>> Thanks for any clarification,
>>
>> Nick.
>>
>>
>>
>>
>> James Lemieux wrote:
>> >
>> > Kevin is correct.
>> >
>> > SortedList is a transformation used to create an ordered *view* of any
>> > EventList.
>> >
>> > TableComparatorChooser is simply a big fancy way to interpret mouse
>> clicks
>> > on a column header as a change in the Comparator of a SortedList.
>> >
>> > If the original question posed in this Thread is essentially "why don't
>> > you
>> > just sort data in place, why do you have sorted "views" at all?" that's
>> a
>> > really long winded explanation. Some quick but obvious reasons include:
>> >
>> > a) what if I want 2 different sorted views of the same data?
>> > b) what if the original order has special meaning to my app, and
>> shouldn't
>> > be disturbed?
>> > c) how can I return to the original order after it has been disturbed?
>> >
>> > etc.
>> >
>> > James
>> >
>> > On Thu, Apr 30, 2009 at 11:00 AM, Kevin Day <kevin@...>
>> wrote:
>> >
>> >>  I'm pretty sure that TableComparitorChooser is actually swapping out
>> the
>> >> comparator on your sorted list.
>> >>
>> >> - K
>> >>
>> >>
>> >>  ----------------------- *Original Message* -----------------------
>> >>
>> >> *From:* Boomah <nickdarcy@...> <nickdarcy@...>
>> >> *To:* users@...
>> >> *Cc:*
>> >> *Date:* Thu, 30 Apr 2009 10:41:56 -0700 (PDT)
>> >> *Subject: I don't understand how SortedList and TableComparatorChooser
>> >> work together*
>> >>
>> >>
>> >> Hi people. I don't understand how SortedList and
>> TableComparatorChooser
>> >> work
>> >> together.
>> >>
>> >> I have objects that get added to a SortedList that represent (via my
>> >> TableFormat) a row in a table. The SortedList uses this object to
>> sort,
>> >> and
>> >> if I just use a standard JTable, whenever an object is added to my
>> list,
>> >> it
>> >> gets added to my table in the appropriate position. Everything works
>> >> exactly
>> >> as I would expect.
>> >>
>> >> Now I install a TableComparatorChooser on my JTable. If I start my
>> >> application, I see items being added to the table in the correct
>> position
>> >> given my SortedList as before. However, if I now click on one of the
>> >> columns, it sorts not using my SortedList but by using the objects in
>> the
>> >> column I clicked on. In my case they are all strings and so get sorted
>> >> using
>> >> the standard string comparator.
>> >>
>> >> I don't understand why the TableComparatorChooser requires a
>> SortedList
>> >> if
>> >> once the user clicks on a column, it gets sorted by th e objects it
>> >> contains.
>> >> Why isn't it possible to use an EventList?
>> >>
>> >> It feels like I'm missing something obvious, but I think that
>> SortedList
>> >> and
>> >> TableComparatorChooser completely work against each other and should
>> be
>> >> separated.
>> >>
>> >> Have I completely missed the point?
>> >>
>> >> Thanks, Nick.
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/I-don%27t-understand-how-SortedList-and-TableComparatorChooser-work-together-tp23321078p23321078.html
>> >> Sent from the GlazedLists - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@...
>> >> For additional commands, e-ma il: users-help@...
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> To
>> >> unsubscribe, e-mail: users-unsubscribe@... For
>> >> additional commands, e-mail: users-help@...
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/I-don%27t-understand-how-SortedList-and-TableComparatorChooser-work-together-tp23321078p23329393.html
>> Sent from the GlazedLists - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@...
>> For additional commands, e-mail: users-help@...
>>
>>
>
>

--
View this message in context: http://www.nabble.com/I-don%27t-understand-how-SortedList-and-TableComparatorChooser-work-together-tp23321078p23487034.html
Sent from the GlazedLists - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...