ListEvent - TableModelEvent translation

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

ListEvent - TableModelEvent translation

Holger
Hey James,

the recent change for EventTableModel we discussed
has a side effect:
When a complex list event with blocks gets translated to
a "data changed" table model event, the current selection
is lost. This is because JTable clears the selection, when
it receives an event with lastRow == Integer.MAX_VALUE.

Attached is an example test with debug output.

Holger

---

    public void guiTestRemoveInBlock() {
        final EventList<String> list = new BasicEventList<String>();
        list.addListEventListener(new ListEventListener<String>() {
            public void listChanged(ListEvent<String> listChanges) {
                System.out.println(listChanges);
            }
        });
        final EventSelectionModel selModel = new EventSelectionModel<String>(list);
        list.addAll(GlazedListsTests.delimitedStringToList("A B C D E F"));

        final EventTableModel<String> model = new EventTableModel<String>(list,
                GlazedLists.tableFormat(new String[] {"bytes"}, new String [] {"Bytes"}));
        model.addTableModelListener(new TableModelListener() {
            public void tableChanged(TableModelEvent e) {
               System.out.println("tableChanged " + e);
            }
        });
        final JTable table = new JTable(model);
        table.setSelectionModel(selModel);
        selModel.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                System.out.println("listselectionChanged: " + e);
            }
        });

        selModel.setSelectionInterval(1, 1);
        assertEquals(Arrays.asList("B"), selModel.getSelected());
        assertEquals(GlazedListsTests.delimitedStringToList("A C D E F"), selModel.getDeselected());
        System.out.println("removing in blocks...");
        list.removeAll(GlazedListsTests.delimitedStringToList("E F"));
        assertEquals(Arrays.asList("B"), selModel.getSelected());
        assertEquals(Arrays.asList("A", "C", "D"), selModel.getDeselected());
    }

_________________________________________________________________________
Mit der Gruppen-SMS von WEB.DE FreeMail können Sie eine SMS an alle
Freunde gleichzeitig schicken: http://freemail.web.de/features/?mc=021179




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: ListEvent - TableModelEvent translation

James Lemieux
I guess this is the evidence that pushes us back to having a method on EventTableModel that lets you choose your behaviour? Or do we restore the original behaviour and tell JXTable people to subclass EventTableModel themselves to add in the logic for firing a single TableModelEvent?

None of these solutions are particularly appealing...

James

On Fri, Apr 4, 2008 at 5:03 AM, Holger Brands <[hidden email]> wrote:
Hey James,

the recent change for EventTableModel we discussed
has a side effect:
When a complex list event with blocks gets translated to
a "data changed" table model event, the current selection
is lost. This is because JTable clears the selection, when
it receives an event with lastRow == Integer.MAX_VALUE.

Attached is an example test with debug output.

Holger

---

   public void guiTestRemoveInBlock() {
       final EventList<String> list = new BasicEventList<String>();
       list.addListEventListener(new ListEventListener<String>() {
           public void listChanged(ListEvent<String> listChanges) {
               System.out.println(listChanges);
           }
       });
       final EventSelectionModel selModel = new EventSelectionModel<String>(list);
       list.addAll(GlazedListsTests.delimitedStringToList("A B C D E F"));

       final EventTableModel<String> model = new EventTableModel<String>(list,
               GlazedLists.tableFormat(new String[] {"bytes"}, new String [] {"Bytes"}));
       model.addTableModelListener(new TableModelListener() {
           public void tableChanged(TableModelEvent e) {
              System.out.println("tableChanged " + e);
           }
       });
       final JTable table = new JTable(model);
       table.setSelectionModel(selModel);
       selModel.addListSelectionListener(new ListSelectionListener() {
           public void valueChanged(ListSelectionEvent e) {
               System.out.println("listselectionChanged: " + e);
           }
       });

       selModel.setSelectionInterval(1, 1);
       assertEquals(Arrays.asList("B"), selModel.getSelected());
       assertEquals(GlazedListsTests.delimitedStringToList("A C D E F"), selModel.getDeselected());
       System.out.println("removing in blocks...");
       list.removeAll(GlazedListsTests.delimitedStringToList("E F"));
       assertEquals(Arrays.asList("B"), selModel.getSelected());
       assertEquals(Arrays.asList("A", "C", "D"), selModel.getDeselected());
   }

_________________________________________________________________________
Mit der Gruppen-SMS von WEB.DE FreeMail können Sie eine SMS an alle
Freunde gleichzeitig schicken: http://freemail.web.de/features/?mc=021179




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: ListEvent - TableModelEvent translation

Holger
In reply to this post by Holger

Please note, that in the posted test EventSelectionModel fires a ListSelectionEvent
indicating an existing selection, but method getSelected() returns an empty list.
So there is an inconsistency we've to fix I guess.

Anyway, I tried the current GL version with our app and we observed weird behaviour.
For example, the demonstrated issue applies in one of the most typical
use cases: using a live text filter almost always leads to a "table data changed" event.
I don't think this behaviour is acceptable at all.

Holger

>I guess this is the evidence that pushes us back to having a method on EventTableModel that lets you choose your behaviour? Or do we restore the original behaviour and tell JXTable people to subclass EventTableModel themselves to add in the logic for firing a single TableModelEvent?
>
> None of these solutions are particularly appealing...
>
> James
>
>
> On Fri, Apr 4, 2008 at 5:03 AM, Holger Brands <[hidden email]> wrote:
> Hey James,
>
> the recent change for EventTableModel we discussed
> has a side effect:
> When a complex list event with blocks gets translated to
> a "data changed" table model event, the current selection
> is lost. This is because JTable clears the selection, when
> it receives an event with lastRow == Integer.MAX_VALUE.
>
> Attached is an example test with debug output.
>
> Holger
>
> ---
>
>     public void guiTestRemoveInBlock() {
>         final EventList<String> list = new BasicEventList<String>();
>         list.addListEventListener(new ListEventListener<String>() {
>             public void listChanged(ListEvent<String> listChanges) {
>                 System.out.println(listChanges);
>             }
>         });
>         final EventSelectionModel selModel = new EventSelectionModel<String>(list);
>         list.addAll(GlazedListsTests.delimitedStringToList("A B C D E F"));
>
>         final EventTableModel<String> model = new EventTableModel<String>(list,
>                 GlazedLists.tableFormat(new String[] {"bytes"}, new String [] {"Bytes"}));
>         model.addTableModelListener(new TableModelListener() {
>             public void tableChanged(TableModelEvent e) {
>                System.out.println("tableChanged " + e);
>             }
>         });
>         final JTable table = new JTable(model);
>         table.setSelectionModel(selModel);
>         selModel.addListSelectionListener(new ListSelectionListener() {
>             public void valueChanged(ListSelectionEvent e) {
>                 System.out.println("listselectionChanged: " + e);
>             }
>         });
>
>         selModel.setSelectionInterval(1, 1);
>         assertEquals(Arrays.asList("B"), selModel.getSelected());
>         assertEquals(GlazedListsTests.delimitedStringToList("A C D E F"), selModel.getDeselected());
>         System.out.println("removing in blocks...");
>         list.removeAll(GlazedListsTests.delimitedStringToList("E F"));
>         assertEquals(Arrays.asList("B"), selModel.getSelected());
>         assertEquals(Arrays.asList("A", "C", "D"), selModel.getDeselected());
>     }
>
> _________________________________________________________________________
> Mit der Gruppen-SMS von WEB.DE FreeMail können Sie eine SMS an alle
> Freunde gleichzeitig schicken: http://freemail.web.de/features/?mc=021179
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>


_________________________________________________________________________
Mit der Gruppen-SMS von WEB.DE FreeMail können Sie eine SMS an alle
Freunde gleichzeitig schicken: http://freemail.web.de/features/?mc=021179




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: ListEvent - TableModelEvent translation

Holger
In reply to this post by Holger
I just upgraded our SwingX extension to the latest SwingX version 0.9.2.
JXTable also has the selection lost problem. Just try our JXTableTestApp.
Maybe we find a workaround for this problem...

Holger

>
>
> Please note, that in the posted test EventSelectionModel fires a ListSelectionEvent
> indicating an existing selection, but method getSelected() returns an empty list.
> So there is an inconsistency we've to fix I guess.
>
> Anyway, I tried the current GL version with our app and we observed weird behaviour.
> For example, the demonstrated issue applies in one of the most typical
> use cases: using a live text filter almost always leads to a "table data changed" event.
> I don't think this behaviour is acceptable at all.
>
> Holger
>
> >I guess this is the evidence that pushes us back to having a method on EventTableModel that lets you choose your behaviour? Or do we restore the original behaviour and tell JXTable people to subclass EventTableModel themselves to add in the logic for firing a single TableModelEvent?
> >
> > None of these solutions are particularly appealing...
> >
> > James
> >
> >
> > On Fri, Apr 4, 2008 at 5:03 AM, Holger Brands <[hidden email]> wrote:
> > Hey James,
> >
> > the recent change for EventTableModel we discussed
> > has a side effect:
> > When a complex list event with blocks gets translated to
> > a "data changed" table model event, the current selection
> > is lost. This is because JTable clears the selection, when
> > it receives an event with lastRow == Integer.MAX_VALUE.
> >
> > Attached is an example test with debug output.
> >
> > Holger
> >
> > ---
> >
> >     public void guiTestRemoveInBlock() {
> >         final EventList<String> list = new BasicEventList<String>();
> >         list.addListEventListener(new ListEventListener<String>() {
> >             public void listChanged(ListEvent<String> listChanges) {
> >                 System.out.println(listChanges);
> >             }
> >         });
> >         final EventSelectionModel selModel = new EventSelectionModel<String>(list);
> >         list.addAll(GlazedListsTests.delimitedStringToList("A B C D E F"));
> >
> >         final EventTableModel<String> model = new EventTableModel<String>(list,
> >                 GlazedLists.tableFormat(new String[] {"bytes"}, new String [] {"Bytes"}));
> >         model.addTableModelListener(new TableModelListener() {
> >             public void tableChanged(TableModelEvent e) {
> >                System.out.println("tableChanged " + e);
> >             }
> >         });
> >         final JTable table = new JTable(model);
> >         table.setSelectionModel(selModel);
> >         selModel.addListSelectionListener(new ListSelectionListener() {
> >             public void valueChanged(ListSelectionEvent e) {
> >                 System.out.println("listselectionChanged: " + e);
> >             }
> >         });
> >
> >         selModel.setSelectionInterval(1, 1);
> >         assertEquals(Arrays.asList("B"), selModel.getSelected());
> >         assertEquals(GlazedListsTests.delimitedStringToList("A C D E F"), selModel.getDeselected());
> >         System.out.println("removing in blocks...");
> >         list.removeAll(GlazedListsTests.delimitedStringToList("E F"));
> >         assertEquals(Arrays.asList("B"), selModel.getSelected());
> >         assertEquals(Arrays.asList("A", "C", "D"), selModel.getDeselected());
> >     }
> >
> > _________________________________________________________________________
> > Mit der Gruppen-SMS von WEB.DE FreeMail können Sie eine SMS an alle
> > Freunde gleichzeitig schicken: http://freemail.web.de/features/?mc=021179
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
> >
>
>
> _________________________________________________________________________
> Mit der Gruppen-SMS von WEB.DE FreeMail können Sie eine SMS an alle
> Freunde gleichzeitig schicken: http://freemail.web.de/features/?mc=021179
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


_______________________________________________________________
Schon gehört? Der neue WEB.DE MultiMessenger kann`s mit allen:
http://www.produkte.web.de/messenger/?did=3016


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: ListEvent - TableModelEvent translation

Holger
In reply to this post by Holger
Hey James,

some more comments inline ...

>
>
> Please note, that in the posted test EventSelectionModel fires a ListSelectionEvent
> indicating an existing selection, but method getSelected() returns an empty list.
> So there is an inconsistency we've to fix I guess.

Forget this comment, I was wrong here.

>
> Anyway, I tried the current GL version with our app and we observed weird behaviour.
> For example, the demonstrated issue applies in one of the most typical
> use cases: using a live text filter almost always leads to a "table data changed" event.
> I don't think this behaviour is acceptable at all.

Because of the loss of table selection I made the ListEvent-TableModelEvent-translation
configurable. See EventTableModel#setFireOneTableModelEventOnly(boolean).
Default is the old behaviour.

I also added a failing test case related to Jan's latest reported issue:
Combining a reorder event with an EventTableModel that has fireOneTableModelEventOnly==true
in a JTable. Please see
EventTableModelTest.guiTestReorderWithFireOneTableModelEventOnly_FixMe()

One workaround for this problem would be to always fallback to our old
ListEvent-TableModelEvent-translation when a reorder event is encountered in
EventTableModel.

Hopefully there is a better solution ;-)

Holger
_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]