Search in sources :

Example 1 with SurveyObject

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

the class CodeAttributeVM method openParentAttributeSelector.

@Command
public void openParentAttributeSelector(@ContextParam(ContextType.BINDER) final Binder binder) {
    String title = Labels.getLabel("survey.schema.attribute.code.select_parent_for_node", new String[] { editedItem.getName() });
    final Collection<CodeAttributeDefinition> assignableParentAttributes = editedItem.getAssignableParentCodeAttributeDefinitions();
    if (assignableParentAttributes.isEmpty()) {
        MessageUtil.showWarning("survey.schema.attribute.code.no_assignable_parent_available");
    } else {
        CodeAttributeDefinition parentCodeAttributeDefinition = ((CodeAttributeDefinitionFormObject) formObject).getParentCodeAttributeDefinition();
        Predicate<SurveyObject> includedNodePredicate = new Predicate<SurveyObject>() {

            @Override
            public boolean evaluate(SurveyObject item) {
                return item instanceof UITab || item instanceof EntityDefinition || item instanceof CodeAttributeDefinition && assignableParentAttributes.contains(item);
            }
        };
        Predicate<SurveyObject> disabledNodePredicate = new Predicate<SurveyObject>() {

            @Override
            public boolean evaluate(SurveyObject item) {
                return !(item instanceof CodeAttributeDefinition);
            }
        };
        final Window parentSelectorPopUp = SchemaTreePopUpVM.openPopup(title, editedItem.getRootEntity(), null, includedNodePredicate, false, false, disabledNodePredicate, null, parentCodeAttributeDefinition, true);
        parentSelectorPopUp.addEventListener(SchemaTreePopUpVM.NODE_SELECTED_EVENT_NAME, new EventListener<NodeSelectedEvent>() {

            public void onEvent(NodeSelectedEvent event) throws Exception {
                CodeAttributeDefinition parentAttrDefn = (CodeAttributeDefinition) event.getSelectedItem();
                CodeAttributeDefinitionFormObject fo = (CodeAttributeDefinitionFormObject) formObject;
                fo.setParentCodeAttributeDefinition(parentAttrDefn);
                String hierarchicalLevel = getHierarchicalLevelName(parentAttrDefn);
                fo.setHierarchicalLevel(hierarchicalLevel);
                notifyChange("formObject");
                dispatchApplyChangesCommand(binder);
                notifyChange("dependentCodePaths");
                closePopUp(parentSelectorPopUp);
            }
        });
    }
}
Also used : Window(org.zkoss.zul.Window) CodeAttributeDefinitionFormObject(org.openforis.collect.designer.form.CodeAttributeDefinitionFormObject) 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) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) SurveyObject(org.openforis.idm.metamodel.SurveyObject) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 2 with SurveyObject

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

the class SchemaVM method getSelectedNodeParentTab.

private UITab getSelectedNodeParentTab() {
    UITab parentTab;
    SurveyObject selectedSurveyObject = selectedTreeNode.getSurveyObject();
    if (selectedSurveyObject instanceof UITab) {
        parentTab = (UITab) selectedSurveyObject;
    } else {
        UIOptions uiOptions = survey.getUIOptions();
        parentTab = uiOptions.getAssignedTab((NodeDefinition) selectedSurveyObject);
    }
    return parentTab;
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) SurveyObject(org.openforis.idm.metamodel.SurveyObject) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Example 3 with SurveyObject

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

the class SchemaVM method openMoveNodePopup.

@Command
public void openMoveNodePopup() {
    SchemaNodeData selectedTreeNode = getSelectedTreeNode();
    if (selectedTreeNode == null) {
        return;
    }
    SurveyObject selectedItem = selectedTreeNode.getSurveyObject();
    if (selectedItem instanceof NodeDefinition) {
        NodeDefinition selectedNode = (NodeDefinition) selectedItem;
        boolean changeParentNodeAllowed = checkChangeParentNodeAllowed(selectedNode);
        if (changeParentNodeAllowed) {
            openSelectParentNodePopupForReparent(selectedNode);
        }
    } else {
        // TODO support tab moving
        return;
    }
}
Also used : SurveyObject(org.openforis.idm.metamodel.SurveyObject) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) SchemaNodeData(org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Example 4 with SurveyObject

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

the class SchemaVM method performSelectNode.

protected void performSelectNode(Binder binder, SchemaNodeData data) {
    selectedTreeNode = data;
    treeModel.select(data);
    SurveyObject surveyObject = data.getSurveyObject();
    EntityDefinition parentDefn = treeModel.getNearestParentEntityDefinition(surveyObject);
    editNode(binder, false, parentDefn, surveyObject);
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) SurveyObject(org.openforis.idm.metamodel.SurveyObject)

Example 5 with SurveyObject

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

the class SchemaVM method openDuplicateNodePopup.

@Command
public void openDuplicateNodePopup() {
    if (!checkCanLeaveForm()) {
        return;
    }
    SchemaNodeData selectedTreeNode = getSelectedTreeNode();
    if (selectedTreeNode == null) {
        return;
    }
    SurveyObject selectedItem = selectedTreeNode.getSurveyObject();
    if (selectedItem instanceof NodeDefinition) {
        openSelectParentNodePopupForDuplicate((NodeDefinition) selectedItem);
    }
}
Also used : SurveyObject(org.openforis.idm.metamodel.SurveyObject) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) SchemaNodeData(org.openforis.collect.designer.component.SchemaTreeModel.SchemaNodeData) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

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