Package org.openquark.gems.client.Gem

Examples of org.openquark.gems.client.Gem.PartInput


                    outputConnection.getDestination().bindConnection(null);

                    connectionSet.remove(outputConnection);
                }
                for (int i = 0, nInputParts = gem.getNInputs(); i < nInputParts; i++) {
                    PartInput inputPart = gem.getInputPart(i);
                    Connection inputConnection = inputPart.getConnection();
                    if (inputConnection != null) {
                        inputPart.bindConnection(null);
                        inputConnection.getSource().bindConnection(null);

                        connectionSet.remove(inputConnection);
                    }
                }
View Full Code Here


     */
    public static JComponent makeEditor(RecordFieldSelectionGem recordFieldSelectionGem, TableTop tableTop) {
        // field editor to return
        final JComponent fieldEditor;
        final PartInput inputPart = recordFieldSelectionGem.getInputPart();
       
        final TypeExpr inputTypeExpr;
        TypeExpr outputTypeExpr = TypeExpr.makeParametricType();
       
        //determine the input type
        if (inputPart.isConnected() ) {
            inputTypeExpr = inputPart.inferType(tableTop.getTypeCheckInfo()) ;
            if (recordFieldSelectionGem.getOutputPart().getConnection() != null) {
                outputTypeExpr = recordFieldSelectionGem.getOutputPart().inferType(tableTop.getTypeCheckInfo());
            }
        } else if (inputPart.isBurnt() && recordFieldSelectionGem.getOutputPart().getConnection() != null) {  
            TypeExpr outputType = recordFieldSelectionGem.getOutputPart().inferType(tableTop.getTypeCheckInfo());
           
            if (outputType.getArity() > 0) {
                TypeExpr[] typePieces = outputType.getTypePieces(1);
                inputTypeExpr = typePieces[0];
View Full Code Here

     * @return Argument.Status the status of the given argument.
     */
    private Argument.Status getArgStatus(int argNum) {

        Argument.NameTypePair[] arguments = codeGem.getArguments();
        PartInput input = codeGem.getInputPart(argNum);

        if (incompatiblePartToInferredTypeMap.containsKey(input)) {
            // Check if it's an incompatible arg.
            return Argument.Status.TYPE_CLASH;

        } else if (input.isConnected()) {
            // Check whether the arg is used (appears in the code).
            if (unusedArgNames.contains(arguments[argNum].getName())) {
                return Argument.Status.CONNECTED_UNUSED;
            }
            return Argument.Status.CONNECTED;

        } else if (input.isBurnt()) {
            // also no type if the input is burnt
            return Argument.Status.BURNT;

        } else if (input.getType() != null) {
            // Return the type from the input
            return Argument.Status.NATURAL;

        } else {
            // Unconnected, unburnt input has no type.
View Full Code Here

                text.append("<br>");
            }
            text.append("<i>" + ToolTipHelpers.wrapTextToHTMLLines(argTypeText, gemCodePanel) + "</i>");

        } else {
            PartInput input = codeGem.getInputPart(argNum);
            TypeExpr argType = arguments[argNum].getType();
            TypeExpr inferredInputType = incompatiblePartToInferredTypeMap.get(input);
           
            text.append(GemCutterMessages.getString("CGE_WrongArgTypeToolTip",
                        ToolTipHelpers.wrapTextToHTMLLines(inferredInputType.toString(), gemCodePanel),
View Full Code Here

     * @return True if argument change form is allowed; False if not
     */
    private boolean isArgumentFormChangeAllowed(String name) {

        // Disallow if the variable is connected.
        PartInput input = oldNameToInputMap.get(name);
        if (input != null && input.isConnected()) {
            return false;
        } else {
            return true;
        }
    }
View Full Code Here

            // Add connected arguments not in the code. The nth arg is
            // associated with the nth input
            for (int i = 0; i < numCurrentArgs; i++) {
                String inputArgName = currentArgs[i].getName();
                PartInput input = oldNameToInputMap.get(inputArgName);

                if (input != null && input.isConnected() && !newNameToArgMap.containsKey(inputArgName)) {
                    argsInOrderList.add(new Argument.NameTypePair(inputArgName, TypeExpr.makeParametricType()));
                }
            }

        } else {

            // Try to preserve the last order as much as possible, and add new inputs to the end.
            // Args in order = args present in new args + new args not present in old args
            argsInOrderList = new ArrayList<NameTypePair>();

            // We also want the new name to arg map to include names for connected args not in the code
            //   so that we don't consider it a new arg and add it to the end.
            for (int i = 0; i < numCurrentArgs; i++) {
                String inputArgName = currentArgs[i].getName();
                PartInput input = oldNameToInputMap.get(inputArgName);

                if (input != null && input.isConnected() && !newNameToArgMap.containsKey(inputArgName)) {
                    newNameToArgMap.put(inputArgName, new Argument.NameTypePair(inputArgName, TypeExpr.makeParametricType()));
                }
            }

            // The code args which are new. We'll remove old args from this.
View Full Code Here

        // Find incompatibly-connected inputs.
        Argument.NameTypePair[] args = codeGem.getArguments();
        for (int i = 0; i < args.length; i++) {

            // Skip if not connected.
            PartInput input = codeGem.getInputPart(i);
            if (!input.isConnected()) {
                continue;
            }

            // If there's no arg type, this must be an "orphaned" arg (ie.
            // doesn't appear in the source).
            TypeExpr argType = args[i].getType();
            if (argType == null) {
                continue;
            }

            // Broken if the arg type doesn't unify with its inferred type, or
            // if the attached gem
            // is a value gem and the value system is unable to handle the type
            // of the argument.
            TypeExpr inferredInputType = input.inferType(typeCheckInfo);
            if (!GemGraph.typesWillUnify(argType, inferredInputType, typeCheckInfo)
                    || (input.getConnectedGem() instanceof ValueGem && !valueEditorManager.canInputDefaultValue(argType))) {

                incompatiblyConnectedPartToInferredTypeMap.put(input, inferredInputType);
            }
        }
View Full Code Here

       
        if (disableArgumentUpdating) {
            return;
        }
       
        PartInput destInput = conn.getDestination();
        Gem destGem = destInput.getGem();
       
        // Get the input argument which is disappearing.  Note the affected collector.
        CollectorGem replacedArgumentTarget = GemGraph.getInputArgumentTarget(destInput);

        // Make sure inputs from the connected subtree make sense.
View Full Code Here

       
        // Make sure inputs from the disconnected subtree make sense.
        Set<CollectorGem> affectedCollectorSet = new HashSet<CollectorGem>(reconcileArgumentTargetsOnDisconnect(conn));
       
        {
            PartInput freedInput = conn.getDestination();
            Gem.PartOutput disconnectedOutput = conn.getSource();

            // (HACK!?) Temporarily re-bind a connection so that argument target resolution can take place for the connected tree.
            // Collectors targeted by arguments on trees rooted at collectors at inner scopes of the current tree will be affected.
            freedInput.bindConnection(conn);
            disconnectedOutput.bindConnection(conn);

            // Find collectors targeted by free inputs in the descendant gem forest
            // (when considering the gem graph after connection)
            List<PartInput> freeInputsInDescendantForestList =
                GemGraph.obtainUnboundDescendantInputs(freedInput.getGem(), TraversalScope.FOREST, InputCollectMode.UNBURNT_ONLY);

            for (final PartInput partInput : freeInputsInDescendantForestList) {
                CollectorGem inputArgumentTarget = GemGraph.getInputArgumentTarget(partInput);

                if (inputArgumentTarget != null) {
                    affectedCollectorSet.add(inputArgumentTarget);
                }
            }

            // Unbind the connection.
            freedInput.bindConnection(null);
            disconnectedOutput.bindConnection(null);
        }
       
        // Update the corresponding collectors.
        updateForArgumentChange(affectedCollectorSet);
View Full Code Here

        if (disableArgumentUpdating) {
            return;
        }
       
        // get the input argument.
        PartInput newPartInput = addedCollector.getCollectingPart();

        // Add the arg to the target collector, if it's not already targeted.
        // TODOEL: this assumes that the target is (or will be) in the graph.
        CollectorGem inputTarget = GemGraph.getInputArgumentTarget(newPartInput);
        if (inputTarget == null) {
View Full Code Here

TOP

Related Classes of org.openquark.gems.client.Gem.PartInput

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.