Package org.openquark.cal.valuenode

Examples of org.openquark.cal.valuenode.NTupleValueNode


                       
                        // Iterate through the list and convert tuple nodes to record nodes.
                        for (int i = 0; i < listSize; i++) {
                           
                            // Get the tuple node.
                            NTupleValueNode nTupleValueNode = (NTupleValueNode)listValueNode.getValueAt(i);
                           
                            // Get the list of values.
                            List<ValueNode> fieldValueList = new ArrayList<ValueNode>(nTupleValueNode.getValue());
                           
                            // Create and set the record value node with the list of values.
                            ValueNode recordValueNode = recordVNProvider.getNodeInstance(fieldValueList, null, recordTypeExpr);
                            ((ListValueNode)getValueNode()).setValueNodeAt(i, recordValueNode);
                        }
View Full Code Here


               
                // For tuple and record lists, we have to also put the individual elements of the list items
               
                if (isListOfNTupleVNs) {
                   
                    NTupleValueNode currentTupleValue = (NTupleValueNode)listElementNode;
                    RecordType unconstrainedListElementRecordType = (RecordType)unconstrainedListElementType;
                    Map<FieldName, TypeExpr>  hasFieldsMap = unconstrainedListElementRecordType.getHasFieldsMap();
                    int j = 0;
                    for (final TypeExpr unconstrainedTupleElementType : hasFieldsMap.values()) {
                        ValueNode currentTupleItem = currentTupleValue.getValueAt(j);
                        returnMap.put(currentTupleItem, unconstrainedTupleElementType);
                        ++j;
                    }
                   
                } else if (isListRecord) {
View Full Code Here

    private Map<ValueNode, TypeExpr> getValueNodeToUnconstrainedTypeMap() {
       
        Map<ValueNode, TypeExpr> returnMap = new HashMap<ValueNode, TypeExpr>();
       
        // Get the value nodes for the tuple and the items in the tuple.
        NTupleValueNode currentTupleValue = (NTupleValueNode)getValueNode();
        int tupleSize = currentTupleValue.getTupleSize();

        // Populate the map
       
        // Tuple
        TypeExpr unconstrainedTupleType = getContext().getLeastConstrainedTypeExpr();
        if (unconstrainedTupleType.rootTypeVar() != null) {
            // not constrained by the context to be a tuple
            unconstrainedTupleType = TypeExpr.makeTupleType(tupleSize);
        }
        returnMap.put(currentTupleValue, unconstrainedTupleType);
       
        // Tuple elements
        Map<FieldName, TypeExpr> hasFieldsMap = unconstrainedTupleType.rootRecordType().getHasFieldsMap();
        int j = 0;
        for (final TypeExpr unconstrainedTupleElementType : hasFieldsMap.values()) {
            ValueNode currentTupleItem = currentTupleValue.getValueAt(j);
            returnMap.put(currentTupleItem, unconstrainedTupleElementType);
            ++j;
        }

        return returnMap;
View Full Code Here

    @Override
    public void commitChildChanges(ValueNode oldChild, ValueNode newChild) {
               
        // Get the copy of the current value node, type switched if necessary.
       
        NTupleValueNode oldValueNode = (NTupleValueNode)getValueNode();
        NTupleValueNode newValueNode;
        if (!oldChild.getTypeExpr().sameType(newChild.getTypeExpr())) {
            Map<ValueNode, TypeExpr> valueNodeToUnconstrainedTypeMap = getValueNodeToUnconstrainedTypeMap();
            Map<ValueNode, ValueNode>  commitValueMap = valueEditorManager.getValueNodeCommitHelper().getCommitValues(oldChild, newChild, valueNodeToUnconstrainedTypeMap);
           
            newValueNode = (NTupleValueNode)commitValueMap.get(oldValueNode);

        } else {
            newValueNode = (NTupleValueNode)oldValueNode.copyValueNode();
        }       
       
        // Modify the new value node so that the old child is replaced by the new child.
        // Note that the cell editor may now be editing a different column so we have to search for the row that changed
        //   This can happen if one clicks from an editor for one cell to another cell
        //   (eg. in a list of colours, from a colour value editor for one cell, onto the cell editor for another cell.)

        List<ValueNode> currentChildrenList = oldValueNode.getValue();

        for (int i = 0, listSize = newValueNode.getTupleSize(); i < listSize; i++) {
            if (currentChildrenList.get(i) == oldChild) {
                TypeExpr childType = newValueNode.getValueAt(i).getTypeExpr();
                newValueNode.setValueNodeAt(i, newChild.copyValueNode(childType));
                break;
            }
        }

        // Set the value node
View Full Code Here

TOP

Related Classes of org.openquark.cal.valuenode.NTupleValueNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.