From 89cbd6b834c92ef65e7682894e4f0f83455a452f Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 14 Jan 2014 10:53:16 -0700 Subject: [PATCH] Move PaneContainerView::saveAll to the model --- src/pane-container-view.coffee | 5 ++--- src/pane-container.coffee | 3 +++ src/workspace-view.coffee | 6 +----- src/workspace.coffee | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/pane-container-view.coffee b/src/pane-container-view.coffee index e3d5431b3..c38f73818 100644 --- a/src/pane-container-view.coffee +++ b/src/pane-container-view.coffee @@ -1,4 +1,5 @@ Serializable = require 'serializable' +Delegator = require 'delegato' {$, View} = require './space-pen-extensions' PaneView = require './pane-view' PaneContainer = require './pane-container' @@ -8,6 +9,7 @@ module.exports = class PaneContainerView extends View atom.deserializers.add(this) Serializable.includeInto(this) + Delegator.includeInto(this) @deserialize: (state) -> new this(PaneContainer.deserialize(state.model)) @@ -62,9 +64,6 @@ class PaneContainerView extends View @setRoot(null) @trigger 'pane:removed', [child] if child instanceof PaneView - saveAll: -> - pane.saveItems() for pane in @getPanes() - confirmClose: -> saved = true for pane in @getPanes() diff --git a/src/pane-container.coffee b/src/pane-container.coffee index 6b8fd1d80..d4273db88 100644 --- a/src/pane-container.coffee +++ b/src/pane-container.coffee @@ -40,6 +40,9 @@ class PaneContainer extends Model paneForUri: (uri) -> find @getPanes(), (pane) -> pane.itemForUri(uri)? + saveAll: -> + pane.saveItems() for pane in @getPanes() + activateNextPane: -> panes = @getPanes() if panes.length > 1 diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index f0c6f2426..8cddf468b 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -46,7 +46,7 @@ class WorkspaceView extends View @delegatesProperty 'fullScreen', 'destroyedItemUris', toProperty: 'model' @delegatesMethods 'open', 'openSync', 'openSingletonSync', 'reopenItemSync', - 'saveActivePaneItem', 'saveActivePaneItemAs', toProperty: 'model' + 'saveActivePaneItem', 'saveActivePaneItemAs', 'saveAll', toProperty: 'model' @version: 4 @@ -231,10 +231,6 @@ class WorkspaceView extends View # FIXME: Difference between active and focused pane? getFocusedPane: -> @panes.getFocusedPane() - # Public: Saves all of the open items within panes. - saveAll: -> - @panes.saveAll() - # Public: Fires a callback on each open {PaneView}. eachPane: (callback) -> @panes.eachPane(callback) diff --git a/src/workspace.coffee b/src/workspace.coffee index 48e563293..ed68d9ce4 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -12,7 +12,7 @@ class Workspace extends Model Serializable.includeInto(this) @delegatesProperty 'activePane', 'activePaneItem', toProperty: 'paneContainer' - @delegatesMethod 'getPanes', toProperty: 'paneContainer' + @delegatesMethod 'getPanes', 'saveAll', toProperty: 'paneContainer' @properties paneContainer: -> new PaneContainer