<commit_before>_                             = require 'lodash'
$                             = require 'jquery'
kd                            = require 'kd'
nick                          = require 'app/util/nick'
ndpane                        = require 'ndpane'
remote                        = require('app/remote').getInstance()
KDView                        = kd.View
whoami                        = require 'app/util/whoami'
globals                       = require 'globals'
kookies                       = require 'kookies'
Encoder                       = require 'htmlencode'
Machine                       = require 'app/providers/machine'
IDEView                       = require './views/tabview/ideview'
FSHelper                      = require 'app/util/fs/fshelper'
showError                     = require 'app/util/showError'
KDModalView                   = kd.ModalView
KDSplitView                   = kd.SplitView
IDEWorkspace                  = require './workspace/ideworkspace'
IDEStatusBar                  = require './views/statusbar/idestatusbar'
KodingKontrol                 = require 'app/kite/kodingkontrol'
AppController                 = require 'app/appcontroller'
IDEEditorPane                 = require './workspace/panes/ideeditorpane'
IDEFileFinder                 = require './views/filefinder/idefilefinder'
splashMarkups                 = require './util/splashmarkups'
IDEFilesTabView               = require './views/tabview/idefilestabview'
IDETerminalPane               = require './workspace/panes/ideterminalpane'
KDCustomHTMLView              = kd.CustomHTMLView
KDSplitViewPanel              = kd.SplitViewPanel
IDEStatusBarMenu              = require './views/statusbar/idestatusbarmenu'
IDEContentSearch              = require './views/contentsearch/idecontentsearch'
KDNotificationView            = kd.NotificationView
KDBlockingModalView           = kd.BlockingModalView
IDEApplicationTabView         = require './views/tabview/ideapplicationtabview'
AceFindAndReplaceView         = require 'ace/acefindandreplaceview'
environmentDataProvider       = require 'app/userenvironmentdataprovider'
CollaborationController       = require './collaborationcontroller'
VideoCollaborationController  = require './videocollaborationcontroller'
EnvironmentsMachineStateModal = require 'app/providers/environmentsmachinestatemodal'
KlientEventManager            = require 'app/kite/klienteventmanager'
IDELayoutManager              = require './workspace/idelayoutmanager'


require('./routes')()


module.exports =

class IDEAppController extends AppController

  _.extend @prototype, CollaborationController
  _.extend @prototype, VideoCollaborationController

  {
    Stopped, Running, NotInitialized, Terminated, Unknown, Pending,
    Starting, Building, Stopping, Rebooting, Terminating, Updating
  } = Machine.State

  {noop, warn} = kd

  @options = require './ideappcontrolleroptions'

  constructor: (options = {}, data) ->

    options.view    = new KDView cssClass: 'dark'
    options.appInfo =
      type          : 'application'
      name          : 'IDE'

    super options, data

    layoutOptions     =
      splitOptions    :
        direction     : 'vertical'
        name          : 'BaseSplit'
        sizes         : [ 250, null ]
        maximums      : [ 400, null ]
        views         : [
          {
            type      : 'custom'
            name      : 'filesPane'
            paneClass : IDEFilesTabView
          },
          {
            type      : 'custom'
            name      : 'editorPane'
            paneClass : IDEView
          }
        ]

    @silent    = no
    @workspace = new IDEWorkspace { layoutOptions }
    @ideViews  = []

    # todo:
    # - following two should be abstracted out into a separate api
    @layout = ndpane(16)
    @layoutMap = new Array(16*16)

    { windowController, appManager } = kd.singletons
    windowController.addFocusListener @bound 'handleWindowFocus'

    @layoutManager = new IDELayoutManager delegate : this

    @workspace.once 'ready', => @getView().addSubView @workspace.getView()

    appManager.on 'AppIsBeingShown', (app) =>

      return  unless app instanceof IDEAppController

      @setActivePaneFocus on, yes

      # Temporary fix for IDE is not shown after
      # opening pages which uses old SplitView.
      # TODO: This needs to be fixed. ~Umut
      windowController.notifyWindowResizeListeners()

      @resizeActiveTerminalPane()

      @runOnboarding()  if @isMachineRunning()

      if app.getId() is @getId() and not @layoutManager.isSnapshotRestored()
        @layoutManager.restoreSnapshot()

      @bindListeners()


  bindListeners: ->

    @on 'CloseFullScreen', =>
      [ideView] = @ideViews.filter (ideView) -> ideView.isFullScreen
      ideView.emit 'CloseFullScreen'  if ideView

    @on 'SnapshotUpdated', @bound 'saveLayoutSize'


  prepareIDE: (withFakeViews = no) ->

    panel     = @workspace.getView()
    appView   = @getView()
    ideView   = panel.getPaneByName 'editorPane'

    @setActiveTabView ideView.tabView
    @registerIDEView  ideView

    splitViewPanel = ideView.parent.parent
    @createStatusBar splitViewPanel
    @createFindAndReplaceView splitViewPanel

    appView.emit 'KeyViewIsSet'

    @createInitialView withFakeViews
    @bindCollapseEvents()

    {@finderPane, @settingsPane} = @workspace.panel.getPaneByName 'filesPane'

    @bindRouteHandler()
    @initiateAutoSave()
    @emit 'ready'


  bindRouteHandler: ->

    {router, mainView} = kd.singletons
<commit_msg>FinderPane: Add missing filetree snyc event handler.<commit_after>_                             = require 'lodash'
$                             = require 'jquery'
kd                            = require 'kd'
nick                          = require 'app/util/nick'
ndpane                        = require 'ndpane'
remote                        = require('app/remote').getInstance()
KDView                        = kd.View
whoami                        = require 'app/util/whoami'
globals                       = require 'globals'
kookies                       = require 'kookies'
Encoder                       = require 'htmlencode'
Machine                       = require 'app/providers/machine'
IDEView                       = require './views/tabview/ideview'
FSHelper                      = require 'app/util/fs/fshelper'
showError                     = require 'app/util/showError'
KDModalView                   = kd.ModalView
KDSplitView                   = kd.SplitView
IDEWorkspace                  = require './workspace/ideworkspace'
IDEStatusBar                  = require './views/statusbar/idestatusbar'
KodingKontrol                 = require 'app/kite/kodingkontrol'
AppController                 = require 'app/appcontroller'
IDEEditorPane                 = require './workspace/panes/ideeditorpane'
IDEFileFinder                 = require './views/filefinder/idefilefinder'
splashMarkups                 = require './util/splashmarkups'
IDEFilesTabView               = require './views/tabview/idefilestabview'
IDETerminalPane               = require './workspace/panes/ideterminalpane'
KDCustomHTMLView              = kd.CustomHTMLView
KDSplitViewPanel              = kd.SplitViewPanel
IDEStatusBarMenu              = require './views/statusbar/idestatusbarmenu'
IDEContentSearch              = require './views/contentsearch/idecontentsearch'
KDNotificationView            = kd.NotificationView
KDBlockingModalView           = kd.BlockingModalView
IDEApplicationTabView         = require './views/tabview/ideapplicationtabview'
AceFindAndReplaceView         = require 'ace/acefindandreplaceview'
environmentDataProvider       = require 'app/userenvironmentdataprovider'
CollaborationController       = require './collaborationcontroller'
VideoCollaborationController  = require './videocollaborationcontroller'
EnvironmentsMachineStateModal = require 'app/providers/environmentsmachinestatemodal'
KlientEventManager            = require 'app/kite/klienteventmanager'
IDELayoutManager              = require './workspace/idelayoutmanager'


require('./routes')()


module.exports =

class IDEAppController extends AppController

  _.extend @prototype, CollaborationController
  _.extend @prototype, VideoCollaborationController

  {
    Stopped, Running, NotInitialized, Terminated, Unknown, Pending,
    Starting, Building, Stopping, Rebooting, Terminating, Updating
  } = Machine.State

  {noop, warn} = kd

  @options = require './ideappcontrolleroptions'

  constructor: (options = {}, data) ->

    options.view    = new KDView cssClass: 'dark'
    options.appInfo =
      type          : 'application'
      name          : 'IDE'

    super options, data

    layoutOptions     =
      splitOptions    :
        direction     : 'vertical'
        name          : 'BaseSplit'
        sizes         : [ 250, null ]
        maximums      : [ 400, null ]
        views         : [
          {
            type      : 'custom'
            name      : 'filesPane'
            paneClass : IDEFilesTabView
          },
          {
            type      : 'custom'
            name      : 'editorPane'
            paneClass : IDEView
          }
        ]

    @silent    = no
    @workspace = new IDEWorkspace { layoutOptions }
    @ideViews  = []

    # todo:
    # - following two should be abstracted out into a separate api
    @layout = ndpane(16)
    @layoutMap = new Array(16*16)

    { windowController, appManager } = kd.singletons
    windowController.addFocusListener @bound 'handleWindowFocus'

    @layoutManager = new IDELayoutManager delegate : this

    @workspace.once 'ready', => @getView().addSubView @workspace.getView()

    appManager.on 'AppIsBeingShown', (app) =>

      return  unless app instanceof IDEAppController

      @setActivePaneFocus on, yes

      # Temporary fix for IDE is not shown after
      # opening pages which uses old SplitView.
      # TODO: This needs to be fixed. ~Umut
      windowController.notifyWindowResizeListeners()

      @resizeActiveTerminalPane()

      @runOnboarding()  if @isMachineRunning()

      if app.getId() is @getId() and not @layoutManager.isSnapshotRestored()
        @layoutManager.restoreSnapshot()

      @bindListeners()


  bindListeners: ->

    @on 'CloseFullScreen', =>
      [ideView] = @ideViews.filter (ideView) -> ideView.isFullScreen
      ideView.emit 'CloseFullScreen'  if ideView

    @on 'SnapshotUpdated', @bound 'saveLayoutSize'


  prepareIDE: (withFakeViews = no) ->

    panel     = @workspace.getView()
    appView   = @getView()
    ideView   = panel.getPaneByName 'editorPane'

    @setActiveTabView ideView.tabView
    @registerIDEView  ideView

    splitViewPanel = ideView.parent.parent
    @createStatusBar splitViewPanel
    @createFindAndReplaceView splitViewPanel

    appView.emit 'KeyViewIsSet'

    @createInitialView withFakeViews
    @bindCollapseEvents()

    {@finderPane, @settingsPane} = @workspace.panel.getPaneByName 'filesPane'

    @finderPane.on 'ChangeHappened', @bound 'syncChange'

    @bindRouteHandler()
    @initiateAutoSave()
    @emit 'ready'


  bindRouteHandler: ->

    {router, mainView} = kd.singletons

{'fraction_non_alphanumeric': 0.08674698795180723, 'fraction_numerical': 0.00214190093708166, 'mean_word_length': 2.1583990980834273, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '7431322', 'n_tokens_mistral': 3108, 'n_tokens_neox': 2962, 'n_words': 648}