use of com.manydesigns.elements.fields.search.SearchField in project Portofino by ManyDesigns.
the class BooleanFieldHelper method tryToInstantiateSearchField.
public SearchField tryToInstantiateSearchField(ClassAccessor classAccessor, PropertyAccessor propertyAccessor, String prefix) {
SearchField result;
Class type = propertyAccessor.getType();
if (type == Boolean.class || type == Boolean.TYPE) {
result = new BooleanSearchField(propertyAccessor, prefix);
} else {
result = null;
}
return result;
}
use of com.manydesigns.elements.fields.search.SearchField in project Portofino by ManyDesigns.
the class SearchForm method toXhtml.
public void toXhtml(@NotNull XhtmlBuffer xb) {
xb.openElement("div");
xb.addAttribute("class", "searchform");
for (SearchField current : this) {
current.toXhtml(xb);
}
xb.closeElement("div");
}
use of com.manydesigns.elements.fields.search.SearchField in project Portofino by ManyDesigns.
the class SearchFormBuilder method build.
// **************************************************************************
// Building
// **************************************************************************
public SearchForm build() {
logger.debug("build");
SearchForm searchForm = new SearchForm();
FieldsManager manager = FieldsManager.getManager();
if (propertyAccessors == null) {
configReflectiveFields();
}
Map<String, SearchField> fieldMap = new HashMap<String, SearchField>();
for (PropertyAccessor propertyAccessor : propertyAccessors) {
SearchField field = null;
String fieldName = propertyAccessor.getName();
for (Map.Entry<String[], SelectionProvider> current : selectionProviders.entrySet()) {
String[] fieldNames = current.getKey();
int index = ArrayUtils.indexOf(fieldNames, fieldName);
if (index >= 0) {
field = new SelectSearchField(propertyAccessor, current.getValue(), prefix);
break;
}
}
if (field == null) {
field = manager.tryToInstantiateSearchField(classAccessor, propertyAccessor, prefix);
}
if (field == null) {
logger.warn("Cannot instantiate field for property {}", propertyAccessor);
continue;
}
fieldMap.put(fieldName, field);
searchForm.add(field);
}
// handle cascaded select fields
for (Map.Entry<String[], SelectionProvider> current : selectionProviders.entrySet()) {
String[] fieldNames = current.getKey();
SelectionProvider selectionProvider = current.getValue();
SelectionModel selectionModel = selectionProvider.createSelectionModel();
SelectSearchField previousField = null;
for (int i = 0; i < fieldNames.length; i++) {
SelectSearchField selectSearchField = (SelectSearchField) fieldMap.get(fieldNames[i]);
if (selectSearchField == null) {
previousField = null;
continue;
}
selectSearchField.setSelectionModel(selectionModel);
selectSearchField.setSelectionModelIndex(i);
if (previousField != null) {
selectSearchField.setPreviousSelectField(previousField);
previousField.setNextSelectField(selectSearchField);
}
previousField = selectSearchField;
}
}
return searchForm;
}
Aggregations