From 7f41be31030fbd9bd496f37c401a3800c06129ab Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 16 Sep 2014 18:06:23 -0600 Subject: [PATCH] Use atom.workspace.getView to construct WorkspaceViews MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It returns the root DOM node of the workspace. Eventually this will be a custom element but for now it’s just a DOM node with a __spacePenView reference on it. --- benchmark/benchmark-suite.coffee | 2 +- spec/atom-spec.coffee | 2 +- spec/theme-manager-spec.coffee | 2 +- spec/workspace-view-spec.coffee | 7 ++++--- src/atom.coffee | 2 +- src/workspace.coffee | 4 ++++ 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/benchmark/benchmark-suite.coffee b/benchmark/benchmark-suite.coffee index 0a3901ec9..207c056df 100644 --- a/benchmark/benchmark-suite.coffee +++ b/benchmark/benchmark-suite.coffee @@ -7,7 +7,7 @@ describe "editorView.", -> beforeEach -> atom.workspaceViewParentSelector = '#jasmine-content' - atom.workspaceView = new WorkspaceView + atom.workspaceView = atom.workspace.getView(atom.workspace).__spacePenView atom.workspaceView.attachToDom() atom.workspaceView.width(1024) diff --git a/spec/atom-spec.coffee b/spec/atom-spec.coffee index c71f89faa..5389886ca 100644 --- a/spec/atom-spec.coffee +++ b/spec/atom-spec.coffee @@ -6,7 +6,7 @@ ThemeManager = require '../src/theme-manager' describe "the `atom` global", -> beforeEach -> - atom.workspaceView = new WorkspaceView + atom.workspaceView = atom.workspace.getView(atom.workspace).__spacePenView describe 'window sizing methods', -> describe '::getPosition and ::setPosition', -> diff --git a/spec/theme-manager-spec.coffee b/spec/theme-manager-spec.coffee index 7028d7c95..4a037d2f9 100644 --- a/spec/theme-manager-spec.coffee +++ b/spec/theme-manager-spec.coffee @@ -209,7 +209,7 @@ describe "ThemeManager", -> describe "base stylesheet loading", -> beforeEach -> - atom.workspaceView = new WorkspaceView + atom.workspaceView = atom.workspace.getView(atom.workspace).__spacePenView atom.workspaceView.append $$ -> @div class: 'editor' atom.workspaceView.attachToDom() diff --git a/spec/workspace-view-spec.coffee b/spec/workspace-view-spec.coffee index 8adbc69e5..f0d81943e 100644 --- a/spec/workspace-view-spec.coffee +++ b/spec/workspace-view-spec.coffee @@ -13,7 +13,7 @@ describe "WorkspaceView", -> atom.project.setPath(atom.project.resolve('dir')) pathToOpen = atom.project.resolve('a') atom.workspace = new Workspace - atom.workspaceView = new WorkspaceView(atom.workspace) + atom.workspaceView = atom.workspace.getView(atom.workspace).__spacePenView atom.workspaceView.enableKeymap() atom.workspaceView.focus() @@ -29,7 +29,7 @@ describe "WorkspaceView", -> atom.workspaceView.remove() atom.project = atom.deserializers.deserialize(projectState) atom.workspace = Workspace.deserialize(workspaceState) - atom.workspaceView = new WorkspaceView(atom.workspace) + atom.workspaceView = atom.workspace.getView(atom.workspace).__spacePenView atom.workspaceView.attachToDom() describe "when the serialized WorkspaceView has an unsaved buffer", -> @@ -185,7 +185,8 @@ describe "WorkspaceView", -> describe "when the root view is deserialized", -> it "updates the title to contain the project's path", -> - workspaceView2 = new WorkspaceView(atom.workspace.testSerialization()) + workspace2 = atom.workspace.testSerialization() + workspaceView2 = workspace2.getView(workspace2).__spacePenView item = atom.workspace.getActivePaneItem() expect(workspaceView2.title).toBe "#{item.getTitle()} - #{atom.project.getPath()}" workspaceView2.remove() diff --git a/src/atom.coffee b/src/atom.coffee index 40b52b9d6..c94c10007 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -582,7 +582,7 @@ class Atom extends Model startTime = Date.now() @workspace = Workspace.deserialize(@state.workspace) ? new Workspace - @workspaceView = new WorkspaceView(@workspace) + @workspaceView = @workspace.getView(@workspace).__spacePenView @deserializeTimings.workspace = Date.now() - startTime @keymaps.defaultTarget = @workspaceView[0] diff --git a/src/workspace.coffee b/src/workspace.coffee index 8c0bedf10..f87b3905e 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -10,6 +10,7 @@ Editor = require './editor' PaneContainer = require './pane-container' Pane = require './pane' {jQuery} = require './space-pen-extensions' +WorkspaceView = null # Essential: Represents the state of the user interface for the entire window. # An instance of this class is available via the `atom.workspace` global. @@ -66,6 +67,9 @@ class Workspace extends Model fullScreen: atom.isFullScreen() packagesWithActiveGrammars: @getPackageNamesWithActiveGrammars() + getViewClass: -> + WorkspaceView ?= require './workspace-view' + getPackageNamesWithActiveGrammars: -> packageNames = [] addGrammar = ({includedGrammarScopes, packageName}={}) ->