use of org.openforis.collect.metamodel.ui.NodeDefinitionUIComponent in project collect by openforis.
the class CollectEarthBalloonGenerator method createTabComponent.
private CETab createTabComponent(EntityDefinition rootEntityDef, UIForm form, boolean main) {
final CollectAnnotations annotations = survey.getAnnotations();
String label = form.getLabel(language);
if (label == null && !isDefaultLanguage()) {
String defaultLanguage = survey.getDefaultLanguage();
label = form.getLabel(defaultLanguage);
}
CETab tab = new CETab(rootEntityDef.getName(), label);
// consider the first tab as the main one
tab.setMain(main);
for (UIFormComponent formComponent : form.getChildren()) {
if (formComponent instanceof NodeDefinitionUIComponent) {
NodeDefinition nodeDef = ((NodeDefinitionUIComponent) formComponent).getNodeDefinition();
if (formComponent instanceof UIField) {
AttributeDefinition attrDef = ((UIField) formComponent).getAttributeDefinition();
String nodeName = nodeDef.getName();
boolean includeInHTML = !(HIDDEN_ATTRIBUTE_NAMES.contains(nodeName) || (annotations.isFromCollectEarthCSV(attrDef) && !annotations.isShowReadOnlyFieldInCollectEarth(attrDef)) || ((UIField) formComponent).isHidden() || ((UIField) formComponent).getAttributeDefinition().isKey());
boolean includeAsAncillaryData = annotations.isIncludedInCollectEarthHeader((AttributeDefinition) nodeDef);
if (includeInHTML) {
CEComponent component = createComponent(nodeDef);
tab.addChild(component);
} else if (includeAsAncillaryData) {
CEAncillaryFields ancillaryDataHeader = tab.getAncillaryDataHeader();
if (ancillaryDataHeader == null) {
ancillaryDataHeader = new CEAncillaryFields("ancillary_data", "Ancillary data");
tab.setAncillaryDataHeader(ancillaryDataHeader);
}
CEComponent component = createComponent(nodeDef);
ancillaryDataHeader.addChild(component);
}
} else if (formComponent instanceof UITable || formComponent instanceof UIFormSection) {
CEComponent component = createComponent(nodeDef);
tab.addChild(component);
} else {
// $NON-NLS-1$
throw new IllegalArgumentException("Form component not supported: " + formComponent.getClass().getName());
}
}
}
return tab;
}
Aggregations