Editor and RootView have deserialize class method

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-04-12 16:26:59 -07:00
parent 1bd93e5565
commit dac91d1f29
3 changed files with 12 additions and 3 deletions

View File

@@ -39,6 +39,9 @@ class Editor extends View
softTabs: true
tabText: ' '
@deserialize: (viewState) ->
new Editor(viewState)
initialize: ({editSessions, activeEditSessionIndex, buffer, isFocused}) ->
requireStylesheet 'editor.css'
requireStylesheet 'theme/twilight.css'

View File

@@ -20,6 +20,9 @@ class RootView extends View
@div id: 'root-view', tabindex: -1, =>
@div id: 'panes', outlet: 'panes'
@deserialize: (viewState) ->
new RootView(viewState)
initialize: ({ pathToOpen, projectPath, panesViewState }) ->
@on 'toggle-file-finder', => @toggleFileFinder()
@on 'show-console', => window.showConsole()
@@ -57,7 +60,7 @@ class RootView extends View
when 'Pane' then Pane.deserialize(viewState, this)
when 'PaneRow' then PaneRow.deserialize(viewState, this)
when 'PaneColumn' then PaneColumn.deserialize(viewState, this)
when 'Editor' then new Editor(viewState)
when 'Editor' then Editor.deserialize(viewState)
open: (path) ->
@activeEditor().setBuffer(@project.open(path))

View File

@@ -36,8 +36,11 @@ windowAdditions =
atom.windowClosed this
attachRootView: (pathToOpen) ->
rootViewState = atom.rootViewStates[$windowNumber] or { pathToOpen }
@rootView = new RootView(rootViewState)
rootViewState = atom.rootViewStates[$windowNumber]
@rootView = if rootViewState
RootView.deserialize(rootViewState)
else
new RootView {pathToOpen}
$(@rootViewParentSelector).append @rootView
saveRootViewState: ->