Ejemplo n.º 1
0
 /// <summary>
 ///     Executes the action
 /// </summary>
 /// <param name="e"></param>
 protected override void OnClick(EventArgs e)
 {
     if (SubStep != null)
     {
         Action action = (Action)acceptor.getFactory().createAction();
         action.Name = "";
         SubStep.appendActions(action);
     }
     base.OnClick(e);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Splits the selected action to several sub-actions
        /// </summary>
        public virtual void SplitHandler(object sender, EventArgs args)
        {
            DataDictionary.Interpreter.Statement.Statement statement = Item.EFSSystem.Parser.Statement(Item, Item.ExpressionText);
            DataDictionary.Interpreter.Statement.VariableUpdateStatement variableUpdateStatement = statement as DataDictionary.Interpreter.Statement.VariableUpdateStatement;
            if (variableUpdateStatement != null)
            {
                DataDictionary.Interpreter.Expression       expression       = variableUpdateStatement.Expression;
                DataDictionary.Interpreter.StructExpression structExpression = expression as DataDictionary.Interpreter.StructExpression;
                if (structExpression != null)
                {
                    Dictionary <string, DataDictionary.Interpreter.Expression> associations = structExpression.Associations;
                    foreach (KeyValuePair <string, DataDictionary.Interpreter.Expression> value in associations)
                    {
                        DataDictionary.Rules.Action action = (DataDictionary.Rules.Action)DataDictionary.Generated.acceptor.getFactory().createAction();
                        action.Expression = structExpression.Structure.ToString() + "." + value.Key + " <- " + value.Value.ToString();
                        string         aString        = value.Value.ToString();
                        ActionTreeNode actionTreeNode = new ActionTreeNode(action);

                        BaseTreeNode parent = Parent as BaseTreeNode;
                        if ((parent != null) && (parent.Nodes != null))
                        {
                            DataDictionary.Rules.RuleCondition ruleCondition = Item.Enclosing as DataDictionary.Rules.RuleCondition;
                            if (ruleCondition != null)
                            {
                                ruleCondition.appendActions(action);
                            }
                            else
                            {
                                DataDictionary.Tests.SubStep subStep = Item.Enclosing as DataDictionary.Tests.SubStep;
                                if (subStep != null)
                                {
                                    subStep.appendActions(action);
                                }
                            }
                            parent.Nodes.Add(actionTreeNode);
                        }
                    }
                }
            }
            Delete();
            SortSubNodes();
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Splits the selected action to several sub-actions
        /// </summary>
        public virtual void SplitHandler(object sender, EventArgs args)
        {
            Statement statement = new Parser().Statement(Item, Item.ExpressionText);
            VariableUpdateStatement variableUpdateStatement = statement as VariableUpdateStatement;

            if (variableUpdateStatement != null)
            {
                Expression       expression       = variableUpdateStatement.Expression;
                StructExpression structExpression = expression as StructExpression;
                if (structExpression != null)
                {
                    Dictionary <Designator, Expression> associations = structExpression.Associations;
                    foreach (KeyValuePair <Designator, Expression> value in associations)
                    {
                        Action action = (Action)acceptor.getFactory().createAction();
                        action.ExpressionText = structExpression.Structure + "." + value.Key + " <- " +
                                                value.Value;
                        ActionTreeNode actionTreeNode = new ActionTreeNode(action, true);

                        BaseTreeNode parent = Parent as BaseTreeNode;
                        if (parent != null)
                        {
                            RuleCondition ruleCondition = Item.Enclosing as RuleCondition;
                            if (ruleCondition != null)
                            {
                                ruleCondition.appendActions(action);
                            }
                            else
                            {
                                SubStep subStep = Item.Enclosing as SubStep;
                                if (subStep != null)
                                {
                                    subStep.appendActions(action);
                                }
                            }
                            parent.Nodes.Add(actionTreeNode);
                        }
                    }
                }
            }
            Delete();
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Handles a drop event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TimeLineControl_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("WindowsForms10PersistentObject", false))
            {
                BaseTreeNode sourceNode = e.Data.GetData("WindowsForms10PersistentObject") as BaseTreeNode;
                if (sourceNode != null)
                {
                    VariableTreeNode variableNode = sourceNode as VariableTreeNode;
                    if (variableNode != null)
                    {
                        SubStep subStep = SubStepRelatedToMousePosition();
                        if (subStep != null)
                        {
                            // Create the default value
                            IValue     value        = null;
                            Expression expression   = null;
                            string     defaultValue = variableNode.Item.Default;
                            if (defaultValue != null)
                            {
                                const bool doSemanticalAnalysis = true;
                                const bool silent = true;
                                expression = new Parser().Expression(variableNode.Item, defaultValue,
                                                                     AllMatches.INSTANCE, doSemanticalAnalysis, null, silent);
                            }

                            if (expression != null)
                            {
                                InterpretationContext context = new InterpretationContext {
                                    UseDefaultValue = false
                                };
                                value = expression.GetExpressionValue(context, null);
                            }

                            if (value == null || value is EmptyValue)
                            {
                                Structure structureType = variableNode.Item.Type as Structure;
                                if (structureType != null)
                                {
                                    const bool setDefaultValue = false;
                                    value = new StructureValue(structureType, setDefaultValue);
                                }
                            }

                            // Create the action or the expectation according to the keyboard modifier keys
                            if (value != null)
                            {
                                if ((e.KeyState & Ctrl) != 0)
                                {
                                    Expectation expectation = (Expectation)acceptor.getFactory().createExpectation();
                                    expectation.ExpressionText = variableNode.Item.FullName + " == " + value.FullName;
                                    subStep.appendExpectations(expectation);
                                }
                                else
                                {
                                    Action action = (Action)acceptor.getFactory().createAction();
                                    action.ExpressionText = variableNode.Item.FullName + " <- " + value.FullName;
                                    subStep.appendActions(action);
                                }
                            }
                            else
                            {
                                MessageBox.Show(
                                    Resources
                                    .StaticTimeLineControl_TimeLineControl_DragDrop_Cannot_evaluate_variable_default_value,
                                    Resources.StaticTimeLineControl_TimeLineControl_DragDrop_Cannot_create_event,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                            }
                        }
                    }
                }
            }
        }