private void OnControllerStepDone(object sender,
                                          EventArgs args)
        {
            Application.Invoke(delegate(object resender, EventArgs a)
            {
                if (currentNode.Parent != null)
                {
                    string currentLabel = currentNode.Matcher.Label;
                    currentNode         = currentNode.Parent as SyntacticalCoverNode;
                    currentNode.Select();
                    syntacticalCoverTree.CollapseRow(syntacticalCoverTree.Selection.GetSelectedRows()[0]);

                    parsingTaskLabel.Markup =
                        String.Format("<b>Volviendo al nodo padre de <i>{0}</i>, <i>{1}</i></b>",
                                      GLib.Markup.EscapeText(currentLabel),
                                      GLib.Markup.EscapeText(currentNode.Matcher.Label));
                }

                MarkImage(null);


                if (controller.StepMode == ControllerStepMode.StepByStep)
                {
                    parsingNextButtonsAlign.Sensitive = true;
                }
            });
        }
        private void OnParsingProcessBtnClicked(object sender, EventArgs args)
        {
            syntacticalCoverModel.Clear();

            parsingTaskLabel.Markup = "-";

            // We set the tokens from the previous step.
            controller.SetStartTokens(MainRecognizerWindow.TokenizingWidget.ResultTokens);

            // We set the rules library.
            SyntacticalRulesLibrary.Instance.ClearRules();

            List <SyntacticalRule> rules =
                Config.RecognizerConfig.Instance.SyntacticalRules;

            foreach (SyntacticalRule rule in  rules)
            {
                SyntacticalRulesLibrary.Instance.AddRule(rule);
            }

            SyntacticalRulesLibrary.Instance.StartRule = rules[0];

            parsingButtonsNB.Page = 1;

            currentNode = null;

            controller.Next(ControllerStepMode.StepByStep);
        }
        private void OnControllerMatching(object sender,
                                          MatchingArgs _args)
        {
            Application.Invoke(sender,
                               _args,
                               delegate(object resender, EventArgs a)
            {
                MatchingArgs args            = a as MatchingArgs;
                SyntacticalCoverNode newNode =
                    new SyntacticalCoverNode(args.Matcher,
                                             syntacticalCoverTree);

                if (currentNode == null)
                {
                    syntacticalCoverModel.AddNode(newNode);
                }
                else
                {
                    currentNode.Select();
                    currentNode.AddChild(newNode);
                    syntacticalCoverTree.ExpandRow(syntacticalCoverTree.Selection.GetSelectedRows()[0],
                                                   false);
                }

                currentNode = newNode;


                currentNode.Select();


                parsingTaskLabel.Markup =
                    String.Format("<b>Intentando encajar los elementos restantes con <i>{0}</i></b>",
                                  GLib.Markup.EscapeText(currentNode.Matcher.Label));

                parsingNextButtonsAlign.Sensitive =
                    controller.StepMode == ControllerStepMode.StepByStep;
            });
        }