Search in sources :

Example 11 with SurveyObject

use of org.openforis.idm.metamodel.SurveyObject in project collect by openforis.

the class SchemaTreeModel method getOpenSchemaNodes.

public Set<SurveyObject> getOpenSchemaNodes() {
    Set<SurveyObject> result = new HashSet<SurveyObject>();
    Set<TreeNode<SchemaNodeData>> openObjects = getOpenObjects();
    for (TreeNode<SchemaNodeData> treeNode : openObjects) {
        if (treeNode != null) {
            SchemaNodeData data = treeNode.getData();
            SurveyObject node = data.getSurveyObject();
            result.add(node);
        }
    }
    return result;
}
Also used : SurveyObject(org.openforis.idm.metamodel.SurveyObject) TreeNode(org.zkoss.zul.TreeNode) HashSet(java.util.HashSet)

Example 12 with SurveyObject

use of org.openforis.idm.metamodel.SurveyObject in project collect by openforis.

the class SchemaTreeModel method getSiblingsAndSelf.

public List<SurveyObject> getSiblingsAndSelf(SurveyObject obj, boolean sameType) {
    List<SurveyObject> result = new ArrayList<SurveyObject>();
    TreeNode<SchemaNodeData> treeNode = getTreeNode(obj);
    SchemaTreeNode parent = (SchemaTreeNode) treeNode.getParent();
    List<TreeNode<SchemaNodeData>> children = parent.getChildren();
    for (TreeNode<SchemaNodeData> child : children) {
        SurveyObject surveyObject = child.getData().getSurveyObject();
        if (sameType && ((obj instanceof UITab && surveyObject instanceof UITab) || (obj instanceof NodeDefinition && surveyObject instanceof NodeDefinition))) {
            result.add(surveyObject);
        }
    }
    return result;
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) SurveyObject(org.openforis.idm.metamodel.SurveyObject) TreeNode(org.zkoss.zul.TreeNode) ArrayList(java.util.ArrayList) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Example 13 with SurveyObject

use of org.openforis.idm.metamodel.SurveyObject in project collect by openforis.

the class SchemaAttributesImportVM method openParentEntitySelectionButton.

@Command
public void openParentEntitySelectionButton() {
    Predicate<SurveyObject> includedNodePredicate = new Predicate<SurveyObject>() {

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

        public boolean evaluate(SurveyObject item) {
            return item instanceof EntityDefinition;
        }
    };
    String title = Labels.getLabel("survey.schema.attributes_import.select_entity.popup.title");
    // calculate parent item (tab or entity)
    final Window popup = SchemaTreePopUpVM.openPopup(title, parentEntityDefinition.getRootEntity(), null, includedNodePredicate, true, true, null, selectableNodePredicate, parentEntityDefinition, false);
    popup.addEventListener(SchemaTreePopUpVM.NODE_SELECTED_EVENT_NAME, new EventListener<NodeSelectedEvent>() {

        public void onEvent(NodeSelectedEvent event) throws Exception {
            SurveyObject selectedParent = event.getSelectedItem();
            parentEntityDefinition = (EntityDefinition) selectedParent;
            notifyChange("parentEntityDefinitionPath");
            closePopUp(popup);
        }
    });
}
Also used : Window(org.zkoss.zul.Window) UITab(org.openforis.collect.metamodel.ui.UITab) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) SurveyObject(org.openforis.idm.metamodel.SurveyObject) NodeSelectedEvent(org.openforis.collect.designer.viewmodel.SchemaTreePopUpVM.NodeSelectedEvent) ParseException(java.text.ParseException) Predicate(org.openforis.collect.designer.util.Predicate) Command(org.zkoss.bind.annotation.Command)

Example 14 with SurveyObject

use of org.openforis.idm.metamodel.SurveyObject 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 15 with SurveyObject

use of org.openforis.idm.metamodel.SurveyObject 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

SurveyObject (org.openforis.idm.metamodel.SurveyObject)23 UITab (org.openforis.collect.metamodel.ui.UITab)10 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)9 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)7 SchemaNodeData (org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData)6 Window (org.zkoss.zul.Window)6 SchemaTreeNode (org.openforis.collect.designer.component.SchemaTreeModel.SchemaTreeNode)5 Predicate (org.openforis.collect.designer.util.Predicate)5 NodeSelectedEvent (org.openforis.collect.designer.viewmodel.SchemaTreePopUpVM.NodeSelectedEvent)5 Command (org.zkoss.bind.annotation.Command)5 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)4 HashSet (java.util.HashSet)3 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)3 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)3 ArrayList (java.util.ArrayList)2 KeyAttributeDefinition (org.openforis.idm.metamodel.KeyAttributeDefinition)2 TreeNode (org.zkoss.zul.TreeNode)2 ParseException (java.text.ParseException)1 HashMap (java.util.HashMap)1 AbstractNode (org.openforis.collect.designer.component.BasicTreeModel.AbstractNode)1