/** * Adds a new property to the table and show it as a visible column. * * @param propertyId * the Id of the property. * @param type * the class of the property. * @param defaultValue * the default value given for all existing items. * @see Container#addContainerProperty(Object, Class, Object) */ @Override public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) throws UnsupportedOperationException { boolean visibleColAdded = false; if (!visibleColumns.contains(propertyId)) { visibleColumns.add(propertyId); visibleColAdded = true; } if (!super.addContainerProperty(propertyId, type, defaultValue)) { if (visibleColAdded) { visibleColumns.remove(propertyId); } return false; } if (!(items instanceof Container.PropertySetChangeNotifier)) { refreshRowCache(); } return true; }
/** * 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()); } } }
newField.addContainerProperty("desc", String.class, ""); newField.setItemCaptionPropertyId("desc"); for (int i = 0; i < values.length; i++) {