示例#1
0
        /// <summary>
        ///     Shows the messages associated to this step
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void ShowMessagesHandler(object sender, EventArgs args)
        {
            string messageExpression = "[";

            bool first = true;

            foreach (DBMessage message in Item.StepMessages)
            {
                if (!first)
                {
                    messageExpression = messageExpression + ",";
                }

                if (message != null)
                {
                    messageExpression = messageExpression + Translation.format_message(message);
                    first             = false;
                }
            }
            messageExpression += "]";

            Expression expression = new Parser().Expression(Item.Dictionary, messageExpression);
            IValue     value      = expression.GetExpressionValue(new InterpretationContext(), null);

            StructureEditor.Window editor = new StructureEditor.Window();
            editor.SetModel(value);
            editor.ShowDialog();
        }
示例#2
0
        /// <summary>
        ///     Creates a new translation
        /// </summary>
        /// <param name="translation"></param>
        /// <returns></returns>
        public void CreateTranslation(Translation translation)
        {
            Translation existingTranslation = null;

            foreach (SourceText sourceText in translation.SourceTexts)
            {
                existingTranslation = Item.Dictionary.TranslationDictionary.FindExistingTranslation(sourceText);
                if (existingTranslation != null)
                {
                    break;
                }
            }

            if (existingTranslation != null)
            {
                DialogResult dialogResult =
                    MessageBox.Show(
                        @"Translation already exists. Do you want to create a new one (Cancel will select the existing translation) ?",
                        @"Already existing translation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (dialogResult == DialogResult.OK)
                {
                    existingTranslation = null;
                }
            }

            if (existingTranslation == null)
            {
                Item.appendTranslations(translation);
            }
        }
        /// <summary>
        /// Creates a new translation based on a step
        /// </summary>
        /// <param name="step"></param>
        private void createTranslation(DataDictionary.Tests.Step step)
        {
            DataDictionary.Tests.Translations.Translation translation = (DataDictionary.Tests.Translations.Translation)DataDictionary.Generated.acceptor.getFactory().createTranslation();
            DataDictionary.Tests.Translations.SourceText  sourceText  = (DataDictionary.Tests.Translations.SourceText)DataDictionary.Generated.acceptor.getFactory().createSourceText();

            sourceText.Name = step.getDescription();
            translation.appendSourceTexts(sourceText);
            createTranslation(translation);
        }
 public override void visit(Generated.Translation obj, bool visitSubNodes)
 {
     DataDictionary.Tests.Translations.Translation translation = (DataDictionary.Tests.Translations.Translation)obj;
     if (!translation.getImplemented())
     {
         translation.AddInfo("Not implemented translation");
     }
     base.visit(obj, visitSubNodes);
 }
        /// <summary>
        /// Creates a new translation
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public TranslationTreeNode createTranslation(DataDictionary.Tests.Translations.Translation translation)
        {
            TranslationTreeNode retVal;

            Item.appendTranslations(translation);
            retVal = new TranslationTreeNode(translation);
            Nodes.Add(retVal);
            SortSubNodes();

            return(retVal);
        }
示例#6
0
        /// <summary>
        ///     Provides the description of the requirements related to this model element
        /// </summary>
        /// <returns></returns>
        public override string RequirementDescription()
        {
            string retVal = base.RequirementDescription();

            if (Translation != null)
            {
                // TODO : Check, this seems strange
                retVal = Translation.getSourceTextExplain();
            }

            return(retVal);
        }
示例#7
0
        /// <summary>
        ///     Handles drop event
        /// </summary>
        /// <param name="sourceNode"></param>
        public override void AcceptDrop(BaseTreeNode sourceNode)
        {
            base.AcceptDrop(sourceNode);
            if (sourceNode is StepTreeNode)
            {
                StepTreeNode step = sourceNode as StepTreeNode;

                CreateTranslation(step.Item);
            }
            else if (sourceNode is TranslationTreeNode)
            {
                TranslationTreeNode translation      = sourceNode as TranslationTreeNode;
                Translation         otherTranslation = translation.Item;
                translation.Delete();
                CreateTranslation(otherTranslation);
            }
        }
        /// <summary>
        /// Accepts a drop event
        /// </summary>
        /// <param name="SourceNode"></param>
        public override void AcceptDrop(BaseTreeNode SourceNode)
        {
            base.AcceptDrop(SourceNode);
            if (SourceNode is TestRunnerView.StepTreeNode)
            {
                TestRunnerView.StepTreeNode step = SourceNode as TestRunnerView.StepTreeNode;

                createTranslation(step.Item);
            }
            else if (SourceNode is TranslationTreeNode)
            {
                TranslationTreeNode translation = SourceNode as TranslationTreeNode;

                DataDictionary.Tests.Translations.Translation otherTranslation = (DataDictionary.Tests.Translations.Translation)DataDictionary.Generated.acceptor.getFactory().createTranslation();
                translation.Item.copyTo(otherTranslation);
                createTranslation(otherTranslation);

                translation.Delete();
            }
        }
示例#9
0
        /// <summary>
        ///     Shows the translation which should be applied on this step
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void ShowTranslationHandler(object sender, EventArgs args)
        {
            if (Item.getTranslationRequired())
            {
                Translation translation = EfsSystem.Instance.FindTranslation(Item);
                if (translation != null)
                {
                    // Finds the translation window which corresponds to this translation
                    TranslationRules.Window translationWindow = null;
                    foreach (IBaseForm form in GuiUtils.MdiWindow.SubWindows)
                    {
                        translationWindow = form as TranslationRules.Window;
                        if (translationWindow != null)
                        {
                            TypedTreeView <TranslationDictionary> treeView =
                                translationWindow.TreeView as TypedTreeView <TranslationDictionary>;
                            if (treeView != null && treeView.Root == translation.TranslationDictionary)
                            {
                                break;
                            }
                        }
                    }

                    if (translationWindow == null)
                    {
                        translationWindow = new TranslationRules.Window(translation.TranslationDictionary);
                        GuiUtils.MdiWindow.AddChildWindow(translationWindow);
                    }

                    EfsSystem.Instance.Context.SelectElement(translation, this, Context.SelectionCriteria.DoubleClick);
                }
            }
            else
            {
                MessageBox.Show(@"No translation required for this step");
            }
        }
示例#10
0
        /// <summary>
        ///     Translates the current step according to the translation dictionary
        ///     Removes all preconditions, actions and expectations
        /// </summary>
        /// <param name="applyTranslation">Indicates that the translation should be applied. Otherwise, this method only cleans the step.
        /// This is used to handle the fact that a blocking error has been found, and translating the sub sequence should be stopped,
        /// but the next steps should be cleaned</param>
        /// <returns>False if an error has been found while translating this step, or if translations should not be applied</returns>
        public bool Translate(bool applyTranslation)
        {
            bool retVal = applyTranslation;

            Counter counter = new Counter();

            counter.visit(this);
            if (counter.Issues[IssueKind.Blocking] != 0)
            {
                retVal = false;
            }

            if (getTranslationRequired())
            {
                Util.DontNotify(() =>
                {
                    setTranslated(false);
                    SubSteps.Clear();

                    if (retVal)
                    {
                        Translation translation = EFSSystem.FindTranslation(this);
                        if (translation != null)
                        {
                            translation.UpdateStep(this);
                            setTranslated(true);
                        }
                        else
                        {
                            AddWarning("Cannot find translation for this step");
                        }
                    }
                });
            }

            return(retVal);
        }
 public void AddTranslationHandler(object sender, EventArgs args)
 {
     DataDictionary.Tests.Translations.Translation translation = (DataDictionary.Tests.Translations.Translation)DataDictionary.Generated.acceptor.getFactory().createTranslation();
     translation.Name = "<Translation " + (Item.Translations.Count + 1) + ">";
     createTranslation(translation);
 }
示例#12
0
 /// <summary>
 /// Adds a new translation
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 public void AddTranslationHandler(object sender, EventArgs args)
 {
     CreateTranslation(Translation.CreateDefault(Item.Translations, null));
 }
示例#13
0
 /// <summary>
 ///     Creates a new translation based on a step's source text
 /// </summary>
 /// <param name="step"></param>
 private void CreateTranslation(Step step)
 {
     CreateTranslation(Translation.CreateDefault(Item.Translations, step.CreateSourceText()));
 }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="translation"></param>
 public MarkUsageVisitor(Translation translation)
 {
     Translation = translation;
 }
示例#15
0
 /// <summary>
 /// Creates a new frame
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public TranslationTreeNode createTranslation(DataDictionary.Tests.Translations.Translation translation)
 {
     return(dictionary.createTranslation(translation));
 }