Exemplo n.º 1
0
        internal void SetErrorValue(object data, ErrorType errorType, bool runtime = false)
        {
            if (this.errorBubble == null)
            {
                if (data == null)
                    return;
                else
                    this.errorBubble = new ErrorBubble(this.graphController, this.nodeId);
            }

            #if DEBUG
            // Ensure priority order is not changed: Syntax, Semantic, Warning, None.
            System.Diagnostics.Debug.Assert(ErrorType.Syntax > ErrorType.Semantic);
            System.Diagnostics.Debug.Assert(ErrorType.Semantic > ErrorType.Warning);
            System.Diagnostics.Debug.Assert(ErrorType.Warning > ErrorType.None);
            #endif

            if (null == data) // No error data, reset error bubble.
            {
                data = string.Empty;
                errorType = ErrorType.None;
                this.Error = false;
            }
            else if (data is string)
            {
                // Empty error string, reset error bubble.
                if (string.IsNullOrEmpty(data as string))
                {
                    data = string.Empty;
                    errorType = ErrorType.None;
                    this.Error = false;
                }
            }

            //check if error need to be shown
            if (!runtime || (this.ShowError() == true))
            {
                if (errorType > ErrorType.Warning) // There's an error.
                {
                    // If the new error is of a higher priority than the one we
                    // have internally, then overwrite the current error message.
                    if (errorType >= this.errorBubble.ErrType)
                    {
                        this.errorBubble.SetContent(data);
                        this.errorBubble.SetErrorType(errorType);
                        this.Error = true;
                    }
                }
                else // Warning or no error.
                {
                    this.errorBubble.SetContent(data);
                    this.errorBubble.SetErrorType(errorType);
                    this.Error = false;
                }
            }
            if (false != this.Error && this.previewBubble != null)
                this.previewBubble.SetContent(null); // Dismiss preview bubble.
        }
Exemplo n.º 2
0
        internal void SetErrorValue(object data, ErrorType errorType, bool runtime = false)
        {
            if (this.errorBubble == null)
            {
                if (data == null)
                {
                    return;
                }
                else
                {
                    this.errorBubble = new ErrorBubble(this.graphController, this.nodeId);
                }
            }

#if DEBUG
            // Ensure priority order is not changed: Syntax, Semantic, Warning, None.
            System.Diagnostics.Debug.Assert(ErrorType.Syntax > ErrorType.Semantic);
            System.Diagnostics.Debug.Assert(ErrorType.Semantic > ErrorType.Warning);
            System.Diagnostics.Debug.Assert(ErrorType.Warning > ErrorType.None);
#endif

            if (null == data) // No error data, reset error bubble.
            {
                data       = string.Empty;
                errorType  = ErrorType.None;
                this.Error = false;
            }
            else if (data is string)
            {
                // Empty error string, reset error bubble.
                if (string.IsNullOrEmpty(data as string))
                {
                    data       = string.Empty;
                    errorType  = ErrorType.None;
                    this.Error = false;
                }
            }

            //check if error need to be shown
            if (!runtime || (this.ShowError() == true))
            {
                if (errorType > ErrorType.Warning) // There's an error.
                {
                    // If the new error is of a higher priority than the one we
                    // have internally, then overwrite the current error message.
                    if (errorType >= this.errorBubble.ErrType)
                    {
                        this.errorBubble.SetContent(data);
                        this.errorBubble.SetErrorType(errorType);
                        this.Error = true;
                    }
                }
                else // Warning or no error.
                {
                    this.errorBubble.SetContent(data);
                    this.errorBubble.SetErrorType(errorType);
                    this.Error = false;
                }
            }
            if (false != this.Error && this.previewBubble != null)
            {
                this.previewBubble.SetContent(null); // Dismiss preview bubble.
            }
        }