private void OnFocus() { if (EditorConfigurator.Instance.Validation.IsAllowedToValidate() && activeCourse != null) { EditorConfigurator.Instance.Validation.Validate(activeCourse.Data, GlobalEditorHandler.GetCurrentCourse()); } }
public void SetChapter(IChapter chapter) { if (chapter != GlobalEditorHandler.GetCurrentChapter()) { GlobalEditorHandler.SetCurrentChapter(chapter); } CurrentChapter = chapter; Graphics.Reset(); Grid = new WorkflowEditorGrid(Graphics, gridCellSize); Graphics.Canvas.ContextClick += HandleCanvasContextClick; EntryNode entryNode = CreateEntryNode(chapter); IDictionary <IStep, StepNode> stepNodes = SetupSteps(chapter); SetupTransitions(chapter, entryNode, stepNodes); Graphics.CalculateBoundingBox(); if (EditorConfigurator.Instance.Validation.IsAllowedToValidate()) { EditorConfigurator.Instance.Validation.Validate(CurrentChapter.Data, GlobalEditorHandler.GetCurrentCourse(), null); } }
private void OnFocus() { if (step?.Data == null) { return; } if (EditorConfigurator.Instance.Validation.IsAllowedToValidate()) { EditorConfigurator.Instance.Validation.Validate(step.Data, GlobalEditorHandler.GetCurrentCourse()); } }
public override void Draw() { EditorDrawingHelper.DrawRoundedRect(Owner.BoundingBox, CurrentColor, 10f); IValidationHandler validation = EditorConfigurator.Instance.Validation; if (validation.IsAllowedToValidate()) { IContextResolver resolver = validation.ContextResolver; IContext context = resolver.FindContext(Owner.Step.Data, GlobalEditorHandler.GetCurrentCourse()); if (validation.LastReport != null) { List <EditorReportEntry> errors = validation.LastReport.GetEntriesFor(context); if (errors.Count > 0) { string tooltip = ValidationTooltipGenerator.CreateStepTooltip(errors, resolver.FindContext(Owner.ActiveChapter.Data, GlobalEditorHandler.GetCurrentCourse())); GUIContent content = new GUIContent("", null, tooltip); Rect rect = new Rect(Owner.BoundingBox.x + Owner.BoundingBox.width * 0.70f, Owner.BoundingBox.y - 8, 16, 16); // Label icons are too small so we draw a label for the tool tip and icon separated. GUI.Label(rect, content); GUI.DrawTexture(rect, EditorGUIUtility.IconContent("Warning").image); } } } float labelX = Owner.BoundingBox.x + labelBorderOffsetInwards; float labelY = Owner.BoundingBox.y + labelBorderOffsetInwards; float labelWidth = Owner.BoundingBox.width - labelBorderOffsetInwards * 2f; float labelHeight = Owner.BoundingBox.height - labelBorderOffsetInwards * 2f; Rect labelPosition = new Rect(labelX, labelY, labelWidth, labelHeight); GUIStyle labelStyle = new GUIStyle { alignment = TextAnchor.MiddleCenter, normal = { textColor = TextColor }, wordWrap = false, }; string name = EditorDrawingHelper.TruncateText(Owner.Step.Data.Name, labelStyle, labelPosition.width); GUIContent labelContent = new GUIContent(name); GUI.Label(labelPosition, labelContent, labelStyle); }