/**/ boolean doSort(boolean ascending) { final Comparator cmpr = ascending ? _sortAsc : _sortDsc; if (cmpr == null) return false; final Listbox box = getListbox(); if (box == null) return false; // comparator might be zscript Scopes.beforeInterpret(this); try { final ListModel model = box.getModel(); boolean isPagingMold = box.inPagingMold(); int activePg = isPagingMold ? box.getPaginal().getActivePage() : 0; if (model != null) { // live data if (model instanceof GroupsSortableModel) { sortGroupsModel(box, (GroupsSortableModel) model, cmpr, ascending); } else { if (!(model instanceof Sortable)) throw new UiException( GroupsSortableModel.class + " or " + Sortable.class + " must be implemented in " + model.getClass().getName()); sortListModel((Sortable) model, cmpr, ascending); } } else { // not live data sort0(box, cmpr); } if (isPagingMold) box.getPaginal().setActivePage(activePg); // Because of maintaining the number of the visible item, we cause // the wrong active page when dynamically add/remove the item (i.e. sorting). // Therefore, we have to reset the correct active page. } finally { Scopes.afterInterpret(); } _ignoreSort = true; // maintain for (Iterator it = box.getListhead().getChildren().iterator(); it.hasNext(); ) { final Listheader hd = (Listheader) it.next(); hd.setSortDirection(hd != this ? "natural" : ascending ? "ascending" : "descending"); } _ignoreSort = false; // sometimes the items at client side are out of date box.invalidate(); return true; }