Example #1
0
        private void GenerateContextMenu
        (
            Event current,
            Rect rowRect,
            string fullPath,
            IErrorDetails error,
            string projectRelativePath,
            ErrorTypeGUI errorTypeGUI
        )
        {
            var menuOpenClick = current.type == EventType.ContextClick ||
                                current.type == EventType.MouseDown;

            if (menuOpenClick && rowRect.Contains(current.mousePosition))
            {
                GenericMenu menu = new GenericMenu();

                menu.AddItem(new GUIContent($"Reveal in {GUIUtil.FileManagerName}"), false, ShowInFileManager, fullPath);
                menu.AddItem(new GUIContent("Highlight in project"), false, HighlightInEditor, projectRelativePath);
                menu.AddItem(new GUIContent("Copy path to clipboard/Repository relative"), false, CopyFilenameToClipboard, error.FilePosixPath);
                menu.AddItem(new GUIContent("Copy path to clipboard/Project relative"), false, CopyFilenameToClipboard, projectRelativePath);
                menu.AddItem(new GUIContent("Copy path to clipboard/Full"), false, CopyFilenameToClipboard, fullPath);
                menu.AddItem(new GUIContent($"How to fix..."), false, LearnMoreAboutError, errorTypeGUI.HelpUri);
                menu.ShowAsContext();

                current.Use();
            }
        }
Example #2
0
 public IndieBackendError(int statusCode, string error, string message, IErrorDetails details = null)
 {
     StatusCode = statusCode;
     Error      = error;
     Message    = message;
     Details    = details;
 }
    //Public Methods
    public Boolean IsValid(DataRow record, ref IErrorDetails[] errors)
    {
        //Check whether the record is null
        if (record == null)
        {
            errors = new IErrorDetails[] { new ErrorDetails(record, null, "The given record is null!") };
            return(false);
        }
        //Loop through every check and invoke them
        List <IErrorDetails> myErrors = null;
        IErrorDetails        myError  = null;

        foreach (EntityValidationRule myRule in GetRules(record.Table.TableName))
        {
            if (myRule.IsValid(record, ref myError))
            {
                if (myErrors == null)
                {
                    myErrors = new List <IErrorDetails>();
                }
                myErrors.Add(myError);
            }
        }
        //Return true if there are no errors
        if (myErrors == null)
        {
            return(true);
        }
        //Otherwise assign them as result and return false
        errors = myErrors.ToArray();
        return(false);
    }
Example #4
0
        /// <inheritdoc />
        public void Publish(IErrorDetails details)
        {
            Guard.ArgumentNotNull(details,
                                  nameof(details));

            _logger.Debug($"Received {details}");

            _subject.OnNext(details);
        }
Example #5
0
        public ErrorTypeGUI FindForError(IErrorDetails error)
        {
            var errorPattern = new ErrorPattern(error.ErrorType, error.FileStatus);

            if (_guisByType.ContainsKey(errorPattern))
            {
                return(_guisByType[errorPattern]);
            }

            return(null);
        }
Example #6
0
        public void Reset
        (
            string basePath,
            string projectPath,
            IErrorDetails initialError
        )
        {
            _basePath    = basePath;
            _projectPath = projectPath;

            if (initialError != null)
            {
                _prevErrorProjectPath = GetProjectPathForError(initialError);
            }
            else
            {
                _prevErrorProjectPath = null;
            }
        }
    //Public Methods
    public Boolean IsValid(DataRow record, ref IErrorDetails errorDetails)
    {
        if (record == null)
        {
            throw new InvalidOperationException("Programming error in Validator.cs");
        }
        if (!Validator.IdentifyerComparer.Equals(record.Table.TableName, TableName))
        {
            throw new InvalidOperationException("Programming error in Validator.cs");
        }
        String myError = GetErrorMessageIfInvalid(record);

        if (myError == null)
        {
            return(true);
        }
        errorDetails = CreateErrorDetails(record, myError);
        return(false);
    }
Example #8
0
        public void Generate
        (
            IErrorDetails error,
            ErrorTypeGUI errorTypeGUI,
            bool isOdd
        )
        {
            var backgroundStyle = isOdd
                ? _oddStyle.Get
                : _evenStyle.Get;

            EditorGUILayout.BeginHorizontal(backgroundStyle);

            var fullPath            = GetFullPathForError(error);
            var projectRelativePath = GetProjectPathForError(error, fullPath);

            GeneratePathGUI(projectRelativePath, _prevErrorProjectPath);
            GUILayout.FlexibleSpace();
            errorTypeGUI.Generate();

            EditorGUILayout.EndHorizontal();

            var rowRect      = GUILayoutUtility.GetLastRect();
            var currentEvent = Event.current;

            GenerateHoverHighlight(currentEvent, rowRect);

            GenerateContextMenu(
                currentEvent,
                rowRect,
                fullPath,
                error,
                projectRelativePath,
                errorTypeGUI
                );

            _prevErrorProjectPath = projectRelativePath;
        }
Example #9
0
 private string GetProjectPathForError(IErrorDetails error)
 {
     return(GetProjectPathForError(error, GetFullPathForError(error)));
 }
Example #10
0
 private string GetProjectPathForError(IErrorDetails error, string fullPath)
 {
     return(PathHelpers.MakeRelativePath(_projectPath, fullPath));
 }
Example #11
0
 private string GetFullPathForError(IErrorDetails error)
 {
     return(Path.Combine(_basePath, error.FilePosixPath));
 }