RootView talks about packages and packageModules, not extensions

Now you call `rootView.activatePackage`, etc
This commit is contained in:
Nathan Sobo
2012-12-19 19:24:44 -07:00
parent 275f6f2df5
commit 7dcb12ada2
12 changed files with 77 additions and 82 deletions

View File

@@ -14,9 +14,9 @@ _.extend atom,
packagePath = require.resolve(name, verifyExistence: false)
throw new Error("No package found named '#{name}'") unless packagePath
packagePath = fs.directory(packagePath)
extension = require(packagePath)
extension.name = name
rootView.activateExtension(extension)
packageModule = require(packagePath)
packageModule.name = name
rootView.activatePackage(packageModule)
extensionKeymapPath = require.resolve(fs.join(name, "src/keymap"), verifyExistence: false)
require extensionKeymapPath if fs.exists(extensionKeymapPath)
catch e

View File

@@ -24,19 +24,19 @@ class RootView extends View
@div id: 'vertical', outlet: 'vertical', =>
@div id: 'panes', outlet: 'panes'
@deserialize: ({ projectPath, panesViewState, extensionStates }) ->
rootView = new RootView(projectPath, extensionStates: extensionStates, suppressOpen: true)
@deserialize: ({ projectPath, panesViewState, packageStates }) ->
rootView = new RootView(projectPath, packageStates: packageStates, suppressOpen: true)
rootView.setRootPane(rootView.deserializeView(panesViewState)) if panesViewState
rootView
extensions: null
extensionStates: null
packageModules: null
packageStates: null
title: null
initialize: (pathToOpen, { @extensionStates, suppressOpen } = {}) ->
initialize: (pathToOpen, { @packageStates, suppressOpen } = {}) ->
window.rootView = this
@extensionStates ?= {}
@extensions = {}
@packageStates ?= {}
@packageModules = {}
@project = new Project(pathToOpen)
config.load()
@@ -53,7 +53,7 @@ class RootView extends View
serialize: ->
projectPath: @project?.getPath()
panesViewState: @panes.children().view()?.serialize()
extensionStates: @serializeExtensions()
packageStates: @serializePackages()
handleEvents: ->
@on 'toggle-dev-tools', => atom.toggleDevTools()
@@ -95,14 +95,14 @@ class RootView extends View
afterAttach: (onDom) ->
@focus() if onDom
serializeExtensions: ->
extensionStates = {}
for name, extension of @extensions
serializePackages: ->
packageStates = {}
for name, packageModule of @packageModules
try
extensionStates[name] = extension.serialize?()
packageStates[name] = packageModule.serialize?()
catch e
console?.error("Exception serializing '#{name}' extension\n", e.stack)
extensionStates
console?.error("Exception serializing '#{name}' package's module\n", e.stack)
packageStates
deserializeView: (viewState) ->
switch viewState.viewClass
@@ -111,18 +111,18 @@ class RootView extends View
when 'PaneColumn' then PaneColumn.deserialize(viewState, this)
when 'Editor' then Editor.deserialize(viewState, this)
activateExtension: (extension, config) ->
throw new Error("Trying to activate an extension with no name attribute") unless extension.name?
@extensions[extension.name] = extension
extension.activate(this, @extensionStates[extension.name], config)
activatePackage: (packageModule) ->
throw new Error("Trying to activate a package module with no name attribute") unless packageModule.name?
@packageModules[packageModule.name] = packageModule
packageModule.activate(this, @packageStates[packageModule.name])
deactivateExtension: (extension) ->
extension.deactivate?()
delete @extensions[extension.name]
deactivatePackage: (packageModule) ->
packageModule.deactivate?()
delete @packageModules[packageModule.name]
deactivate: ->
atom.setRootViewStateForPath(@project.getPath(), @serialize())
@deactivateExtension(extension) for name, extension of @extensions
@deactivatePackage(packageModule) for name, packageModule of @packageModules
@remove()
open: (path, options = {}) ->