java - NatTable sorting with custom comparator -
i looking @ (509_sortheaderlayer.java) example reference point.
i add custom comparator directly sortedlist shown in example below. however, when click on columns in debugger, custom comparator never reaches breakpoint set in first line of compare() method.
if add comparator abstractregistryconfiguration works expected (the breakpoint reached when click on column).
why setting comparator in sortedlists constructor not work expected? general code snippets shown below:
public void setsortcomparatorworks() { sortedlist<t> sortedlist = new sortedlist<>(eventlist, null); init(sortedlist); getnattable().addconfiguration(new abstractregistryconfiguration() { @override public void configureregistry(iconfigregistry configregistry) { configregistry.registerconfigattribute(sortconfigattributes. sort_comparator, new mycomparator<t>(), displaymode.normal); } }); getnattable().configure(); } public void setsortcomparatordoesntwork() { sortedlist<t> sortedlist = new sortedlist<>(eventlist, new mycomparator<t>); init(sortedlist); getnattable().configure(); } private void init(sortedlist sortedlist){ this.bodydataprovider = new listdataprovider<>(sortedlist, columnpropertyaccessor); this.bodydatalayer = new datalayer(this.bodydataprovider); this.bodylayerstack = new defaultbodylayerstack(new glazedlistseventlayer<>(this.bodydatalayer, eventlist)); this.columnheaderlayerstack = new glazedlistscolumnheaderlayerstack<>( columnheaderdataprovider, sortedlist, columnpropertyaccessor, configregistry, this.bodylayerstack); this.sortheaderlayer = new sortheaderlayer<>(columnheaderlayerstack, new glazedlistssortmodel<t>(sortedlist, columnpropertyaccessor, configregistry, bodydatalayer), false); setchildlayer(gridregion.column_header, sortheaderlayer, 0, 0); setchildlayer(gridregion.body, bodylayerstack, 0, 1); getnattable().addconfiguration(new singleclicksortconfiguration()); }
it not work expect, because internal function replace existing comparator
on sortedlist
comparator
derived out of configregistry
, current applied sort state.
btw, interesting refer _509_sortheaderlayerexample
while example glazedlists _602_glazedlistssortingexample
.
Comments
Post a Comment