Search in sources :

Example 36 with UIOptions

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);
}
Also used : Layout(org.openforis.collect.metamodel.ui.UIOptions.Layout) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) CollectSurvey(org.openforis.collect.model.CollectSurvey) ExternalizedProperty(org.granite.messaging.amf.io.util.externalizer.annotation.ExternalizedProperty)

Example 37 with UIOptions

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;
}
Also used : TaxonAttributeDefinition(org.openforis.idm.metamodel.TaxonAttributeDefinition) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) ArrayList(java.util.ArrayList) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) FileAttributeDefinition(org.openforis.idm.metamodel.FileAttributeDefinition) CoordinateAttributeDefinition(org.openforis.idm.metamodel.CoordinateAttributeDefinition) NumberAttributeDefinition(org.openforis.idm.metamodel.NumberAttributeDefinition) TimeAttributeDefinition(org.openforis.idm.metamodel.TimeAttributeDefinition) BooleanAttributeDefinition(org.openforis.idm.metamodel.BooleanAttributeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) TextAttributeDefinition(org.openforis.idm.metamodel.TextAttributeDefinition) RangeAttributeDefinition(org.openforis.idm.metamodel.RangeAttributeDefinition) DateAttributeDefinition(org.openforis.idm.metamodel.DateAttributeDefinition) TaxonAttributeDefinition(org.openforis.idm.metamodel.TaxonAttributeDefinition) DateAttributeDefinition(org.openforis.idm.metamodel.DateAttributeDefinition) CoordinateAttributeDefinition(org.openforis.idm.metamodel.CoordinateAttributeDefinition) BooleanAttributeDefinition(org.openforis.idm.metamodel.BooleanAttributeDefinition) FileAttributeDefinition(org.openforis.idm.metamodel.FileAttributeDefinition) TimeAttributeDefinition(org.openforis.idm.metamodel.TimeAttributeDefinition) NumberAttributeDefinition(org.openforis.idm.metamodel.NumberAttributeDefinition) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) TextAttributeDefinition(org.openforis.idm.metamodel.TextAttributeDefinition) CollectSurvey(org.openforis.collect.model.CollectSurvey) RangeAttributeDefinition(org.openforis.idm.metamodel.RangeAttributeDefinition)

Example 38 with UIOptions

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;
}
Also used : UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) ArrayList(java.util.ArrayList) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 39 with UIOptions

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);
}
Also used : UIOptions(org.openforis.collect.metamodel.ui.UIOptions)

Example 40 with UIOptions

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));
}
Also used : Calculable(org.openforis.idm.metamodel.Calculable) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Aggregations

UIOptions (org.openforis.collect.metamodel.ui.UIOptions)69 CollectSurvey (org.openforis.collect.model.CollectSurvey)38 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)22 UITab (org.openforis.collect.metamodel.ui.UITab)19 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)18 Layout (org.openforis.collect.metamodel.ui.UIOptions.Layout)10 ArrayList (java.util.ArrayList)9 CollectAnnotations (org.openforis.collect.metamodel.CollectAnnotations)9 UITabSet (org.openforis.collect.metamodel.ui.UITabSet)9 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)9 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)5 Schema (org.openforis.idm.metamodel.Schema)5 Command (org.zkoss.bind.annotation.Command)5 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)5 ExternalizedProperty (org.granite.messaging.amf.io.util.externalizer.annotation.ExternalizedProperty)4 SchemaNodeData (org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData)4 SchemaTreeNode (org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode)4 SurveyObjectsGenerator (org.openforis.collect.manager.SurveyObjectsGenerator)3 KeyAttributeDefinition (org.openforis.idm.metamodel.KeyAttributeDefinition)3 SurveyObject (org.openforis.idm.metamodel.SurveyObject)3