private View createFieldView(final View view, final Axes axes, final ObjectAdapter object, final ObjectAssociation field, final ObjectAdapter value) {
if (field == null) {
throw new NullPointerException();
}
final GlobalViewFactory factory = Toolkit.getViewFactory();
ViewSpecification cellSpec;
Content content;
if (field instanceof OneToManyAssociation) {
throw new UnexpectedCallException("no collections allowed");
} else if (field instanceof OneToOneAssociation) {
final ObjectSpecification fieldSpecification = field.getSpecification();
if (fieldSpecification.isParseable()) {
content = new TextParseableFieldImpl(object, value, (OneToOneAssociation) field);
// REVIEW how do we deal with IMAGES?
if (content.getAdapter() instanceof ImageValueFacet) {
return new BlankView(content);
}
if (!field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed()) {
return new BlankView(content);
}
if (((TextParseableContent) content).getNoLines() > 0) {
/*
* TODO remove this after introducing constraints into view
* specs that allow the parent view to specify what kind of
* subviews it can deal
*/
if (fieldSpecification.containsFacet(BooleanValueFacet.class)) {
cellSpec = new CheckboxField.Specification();
} else {
cellSpec = new UnlinedTextFieldSpecification();
}
} else {
return factory.createView(new ViewRequirement(content, ViewRequirement.CLOSED));
}
} else {
content = new OneToOneFieldImpl(object, value, (OneToOneAssociation) field);
if (!field.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed()) {
return new BlankView(content);
}
return factory.createView(new ViewRequirement(content, ViewRequirement.CLOSED | ViewRequirement.SUBVIEW));
}
} else {
throw new UnknownTypeException(field);
}
return cellSpec.createView(content, axes, -1);
}