Added 'load' method for plugins.

This is called after all the plugins have been
created.
This commit is contained in:
Corey Johnson
2011-09-22 11:08:53 -07:00
parent 16eef1cf07
commit 290f519d76
3 changed files with 24 additions and 11 deletions

View File

@@ -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

View File

@@ -8,6 +8,9 @@ class Plugin
for shortcut, method of @keymap()
bindKey @, shortcut, method
# Called after all plugins are loaded
load: ->
pane: ->
keymap: ->

View File

@@ -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')