Example #1
0
        /// <summary>
        /// A new set of Inputs reflecting the current Procedure state.
        /// </summary>
        protected override List <Input> BuildUpdatedInputs()
        {
            List <string> args     = mProcedure.Arguments;
            int           argCount = args.Count;
            List <Input>  inputs   = new List <Input>();

            // Procedure name
            inputs.Add(mBlock.InputList[0]);

            // Argument inputs
            for (int i = 0; i < argCount; ++i)
            {
                Input stackInput = InputFactory.Create(Define.EConnection.InputValue, "ARG" + i, Define.EAlign.Right, null);

                // add "with: " label
                if (i == 0)
                {
                    FieldLabel withLabel = new FieldLabel("WITH", I18n.Msg[MsgDefine.PROCEDURES_CALL_BEFORE_PARAMS]);
                    stackInput.AppendField(withLabel);
                }

                // add argument's label
                FieldLabel label = new FieldLabel(null, args[i]);
                stackInput.AppendField(label);

                inputs.Add(stackInput);
            }
            return(inputs);
        }
Example #2
0
        protected override void UpdateInternal()
        {
            base.UpdateInternal();
            FieldLabel nameField = this.GetNameField();

            if (mProcedure != null && nameField != null)
            {
                nameField.SetValue(mProcedure.Name);
            }
        }
Example #3
0
        /// Sets the mutator name, including setting the associated name field on the block.
        /// </summary>
        protected override void SetProcedureNameInternal(string name)
        {
            mProcedure = mProcedure.CloneWithName(name);
            FieldLabel nameField = GetNameField();

            if (nameField != null)
            {
                nameField.SetValue(name);
            }
        }
Example #4
0
        protected override void OnAttached()
        {
            Input defaultInput = mBlock.InputList[0];

            defaultInput.SetName(EMPTY_NAME);
            FieldLabel field = defaultInput.FieldRow[0] as FieldLabel;

            mLabelText = field.GetText();
            UpdateInternal();
        }
Example #5
0
        public FieldLabel GetNameField()
        {
            if (mBlock == null)
            {
                return(null);
            }

            FieldLabel field = mBlock.GetField(ProcedureDB.PROCEDURE_NAME_FIELD) as FieldLabel;

            return(field);
        }
Example #6
0
        protected override Procedure DeserializeProcedure(XmlElement xmlElement)
        {
            Procedure  info      = Procedure.Deserialize(xmlElement);
            FieldLabel nameField = GetNameField();

            if (string.IsNullOrEmpty(info.Name) && nameField != null)
            {
                info = new Procedure(nameField.GetText(), info.Arguments, info.DefinitionHasStatementBody);
            }
            return(info);
        }
Example #7
0
        /// <summary>
        /// Called when the mutator is attached to a block. It will make sure the procedure name on the
        /// block's name field is in sync with the mutator's Procedure Info, and register a listener on the name field for future edits.
        /// </summary>
        protected override void OnAttached()
        {
            string procedureName = null;

            // Update the Procedure Info with procedure name from NAME field.
            // In the case of this class, this will not update the mutation serialization,
            // but initializes the value to synch with caller's Procedure Info.
            FieldLabel nameField = GetNameField();

            if (nameField != null)
            {
                string blockProcName = nameField.GetValue();
                string infoProcName  = (mProcedure == null) ? null : mProcedure.Name;
                if (!string.IsNullOrEmpty(blockProcName) && !blockProcName.Equals(infoProcName))
                {
                    if (!string.IsNullOrEmpty(infoProcName))
                    {
                        throw new Exception("Attached to block that already has a differing procedure name.");
                    }
                    procedureName = blockProcName;
                }
                else
                {
                    procedureName = infoProcName;
                }
            }
            mProcedure = mProcedure == null
                        ? new Procedure(procedureName, new List <string>(), ProcedureDB.HAS_STATEMENTS_DEFAULT)
                        : new Procedure(procedureName, mProcedure.Arguments, mProcedure.DefinitionHasStatementBody);

            base.OnAttached();

            if (nameField != null)
            {
                nameField.SetValue(procedureName);
            }
        }
Example #8
0
        /// <summary>
        /// Inserts a label from string
        /// </summary>
        /// <param name="index"> The index at which to insert field.</param>
        /// <param name="field"> label string to add as a field.</param>
        /// <param name="optName"> Language-neutral identifier which may used to find this field again. Should be unique to the host block.</param>
        public int InsertFieldAt(int index, string field, string optName = null)
        {
            FieldLabel fieldLabel = string.IsNullOrEmpty(field) ? null : new FieldLabel(optName, field);

            return(InsertFieldAt(index, fieldLabel));
        }