<commit_before>import Cocoa

class RemoteRepositoryFormController: NSWindowController, NSWindowDelegate, FocussingNSTextFieldDelegate {
  
  @IBOutlet weak var urlTextField: FocussingNSTextField!
  @IBOutlet weak var subdirectoryTextField: FocussingNSTextField!
  @IBOutlet var urlHelpPopover: NSPopover!
  @IBOutlet var urlHelpPopoverViewController: NSViewController!
  @IBOutlet var subdirectoryHelpPopover: NSPopover!
  @IBOutlet var subdirectoryHelpPopoverViewController: NSViewController!

  func windowDidChangeOcclusionState(_ notification: Notification) {
    if (window!.occlusionState.contains(.visible)) {
      // Without the following line, the subdirectory popover is not shown the first time :/
      let _ = subdirectoryTextField.becomeFirstResponder()
      // Without the following lines, the url popover is not shown initially
      let _ = urlTextField.becomeFirstResponder()
      textFieldDidBecomeFirstResponder(urlTextField)
    }
  }
 
  @IBAction func urlHelp(sender: NSButton) {
  }
  
  @IBAction func cancel(sender: NSButton) {
    Log.debug("Cancelling the sheet")
    window?.sheetParent!.endSheet(window!)
  }
  
  
  func textFieldDidBecomeFirstResponder(_ textField: FocussingNSTextField) {
    switch textField {
    case urlTextField:
      urlHelpPopover.show(relativeTo: NSRect(), of: textField, preferredEdge: NSRectEdge.maxX)
    case subdirectoryTextField:<commit_msg>Show help a little later<commit_after>import Cocoa

class RemoteRepositoryFormController: NSWindowController, NSWindowDelegate, FocussingNSTextFieldDelegate {
  
  @IBOutlet weak var urlTextField: FocussingNSTextField!
  @IBOutlet weak var subdirectoryTextField: FocussingNSTextField!
  @IBOutlet var urlHelpPopover: NSPopover!
  @IBOutlet var urlHelpPopoverViewController: NSViewController!
  @IBOutlet var subdirectoryHelpPopover: NSPopover!
  @IBOutlet var subdirectoryHelpPopoverViewController: NSViewController!

  func windowDidChangeOcclusionState(_ notification: Notification) {
    if (window!.occlusionState.contains(.visible)) {
      // Without the following line, the subdirectory popover is not shown the first time :/
      let _ = subdirectoryTextField.becomeFirstResponder()
      // Without the following lines, the url popover is not shown initially
      let _ = urlTextField.becomeFirstResponder()
      
      DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
        // Show the popup after 2 seconds to not overload people's brains
        self.textFieldDidBecomeFirstResponder(self.urlTextField)
      }
    }
  }
 
  @IBAction func urlHelp(sender: NSButton) {
  }
  
  @IBAction func cancel(sender: NSButton) {
    Log.debug("Cancelling the sheet")
    window?.sheetParent!.endSheet(window!)
  }
  
  
  func textFieldDidBecomeFirstResponder(_ textField: FocussingNSTextField) {
    switch textField {
    case urlTextField:
      urlHelpPopover.show(relativeTo: NSRect(), of: textField, preferredEdge: NSRectEdge.maxX)
    case subdirectoryTextField:
{'fraction_non_alphanumeric': 0.07224080267558529, 'fraction_numerical': 0.0006688963210702341, 'mean_word_length': 4.675521821631879, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1369224', 'n_tokens_mistral': 899, 'n_tokens_neox': 860, 'n_words': 209}