Search in sources :

Example 1 with AbstractNode

use of org.openforis.collect.designer.component.BasicTreeModel.AbstractNode in project collect by openforis.

the class SurveyObjectTreeModelCreator method createNode.

public AbstractNode<SchemaNodeData> createNode(SchemaNodeData data, boolean defineEmptyChildrenForLeaves) {
    SchemaTreeNode node = null;
    SurveyObject surveyObject = data.getSurveyObject();
    if (includeNodePredicate == null || includeNodePredicate.evaluate(surveyObject)) {
        List<AbstractNode<SchemaNodeData>> childNodes = createChildNodes(surveyObject);
        // create result
        if (childNodes == null) {
            node = new SchemaTreeNode(data);
        } else if (childNodes.isEmpty()) {
            if (includeEmptyNodes) {
                if (defineEmptyChildrenForLeaves) {
                    node = new SchemaTreeNode(data, Collections.<AbstractNode<SchemaNodeData>>emptyList());
                } else {
                    node = new SchemaTreeNode(data);
                }
            } else {
                node = null;
            }
        } else {
            node = new SchemaTreeNode(data, (List<AbstractNode<SchemaNodeData>>) childNodes);
        }
    }
    if (node != null && disabledNodePredicate != null) {
        if (disabledNodePredicate.evaluate(surveyObject)) {
            node.setDisabled(true);
        }
    }
    return node;
}
Also used : SchemaTreeNode(org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode) SurveyObject(org.openforis.idm.metamodel.SurveyObject) AbstractNode(org.openforis.collect.designer.component.BasicTreeModel.AbstractNode) SchemaNodeData(org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData)

Example 2 with AbstractNode

use of org.openforis.collect.designer.component.BasicTreeModel.AbstractNode in project collect by openforis.

the class UITreeModelCreator method createFirstLevelNodes.

@Override
protected List<AbstractNode<SchemaNodeData>> createFirstLevelNodes(EntityDefinition rootEntity) {
    List<AbstractNode<SchemaNodeData>> firstLevelTreeNodes = new ArrayList<AbstractNode<SchemaNodeData>>();
    if (includeRootEntity) {
        SchemaTreeNode node = createRootNode(rootEntity);
        if (node != null) {
            firstLevelTreeNodes.add(node);
        }
    } else {
        CollectSurvey survey = (CollectSurvey) rootEntity.getSurvey();
        UIOptions uiOptions = survey.getUIOptions();
        UITabSet tabSet = uiOptions.getAssignedRootTabSet(rootEntity);
        for (UITab tab : tabSet.getTabs()) {
            SchemaTreeNode node = createNode(tab);
            if (node != null) {
                firstLevelTreeNodes.add(node);
            }
        }
    }
    return firstLevelTreeNodes;
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) SchemaTreeNode(org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode) AbstractNode(org.openforis.collect.designer.component.BasicTreeModel.AbstractNode) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) UITabSet(org.openforis.collect.metamodel.ui.UITabSet) ArrayList(java.util.ArrayList) CollectSurvey(org.openforis.collect.model.CollectSurvey) SchemaNodeData(org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData)

Example 3 with AbstractNode

use of org.openforis.collect.designer.component.BasicTreeModel.AbstractNode in project collect by openforis.

the class SurveyObjectTreeModelCreator method createModel.

public SchemaTreeModel createModel(EntityDefinition rootEntity) {
    if (rootEntity != null && (version == null || version.isApplicable(rootEntity))) {
        Collection<AbstractNode<SchemaNodeData>> firstLevelTreeNodes = createFirstLevelNodes(rootEntity);
        SchemaTreeNode root = new SchemaTreeNode(null, firstLevelTreeNodes);
        SchemaTreeModel result = new SchemaTreeModel(this, root, rootEntity, labelLanguage);
        return result;
    } else {
        return null;
    }
}
Also used : SchemaTreeNode(org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode) AbstractNode(org.openforis.collect.designer.component.BasicTreeModel.AbstractNode)

Example 4 with AbstractNode

use of org.openforis.collect.designer.component.BasicTreeModel.AbstractNode in project collect by openforis.

the class UITreeModelCreator method createChildNodes.

private List<AbstractNode<SchemaNodeData>> createChildNodes(EntityDefinition entityDefn) {
    List<AbstractNode<SchemaNodeData>> childNodes = new ArrayList<AbstractNode<SchemaNodeData>>();
    CollectSurvey survey = (CollectSurvey) entityDefn.getSurvey();
    UIOptions uiOptions = survey.getUIOptions();
    UITab assignedTab = uiOptions.getAssignedTab(entityDefn);
    // include node definitions
    List<NodeDefinition> childDefns = entityDefn.getChildDefinitions();
    Collection<? extends AbstractNode<SchemaNodeData>> schemaTreeNodes = createNodes(assignedTab, childDefns);
    childNodes.addAll(schemaTreeNodes);
    // include tabs
    if (entityDefn.isMultiple() && uiOptions.getLayout(entityDefn) == Layout.FORM) {
        List<UITab> tabs = uiOptions.getTabsAssignableToChildren(entityDefn, false);
        Collection<? extends AbstractNode<SchemaNodeData>> tabNodes = createNodes(tabs);
        childNodes.addAll(tabNodes);
    }
    return childNodes;
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) AbstractNode(org.openforis.collect.designer.component.BasicTreeModel.AbstractNode) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) ArrayList(java.util.ArrayList) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) CollectSurvey(org.openforis.collect.model.CollectSurvey) SchemaNodeData(org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData)

Aggregations

AbstractNode (org.openforis.collect.designer.component.BasicTreeModel.AbstractNode)4 SchemaNodeData (org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData)3 SchemaTreeNode (org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode)3 ArrayList (java.util.ArrayList)2 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)2 UITab (org.openforis.collect.metamodel.ui.UITab)2 CollectSurvey (org.openforis.collect.model.CollectSurvey)2 UITabSet (org.openforis.collect.metamodel.ui.UITabSet)1 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)1 SurveyObject (org.openforis.idm.metamodel.SurveyObject)1