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;
}
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;
}
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;
}
}
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;
}
Aggregations