/** Callback if a child has been inserted. * <p>Default: invalidate if it is the paging mold and it affects * the view of the active page. * @since 3.0.5 */ protected void afterInsert(Component comp) { if (_isReplacingRow) //@see Grid.Renderer#render return; //called by #insertBefore(), skip handling item count, etc. updateVisibleCount((Row) comp, false); checkInvalidateForMoved(comp, false); }
/** Callback if a child will be removed (not removed yet). * <p>Default: invalidate if it is the paging mold and it affects * the view of the active page. * @since 3.0.5 */ protected void beforeRemove(Component comp) { if (_isReplacingRow) //@see Grid.Renderer#render return; //called by #removeChild(), skip handling item count, etc. updateVisibleCount((Row) comp, true); checkInvalidateForMoved(comp, true); }
public boolean insertBefore(Component child, Component refChild) { final Grid grid = getGrid(); final boolean isReorder = child.getParent() == this; //bug #3051305: Active Page not update when drag & drop item to the end if (isReorder) { checkInvalidateForMoved(child, true); } Row newItem = (Row) child; final int jfrom = hasGroup() && newItem.getParent() == this ? newItem.getIndex() : -1; fixGroupsInfoBeforeInsert(newItem, (Row) refChild, isReorder); if (super.insertBefore(child, refChild)) { final int jto = refChild instanceof Row ? ((Row) refChild).getIndex() : -1, fixFrom = jfrom < 0 || (jto >= 0 && jfrom > jto) ? jto : jfrom; if (fixFrom < 0) { newItem.setIndexDirectly( getChildren().size() - 1 + (grid != null ? grid.getDataLoader().getOffset() : 0)); } else { fixGroupIndex(fixFrom, jfrom >= 0 && jto >= 0 ? jfrom > jto ? jfrom : jto : -1, !isReorder); } fixGroupsInfoAfterInsert(newItem); //bug #3049167: Totalsize increase when drag & drop in paging Listbox/Grid if (!isReorder) { afterInsert(child); } return true; } return false; }