private AbstractField createBooleanField(Object propertyId) { ComboBox booleanSelect = new ComboBox(); booleanSelect.addItem(true); booleanSelect.addItem(false); if (owner.getFilterDecorator() != null) { /* Add possible 'view all' item */ if (owner.getFilterDecorator().getAllItemsVisibleString() != null) { Object nullItem = booleanSelect.addItem(); booleanSelect.setNullSelectionItemId(nullItem); booleanSelect.setItemCaption( nullItem, owner.getFilterDecorator().getAllItemsVisibleString()); } String caption = owner.getFilterDecorator().getBooleanFilterDisplayName(propertyId, true); booleanSelect.setItemCaption(true, caption == null ? "true" : caption); Resource icon = owner.getFilterDecorator().getBooleanFilterIcon(propertyId, true); if (icon != null) { booleanSelect.setItemIcon(true, icon); } caption = owner.getFilterDecorator().getBooleanFilterDisplayName(propertyId, false); booleanSelect.setItemCaption(false, caption == null ? "false" : caption); icon = owner.getFilterDecorator().getBooleanFilterIcon(propertyId, false); if (icon != null) { booleanSelect.setItemIcon(false, icon); } } else { booleanSelect.setItemCaption(true, "true"); booleanSelect.setItemCaption(false, "false"); } booleans.put(booleanSelect, propertyId); return booleanSelect; }
@SuppressWarnings({"rawtypes", "unchecked"}) private AbstractField createEnumField(Class<?> type, Object propertyId) { ComboBox enumSelect = new ComboBox(); /* Add possible 'view all' item */ if (owner.getFilterDecorator() != null && owner.getFilterDecorator().getAllItemsVisibleString() != null) { Object nullItem = enumSelect.addItem(); enumSelect.setNullSelectionItemId(nullItem); enumSelect.setItemCaption(nullItem, owner.getFilterDecorator().getAllItemsVisibleString()); } /* Add items from enumeration */ for (Object o : EnumSet.allOf((Class<Enum>) type)) { enumSelect.addItem(o); if (owner.getFilterDecorator() != null) { String caption = owner.getFilterDecorator().getEnumFilterDisplayName(propertyId, o); enumSelect.setItemCaption(o, caption == null ? o.toString() : caption); Resource icon = owner.getFilterDecorator().getEnumFilterIcon(propertyId, o); if (icon != null) { enumSelect.setItemIcon(o, icon); } } else { enumSelect.setItemCaption(o, o.toString()); } } enums.put(enumSelect, propertyId); return enumSelect; }