private void OnFocus()
 {
     if (!EditorApplication.isPlaying)
     {
         return;
     }
     integrator = FindObjectOfType <AtfFileSystemBasedIntegrator>();
     AtfWindow.InitTreeViewOf(ref _treeViewForPaths, ref _searchFieldForPaths, ref treeViewStateForPaths, TreePurpose.PATHS, integrator);
     _treeViewForPaths.PathChanged += (s, context) => _currentPath = s;
 }
 private void OnFocus()
 {
     if (!EditorApplication.isPlaying)
     {
         return;
     }
     storage  = FindObjectOfType <AtfDictionaryBasedActionStorage>();
     recorder = FindObjectOfType <AtfQueueBasedRecorder>();
     AtfWindow.InitTreeViewOf(ref _treeViewForCurrentNames, ref _searchFieldForCurrentNames, ref treeViewStateForCurrentNames, TreePurpose.DRAW_CURRENT_NAMES, recorder, storage);
     AtfWindow.InitTreeViewOf(ref _treeViewForCurrentKindsAndActions, ref _searchFieldForCurrentKindsAndActions,
                              ref treeViewStateForCurrentKindsAndActions, TreePurpose.DRAW_CURRENT_KINDS_AND_ACTIONS, recorder, storage);
     AtfWindow.InitTreeViewOf(ref _treeViewForSavedNames, ref _searchFieldForSavedNames,
                              ref treeViewStateForSavedNames, TreePurpose.DRAW_SAVED_NAMES, recorder, storage);
     AtfWindow.InitTreeViewOf(ref _treeViewForSavedKindsAndActions, ref _searchFieldForSavedKindsAndActions,
                              ref treeViewStateForSavedKindsAndActions, TreePurpose.DRAW_SAVED_KINDS_AND_ACTIONS, recorder, storage);
     _treeViewForCurrentNames.KindsAndActionsTreeView = _treeViewForCurrentKindsAndActions;
     _treeViewForCurrentNames.RecordNameChanged      += AtfWindow.RepaintRecorderWindow;
     _treeViewForSavedNames.KindsAndActionsTreeView   = _treeViewForSavedKindsAndActions;
 }
        private void OnGUI()
        {
            var integratorLoaded = integrator != null;

            if (EditorApplication.isPlaying)
            {
                GUILayout.Label("Integrator Control Panel", EditorStyles.boldLabel);
                GUILayout.Label(
                    integratorLoaded
                        ? $"Integrator current realisation: {integrator.GetType().Name}"
                        : "Integrator current realisation: Waiting to focus...", EditorStyles.label);
                if (!integratorLoaded)
                {
                    return;
                }

                GUILayout.Label("Adding files to integrate", EditorStyles.boldLabel);
                _currentPath = EditorGUILayout.TextField(".cs file path", _currentPath);

                EditorGUILayout.BeginHorizontal();
                UpdatePathsButton("Add path", () => _pathsToSendIntoIntegrator.Add(_currentPath));
                UpdatePathsButton("Remove path", () => _pathsToSendIntoIntegrator.Remove(_currentPath));
                EditorGUILayout.EndHorizontal();

                GUILayout.Label("Paths chosen", EditorStyles.boldLabel);
                AtfWindow.DoToolbarFor(_treeViewForPaths, _searchFieldForPaths);
                AtfWindow.DoTreeViewFor(_treeViewForPaths);
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Integrate"))
                {
                    integrator.Integrate();
                }
                if (GUILayout.Button("Integrate and replace"))
                {
                    integrator.IntegrateAndReplace();
                }
                EditorGUILayout.EndHorizontal();
                if (GUILayout.Button("Integrate All"))
                {
                    integrator.IntegrateAll();
                }
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Save paths"))
                {
                    integrator.SaveUris();
                }
                if (GUILayout.Button("Load paths"))
                {
                    _pathsToSendIntoIntegrator = new HashSet <string>();
                    var rawPaths = integrator.LoadUris();
                    foreach (var path in rawPaths)
                    {
                        _pathsToSendIntoIntegrator.Add(path);
                    }
                    UpdateTree();
                }
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                GUILayout.Label("Waiting for Play Mode...", EditorStyles.boldLabel);
            }
        }
        private void OnGUI()
        {
            var stateLoaded = storage != null;

            if (EditorApplication.isPlaying)
            {
                GUILayout.Label("Storage Settings", EditorStyles.boldLabel);
                GUILayout.Label(
                    stateLoaded
                        ? $"Storage realisation: {storage.GetType().Name}"
                        : "Storage realisation: Waiting to focus...", EditorStyles.label);
                if (!stateLoaded)
                {
                    return;
                }

                GUILayout.Label($"Current recording name: {storage.GetCurrentRecordName()}", EditorStyles.boldLabel);

                EditorGUILayout.BeginHorizontal();
                _showDetailsOfSavedRecord   = EditorGUILayout.Toggle("Display saved details", _showDetailsOfSavedRecord);
                _showDetailsOfCurrentRecord = EditorGUILayout.Toggle("Display current details", _showDetailsOfCurrentRecord);
                EditorGUILayout.EndHorizontal();

                if (!recorder.IsPlaying() && !recorder.IsRecording())
                {
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Save"))
                    {
                        storage.SaveStorage();
                    }
                    if (GUILayout.Button("Load"))
                    {
                        storage.LoadStorage();
                    }
                    if (GUILayout.Button("Scrap saved"))
                    {
                        storage.ScrapSavedStorage();
                    }
                    EditorGUILayout.EndHorizontal();
                }

                _fullPathForStorageExport = EditorGUILayout.TextField("Absolute path:", _fullPathForStorageExport);
                EditorGUILayout.BeginHorizontal();
                ImportExportButtons("Export saved storage", false);
                ImportExportButtons("Import saved storage", true);
                EditorGUILayout.EndHorizontal();

                GUILayout.Label("Current records", EditorStyles.boldLabel);
                AtfWindow.DoToolbarFor(_treeViewForCurrentNames, _searchFieldForCurrentNames);
                AtfWindow.DoTreeViewFor(_treeViewForCurrentNames);

                if (_showDetailsOfCurrentRecord)
                {
                    GUILayout.Label("Current commands and actions queues", EditorStyles.boldLabel);
                    AtfWindow.DoToolbarFor(_treeViewForCurrentKindsAndActions, _searchFieldForCurrentKindsAndActions);
                    AtfWindow.DoTreeViewFor(_treeViewForCurrentKindsAndActions);
                }

                GUILayout.Label("Saved records", EditorStyles.boldLabel);
                AtfWindow.DoToolbarFor(_treeViewForSavedNames, _searchFieldForSavedNames);
                AtfWindow.DoTreeViewFor(_treeViewForSavedNames);

                if (!_showDetailsOfSavedRecord)
                {
                    return;
                }
                GUILayout.Label("Saved commands and actions queues", EditorStyles.boldLabel);
                AtfWindow.DoToolbarFor(_treeViewForSavedKindsAndActions, _searchFieldForSavedKindsAndActions);
                AtfWindow.DoTreeViewFor(_treeViewForSavedKindsAndActions);
            }
            else
            {
                GUILayout.Label("Waiting for Play Mode...", EditorStyles.boldLabel);
            }
        }