/// <summary> /// Edits a value expression and provides the edited expression after user has performed his changes /// </summary> /// <param name="expression"></param> /// <returns></returns> private Expression EditExpression(Expression expression) { Expression retVal = expression; if (expression != null) { ModelElement.DontRaiseError(() => { InterpretationContext context = new InterpretationContext(Model) { UseDefaultValue = false }; IValue value = expression.GetExpressionValue(context, null); if (value != null) { StructureEditor.Window window = new StructureEditor.Window(); window.SetModel(value); window.ShowDialog(); string newExpression = value.ToExpressionWithDefault(); const bool doSemanticalAnalysis = true; const bool silent = true; retVal = new Parser().Expression(expression.Root, newExpression, AllMatches.INSTANCE, doSemanticalAnalysis, null, silent); } }); } return(retVal); }
/// <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(); }
private void openStructureEditorToolStripMenuItem_Click(object sender, EventArgs e) { bool dialogShown = false; ExplanationPart part = Instance as ExplanationPart; if (part != null) { IValue value = part.RightPart as IValue; if (value != null) { StructureEditor.Window window = new StructureEditor.Window(); window.SetModel(value); window.ShowDialog(); dialogShown = true; } Action action = part.Element as Action; if (!dialogShown && action != null) { VisitStatement(action.Statement); dialogShown = true; } Expectation expectation = part.Element as Expectation; if (!dialogShown && expectation != null) { VisitExpression(expectation.Expression); dialogShown = true; } } if (!dialogShown) { const bool doSemanticalAnalysis = true; const bool silent = true; ModelElement root = Instance as ModelElement; if (root == null) { root = EfsSystem.Instance.Dictionaries[0]; } string text = EditionTextBox.Text; Expression expression = new Parser().Expression(root, text, AllMatches.INSTANCE, doSemanticalAnalysis, null, silent); if (expression != null) { expression = VisitExpression(expression); EditionTextBox.Text = expression.ToString(); } Statement statement = new Parser().Statement(root, text, silent); if (statement != null) { statement = VisitStatement(statement); EditionTextBox.Text = statement.ToString(); } } }
/// <summary> /// Edits a value expression and provides the edited expression after user has performed his changes /// </summary> /// <param name="expression"></param> /// <returns></returns> private Expression EditExpression(Expression expression) { Expression retVal = expression; if (expression != null) { ModelElement.DontRaiseError(() => { InterpretationContext context = new InterpretationContext(Model) {UseDefaultValue = false}; IValue value = expression.GetExpressionValue(context, null); if (value != null) { StructureEditor.Window window = new StructureEditor.Window(); window.SetModel(value); window.ShowDialog(); string newExpression = value.ToExpressionWithDefault(); const bool doSemanticalAnalysis = true; const bool silent = true; retVal = new Parser().Expression(expression.Root, newExpression, AllMatches.INSTANCE, doSemanticalAnalysis, null, silent); } }); } return retVal; }