* @param request request
* @throws Exception
*/
protected void rebuildItems(PropertiesForm form, HttpServletRequest request) throws Exception {
configureProperties();
AbstractWizardPropertiesForm pf = (AbstractWizardPropertiesForm) form;
List<PropertyItemImpl> propertyItemImpls = new ArrayList<PropertyItemImpl>();
List<PropertyDefinitionCategory> categoryDefinitions = new ArrayList<PropertyDefinitionCategory>();
Collection<PropertyDefinitionCategory> sourceCategories = null;
int parentCategory = pf.getParentCategory();
for (PropertyClass propertyClass : pf.getPropertyClasses()) {
/*
* If no parent category is supplied, then assume all categories in
* the class, otherwise get all the child categories of the supplied
* one
*/
if (parentCategory == 0) {
sourceCategories = propertyClass.getCategories();
} else {
PropertyDefinitionCategory category = propertyClass.getPropertyDefinitionCategory(parentCategory);
if (category != null) {
sourceCategories = category.getCategories();
} else {
sourceCategories = null;
}
}
if (sourceCategories != null) {
for (PropertyDefinitionCategory def : sourceCategories) {
if (def.isEnabled()) {
categoryDefinitions.add(def);
if (pf.getSelectedCategory() == -1) {
pf.setSelectedCategory(def.getId());
pf.setSelectedTab("category." + def.getId());
}
// TODO needs to more be efficient
for (PropertyDefinition propDef : propertyClass.getDefinitions()) {
if (!propDef.isHidden() && propDef.getCategory() == def.getId()) {
propertyItemImpls.add(new PropertyItemImpl(request, propDef, Property.getProperty(createKey(
propDef, pf))));
}
}
}
}
}
}
PropertyItemImpl[] items = new PropertyItemImpl[propertyItemImpls.size()];
propertyItemImpls.toArray(items);
pf.setPropertyItems(items);
pf.setCategoryDefinitions(categoryDefinitions);
}