mirror of
https://github.com/atom/atom.git
synced 2026-02-17 10:01:25 -05:00
Move PaneContainer.deserialize to an instance method
Signed-off-by: Max Brunsfeld <maxbrunsfeld@github.com>
This commit is contained in:
@@ -7,42 +7,35 @@ ItemRegistry = require './item-registry'
|
||||
|
||||
module.exports =
|
||||
class PaneContainer extends Model
|
||||
@version: 1
|
||||
|
||||
serializationVersion: 1
|
||||
root: null
|
||||
|
||||
@deserialize: (state) ->
|
||||
container = Object.create(@prototype) # allows us to pass a self reference to our child before invoking constructor
|
||||
state.root = atom.deserializers.deserialize(state.root, {container})
|
||||
state.destroyEmptyPanes = atom.config.get('core.destroyEmptyPanes')
|
||||
state.activePane = find state.root.getPanes(), (pane) -> pane.id is state.activePaneId
|
||||
@call(container, state) # run constructor
|
||||
container
|
||||
|
||||
constructor: (params) ->
|
||||
super
|
||||
|
||||
@activePane = params?.activePane
|
||||
|
||||
@config = params.config
|
||||
@emitter = new Emitter
|
||||
@subscriptions = new CompositeDisposable
|
||||
|
||||
@itemRegistry = new ItemRegistry
|
||||
|
||||
@setRoot(params?.root ? new Pane)
|
||||
@setActivePane(@getPanes()[0]) unless @getActivePane()
|
||||
|
||||
@destroyEmptyPanes() if params?.destroyEmptyPanes
|
||||
|
||||
@setRoot(new Pane(container: this))
|
||||
@setActivePane(@getRoot())
|
||||
@monitorActivePaneItem()
|
||||
@monitorPaneItems()
|
||||
|
||||
serialize: (params) ->
|
||||
deserializer: 'PaneContainer'
|
||||
version: @constructor.version
|
||||
version: @serializationVersion
|
||||
root: @root?.serialize()
|
||||
activePaneId: @activePane.id
|
||||
|
||||
deserialize: (state, deserializerManager) ->
|
||||
return unless state.version is @serializationVersion
|
||||
@setRoot(deserializerManager.deserialize(state.root, {container: this}))
|
||||
activePane = find @getRoot().getPanes(), (pane) -> pane.id is state.activePaneId
|
||||
@setActivePane(activePane ? @getPanes()[0])
|
||||
@destroyEmptyPanes() if @config.get('core.destroyEmptyPanes')
|
||||
|
||||
onDidChangeRoot: (fn) ->
|
||||
@emitter.on 'did-change-root', fn
|
||||
|
||||
|
||||
@@ -32,7 +32,9 @@ class Workspace extends Model
|
||||
for packageName in state.packagesWithActiveGrammars ? []
|
||||
atom.packages.getLoadedPackage(packageName)?.loadGrammarsSync()
|
||||
|
||||
state.paneContainer = PaneContainer.deserialize(state.paneContainer)
|
||||
paneContainer = new PaneContainer(config: atom.config)
|
||||
paneContainer.deserialize(state.paneContainer, atom.deserializers)
|
||||
state.paneContainer = paneContainer
|
||||
new this(state)
|
||||
|
||||
constructor: (params) ->
|
||||
@@ -45,7 +47,7 @@ class Workspace extends Model
|
||||
@emitter = new Emitter
|
||||
@openers = []
|
||||
|
||||
@paneContainer ?= new PaneContainer()
|
||||
@paneContainer ?= new PaneContainer(config: atom.config)
|
||||
@paneContainer.onDidDestroyPaneItem(@didDestroyPaneItem)
|
||||
|
||||
@directorySearchers = []
|
||||
|
||||
Reference in New Issue
Block a user