Search in sources :

Example 51 with UIOptions

use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.

the class SchemaVM method performRemoveTab.

protected void performRemoveTab(UITab tab) {
    // remove all nodes associated to the tab
    UIOptions uiOptions = tab.getUIOptions();
    List<NodeDefinition> nodesPerTab = uiOptions.getNodesPerTab(tab, false);
    for (NodeDefinition nodeDefn : nodesPerTab) {
        EntityDefinition parentDefn = nodeDefn.getParentEntityDefinition();
        parentDefn.removeChildDefinition(nodeDefn);
    }
    performRemoveSelectedTreeNode();
    UITabSet parent = tab.getParent();
    parent.removeTab(tab);
    refreshTreeModel();
    dispatchSurveyChangedCommand();
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) UITabSet(org.openforis.collect.metamodel.ui.UITabSet) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Example 52 with UIOptions

use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.

the class NewSurveyParametersPopUpVM method createEmptySurvey.

protected CollectSurvey createEmptySurvey(String name, String langCode) {
    // create empty survey
    CollectSurvey survey = surveyManager.createTemporarySurvey(name, langCode);
    // add default root entity
    Schema schema = survey.getSchema();
    EntityDefinition rootEntity = schema.createEntityDefinition();
    rootEntity.setMultiple(true);
    rootEntity.setName(SurveyController.DEFAULT_ROOT_ENTITY_NAME);
    schema.addRootEntityDefinition(rootEntity);
    // create root tab set
    UIOptions uiOptions = survey.getUIOptions();
    UITabSet rootTabSet = uiOptions.createRootTabSet((EntityDefinition) rootEntity);
    UITab mainTab = uiOptions.getMainTab(rootTabSet);
    mainTab.setLabel(langCode, SurveyController.DEFAULT_MAIN_TAB_LABEL);
    SurveyObjectsGenerator surveyObjectsGenerator = new SurveyObjectsGenerator();
    surveyObjectsGenerator.addPredefinedObjects(survey);
    return survey;
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) UITab(org.openforis.collect.metamodel.ui.UITab) Schema(org.openforis.idm.metamodel.Schema) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) UITabSet(org.openforis.collect.metamodel.ui.UITabSet) SurveyObjectsGenerator(org.openforis.collect.manager.SurveyObjectsGenerator) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 53 with UIOptions

use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.

the class EntityDefinitionFormValidator method validateLayout.

protected void validateLayout(ValidationContext ctx) {
    EntityDefinition editedNode = (EntityDefinition) getEditedNode(ctx);
    if (editedNode.isVirtual()) {
        // skip check
        return;
    }
    String field = LAYOUT_FIELD;
    String layoutValue = getValue(ctx, field);
    Layout layout = Layout.valueOf(layoutValue);
    EntityDefinition parentEntity = getParentEntity(ctx);
    CollectSurvey survey = (CollectSurvey) editedNode.getSurvey();
    UIOptions uiOptions = survey.getUIOptions();
    Boolean multiple = getValue(ctx, MULTIPLE_FIELD);
    UITab tab = uiOptions.getAssignedTab(editedNode);
    // UITab tab = getAssociatedTab(ctx, uiOptions, parentEntity);
    if (tab != null) {
        boolean valid = uiOptions.isLayoutSupported(parentEntity, editedNode.getId(), tab, multiple, layout);
        if (!valid) {
            String message = Labels.getLabel(LabelKeys.LAYOUT_NOT_SUPPORTED_MESSAGE_KEY);
            addInvalidMessage(ctx, field, message);
        }
    } else {
    // defining root entity, not yet added to schema...
    }
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) UITab(org.openforis.collect.metamodel.ui.UITab) Layout(org.openforis.collect.metamodel.ui.UIOptions.Layout) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 54 with UIOptions

use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.

the class TextAttributeDefinitionFormObject method loadFrom.

@Override
public void loadFrom(T source, String languageCode) {
    super.loadFrom(source, languageCode);
    Type typeEnum = source.getType();
    if (typeEnum == null) {
        typeEnum = Type.SHORT;
    }
    type = typeEnum.name();
    autocompleteGroup = source.getAnnotation(Annotation.AUTOCOMPLETE.getQName());
    UIOptions uiOptions = getUIOptions(source);
    autoUppercase = uiOptions.isAutoUppercase(source);
    CollectAnnotations annotations = ((CollectSurvey) source.getSurvey()).getAnnotations();
    TextInput textInput = annotations.getTextInput(source);
    input = textInput.name();
    geometry = annotations.isGeometry(source);
}
Also used : Type(org.openforis.idm.metamodel.TextAttributeDefinition.Type) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) CollectAnnotations(org.openforis.collect.metamodel.CollectAnnotations) CollectSurvey(org.openforis.collect.model.CollectSurvey) TextInput(org.openforis.collect.metamodel.CollectAnnotations.TextInput)

Example 55 with UIOptions

use of org.openforis.collect.metamodel.ui.UIOptions in project collect by openforis.

the class SchemaUpdater method generateAlias.

public EntityDefinition generateAlias(EntityDefinition sourceDef, String sourceFilterAttributeName, EntityDefinition targetParentDef, String targetFilterAttributeName) {
    EntityDefinition aliasDef = survey.getSchema().cloneDefinition(sourceDef, targetFilterAttributeName);
    // add "Alias" suffix to labels
    for (NodeLabel nodeLabel : aliasDef.getLabels()) {
        aliasDef.setLabel(nodeLabel.getType(), nodeLabel.getLanguage(), nodeLabel.getText() + " Alias");
    }
    aliasDef.traverse(new NodeDefinitionVisitor() {

        public void visit(NodeDefinition def) {
            if (def instanceof AttributeDefinition) {
                AttributeDefinition attrDef = (AttributeDefinition) def;
                attrDef.setCalculated(false);
                attrDef.removeAllChecks();
                attrDef.removeAllAttributeDefaults();
            }
            def.setRelevantExpression(null);
            def.setRequiredExpression(null);
        }
    });
    targetParentDef.addChildDefinition(aliasDef);
    aliasDef.setVirtual(true);
    aliasDef.setGeneratorExpression(generateAliasGeneratorExpression(sourceDef, sourceFilterAttributeName, targetParentDef, targetFilterAttributeName));
    UIOptions uiOptions = survey.getUIOptions();
    // prevent layout errors
    uiOptions.setLayout(aliasDef, Layout.FORM);
    uiOptions.setHidden(aliasDef, true);
    return aliasDef;
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) NodeLabel(org.openforis.idm.metamodel.NodeLabel) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) NodeDefinitionVisitor(org.openforis.idm.metamodel.NodeDefinitionVisitor)

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