Update on TreeList causes loss of selection

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

Update on TreeList causes loss of selection

Holger
Hey guys,

happy new year to all. I hope you're doing fine.

We recently came across a small problem with TreeList.
The following test case fails (the last assertion).
An EventSelectionModel based on a TreeList looses
its selection when an update happens on the selected element
in the source list.
Looks like a bug to me or what do you think?

Thanks,
Holger

----
public class TreeListTestCase extends SwingTestCase {

    public void guiTestTreeListSelection() {
        final EventList<String> source = new BasicEventList<String>();
        source.add("zero");
        source.add("one");
        source.add("two");
        source.add("three");

        final EventList<String> sourceProxy = GlazedListsSwing.swingThreadProxyList(source);
        final TreeList<String> treeList = new TreeList<String>(sourceProxy, new StringFormat(),
                TreeList.NODES_START_EXPANDED);
        final EventSelectionModel<String> selModel = new EventSelectionModel<String>(treeList);
        selModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        selModel.setSelectionInterval(2, 2);
        assertEquals(Arrays.asList("two"), selModel.getSelected());
        source.set(2, source.get(2));
        assertEquals(Arrays.asList("two"), selModel.getSelected());
    }

    private static class StringFormat implements TreeList.Format<String> {
        public boolean allowsChildren(String element) {
            return element.equals("zero");
        }
        public Comparator<? extends String> getComparator(int depth) {
            return null;
        }
        public void getPath(List<String> path, String element) {
             if (!element.equals("zero")) {
                 getPath(path, "zero");
             }
             path.add(element);
        }
    }
}

_______________________________________________________________________
Sensationsangebot verlängert: WEB.DE FreeDSL - Telefonanschluss + DSL
für nur 16,37 Euro/mtl.!* http://dsl.web.de/?ac=OM.AD.AD008K15039B7069a


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

Reply | Threaded
Open this post in threaded view
|

Re: Update on TreeList causes loss of selection

James Lemieux
I'm gonna see if Jesse has time to look at this bug and give a quick idea of the Level of Effort to fix.

J

On Wed, Jan 7, 2009 at 7:44 AM, Holger Brands <[hidden email]> wrote:
Hey guys,

happy new year to all. I hope you're doing fine.

We recently came across a small problem with TreeList.
The following test case fails (the last assertion).
An EventSelectionModel based on a TreeList looses
its selection when an update happens on the selected element
in the source list.
Looks like a bug to me or what do you think?

Thanks,
Holger

----
public class TreeListTestCase extends SwingTestCase {

   public void guiTestTreeListSelection() {
       final EventList<String> source = new BasicEventList<String>();
       source.add("zero");
       source.add("one");
       source.add("two");
       source.add("three");

       final EventList<String> sourceProxy = GlazedListsSwing.swingThreadProxyList(source);
       final TreeList<String> treeList = new TreeList<String>(sourceProxy, new StringFormat(),
               TreeList.NODES_START_EXPANDED);
       final EventSelectionModel<String> selModel = new EventSelectionModel<String>(treeList);
       selModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
       selModel.setSelectionInterval(2, 2);
       assertEquals(Arrays.asList("two"), selModel.getSelected());
       source.set(2, source.get(2));
       assertEquals(Arrays.asList("two"), selModel.getSelected());
   }

   private static class StringFormat implements TreeList.Format<String> {
       public boolean allowsChildren(String element) {
           return element.equals("zero");
       }
       public Comparator<? extends String> getComparator(int depth) {
           return null;
       }
       public void getPath(List<String> path, String element) {
            if (!element.equals("zero")) {
                getPath(path, "zero");
            }
            path.add(element);
       }
   }
}

_______________________________________________________________________
Sensationsangebot verlängert: WEB.DE FreeDSL - Telefonanschluss + DSL
für nur 16,37 Euro/mtl.!* http://dsl.web.de/?ac=OM.AD.AD008K15039B7069a


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


Reply | Threaded
Open this post in threaded view
|

Re: Update on TreeList causes loss of selection

Holger
In reply to this post by Holger
Ok,
I added test EventSelectionModelTest.guiTestSelectionOnTreeListUpdate_FixMe()
and issue
https://glazedlists.dev.java.net/issues/show_bug.cgi?id=462
for this.

Holger

>I'm gonna see if Jesse has time to look at this bug and give a quick
> idea of the Level of Effort to fix.
>
> J
>
> On Wed, Jan 7, 2009 at 7:44 AM, Holger Brands <[hidden email]> wrote:
> Hey guys,
>
> happy new year to all. I hope you're doing fine.
>
> We recently came across a small problem with TreeList.
> The following test case fails (the last assertion).
> An EventSelectionModel based on a TreeList looses
> its selection when an update happens on the selected element
> in the source list.
> Looks like a bug to me or what do you think?
>
> Thanks,
> Holger
>
> ----
> public class TreeListTestCase extends SwingTestCase {
>
>  public void guiTestTreeListSelection() {
>  final EventList<String> source = new BasicEventList<String>();
>  source.add("zero");
>  source.add("one");
>  source.add("two");
>  source.add("three");
>
>  final EventList<String> sourceProxy = GlazedListsSwing.swingThreadProx
> yList(source);
>  final TreeList<String> treeList = new TreeList<String>(sourceProxy,
> new StringFormat(),
>  TreeList.NODES_START_EXPANDED);
>  final EventSelectionModel<String> selModel = new EventSelectionModel<
> String>(treeList);
>  selModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
>  selModel.setSelectionInterval(2, 2);
>  assertEquals(Arrays.asList("two"), selModel.getSelected());
>  source.set(2, source.get(2));
>  assertEquals(Arrays.asList("two"), selModel.getSelected());
>  }
>
>  private static class StringFormat implements TreeList.Format<String>
> {
>  public boolean allowsChildren(String element) {
>  return element.equals("zero");
>  }
>  public Comparator<? extends String> getComparator(int depth) {
>  return null;
>  }
>  public void getPath(List<String> path, String element) {
>  if (!element.equals("zero")) {
>  getPath(path, "zero");
>  }
>  path.add(element);
>  }
>  }
> }
>
> ______________________________________________________________________
> _
> Sensationsangebot verlängert: WEB.DE FreeDSL - Telefonanschluss + DSL
> für nur 16,37 Euro/mtl.!* http://dsl.web.de/?ac=OM.AD.AD008K15039B7069a
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>


____________________________________________________________________
Psssst! Schon vom neuen WEB.DE MultiMessenger gehört?
Der kann`s mit allen: http://www.produkte.web.de/messenger/?did=3123


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