/// <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> /// Sets the more information according to the displayed model /// </summary> private void SetMoreInfo() { ModelElement.DontRaiseError(() => { moreInfoRichTextBox.Text = ""; ITextualExplain textualExplain = DisplayedModel as ITextualExplain; if (textualExplain != null) { moreInfoRichTextBox.Instance = DisplayedModel; moreInfoRichTextBox.Text = TextualExplanationUtils.GetText(textualExplain, true); } Refresh(); }); }
/// <summary> /// Provides the display attributes for a model event /// </summary> /// <param name="evt"></param> /// <returns></returns> private EventDisplayAttributes GetDisplayAttributes(ModelEvent evt) { EventDisplayAttributes retVal = new EventDisplayAttributes(Color.White, new Pen(Color.Black), "<undefined>", null, null, null); ModelElement.DontRaiseError(() => { Expect expect = evt as Expect; if (expect != null) { string name = GuiUtils.AdjustForDisplay(ShortName(expect.Expectation.Name), _eventSize.Width - 4, BottomFont); switch (expect.State) { case Expect.EventState.Active: retVal = new EventDisplayAttributes(Color.Violet, new Pen(Color.Black), name, Images.Images[QuestionMarkImageIndex], NameSpaceImages.Instance.GetImage(expect.Expectation), null); break; case Expect.EventState.Fullfilled: retVal = new EventDisplayAttributes(Color.LightGreen, new Pen(Color.Green), name, Images.Images[SuccessImageIndex], NameSpaceImages.Instance.GetImage(expect.Expectation), null); break; case Expect.EventState.TimeOut: retVal = new EventDisplayAttributes(Color.Red, new Pen(Color.DarkRed), name, Images.Images[ErrorImageIndex], NameSpaceImages.Instance.GetImage(expect.Expectation), null); break; } if (expect.Expectation.getKind() == acceptor.ExpectationKind.aContinuous) { retVal.TopRightIconImage.Add(Images.Images[CircularArrowIndex]); } if (expect.Expectation.Blocking) { retVal.TopRightIconImage.Add(Images.Images[DownArrowIndex]); } } ModelInterpretationFailure modelInterpretationFailure = evt as ModelInterpretationFailure; if (modelInterpretationFailure != null) { string name = GuiUtils.AdjustForDisplay(modelInterpretationFailure.Message, _eventSize.Width - 4, BottomFont); retVal = new EventDisplayAttributes(Color.Red, new Pen(Color.DarkRed), name, Images.Images[ErrorImageIndex], NameSpaceImages.Instance.GetImage(modelInterpretationFailure.Instance as ModelElement), null); } RuleFired ruleFired = evt as RuleFired; if (ruleFired != null) { string name = GuiUtils.AdjustForDisplay(ShortName(ruleFired.RuleCondition.Name), _eventSize.Width - 4, BottomFont); retVal = new EventDisplayAttributes(Color.LightBlue, new Pen(Color.Blue), name, null, NameSpaceImages.Instance.GetImage(ruleFired.RuleCondition), Images.Images[ToolsImageIndex]); } VariableUpdate variableUpdate = evt as VariableUpdate; if (variableUpdate != null) { string name = variableUpdate.Action.ExpressionText; Image rightIcon = null; Image rightModifier = null; if (variableUpdate.Action.Statement != null) { name = variableUpdate.Action.Statement.ShortShortDescription(); rightIcon = NameSpaceImages.Instance.GetImage(variableUpdate.Action.Statement.AffectedElement()); switch (variableUpdate.Action.Statement.UsageDescription()) { case Statement.ModeEnum.Call: rightModifier = Images.Images[CallImageIndex]; break; case Statement.ModeEnum.In: rightModifier = Images.Images[InImageIndex]; break; case Statement.ModeEnum.InOut: rightModifier = Images.Images[InOutImageIndex]; break; case Statement.ModeEnum.Internal: rightModifier = Images.Images[InternalImageIndex]; break; case Statement.ModeEnum.Out: rightModifier = Images.Images[OutImageIndex]; break; } } name = GuiUtils.AdjustForDisplay(ShortName(name), _eventSize.Width - 4, BottomFont); NameSpace nameSpace = EnclosingFinder <NameSpace> .find(variableUpdate.Action); if (nameSpace == null) { retVal = new EventDisplayAttributes(Color.LightGray, new Pen(Color.Black), name, null, rightIcon, rightModifier); } else { retVal = new EventDisplayAttributes(Color.BlanchedAlmond, new Pen(Color.Black), name, null, rightIcon, rightModifier); } } SubStepActivated subStepActivated = evt as SubStepActivated; if (subStepActivated != null) { retVal = new EventDisplayAttributes(Color.LightGray, new Pen(Color.Black), "SubStep", null, null, null); } }); return(retVal); }