/** * Destroy a component and all its children upon finalization. * * @see java.lang.Object#finalize() */ @Override public void finalize() throws Throwable { super.finalize(); if (id != null) { destroy(); } }
/** * Removes all items (except for "custom") from the item list. */ @Override public void clear() { List<BaseComponent> items = getChildren(); for (int i = items.size() - 1; i >= 0; i--) { if (items.get(i) != customItem) { items.get(i).destroy(); } } }
/** * Recursively remove empty menu container elements. This is done after removing menu items to * keep the menu structure lean. * * @param parent The starting menu container. */ public static void pruneMenus(BaseComponent parent) { while (parent != null && parent instanceof BaseMenuComponent) { if (parent.getChildren().isEmpty()) { BaseComponent newParent = parent.getParent(); parent.destroy(); parent = newParent; } else { break; } } }
/** * Destroys the child component corresponding to the model object at the specified index. * * @param modelIndex The index of the model object. */ protected void destroyChild(int modelIndex) { if (paginator.inRange(modelIndex)) { BaseComponent child = parent.getChildAt(getChildIndex(modelIndex)); ModelAndView<T, M> linkedView = linkedViews == null ? null : linkedViews.get(child); if (linkedView != null) { linkedViews.remove(child); linkedView.destroy(); } child.destroy(); } }
/** * If set to true, the user may select "Custom..." from the choice list and enter a custom date * range. If set to false, this choice is hidden and any existing custom entries are removed * from the list. * * @param allowCustom Determines whether or not custom entries are allowed. */ @PropertySetter("allowCustom") public void setAllowCustom(boolean allowCustom) { customItem.setVisible(allowCustom); if (!allowCustom) { BaseComponent sibling; while ((sibling = customItem.getNextSibling()) != null) { sibling.destroy(); } } }
anchor.destroy(); parent.addChild(root, index); break;