<commit_before>class EnvironmentContainer extends KDDiaContainer

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

    options.cssClass   = 'environments-container'
    options.draggable  = yes

    super options, data

    title   = @getOption 'title'
    @header = new KDHeaderView {type : "medium", title}

    @itemHeight = options.itemHeight ? 40

    @on "DataLoaded", => @_dataLoaded = yes

    @newItemPlus = new KDCustomHTMLView
      cssClass   : 'new-item-plus'
      click      : => @emit 'PlusButtonClicked'

  viewAppended:->
    super
    @addSubView @header
    @header.addSubView @newItemPlus
    @loadItems()

  addDia:(diaObj, pos)->
    pos = x: 20, y: 60 + @diaCount() * (@itemHeight + 10)
    super diaObj, pos
    @updateHeight()
    diaObj.on "KDObjectWillBeDestroyed", @bound 'updatePositions'

  updatePositions:->
    index = 0
    for _, dia of @dias
      dia.setX 20
      dia.setY 60 + index * 50
      index++
    @updateHeight()

  diaCount:-> Object.keys(@dias).length

  updateHeight:->
    @setHeight 80 + @diaCount() * 50
    @emit 'UpdateScene'

  loadItems:-> yes<commit_msg>Keep container positions in appStorage and load them again for next reload<commit_after>class EnvironmentContainer extends KDDiaContainer

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

    options.cssClass   = 'environments-container'
    options.draggable  = yes

    super options, data

    sc = KD.getSingleton 'appStorageController'
    @appStorage = sc.storage 'EnvironmentsScene', '1.0'

    title   = @getOption 'title'
    @header = new KDHeaderView {type : "medium", title}

    @itemHeight = options.itemHeight ? 40

    @on "DataLoaded", => @_dataLoaded = yes
    @on "DragFinished", @bound 'savePosition'

    @newItemPlus = new KDCustomHTMLView
      cssClass   : 'new-item-plus'
      click      : => @emit 'PlusButtonClicked'

  viewAppended:->
    super
    @addSubView @header
    @header.addSubView @newItemPlus
    @appStorage.ready @bound 'loadPosition'
    @loadItems()

  addDia:(diaObj, pos)->
    pos = x: 20, y: 60 + @diaCount() * (@itemHeight + 10)
    super diaObj, pos

    diaObj.on "KDObjectWillBeDestroyed", @bound 'updatePositions'
    @updateHeight()

  updatePositions:->

    index = 0
    for _, dia of @dias
      dia.setX 20
      dia.setY 60 + index * 50
      index++
    @updateHeight()

  diaCount:-> Object.keys(@dias).length

  updateHeight:->

    @setHeight 80 + @diaCount() * 50
    @emit 'UpdateScene'

  savePosition:->

    name      = @constructor.name
    bounds    = x: @getRelativeX(), y: @getRelativeY()
    positions = (@appStorage.getValue 'containerPositions') or {}
    positions[name] = bounds
    @appStorage.setValue 'containerPositions', positions

  loadPosition:->

    name     = @constructor.name
    position = ((@appStorage.getValue 'containerPositions') or {})[name]
    return  unless position
    @setX position.x; @setY position.y

  loadItems:-> yes

{'fraction_non_alphanumeric': 0.12139917695473251, 'fraction_numerical': 0.013717421124828532, 'mean_word_length': 3.0401662049861495, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '7155903', 'n_tokens_mistral': 993, 'n_tokens_neox': 905, 'n_words': 232}