void RefreshDisplay() { if (!IsAnalysisValid()) { return; } if (m_AnalysisState == AnalysisState.Completed) { UpdateAssemblyNames(); UpdateAssemblySelection(); m_AnalysisState = AnalysisState.Valid; if (m_LoadButtonAnalytic != null) { ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.Load, m_LoadButtonAnalytic); } if (m_AnalyzeButtonAnalytic != null) { ProjectAuditorAnalytics.SendUIButtonEventWithAnalyzeSummary(ProjectAuditorAnalytics.UIButton.Analyze, m_AnalyzeButtonAnalytic, m_ProjectReport); } } activeView.Refresh(); }
void Save() { var path = EditorUtility.SaveFilePanel("Save report to json file", m_SaveLoadDirectory, "project-auditor-report.json", "json"); if (path.Length != 0) { m_ProjectReport.Save(path); m_SaveLoadDirectory = Path.GetDirectoryName(path); EditorUtility.RevealInFinder(path); ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.Save, ProjectAuditorAnalytics.BeginAnalytic()); } }
// stephenm TODO - if AssemblySelectionWindow and AreaSelectionWindow end up sharing a common base class then // DrawAssemblyFilter() and DrawAreaFilter() can be made to call a common method and just pass the selection, names // and the type of window we want. void DrawAreaFilter() { if (!activeView.desc.showAreaSelection) { return; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(Contents.AreaFilter, GUILayout.Width(LayoutSize.FilterOptionsLeftLabelWidth)); if (AreaNames.Length > 0) { var lastEnabled = GUI.enabled; var enabled = IsAnalysisValid() && !AreaSelectionWindow.IsOpen(); GUI.enabled = enabled; if (GUILayout.Button(Contents.AreaFilterSelect, EditorStyles.miniButton, GUILayout.Width(LayoutSize.FilterOptionsEnumWidth))) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); // Note: Window auto closes as it loses focus so this isn't strictly required if (AreaSelectionWindow.IsOpen()) { AreaSelectionWindow.CloseAll(); } else { var windowPosition = new Vector2(Event.current.mousePosition.x + LayoutSize.FilterOptionsEnumWidth, Event.current.mousePosition.y + GUI.skin.label.lineHeight); var screenPosition = GUIUtility.GUIToScreenPoint(windowPosition); AreaSelectionWindow.Open(screenPosition.x, screenPosition.y, this, m_AreaSelection, AreaNames); } ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.AreaSelect, analytic); } GUI.enabled = lastEnabled; m_AreaSelectionSummary = GetSelectedAreasSummary(); Utility.DrawSelectedText(m_AreaSelectionSummary); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); }
void OnViewChanged(object userData) { var index = (int)userData; var activeViewChanged = (m_ActiveViewIndex != index); if (activeViewChanged) { m_ActiveViewIndex = index; activeView.Refresh(); ProjectAuditorAnalytics.SendUIButtonEvent((ProjectAuditorAnalytics.UIButton)activeView.desc.analyticsEvent, ProjectAuditorAnalytics.BeginAnalytic()); } }
void Export(Func <ProjectIssue, bool> match = null) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); if (IsAnalysisValid()) { var path = EditorUtility.SaveFilePanel("Save analysis CSV data", "", "project-auditor-report.csv", "csv"); if (path.Length != 0) { m_ProjectReport.ExportToCSV(path, issue => m_ProjectAuditor.config.GetAction(issue.descriptor, issue.callingMethod) != Rule.Action.None && (match == null || match(issue))); } } ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.Export, analytic); }
void DrawAssemblyFilter() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(Styles.AssemblyFilter, GUILayout.Width(LayoutSize.FilterOptionsLeftLabelWidth)); var lastEnabled = GUI.enabled; GUI.enabled = m_AnalysisState == AnalysisState.Valid && !AssemblySelectionWindow.IsOpen() && activeAnalysisView.desc.showAssemblySelection; if (GUILayout.Button(Styles.AssemblyFilterSelect, EditorStyles.miniButton, GUILayout.Width(LayoutSize.FilterOptionsEnumWidth))) { if (m_AssemblyNames != null && m_AssemblyNames.Length > 0) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); // Note: Window auto closes as it loses focus so this isn't strictly required if (AssemblySelectionWindow.IsOpen()) { AssemblySelectionWindow.CloseAll(); } else { var windowPosition = new Vector2(Event.current.mousePosition.x + LayoutSize.FilterOptionsEnumWidth, Event.current.mousePosition.y + GUI.skin.label.lineHeight); var screenPosition = GUIUtility.GUIToScreenPoint(windowPosition); AssemblySelectionWindow.Open(screenPosition.x, screenPosition.y, this, m_AssemblySelection, m_AssemblyNames); } ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.AssemblySelect, analytic); } } GUI.enabled = lastEnabled; m_AssemblySelectionSummary = GetSelectedAssembliesSummary(); DrawSelectedText(m_AssemblySelectionSummary); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); }
// stephenm TODO - if AssemblySelectionWindow and AreaSelectionWindow end up sharing a common base class then // DrawAssemblyFilter() and DrawAreaFilter() can be made to call a common method and just pass the selection, names // and the type of window we want. private void DrawAreaFilter() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(Styles.AreaFilter, GUILayout.Width(LayoutSize.FilterOptionsLeftLabelWidth)); if (m_AreaNames.Length > 0) { var lastEnabled = GUI.enabled; // stephenm TODO - We don't currently have any sense of when the Auditor is busy and should disallow user input var enabled = /*!IsAnalysisRunning() &&*/ !AreaSelectionWindow.IsOpen(); GUI.enabled = enabled; if (GUILayout.Button(Styles.AreaFilterSelect, EditorStyles.miniButton, GUILayout.Width(LayoutSize.FilterOptionsEnumWidth))) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); // Note: Window auto closes as it loses focus so this isn't strictly required if (AreaSelectionWindow.IsOpen()) { AreaSelectionWindow.CloseAll(); } else { var windowPosition = new Vector2(Event.current.mousePosition.x + LayoutSize.FilterOptionsEnumWidth, Event.current.mousePosition.y + GUI.skin.label.lineHeight); var screenPosition = GUIUtility.GUIToScreenPoint(windowPosition); AreaSelectionWindow.Open(screenPosition.x, screenPosition.y, this, m_AreaSelection, m_AreaNames); } ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.AreaSelect, analytic); } GUI.enabled = lastEnabled; m_AreaSelectionSummary = GetSelectedAreasSummary(); DrawSelectedText(m_AreaSelectionSummary); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); }
void DrawMode() { EditorGUILayout.BeginHorizontal(); var activeModeIndex = GUILayout.Toolbar(m_ActiveModeIndex, m_ModeNames, "LargeButton", GUILayout.Height(LayoutSize.ToolbarHeight)); EditorGUILayout.EndHorizontal(); bool activeModeChanged = (m_ActiveModeIndex != activeModeIndex); if (activeModeChanged) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); m_ActiveModeIndex = activeModeIndex; RefreshDisplay(); ProjectAuditorAnalytics.SendUIButtonEvent(activeAnalysisView.desc.analyticsEvent, analytic); } }
private void DrawToolbar() { EditorGUILayout.BeginHorizontal(GUI.skin.box); { GUI.enabled = (m_AnalysisState == AnalysisState.Valid || m_AnalysisState == AnalysisState.NotStarted); if (GUILayout.Button(Styles.AnalyzeButton, GUILayout.ExpandWidth(true), GUILayout.Width(80))) { Analyze(); } GUI.enabled = m_AnalysisState == AnalysisState.Valid; if (GUILayout.Button(Styles.ExportButton, GUILayout.ExpandWidth(true), GUILayout.Width(80))) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); Export(); ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.Export, analytic); } GUI.enabled = true; if (m_DeveloperMode) { if (GUILayout.Button(Styles.ReloadButton, GUILayout.ExpandWidth(true), GUILayout.Width(80))) { Reload(); } } if (m_AnalysisState == AnalysisState.InProgress) { GUILayout.Label(Styles.AnalysisInProgressLabel, GUILayout.ExpandWidth(true)); } } EditorGUILayout.EndHorizontal(); }
void Export(Func <ProjectIssue, bool> match = null) { var path = EditorUtility.SaveFilePanel("Save to CSV file", s_ExportDirectory, string.Format("project-auditor-{0}.csv", m_Desc.category.ToString()).ToLower(), "csv"); if (path.Length != 0) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); using (var exporter = new Exporter(path, m_Layout)) { exporter.WriteHeader(); var matchingIssues = m_Issues.Where(issue => m_Config.GetAction(issue.descriptor, issue.GetCallingMethod()) != Rule.Severity.None && (match == null || match(issue))); exporter.WriteIssues(matchingIssues.ToArray()); } EditorUtility.RevealInFinder(path); ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.Export, analytic); s_ExportDirectory = Path.GetDirectoryName(path); } }
private void DrawFilters() { if (!IsAnalysisValid()) { return; } EditorGUILayout.BeginVertical( GUI.skin.box /*, GUILayout.Width(LayoutSize.ToolbarWidth), GUILayout.ExpandWidth(true)*/); { EditorGUILayout.BeginHorizontal(); var activeModeIndex = GUILayout.Toolbar(m_ActiveModeIndex, m_ModeNames, GUILayout.MaxWidth(LayoutSize.ModeTabWidth) /*, GUILayout.ExpandWidth(true)*/); EditorGUILayout.EndHorizontal(); DrawAssemblyFilter(); DrawAreaFilter(); EditorGUI.BeginChangeCheck(); var searchRect = GUILayoutUtility.GetRect(1, 1, 18, 18, GUILayout.ExpandWidth(true), GUILayout.Width(200)); EditorGUILayout.BeginHorizontal(); if (m_SearchField == null) { m_SearchField = new SearchField(); } m_SearchText = m_SearchField.OnGUI(searchRect, m_SearchText); m_ActiveIssueTable.searchString = m_SearchText; EditorGUILayout.EndHorizontal(); var shouldRefresh = false; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Selected :", GUILayout.ExpandWidth(true), GUILayout.Width(80)); if (GUILayout.Button(Styles.MuteButton, GUILayout.ExpandWidth(true), GUILayout.Width(100))) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); var selectedItems = m_ActiveIssueTable.GetSelectedItems(); foreach (var item in selectedItems) { SetRuleForItem(item, Rule.Action.None); } if (!m_ProjectAuditor.config.DisplayMutedIssues) { m_ActiveIssueTable.SetSelection(new List <int>()); } ProjectAuditorAnalytics.SendUIButtonEventWithSelectionSummary(ProjectAuditorAnalytics.UIButton.Mute, analytic, m_ActiveIssueTable.GetSelectedItems()); } if (GUILayout.Button(Styles.UnmuteButton, GUILayout.ExpandWidth(true), GUILayout.Width(100))) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); var selectedItems = m_ActiveIssueTable.GetSelectedItems(); foreach (var item in selectedItems) { ClearRulesForItem(item); } ProjectAuditorAnalytics.SendUIButtonEventWithSelectionSummary(ProjectAuditorAnalytics.UIButton.Unmute, analytic, m_ActiveIssueTable.GetSelectedItems()); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Show :", GUILayout.ExpandWidth(true), GUILayout.Width(80)); GUI.enabled = m_ActiveAnalysisView.desc.showCritical; bool wasShowingCritical = m_ProjectAuditor.config.DisplayOnlyCriticalIssues; m_ProjectAuditor.config.DisplayOnlyCriticalIssues = EditorGUILayout.ToggleLeft("Only Critical Issues", m_ProjectAuditor.config.DisplayOnlyCriticalIssues, GUILayout.Width(160)); GUI.enabled = true; if (wasShowingCritical != m_ProjectAuditor.config.DisplayOnlyCriticalIssues) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); var payload = new Dictionary <string, string>(); payload["selected"] = m_ActiveAnalysisView.desc.showCritical ? "true" : "false"; ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.OnlyCriticalIssues, analytic); } bool wasDisplayingMuted = m_ProjectAuditor.config.DisplayMutedIssues; m_ProjectAuditor.config.DisplayMutedIssues = EditorGUILayout.ToggleLeft("Muted Issues", m_ProjectAuditor.config.DisplayMutedIssues, GUILayout.Width(127)); if (wasDisplayingMuted != m_ProjectAuditor.config.DisplayMutedIssues) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); var payload = new Dictionary <string, string>(); payload["selected"] = m_ProjectAuditor.config.DisplayMutedIssues ? "true" : "false"; ProjectAuditorAnalytics.SendUIButtonEventWithKeyValues(ProjectAuditorAnalytics.UIButton.ShowMuted, analytic, payload); } EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { shouldRefresh = true; } bool activeModeChanged = (m_ActiveModeIndex != activeModeIndex); if (activeModeChanged) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); m_ActiveModeIndex = activeModeIndex; RefreshDisplay(); if (m_ActiveModeIndex == (int)IssueCategory.ApiCalls) { ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.ApiCalls, analytic); } else if (m_ActiveModeIndex == (int)IssueCategory.ProjectSettings) { ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.ProjectSettings, analytic); } else { Debug.LogWarning("Unrecognised active mode: couldn't sent analytics event"); } } else if (shouldRefresh || m_ShouldRefresh || m_AnalysisState == AnalysisState.Completed) { RefreshDisplay(); m_ShouldRefresh = false; } } EditorGUILayout.EndVertical(); }
void DrawFilters() { EditorGUILayout.BeginVertical(GUI.skin.box, GUILayout.ExpandWidth(true)); m_Preferences.filters = BoldFoldout(m_Preferences.filters, Styles.FiltersFoldout); if (m_Preferences.filters) { EditorGUI.indentLevel++; DrawAssemblyFilter(); DrawAreaFilter(); EditorGUI.BeginChangeCheck(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(Styles.TextSearchLabel, GUILayout.Width(80)); m_TextFilter.searchText = EditorGUILayout.DelayedTextField(m_TextFilter.searchText, GUILayout.Width(180)); activeAnalysisView.table.searchString = m_TextFilter.searchText; m_TextFilter.matchCase = EditorGUILayout.ToggleLeft(Styles.TextSearchCaseSensitive, m_TextFilter.matchCase, GUILayout.Width(160)); if (m_DeveloperMode) { // this is only available in developer mode because it is still too slow at the moment GUI.enabled = activeAnalysisView.desc.showDependencyView; m_TextFilter.searchDependencies = EditorGUILayout.ToggleLeft("Call Tree (slow)", m_TextFilter.searchDependencies, GUILayout.Width(160)); GUI.enabled = true; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Show :", GUILayout.ExpandWidth(true), GUILayout.Width(80)); GUI.enabled = activeAnalysisView.desc.showCritical; bool wasShowingCritical = m_Preferences.onlyCriticalIssues; m_Preferences.onlyCriticalIssues = EditorGUILayout.ToggleLeft("Only Critical Issues", m_Preferences.onlyCriticalIssues, GUILayout.Width(160)); GUI.enabled = true; if (wasShowingCritical != m_Preferences.onlyCriticalIssues) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); var payload = new Dictionary <string, string>(); payload["selected"] = activeAnalysisView.desc.showCritical ? "true" : "false"; ProjectAuditorAnalytics.SendUIButtonEvent(ProjectAuditorAnalytics.UIButton.OnlyCriticalIssues, analytic); } bool wasDisplayingMuted = m_Preferences.mutedIssues; m_Preferences.mutedIssues = EditorGUILayout.ToggleLeft("Muted Issues", m_Preferences.mutedIssues, GUILayout.Width(127)); if (wasDisplayingMuted != m_Preferences.mutedIssues) { var analytic = ProjectAuditorAnalytics.BeginAnalytic(); var payload = new Dictionary <string, string>(); payload["selected"] = m_Preferences.mutedIssues ? "true" : "false"; ProjectAuditorAnalytics.SendUIButtonEventWithKeyValues(ProjectAuditorAnalytics.UIButton.ShowMuted, analytic, payload); } EditorGUILayout.EndHorizontal(); if (EditorGUI.EndChangeCheck()) { m_ShouldRefresh = true; } EditorGUI.indentLevel--; } EditorGUILayout.EndVertical(); }