Example #1
0
        public void OnGUI()
        {
            EditorGUILayout.Space();
            EditorGUILayout.LabelField((_dataScope == DataScope.Local ? "Local " : "Global ") + "Rules:",
                                       EditorStyles.boldLabel);

            CqaLabel.Italic(
                _dataScope == DataScope.Local
                    ? "Local rules are only available for the current project. They are located in the Assets folder and can be shared via VCS."
                    : "Global rules are available for all Unity projects of your user. They are not located in the Assets folder."
                );

            List <Group> groupsSortedByDescription = _groupList.ToList();

            groupsSortedByDescription.Sort((k1, k2) => string.Compare(k1.key, k2.key, StringComparison.Ordinal));

            if (groupsSortedByDescription.Count == 0)
            {
                CqaLabel.Slim("No rules found.");
            }

            foreach (Group group in groupsSortedByDescription)
            {
                _scroll = EditorGUILayout.BeginScrollView(_scroll);
                CreateGroupCheckboxAndFoldout(group);
                CreateRuleCheckboxesForGroup(group);
                EditorGUILayout.EndScrollView();
            }

            GUILayout.Space(20);
        }
Example #2
0
        public void Show()
        {
            CqaLabel.FormLabel(_label);
            CqaLabel.FormDescription(_description);

            _selected = EditorGUILayout.Popup(_selected, _possibleValues);

            CqaLabel.FormGroupSpacing();
        }
Example #3
0
        public void Show()
        {
            CqaLabel.Heading1("Manage Custom Rules");

            ShowGlobalRuleEditor();
            ShowLocalRuleEditor();

            GUILayout.Space(10);

            if (CqaButton.NormalButton("Create Group"))
            {
                CqaGroupEditWindow.Open(DataScope.Local);
            }

            if ((_localRuleManager.DoGroupsExist() || _globalRuleManager.DoGroupsExist()) &&
                CqaButton.NormalButton("Create Rule"))
            {
                CqaRuleEditWindow.Open(DataScope.Local);
            }

            GUILayout.Space(10);
        }
Example #4
0
        private void CreateRuleCheckboxesForGroup(Group group)
        {
            if (!_groupFoldout[group])
            {
                return;
            }

            foreach (Rule rule in group.rules)
            {
                // Set a horizontal offset.
                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(20);

                if (CqaButton.EditButton())
                {
                    CqaRuleEditWindow.Open(_dataScope, group, rule);
                }

                CqaLabel.FoldoutEntry(rule.description);
                EditorGUILayout.EndHorizontal();
            }
        }
Example #5
0
        public void Show()
        {
            CqaLabel.FormLabel(_label);
            CqaLabel.FormDescription(_description);
            string newValue = GUILayout.TextField(_value);

            if (newValue != Value)
            {
                Touched = true;
            }

            _value = newValue;

            if (Touched && newValue.Length == 0)
            {
                CqaLabel.FormError("This field can not be empty.");
            }
            else if (!HasInitialValue() && newValue != _initialValue && _providePotentialClashes().Contains(Value))
            {
                CqaLabel.FormError("This name is already taken.");
            }

            CqaLabel.FormGroupSpacing();
        }
Example #6
0
        public void Show()
        {
            CqaLabel.FormLabel(_label);
            CqaLabel.FormDescription(_description);

            _scroll = EditorGUILayout.BeginScrollView(_scroll);
            string newValue = GUILayout.TextArea(_value);

            EditorGUILayout.EndScrollView();

            if (newValue != Value)
            {
                Touched = true;
            }

            _value = newValue;

            if (Touched && newValue.Length == 0)
            {
                CqaLabel.FormError("This field can not be empty.");
            }

            CqaLabel.FormGroupSpacing();
        }
Example #7
0
        public void Show()
        {
            CqaLabel.Heading1("Scan");

            if (!JqaManager.CheckIfJqaIsInstalled())
            {
                CqaLabel.Error("CQA is currently not installed.");
                return;
            }

            CqaLabel.Normal("CQA scans all scripts inside your Assets folder.");

            History.History history = _historyManager.LoadHistory();

            if (history != null)
            {
                CqaLabel.Normal("The last scan was at " + history.GetLastScan() + ".");
            }

            EditorGUI.BeginDisabledGroup(_jqaExecutor.IsAnyProcessRunning());
            if (CqaButton.NormalButton("Scan Assets"))
            {
                _jqaExecutor.ScanAssets();
            }

            if (Directory.Exists(JqaPaths.Instance.BuildJqaStorePath()) && CqaButton.NormalButton("Start Server"))
            {
                _jqaExecutor.StartServer();
            }

            EditorGUI.EndDisabledGroup();

            if (_jqaExecutor.IsScanProcessRunning())
            {
                CqaLabel.Bold("Status: Running ...");

                // FIXME: Stopping the process does currently not work.
                //
                // if (CqaButton.NormalButton("Stop Process"))
                // {
                //     _jqaExecutor.StopProcess();
                // }
            }

            GUILayout.Space(30);
            CqaLine.DrawHorizontalLine();

            CqaLabel.Heading1("Report");

            if (!JqaExecutor.DidFinishSuccessfullyOnce())
            {
                CqaLabel.Error("You must scan your project before you can create a report.");
                return;
            }

            CqaLabel.Normal("Select rules that you want to be checked in the report.");

            if (_jqaExecutor.IsReportProcessRunning())
            {
                CqaLabel.Bold("Status: Running ...");

                // FIXME: Stopping the process does currently not work.
                //
                // if (CqaButton.NormalButton("Stop Process"))
                // {
                //     _jqaExecutor.StopProcess();
                // }
            }

            _ruleSelector.OnGUI();

            ShowReportButtons();
        }