/** * Adds given items with given item ids to container. * * @since 7.2 * @param itemId * item identifiers to be added to underlying container * @throws UnsupportedOperationException * if the underlying container don't support adding items with * identifiers */ public void addItems(Object... itemId) throws UnsupportedOperationException { for (Object id : itemId) { addItem(id); } }
@Override protected void populateWithEnumData(AbstractSelect select, Class<? extends Enum> enumClass) { // Use enums directly and the EnumToStringConverter to be consistent // with what is shown in the Grid @SuppressWarnings("unchecked") EnumSet<?> enumSet = EnumSet.allOf(enumClass); for (Object r : enumSet) { select.addItem(r); } } }
/** * Populates the given select with all the enums in the given {@link Enum} * class. Uses {@link Enum}.toString() for caption. * * @param select * The select to populate * @param enumClass * The Enum class to use */ protected void populateWithEnumData(AbstractSelect select, Class<? extends Enum> enumClass) { select.removeAllItems(); for (Object p : select.getContainerPropertyIds()) { select.removeContainerProperty(p); } select.addContainerProperty(CAPTION_PROPERTY_ID, String.class, ""); select.setItemCaptionPropertyId(CAPTION_PROPERTY_ID); @SuppressWarnings("unchecked") EnumSet<?> enumSet = EnumSet.allOf(enumClass); for (Object r : enumSet) { Item newItem = select.addItem(r); newItem.getItemProperty(CAPTION_PROPERTY_ID).setValue(r.toString()); } } }
@Override public void addNewItem(String newItemCaption) { // Checks for readonly if (isReadOnly()) { throw new Property.ReadOnlyException(); } // Adds new option if (addItem(newItemCaption) != null) { // Sets the caption property, if used if (getItemCaptionPropertyId() != null) { getContainerProperty(newItemCaption, getItemCaptionPropertyId()) .setValue(newItemCaption); } if (isMultiSelect()) { Set values = new HashSet((Collection) getValue()); values.add(newItemCaption); setValue(values); } else { setValue(newItemCaption); } } } }