mirror of
https://github.com/atom/atom.git
synced 2026-02-09 06:05:11 -05:00
Merge branch 'master' of github.com:github/atom
Conflicts: spec/app/root-view-spec.coffee src/app/root-view.coffee
This commit is contained in:
@@ -21,13 +21,33 @@ class RootView extends View
|
||||
@div id: 'horizontal', outlet: 'horizontal', =>
|
||||
@div id: 'panes', outlet: 'panes'
|
||||
|
||||
@deserialize: (viewState) ->
|
||||
new RootView(viewState)
|
||||
@deserialize: ({ projectPath, panesViewState, extensionStates }) ->
|
||||
rootView = new RootView(pathToOpen: projectPath)
|
||||
rootView.setRootPane(rootView.deserializeView(panesViewState)) if panesViewState
|
||||
rootView.extensionStates = extensionStates if extensionStates
|
||||
rootView
|
||||
|
||||
extensions: null
|
||||
extensionStates: null
|
||||
|
||||
initialize: ({ pathToOpen, projectPath, panesViewState, @extensionStates }) ->
|
||||
initialize: ({ pathToOpen }) ->
|
||||
@handleEvents()
|
||||
|
||||
@extensions = {}
|
||||
@extensionStates = {}
|
||||
@commandPanel = new CommandPanel({rootView: this})
|
||||
|
||||
@setTitle()
|
||||
@project = new Project(pathToOpen)
|
||||
if pathToOpen? and fs.isFile(pathToOpen)
|
||||
@open(pathToOpen)
|
||||
|
||||
serialize: ->
|
||||
projectPath: @project?.path
|
||||
panesViewState: @panes.children().view()?.serialize()
|
||||
extensionStates: @serializeExtensions()
|
||||
|
||||
handleEvents: ->
|
||||
@on 'show-console', => window.showConsole()
|
||||
@on 'focus', (e) =>
|
||||
if @activeEditor()
|
||||
@@ -40,35 +60,9 @@ class RootView extends View
|
||||
@project.setPath(path) unless @project.getPath()
|
||||
@setTitle(path)
|
||||
|
||||
@commandPanel = new CommandPanel({rootView: this})
|
||||
|
||||
if pathToOpen?
|
||||
@project = new Project(pathToOpen)
|
||||
@open(pathToOpen) if fs.isFile(pathToOpen)
|
||||
else
|
||||
@project = new Project(projectPath)
|
||||
@open() unless panesViewState?
|
||||
|
||||
@deserializePanes(panesViewState) if panesViewState
|
||||
|
||||
@extensionStates ?= {}
|
||||
@extensions = {}
|
||||
|
||||
afterAttach: (onDom) ->
|
||||
@focus() if onDom
|
||||
|
||||
serialize: ->
|
||||
projectPath: @project?.path
|
||||
panesViewState: @serializePanes()
|
||||
extensionStates: @serializeExtensions()
|
||||
|
||||
serializePanes: ->
|
||||
@panes.children().view()?.serialize()
|
||||
|
||||
deserializePanes: (panesViewState) ->
|
||||
@panes.append @deserializeView(panesViewState)
|
||||
@adjustPaneDimensions()
|
||||
|
||||
serializeExtensions: ->
|
||||
extensionStates = {}
|
||||
for name, extension of @extensions
|
||||
@@ -132,6 +126,11 @@ class RootView extends View
|
||||
else
|
||||
@panes.find('.editor:first').view()
|
||||
|
||||
setRootPane: (pane) ->
|
||||
@panes.empty()
|
||||
@panes.append(pane)
|
||||
@adjustPaneDimensions()
|
||||
|
||||
adjustPaneDimensions: ->
|
||||
rootPane = @panes.children().first().view()
|
||||
rootPane?.css(width: '100%', height: '100%', top: 0, left: 0)
|
||||
|
||||
@@ -23,6 +23,7 @@ windowAdditions =
|
||||
startup: (path) ->
|
||||
@attachRootView(path)
|
||||
@loadUserConfiguration()
|
||||
rootView.activateExtension(require 'tree-view')
|
||||
$(window).on 'close', => @close()
|
||||
$(window).on 'beforeunload', =>
|
||||
@shutdown()
|
||||
@@ -39,10 +40,12 @@ windowAdditions =
|
||||
|
||||
attachRootView: (pathToOpen) ->
|
||||
rootViewState = atom.rootViewStates[$windowNumber]
|
||||
@rootView = if rootViewState
|
||||
RootView.deserialize(rootViewState)
|
||||
if rootViewState
|
||||
@rootView = RootView.deserialize(rootViewState)
|
||||
else
|
||||
new RootView {pathToOpen}
|
||||
@rootView = new RootView(pathToOpen: pathToOpen)
|
||||
@rootView.open() unless pathToOpen
|
||||
|
||||
$(@rootViewParentSelector).append @rootView
|
||||
|
||||
loadUserConfiguration: ->
|
||||
|
||||
Reference in New Issue
Block a user