private static Container createContainer(Collection<?> options) { final Container container = new IndexedContainer(); if (options != null) { for (final Iterator<?> i = options.iterator(); i.hasNext(); ) { container.addItem(i.next()); } } return container; }
/** * Creates a new item into container with container managed id. The id of * the created new item is returned. The item can be fetched with getItem() * method. if the creation fails, null is returned. * * @return the Id of the created item or null in case of failure. * @see Container#addItem() */ @Override public Object addItem() throws UnsupportedOperationException { final Object retval = items.addItem(); if (retval != null && !(items instanceof Container.ItemSetChangeNotifier)) { fireItemSetChange(); } return retval; }
/** * Creates a new Item into the Container, assigns it an automatic ID, and * adds it to the ordering. * * @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 (!ordered && id != null) { addToOrderWrapper(id); } return id; }
/** * 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; }
/** * Registers a new Item by its ID to the underlying container and to the * ordering. * * @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 { final Item item = container.addItem(itemId); if (!ordered && item != null) { addToOrderWrapper(itemId); } return item; }
/** * 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; }
/** * Create a new item into container. The created new item is returned and * ready for setting property values. if the creation fails, null is * returned. In case the container already contains the item, null is * returned. * * This functionality is optional. If the function is unsupported, it always * returns null. * * @param itemId * the Identification of the item to be created. * @return the Created item with the given id, or null in case of failure. * @see Container#addItem(java.lang.Object) */ @Override public Item addItem(Object itemId) throws UnsupportedOperationException { final Item retval = items.addItem(itemId); if (retval != null && !(items instanceof Container.ItemSetChangeNotifier)) { fireItemSetChange(); } return retval; }
@Override public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException { // If the previous item is not in the container, fail if (previousItemId != null && !containsId(previousItemId)) { return null; } // Adds the item to container final Object id = container.addItem(); // Puts the new item to its correct place if (!ordered && id != null) { addToOrderWrapper(id, previousItemId); } return id; }
@Override public Item addItemAfter(Object previousItemId, Object newItemId) throws UnsupportedOperationException { // If the previous item is not in the container, fail if (previousItemId != null && !containsId(previousItemId)) { return null; } // Adds the item to container final Item item = container.addItem(newItemId); // Puts the new item to its correct place if (!ordered && item != null) { addToOrderWrapper(newItemId, previousItemId); } return item; }
/** * Creates a new select that is filled from a collection of option values. * * @param caption * the Caption of this field. * @param options * the Collection containing the options. */ public AbstractSelect(String caption, Collection<?> options) { // Creates the options container and add given options to it final Container c = new IndexedContainer(); if (options != null) { for (final Object item : options) { c.addItem(item); } } setCaption(caption); setContainerDataSource(c); }