Search in sources :

Example 51 with NodeDefinition

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

the class SchemaVM method duplicateEditedNodeInto.

private void duplicateEditedNodeInto(NodeDefinition node, SurveyObject parent) {
    NodeDefinition clone = survey.getSchema().cloneDefinition(node);
    EntityDefinition parentEntity = determineRelatedEntity(parent);
    clone.setName(createDuplicateNodeName(node, parentEntity));
    editedNode = clone;
    changeEditedNodeParent(parent, true);
    editNode(false, parentEntity, editedNode);
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Example 52 with NodeDefinition

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

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

the class SchemaVM method changeEditedNodeParentEntity.

private void changeEditedNodeParentEntity(EntityDefinition newParentEntity) {
    // update parent entity
    NodeDefinition node = (NodeDefinition) editedNode;
    Schema schema = survey.getSchema();
    schema.changeParentEntity(node, newParentEntity);
    // update tab
    UIOptions uiOptions = survey.getUIOptions();
    uiOptions.removeTabAssociation(node);
    if (node instanceof AttributeDefinition) {
        survey.getAnnotations().setMeasurementAttribute((AttributeDefinition) node, false);
    }
    // update ui
    refreshTreeModel();
    editedNodeParentEntity = newParentEntity;
    selectTreeNode(editedNode);
    treeModel.showSelectedNode();
    notifyChange("selectedTreeNode", "editedNode");
}
Also used : Schema(org.openforis.idm.metamodel.Schema) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) KeyAttributeDefinition(org.openforis.idm.metamodel.KeyAttributeDefinition) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition)

Example 54 with NodeDefinition

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

Example 55 with NodeDefinition

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

the class SchemaVM method changeEditedNodeParent.

private void changeEditedNodeParent(SurveyObject newParent, boolean forceReassignment) {
    EntityDefinition newParentEntityDef = determineRelatedEntity(newParent);
    NodeDefinition editedNodeDef = (NodeDefinition) editedNode;
    if (forceReassignment || editedNodeDef.getParentDefinition() != newParentEntityDef) {
        changeEditedNodeParentEntity(newParentEntityDef);
    }
    if (newParent instanceof UITab) {
        associateNodeToTab(editedNodeDef, (UITab) newParent);
    }
    dispatchSurveyChangedCommand();
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) UITab(org.openforis.collect.metamodel.ui.UITab) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Aggregations

NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)173 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)70 ArrayList (java.util.ArrayList)42 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)27 Schema (org.openforis.idm.metamodel.Schema)24 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)22 CollectSurvey (org.openforis.collect.model.CollectSurvey)20 Entity (org.openforis.idm.model.Entity)19 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)16 NodeDefinitionVisitor (org.openforis.idm.metamodel.NodeDefinitionVisitor)14 UITab (org.openforis.collect.metamodel.ui.UITab)12 NumericAttributeDefinition (org.openforis.idm.metamodel.NumericAttributeDefinition)11 Survey (org.openforis.idm.metamodel.Survey)11 Test (org.junit.Test)10 DateAttributeDefinition (org.openforis.idm.metamodel.DateAttributeDefinition)9 ModelVersion (org.openforis.idm.metamodel.ModelVersion)9 BooleanAttributeDefinition (org.openforis.idm.metamodel.BooleanAttributeDefinition)8 CoordinateAttributeDefinition (org.openforis.idm.metamodel.CoordinateAttributeDefinition)8 NumberAttributeDefinition (org.openforis.idm.metamodel.NumberAttributeDefinition)8 Node (org.openforis.idm.model.Node)8