From d489e45512ca18179d28b2526dca334cbda1b8b8 Mon Sep 17 00:00:00 2001 From: Seong Jae Lee Date: Sun, 5 Apr 2015 14:24:26 -0700 Subject: [PATCH] Fix more deprecation warnings SelectListView is moved to atom-space-pen-views package from atom package. --- LICENSE.md | 2 +- keymaps/notational-velocity.cson | 2 +- lib/notational-velocity-view.coffee | 52 ++++++++++------------------- lib/notational-velocity.coffee | 12 +++++-- package.json | 3 +- 5 files changed, 32 insertions(+), 39 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index 7ce8c08..69531df 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2014 +Copyright (c) 2014 Seong Jae Lee Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/keymaps/notational-velocity.cson b/keymaps/notational-velocity.cson index 091aaec..76826c1 100644 --- a/keymaps/notational-velocity.cson +++ b/keymaps/notational-velocity.cson @@ -7,5 +7,5 @@ # For more detailed documentation see # https://atom.io/docs/latest/advanced/keymaps -'.atom-workspace': +'atom-workspace': 'ctrl-alt-o': 'notational-velocity:toggle' diff --git a/lib/notational-velocity-view.coffee b/lib/notational-velocity-view.coffee index 288bb29..7d9b847 100644 --- a/lib/notational-velocity-view.coffee +++ b/lib/notational-velocity-view.coffee @@ -1,14 +1,12 @@ path = require 'path' fs = require 'fs' fsPlus = require 'fs-plus' -{$, $$, SelectListView} = require 'atom' +{$, $$, SelectListView} = require 'atom-space-pen-views' module.exports = class NotationalVelocityView extends SelectListView initialize: -> - console.log 'initialize' super - @addClass('notational-velocity from-top overlay') @loadData() @@ -42,7 +40,6 @@ class NotationalVelocityView extends SelectListView loadData: -> @data = [] - # directory = '/Users/seongjae/github/notational-velocity/testdata' directory = atom.config.get('notational-velocity.directory') for filename in fs.readdirSync(directory) @@ -72,10 +69,11 @@ class NotationalVelocityView extends SelectListView toggle: -> console.log 'toggle' - if @hasParent() - @cancel() + if @panel?.isVisible() + @hide() else - @attach() + @populateList() + @show() viewForItem: (item) -> console.log 'viewForItem #{item}' @@ -89,41 +87,27 @@ class NotationalVelocityView extends SelectListView @div "#{content}", class: 'secondary-line' confirmed: (item) -> - # console.log 'confirmed #{item}' - atom.workspaceView.open(item.filepath) + console.log 'confirmed #{item}' + atom.workspace.open(item.filepath) + @cancel() destroy: -> - # console.log 'destroy' + console.log 'destroy' @cancel() - @remove() + @panel?.destroy() - attach: -> - # console.log 'attach' + show: -> + console.log 'show' @storeFocusedElement() - atom.workspaceView.append(this) + @panel ?= atom.workspace.addModalPanel(item: this) + @panel.show() @focusFilterEditor() - # cancel: -> - # console.log 'cancel' - # super + cancelled: -> + @hide() - # cancelled: -> - # console.log 'cancelled' - # super - - # setItems: (items=[]) -> - # console.log 'setItems' - # super(items) - - # populateList: -> - # console.log 'populateList' - # super - - # selectItemView: (view) -> - # console.log 'selectItemView' - # super(view) - # return unless view.length - # console.log @list.indexOf(@list.find('.selected')) + hide: -> + @panel?.hide() populateList: -> console.log 'populateList' diff --git a/lib/notational-velocity.coffee b/lib/notational-velocity.coffee index 323cfac..2955404 100644 --- a/lib/notational-velocity.coffee +++ b/lib/notational-velocity.coffee @@ -1,3 +1,5 @@ +{CompositeDisposable} = require 'atom' + module.exports = configDefaults: directory: '/' @@ -5,10 +7,16 @@ module.exports = notationalVelocityView: null activate: (state) -> - atom.workspaceView.command 'notational-velocity:toggle', => - @createView(state).toggle() + # Events subscribed to in atom's system can be easily cleaned up with a + # CompositeDisposable + @subscriptions = new CompositeDisposable + + # Register command that toggles this view + @subscriptions.add atom.commands.add 'atom-workspace', + 'notational-velocity:toggle': => @createView(state).toggle() deactivate: -> + @subscriptions.dispose() @notationalVelocityView.destroy() serialize: -> diff --git a/package.json b/package.json index e4d2664..43ef273 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "atom": ">0.50.0" }, "dependencies": { - "fs-plus": "2.x" + "fs-plus": "2.x", + "atom-space-pen-views": "^2.0.3" } }