Move package related data to Atom from RootView

This commit is contained in:
Corey Johnson & Kevin Sawicki
2013-02-08 16:32:42 -08:00
parent c27489f608
commit bb5778b659
3 changed files with 28 additions and 17 deletions

View File

@@ -13,6 +13,25 @@ _.extend atom,
loadedThemes: []
pendingBrowserProcessCallbacks: {}
loadedPackages: []
activatedAtomPackages: []
atomPackageStates: {}
activateAtomPackage: (pack) ->
@activatedAtomPackages.push(pack)
pack.packageMain.activate(@atomPackageStates[pack.name])
deactivateAtomPackages: ->
pack.packageMain.deactivate?() for pack in @activatedAtomPackages
@activatedAtomPackages = []
serializeAtomPackages: ->
packageStates = {}
for pack in @activatedAtomPackages
try
packageStates[pack.name] = pack.packageMain.serialize?()
catch e
console?.error("Exception serializing '#{pack.name}' package's module\n", e.stack)
packageStates
loadPackage: (name, options) ->
packagePath = _.find @getPackagePaths(), (packagePath) -> fs.base(packagePath) == name

View File

@@ -29,18 +29,18 @@ class RootView extends View
else
projectOrPathToOpen = projectPath # This will migrate people over to the new project serialization scheme. It should be removed eventually.
rootView = new RootView(projectOrPathToOpen , packageStates: packageStates, suppressOpen: true)
atom.atomPackageStates = packageStates ? {}
rootView = new RootView(projectOrPathToOpen , suppressOpen: true)
rootView.setRootPane(rootView.deserializeView(panesViewState)) if panesViewState
rootView
packages: null
packageStates: null
title: null
pathToOpenIsFile: false
initialize: (projectOrPathToOpen, { @packageStates, suppressOpen } = {}) ->
initialize: (projectOrPathToOpen, { suppressOpen } = {}) ->
window.rootView = this
@packageStates ?= {}
@packages = []
@viewClasses = {
"Pane": Pane,
@@ -263,18 +263,10 @@ class RootView extends View
@project.eachBuffer(callback)
activatePackage: (pack) ->
@packages.push(pack)
pack.packageMain.activate(@packageStates[pack.name])
atom.activateAtomPackage(pack)
deactivatePackages: ->
pack.packageMain.deactivate?() for pack in @packages
@packages = []
atom.deactivateAtomPackages()
serializePackages: ->
packageStates = {}
for pack in @packages
try
packageStates[pack.name] = pack.packageMain.serialize?()
catch e
console?.error("Exception serializing '#{name}' package's module\n", e.stack)
packageStates
atom.serializeAtomPackages()

View File

@@ -37,8 +37,8 @@ windowAdditions =
# Note: RootView assigns itself on window on initialization so that
# window.rootView is available when loading user configuration
attachRootView: (pathToOpen) ->
if rootViewState = atom.getRootViewStateForPath(pathToOpen)
RootView.deserialize(rootViewState)
if pathState = atom.getRootViewStateForPath(pathToOpen)
RootView.deserialize(pathState)
else
new RootView(pathToOpen)