public void OnGUI()
    {
        if (requestFocus && Event.current.type == EventType.Layout) {
            requestFocus = false;
            EditorWindow.FocusWindowIfItsOpen<UTAutomationPlanPopup>();
        }

        EditorGUILayout.LabelField(caption);
        EditorGUILayout.Space();

        GUI.SetNextControlName("AutomationPlanList");
        listData = CUListControl.SelectionList<UTAutomationPlan>(listData, currentItems, itemRenderer, "Plans", GUILayout.ExpandHeight(true));
        if (GUI.GetNameOfFocusedControl() == string.Empty) {
            // move focus to the textfield after the dialog is visible
            GUI.FocusControl("AutomationPlanList");
        }
        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();

        EditorGUI.BeginChangeCheck ();
        showAllItems = GUILayout.Toggle(showAllItems, "Show hidden plans");
        if (EditorGUI.EndChangeCheck ()) {
            currentItems = showAllItems ? allItems : visibleItems;
            listData.ClearSelection();
            if (currentItems.Count > 0) {
                listData[0] = true;
            }
        }

        GUILayout.FlexibleSpace();
        GUI.enabled = !listData.Empty;
        if (GUILayout.Button("Ok")) {
            Apply(listData.First);
        }
        GUI.enabled = true;
        if (GUILayout.Button("Cancel")) {
            CloseDialog();
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();

        if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape) {
            CloseDialog();
        }
        wasGuiPaintedAtLeastOnce = true;
    }
    private void DrawActions()
    {
        GUILayout.Label ("Settings", UTEditorResources.TitleStyle);
        EditorGUILayout.Space ();
        EditorGUI.BeginChangeCheck ();

        EditorGUILayout.BeginHorizontal ();
        showHidden = EditorGUILayout.Toggle ("Show hidden plans", showHidden);
        debugMode = EditorGUILayout.Toggle ("Debug mode", debugMode);
        EditorGUILayout.EndHorizontal ();

        EditorGUILayout.BeginHorizontal ();
        clearConsole = EditorGUILayout.Toggle ("Clear console", clearConsole);
        returnToPlanListAfterRun = EditorGUILayout.Toggle ("Return to plan list after run", returnToPlanListAfterRun);
        EditorGUILayout.EndHorizontal ();

        EditorGUILayout.Space ();

        if (EditorGUI.EndChangeCheck ()) {
            UTPreferences.DebugMode = debugMode;
            UTPreferences.ShowHiddenPlansInRunner = showHidden;
            UTPreferences.ClearConsoleBeforeStart = clearConsole;
            UTPreferences.ReturnToPlanListAfterPlanIsRun = returnToPlanListAfterRun;
        }

        var planList = showHidden ? plans : visiblePlans;
        listData = CUListControl.SelectionList (listData, planList, renderer, "Plans");

        EditorGUILayout.Space ();
        EditorGUILayout.BeginHorizontal ();
        GUILayout.FlexibleSpace ();

        GUI.enabled = listData.Selection.Count > 0 && !UTomateRunner.Instance.IsRunning;
        if (GUILayout.Button ("Run Plan")) {
            currentWindow = 1;
            RunSelected ();
            // some actions will reload the project and not exiting the gui here
            // will yield all kinds of funky exceptions because the gui is trying to draw on a state that
            // no longer exists.
            GUIUtility.ExitGUI ();

        }
        GUI.enabled = true;
        EditorGUILayout.EndHorizontal ();
        EditorGUILayout.Space ();
    }