Extend AtomPackage directly in packages index.coffee

This commit is contained in:
Kevin Sawicki
2013-01-22 08:56:18 -08:00
parent 36e0ad6dc8
commit ca596db310
43 changed files with 252 additions and 175 deletions

View File

@@ -1 +1,8 @@
module.exports = require 'command-panel/src/command-panel'
AtomPackage = require 'atom-package'
CommandPanelView = require './src/command-panel-view'
module.exports =
class CommandPanel extends AtomPackage
activate: (rootView, state) -> CommandPanelView.activate(rootView, state)
deactivate: -> CommandPanelView.deactivate()
serialize: -> CommandPanelView.serialize()

View File

@@ -1,9 +1,9 @@
RootView = require 'root-view'
CommandPanel = require 'command-panel'
CommandPanelView = require 'command-panel/src/command-panel-view'
_ = require 'underscore'
describe "CommandPanel", ->
[rootView, editor, buffer, commandPanel, project] = []
[rootView, editor, buffer, commandPanel, project, CommandPanel] = []
beforeEach ->
rootView = new RootView
@@ -12,8 +12,8 @@ describe "CommandPanel", ->
project = rootView.project
editor = rootView.getActiveEditor()
buffer = editor.activeEditSession.buffer
atom.loadPackage('command-panel')
commandPanel = CommandPanel.instance
CommandPanel = atom.loadPackage('command-panel')
commandPanel = CommandPanelView.instance
commandPanel.history = []
commandPanel.historyIndex = 0

View File

@@ -9,12 +9,12 @@ Editor = require 'editor'
_ = require 'underscore'
module.exports =
class CommandPanel extends View
class CommandPanelView extends View
@activate: (rootView, state) ->
if state?
@instance = CommandPanel.deserialize(state, rootView)
@instance = @deserialize(state, rootView)
else
@instance = new CommandPanel(rootView)
@instance = new CommandPanelView(rootView)
@deactivate: ->
@instance.destroy()
@@ -26,7 +26,7 @@ class CommandPanel extends View
history: @instance.history[-@instance.maxSerializedHistorySize..]
@deserialize: (state, rootView) ->
commandPanel = new CommandPanel(rootView, state.history)
commandPanel = new CommandPanelView(rootView, state.history)
commandPanel.attach(state.text, focus: false) if state.visible
commandPanel.miniEditor.focus() if state.miniEditorFocused
commandPanel
@@ -93,6 +93,7 @@ class CommandPanel extends View
@miniEditor.focus()
attach: (text='', options={}) ->
console.trace 'attached', @rootView
@errorMessages.hide()
focus = options.focus ? true