Search in sources :

Example 6 with SchemaTreeNode

use of org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode in project collect by openforis.

the class SchemaTreeModelCreator method createChildNode.

private SchemaTreeNode createChildNode(NodeDefinition nodeDefn) {
    if (version == null || version.isApplicable(nodeDefn)) {
        SchemaNodeData data = new SchemaNodeData(nodeDefn, nodeDefn.getName(), false, false);
        SchemaTreeNode childNode = (SchemaTreeNode) createNode(data, false);
        return childNode;
    } else {
        return null;
    }
}
Also used : SchemaTreeNode(org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode) SchemaNodeData(org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData)

Example 7 with SchemaTreeNode

use of org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode 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 8 with SchemaTreeNode

use of org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode in project collect by openforis.

the class UITreeModelCreator method createChildNodes.

private List<SchemaTreeNode> createChildNodes(UITab tab) {
    List<SchemaTreeNode> result = new ArrayList<SchemaTreeNode>();
    // add schema node definition tree nodes
    UIOptions uiOptions = tab.getUIOptions();
    List<NodeDefinition> childDefns = uiOptions.getNodesPerTab(tab, false);
    List<SchemaTreeNode> childSchemaNodes = createNodes(tab, childDefns);
    result.addAll(childSchemaNodes);
    // add children unassigned tab tree nodes
    // List<UITab> unassignedTabs = new ArrayList<UITab>();
    // UITabSet rootTabSet = tab.getRootTabSet();
    // EntityDefinition rootEntity = uiOptions.getRootEntityDefinition(rootTabSet);
    // 
    // for (UITab childTab : tab.getTabs()) {
    // boolean unassigned = uiOptions.isUnassigned(childTab, rootEntity);
    // if ( unassigned ) {
    // unassignedTabs.add(childTab);
    // }
    // }
    // List<SchemaTreeNode> unassignedTabNodes = fromTabsList(unassignedTabs, version, includeAttributes, labelLanguage);
    // result.addAll(unassignedTabNodes);
    List<UITab> nestedTabs = new ArrayList<UITab>();
    for (UITab childTab : tab.getTabs()) {
        List<NodeDefinition> nodes = uiOptions.getNodesPerTab(childTab, false);
        boolean toBeAdded = true;
        for (NodeDefinition nestedTabChildNode : nodes) {
            for (NodeDefinition childDefn : childDefns) {
                if (childDefn == nestedTabChildNode || (childDefn instanceof EntityDefinition && nestedTabChildNode.isDescendantOf((EntityDefinition) childDefn))) {
                    toBeAdded = false;
                    break;
                }
            }
        }
        if (toBeAdded) {
            nestedTabs.add(childTab);
        }
    }
    Collection<SchemaTreeNode> tabNodes = createNodes(nestedTabs);
    result.addAll(tabNodes);
    return result;
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) SchemaTreeNode(org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) ArrayList(java.util.ArrayList) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Example 9 with SchemaTreeNode

use of org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode in project collect by openforis.

the class SchemaVM method openSelectParentNodePopupForDuplicate.

private void openSelectParentNodePopupForDuplicate(final NodeDefinition node) {
    Predicate<SurveyObject> includedNodePredicate = new Predicate<SurveyObject>() {

        @Override
        public boolean evaluate(SurveyObject item) {
            return item instanceof UITab || item instanceof EntityDefinition;
        }
    };
    Predicate<SurveyObject> disabledPredicate = new Predicate<SurveyObject>() {

        @Override
        public boolean evaluate(SurveyObject item) {
            return !(item instanceof UITab || item instanceof EntityDefinition);
        }
    };
    String nodeName = node.getName();
    UITab assignedTab = survey.getUIOptions().getAssignedTab((NodeDefinition) node);
    String assignedTabLabel = assignedTab.getLabel(currentLanguageCode);
    String title = Labels.getLabel("survey.schema.duplicate_node_popup_title", new String[] { getNodeTypeHeaderLabel(), nodeName, assignedTabLabel });
    // calculate parent item (tab or entity)
    SchemaTreeNode treeNode = treeModel.getTreeNode(node);
    TreeNode<SchemaNodeData> parentTreeNode = treeNode.getParent();
    SurveyObject parentItem = parentTreeNode.getData().getSurveyObject();
    final Window popup = SchemaTreePopUpVM.openPopup(title, selectedRootEntity, null, includedNodePredicate, false, true, disabledPredicate, null, parentItem, false);
    popup.addEventListener(SchemaTreePopUpVM.NODE_SELECTED_EVENT_NAME, new EventListener<NodeSelectedEvent>() {

        public void onEvent(NodeSelectedEvent event) throws Exception {
            SurveyObject selectedParent = event.getSelectedItem();
            duplicateEditedNodeInto(node, selectedParent);
            closePopUp(popup);
        }
    });
}
Also used : Window(org.zkoss.zul.Window) SchemaTreeNode(org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode) NodeSelectedEvent(org.openforis.collect.designer.viewmodel.SchemaTreePopUpVM.NodeSelectedEvent) Predicate(org.openforis.collect.designer.util.Predicate) UITab(org.openforis.collect.metamodel.ui.UITab) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) SurveyObject(org.openforis.idm.metamodel.SurveyObject) SchemaNodeData(org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData)

Example 10 with SchemaTreeNode

use of org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode in project collect by openforis.

the class SchemaVM method getTreeItem.

// TODO move it to tree model class
private Treeitem getTreeItem(SurveyObject item) {
    for (Treeitem treeItem : nodesTree.getItems()) {
        SchemaTreeNode node = treeItem.getValue();
        SchemaNodeData data = node.getData();
        SurveyObject itemSO = data.getSurveyObject();
        if (itemSO == item) {
            return treeItem;
        }
    }
    return null;
}
Also used : Treeitem(org.zkoss.zul.Treeitem) SchemaTreeNode(org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode) SurveyObject(org.openforis.idm.metamodel.SurveyObject) SchemaNodeData(org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData)

Aggregations

SchemaTreeNode (org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode)12 SchemaNodeData (org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData)9 UITab (org.openforis.collect.metamodel.ui.UITab)6 SurveyObject (org.openforis.idm.metamodel.SurveyObject)5 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)4 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)4 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)4 AbstractNode (org.openforis.collect.designer.component.BasicTreeModel.AbstractNode)3 ArrayList (java.util.ArrayList)2 Predicate (org.openforis.collect.designer.util.Predicate)2 NodeSelectedEvent (org.openforis.collect.designer.viewmodel.SchemaTreePopUpVM.NodeSelectedEvent)2 UITabSet (org.openforis.collect.metamodel.ui.UITabSet)2 CollectSurvey (org.openforis.collect.model.CollectSurvey)2 Treeitem (org.zkoss.zul.Treeitem)2 Window (org.zkoss.zul.Window)2 HashSet (java.util.HashSet)1 Schema (org.openforis.idm.metamodel.Schema)1 Menupopup (org.zkoss.zul.Menupopup)1