/** * Creates a new Item into the Container, assigns it an automatic ID, and * adds it to the hierarchy. * * @return the autogenerated ID of the new Item or <code>null</code> if the * operation failed * @throws UnsupportedOperationException * if the addItem is not supported. */ @Override public Object addItem() throws UnsupportedOperationException { final Object id = container.addItem(); if (!hierarchical && id != null) { addToHierarchyWrapper(id); } return id; }
/** * Adds a new Item by its ID to the underlying container and to the * hierarchy. * * @param itemId * the ID of the Item to be created. * @return the added Item or <code>null</code> if the operation failed. * @throws UnsupportedOperationException * if the addItem is not supported. */ @Override public Item addItem(Object itemId) throws UnsupportedOperationException { // Null ids are not accepted if (itemId == null) { return null; } final Item item = container.addItem(itemId); if (!hierarchical && item != null) { addToHierarchyWrapper(itemId); } return item; }
@Override protected void addToHierarchyWrapper(Object itemId) { super.addToHierarchyWrapper(itemId); // Add item to the end of the list if (!inline.contains(itemId)) { inline.add(itemId); if (areChildrenAllowed(itemId)) { makeInlineElements(inline, getChildren(itemId)); } } }
for (final Object id : ids) { if (!s.contains(id)) { addToHierarchyWrapper(id); s.add(id);