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) { Window window = new 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; DataDictionary.ModelElement root = Instance as DataDictionary.ModelElement; if (root == null) { root = EFSSystem.INSTANCE.Dictionaries[0]; } string text = EditionTextBox.Text; Expression expression = EFSSystem.INSTANCE.Parser.Expression(root, text, AllMatches.INSTANCE, doSemanticalAnalysis, null, silent); if (expression != null) { expression = VisitExpression(expression); EditionTextBox.Text = expression.ToString(); } Statement statement = EFSSystem.INSTANCE.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) { DataDictionary.ModelElement.DontRaiseError(() => { InterpretationContext context = new InterpretationContext(Model) {UseDefaultValue = false}; IValue value = expression.GetValue(context, null); if (value != null) { Window window = new Window(); window.SetModel(value); window.ShowDialog(); string newExpression = value.ToExpressionWithDefault(); const bool doSemanticalAnalysis = true; const bool silent = true; retVal = EFSSystem.INSTANCE.Parser.Expression(expression.Root, newExpression, AllMatches.INSTANCE, doSemanticalAnalysis, null, silent); } }); } return retVal; }