mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Added 'load' method for plugins.
This is called after all the plugins have been created.
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
_ = require 'underscore'
|
||||
|
||||
File = require 'fs'
|
||||
Plugin = require 'plugin'
|
||||
ProjectPane = require 'project/projectpane'
|
||||
|
||||
@@ -9,9 +12,9 @@ class Project extends Plugin
|
||||
storageNamespace: ->
|
||||
@.constructor.name + @dir
|
||||
|
||||
constructor: (args...) ->
|
||||
super(args...)
|
||||
load: ->
|
||||
@pane = new ProjectPane @window, @
|
||||
@pane.toggle()
|
||||
|
||||
# NO! Do not use editor to handle events!
|
||||
editor = @window.document
|
||||
@@ -30,13 +33,12 @@ class Project extends Plugin
|
||||
openedPaths = _.without openedPaths, filename
|
||||
@set 'openedPaths', openedPaths
|
||||
|
||||
editor.ace.on 'loaded', =>
|
||||
# Reopen files (remove ones that no longer exist)
|
||||
openedPaths = @get 'openedPaths', []
|
||||
for path in openedPaths
|
||||
if File.isFile path
|
||||
@window.open path
|
||||
else if not File.exists path
|
||||
openedPaths = _.without openedPaths, path
|
||||
@set 'openedPaths', openedPaths
|
||||
# Reopen files (remove ones that no longer exist)
|
||||
openedPaths = @get 'openedPaths', []
|
||||
for path in openedPaths
|
||||
if File.isFile path
|
||||
@window.open path
|
||||
else if not File.exists path
|
||||
openedPaths = _.without openedPaths, path
|
||||
@set 'openedPaths', openedPaths
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ class Plugin
|
||||
for shortcut, method of @keymap()
|
||||
bindKey @, shortcut, method
|
||||
|
||||
# Called after all plugins are loaded
|
||||
load: ->
|
||||
|
||||
pane: ->
|
||||
|
||||
keymap: ->
|
||||
|
||||
@@ -47,6 +47,14 @@ class Window
|
||||
console.warn "Plugin Failed: #{File.base pluginPath}"
|
||||
console.warn error
|
||||
|
||||
# After all the plugins are created, load them.
|
||||
for plugin in @plugins
|
||||
try
|
||||
plugin.load()
|
||||
catch error
|
||||
console.warn "Plugin Loading Failed:"
|
||||
console.warn error
|
||||
|
||||
addPane: ({position, html}) ->
|
||||
verticalDiv = $('#app-vertical')
|
||||
horizontalDiv = $('#app-horizontal')
|
||||
|
||||
Reference in New Issue
Block a user