use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.
the class EntityDefinitionProxy method getLayout.
@ExternalizedProperty
public String getLayout() {
CollectSurvey survey = (CollectSurvey) entityDefinition.getSurvey();
UIOptions uiOpts = survey.getUIOptions();
Layout layout = uiOpts.getLayout(entityDefinition);
return layout.name().toLowerCase(Locale.ENGLISH);
}
use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.
the class NodeDefinitionProxy method fromList.
static List<NodeDefinitionProxy> fromList(EntityDefinitionProxy parent, List<? extends NodeDefinition> list) {
List<NodeDefinitionProxy> proxies = new ArrayList<NodeDefinitionProxy>();
if (list != null) {
for (NodeDefinition n : list) {
NodeDefinitionProxy p = null;
CollectSurvey survey = (CollectSurvey) n.getSurvey();
UIOptions uiOptions = survey.getUIOptions();
boolean hidden = uiOptions.isHidden(n);
if (!hidden) {
if (n instanceof AttributeDefinition) {
if (n instanceof BooleanAttributeDefinition) {
p = new BooleanAttributeDefinitionProxy(parent, (BooleanAttributeDefinition) n);
} else if (n instanceof CodeAttributeDefinition) {
p = new CodeAttributeDefinitionProxy(parent, (CodeAttributeDefinition) n);
} else if (n instanceof CoordinateAttributeDefinition) {
p = new CoordinateAttributeDefinitionProxy(parent, (CoordinateAttributeDefinition) n);
} else if (n instanceof DateAttributeDefinition) {
p = new DateAttributeDefinitionProxy(parent, (DateAttributeDefinition) n);
} else if (n instanceof FileAttributeDefinition) {
p = new FileAttributeDefinitionProxy(parent, (FileAttributeDefinition) n);
} else if (n instanceof NumberAttributeDefinition) {
p = new NumberAttributeDefinitionProxy(parent, (NumberAttributeDefinition) n);
} else if (n instanceof RangeAttributeDefinition) {
p = new RangeAttributeDefinitionProxy(parent, (RangeAttributeDefinition) n);
} else if (n instanceof TaxonAttributeDefinition) {
p = new TaxonAttributeDefinitionProxy(parent, (TaxonAttributeDefinition) n);
} else if (n instanceof TextAttributeDefinition) {
p = new TextAttributeDefinitionProxy(parent, (TextAttributeDefinition) n);
} else if (n instanceof TimeAttributeDefinition) {
p = new TimeAttributeDefinitionProxy(parent, (TimeAttributeDefinition) n);
} else {
throw new RuntimeException("AttributeDefinition not supported: " + n.getClass().getSimpleName());
}
} else if (n instanceof EntityDefinition) {
p = new EntityDefinitionProxy(parent, (EntityDefinition) n);
}
if (p != null) {
proxies.add(p);
}
}
}
}
return proxies;
}
use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.
the class EntityProxy method getAvailableChildDefinitions.
private List<NodeDefinition> getAvailableChildDefinitions() {
List<NodeDefinition> result = new ArrayList<NodeDefinition>();
UIOptions uiOptions = ((CollectSurvey) entity.getSurvey()).getUIOptions();
for (NodeDefinition childDefinition : getChildDefinitions()) {
if (isApplicable(childDefinition) && !uiOptions.isHidden(childDefinition)) {
result.add(childDefinition);
}
}
return result;
}
use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.
the class UITabPR method onStartTag.
@Override
protected void onStartTag() throws XmlParseException, XmlPullParserException, IOException {
String name = getAttribute(NAME, false);
UIOptions uiOptions = parentTabSet.getUIOptions();
tabSet = uiOptions.createTab(name);
}
use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.
the class NodeDefinitionFormObject method loadFrom.
@Override
public void loadFrom(T source, String language) {
super.loadFrom(source, language);
CollectSurvey survey = (CollectSurvey) source.getSurvey();
UIOptions uiOptions = survey.getUIOptions();
// generic
name = source.getName();
multiple = source.isMultiple();
if (source.isAlwaysRequired()) {
requirenessType = RequirenessType.ALWAYS_REQUIRED.name();
} else {
requiredWhenExpression = source.extractRequiredExpression();
if (requiredWhenExpression == null) {
requirenessType = RequirenessType.NOT_REQUIRED.name();
} else {
requirenessType = RequirenessType.REQUIRED_WHEN.name();
}
}
relevanceType = source.getRelevantExpression() == null ? RelevanceType.ALWAYS_RELEVANT.name() : RelevanceType.RELEVANT_WHEN.name();
relevantExpression = source.getRelevantExpression();
minCountExpression = source.getMinCountExpression();
maxCountExpression = multiple ? source.getMaxCountExpression() : null;
// labels
headingLabel = source.getLabel(Type.HEADING, language);
instanceLabel = source.getLabel(Type.INSTANCE, language);
numberLabel = source.getLabel(Type.NUMBER, language);
abbreviatedLabel = source.getLabel(Type.ABBREVIATED, language);
reportingLabel = source.getLabel(Type.REPORTING, language);
interviewPromptLabel = source.getPrompt(Prompt.Type.INTERVIEW, language);
paperPromptLabel = source.getPrompt(Prompt.Type.PAPER, language);
handheldPromptLabel = source.getPrompt(Prompt.Type.HANDHELD, language);
pcPromptLabel = source.getPrompt(Prompt.Type.PC, language);
description = source.getDescription(language);
defaultInstanceLabel = source.getLabel(Type.INSTANCE);
defaultHeadingLabel = source.getLabel(Type.HEADING);
defaultDescription = source.getDescription();
// layout
hideWhenNotRelevant = uiOptions.isHideWhenNotRelevant(source);
column = uiOptions.getColumn(source);
columnSpan = uiOptions.getColumnSpan(source);
width = uiOptions.getWidth(source);
labelWidth = uiOptions.getLabelWidth(source);
labelOrientation = uiOptions.getLabelOrientation(source).name();
CollectAnnotations annotations = survey.getAnnotations();
autoGenerateMinItems = annotations.isAutoGenerateMinItems(source);
if (source instanceof AttributeDefinition) {
fromCollectEarthCSV = annotations.isFromCollectEarthCSV((AttributeDefinition) source);
includedInCollectEarthHeader = annotations.isIncludedInCollectEarthHeader((AttributeDefinition) source);
showReadOnlyFieldInCollectEarth = annotations.isShowReadOnlyFieldInCollectEarth((AttributeDefinition) source);
hideKeyInCollectEarthRecordList = annotations.isHideKeyInCollectEarthRecordList((AttributeDefinition) source);
showInSummary = annotations.isShowInSummary((AttributeDefinition) source);
qualifier = annotations.isQualifier((AttributeDefinition) source);
}
if (source instanceof Calculable) {
calculated = ((Calculable) source).isCalculated();
// show in UI
showInUI = !uiOptions.isHidden(source);
includeInDataExport = annotations.isIncludedInDataExport(source);
}
backgroundColor = annotations.getBackgroundColor(source);
backgroundTransparency = fromAlphaToTransparency(annotations.getBackgroundAlpha(source));
}
Aggregations