Package org.openquark.cal.valuenode

Examples of org.openquark.cal.valuenode.ValueNode


            Map<PartInput, ValueNode> inputNewValueMap = switcher.getInputSwitchValues(oldValueNode, newValueNode, inputToValueNodeMap);
           
            // Now update with the switched values.
            for (final Map.Entry<PartInput, ValueNode> mapEntry : inputNewValueMap.entrySet()) {
                Gem.PartInput input = mapEntry.getKey();
                ValueNode newInputValue = mapEntry.getValue();
           
                ValueEditor editor = inputToEditorMap.get(input);

                editor.changeOwnerValue(newInputValue);
                editor.setSize(editor.getPreferredSize());
View Full Code Here


                //this is the array of types cached for each argument. If there is no cached type, we just use the argument type.              
                TypeExpr[] cachedTypes = new TypeExpr[numArgs];
                for (int i = 0; i < numArgs; ++i) {
                    // What we do next depends on whether we use cached sink values
                    Gem.PartInput inputPart = argParts.get(i);
                    ValueNode cachedVN = gemCutter.getTableTop().getCachedValue(inputPart);
                    if (cachedVN != null) {
                        cachedTypes[i] = cachedVN.getTypeExpr();
                    }                                                   
                }
               
                try {
                    ModuleTypeInfo contextModuleTypeInfo = gemCutter.getPerspective().getWorkingModuleTypeInfo();                                            
                    specializedInputTypes = TypeExpr.patternMatchPieces(cachedTypes, inputTypes, contextModuleTypeInfo);
                } catch (TypeException te) {
                    throw new IllegalStateException("Error reusing cached args.");
                }                           
            } else {
                specializedInputTypes = TypeExpr.copyTypeExprs(inputTypes);
            }

            ValueEditorManager valueEditorManager = gemCutter.getValueEditorManager();
            ValueEditorDirector valueEditorDirector = valueEditorManager.getValueEditorDirector();

            Map<PartInput, ValueEditor> inputToEditorMap = new LinkedHashMap<PartInput, ValueEditor>();

            // Step through args, create a new value input panel for each, with the correct value type
            for (int i = 0; i < numArgs; i++) {

                // Get the gem and input
                final Gem.PartInput inputPart = argParts.get(i);
                final Gem inputGem = inputPart.getGem();
               
                int argumentNumber = inputPart.getInputNum();
                QualifiedName scName = null;
               
                if (inputGem instanceof FunctionalAgentGem) {
                    scName = ((FunctionalAgentGem) inputGem).getName();
                }

                // What we do next depends on whether we use cached sink values
                ValueNode cachedVN;
                final ValueEditor editor;
                if (canUseCachedArgs && (cachedVN = gemCutter.getTableTop().getCachedValue(inputPart)) != null) {
                    // use cached sink value to generate the VEP

                    // get a copy of the cached VN but with the new type expr
                    ValueNode newVN = cachedVN.copyValueNode();

                    // instantiate the VEP with the new VN (which has the old cached value)
                    editor = valueEditorDirector.getRootValueEditor(valueEditorHierarchyManager,
                                                                    newVN,
                                                                    scName,
View Full Code Here

            // Step through args.  i'th arg corresponds to the i'th piece.
            // Note that there may be more pieces than args if the output type is a function           
            for (int i = 0; i < targetPieces.length; i++) {
                // Get this input, and any cached value
                Gem.PartInput sinkPart = argParts.get(i);           
                ValueNode cachedVN = gemCutter.getTableTop().getCachedValue(sinkPart);
   
                // there may be no cached value for this argument
                if (cachedVN != null) {
                    typesFromCachedArgs[i] = cachedVN.getTypeExpr();
                }                                  
            }
           
            ModuleTypeInfo contextModuleTypeInfo = gemCutter.getPerspective().getWorkingModuleTypeInfo();
           
View Full Code Here

                emitterIndices.add(Integer.valueOf(i));
                continue;
               
            } else if (gem instanceof ValueGem) {
                // Get The associated value node
                ValueNode valueNode = ((ValueGem)gem).getValueNode();
                               
                // Copy the valueNode but link it with a different typeExpr
                ValueNode valueNodeClone = valueNode.copyValueNode();
               
                // Create the new valueGem
                ValueGem valueGemClone = new ValueGem(valueNodeClone);
               
                // Build the associated displayedGem
View Full Code Here

                codeGemEditor.setDelayUpdatingForTextChanges(true);
               
            } else if (gem instanceof ValueGem) {
                ValueGem vGem = (ValueGem) gem;         

                ValueNode vNode = vGem.getValueNode();
                String valueString = vNode.getCALValue();
                String updatedValueString = typeChecker.calculateUpdatedCodeExpression(valueString, workingModuleName, workingModuleNameResolver, null, oldName, newName, SourceIdentifier.Category.TOP_LEVEL_FUNCTION_OR_CLASS_METHOD, null);
               
                if (!valueString.equals(updatedValueString)) {
                    // Create a target to be run by a value runner, and return the result
                    Target valueTarget = new Target.SimpleTarget(updatedValueString);
   
                    ValueNode targetValue = null;
                    try {
                        targetValue = gemCutter.getValueRunner().getValue(valueTarget, workingModuleName);
                    } catch (TargetRunner.ProgramCompileException pce) {
                        status.add(new Status(Status.Severity.ERROR, "Error updating value gem. Can't compile the following text: " + updatedValueString));
                    }
View Full Code Here

    /**
     * Change the value of this gem.
     * @param newValue the new value of this gem.
     */
    public void changeValue(ValueNode newValue) {
        ValueNode oldValue = valueNode;
        this.valueNode = newValue;
       
        fireValueChangeEvent(oldValue);
    }
View Full Code Here

        XMLPersistenceHelper.getAdjacentCharacterData(valueChild, valueText);

        // Create a target to be run by a value runner, and return the result
        Target valueTarget = new Target.SimpleTarget(valueText.toString());

        ValueNode targetValue = null;
        try {
            targetValue = valueRunner.getValue(valueTarget, loadModuleName);
        } catch (TargetRunner.ProgramCompileException pce) {
            XMLPersistenceHelper.handleBadDocument(valueElement, "Can't compile program: \"" + valueText + "\".");
        }
View Full Code Here

    @Override
    protected void commitValue() {

        valueEditorManager.associateInfo(getOwnerValueNode(), new ValueEditor.Info(getSize()));

        ValueNode returnVN = (ValueNode) getEnumeratedValueList().getSelectedValue();
        if (returnVN != null) {
            replaceValueNode(returnVN, true);
            notifyValueCommitted();
        }
    }
View Full Code Here

                                                              int index,
                                                              boolean isSelected,
                                                              boolean cellHasFocus)
                {
                    JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
                    ValueNode vn = (ValueNode) value;
                   
                    label.setText(vn.getTextValue());
                    label.setToolTipText(vn.getTextValue());
                   
                    if (highlightValue != null && vn.sameValue(highlightValue)) {
                        label.setForeground(isSelected ? Color.WHITE : Color.BLUE);
                    }
                   
                    return label;
                }
View Full Code Here

    @Override
    public void setInitialValue() {

        // Select the DataConstructor which matches with the current ValueNode's DataConstructor.
        DefaultListModel listModel = (DefaultListModel) getEnumeratedValueList().getModel();
        ValueNode searchValueNode = getValueNode();

        for (int i = 0, listSize = listModel.getSize(); i < listSize; i++) {
            ValueNode vn = (ValueNode) listModel.get(i);

            if (vn.sameValue(searchValueNode)) {
                getEnumeratedValueList().setSelectedIndex(i);
                break;
            }
        }
    }
View Full Code Here

TOP

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

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.