mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Add PanelContainer.getElement, remove PanelContainer view provider
This commit is contained in:
@@ -34,8 +34,8 @@ describe('PanelContainerElement', () => {
|
||||
model => new TestPanelContainerItemElement().initialize(model)
|
||||
)
|
||||
|
||||
container = new PanelContainer({location: 'left'})
|
||||
element = atom.views.getView(container)
|
||||
container = new PanelContainer({viewRegistry: atom.views, location: 'left'})
|
||||
element = container.getElement()
|
||||
jasmineContent.appendChild(element)
|
||||
})
|
||||
|
||||
@@ -94,8 +94,8 @@ describe('PanelContainerElement', () => {
|
||||
|
||||
describe('when the container is at the bottom location', () => {
|
||||
beforeEach(() => {
|
||||
container = new PanelContainer({location: 'bottom'})
|
||||
element = atom.views.getView(container)
|
||||
container = new PanelContainer({viewRegistry: atom.views, location: 'bottom'})
|
||||
element = container.getElement()
|
||||
jasmineContent.appendChild(element)
|
||||
})
|
||||
|
||||
@@ -127,8 +127,8 @@ describe('PanelContainerElement', () => {
|
||||
|
||||
describe('when the container is modal', () => {
|
||||
beforeEach(() => {
|
||||
container = new PanelContainer({location: 'modal'})
|
||||
element = atom.views.getView(container)
|
||||
container = new PanelContainer({viewRegistry: atom.views, location: 'modal'})
|
||||
element = container.getElement()
|
||||
jasmineContent.appendChild(element)
|
||||
})
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ describe('PanelContainer', () => {
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
container = new PanelContainer()
|
||||
container = new PanelContainer({viewRegistry: atom.views})
|
||||
})
|
||||
|
||||
describe('::addPanel(panel)', () => {
|
||||
|
||||
@@ -47,8 +47,6 @@ Gutter = require './gutter'
|
||||
TextEditorRegistry = require './text-editor-registry'
|
||||
AutoUpdateManager = require './auto-update-manager'
|
||||
|
||||
WorkspaceElement = require './workspace-element'
|
||||
PanelContainerElement = require './panel-container-element'
|
||||
PanelElement = require './panel-element'
|
||||
PaneAxisElement = require './pane-axis-element'
|
||||
{createGutterView} = require './gutter-component-helpers'
|
||||
@@ -285,8 +283,6 @@ class AtomEnvironment extends Model
|
||||
registerDefaultCommands({commandRegistry: @commands, @config, @commandInstaller, notificationManager: @notifications, @project, @clipboard})
|
||||
|
||||
registerDefaultViewProviders: ->
|
||||
@views.addViewProvider PanelContainer, (model, env) ->
|
||||
new PanelContainerElement().initialize(model, env)
|
||||
@views.addViewProvider Panel, (model, env) ->
|
||||
new PanelElement().initialize(model, env)
|
||||
@views.addViewProvider PaneAxis, (model, env) ->
|
||||
|
||||
@@ -15,12 +15,9 @@ class PanelContainerElement extends HTMLElement {
|
||||
}
|
||||
}
|
||||
|
||||
initialize (model, {views}) {
|
||||
initialize (model, viewRegistry) {
|
||||
this.model = model
|
||||
this.views = views
|
||||
if (this.views == null) {
|
||||
throw new Error('Must pass a views parameter when initializing PanelContainerElements')
|
||||
}
|
||||
this.viewRegistry = viewRegistry
|
||||
|
||||
this.subscriptions.add(this.model.onDidAddPanel(this.panelAdded.bind(this)))
|
||||
this.subscriptions.add(this.model.onDidDestroy(this.destroyed.bind(this)))
|
||||
@@ -37,7 +34,7 @@ class PanelContainerElement extends HTMLElement {
|
||||
getModel () { return this.model }
|
||||
|
||||
panelAdded ({panel, index}) {
|
||||
const panelElement = this.views.getView(panel)
|
||||
const panelElement = this.viewRegistry.getView(panel)
|
||||
panelElement.classList.add(this.model.getLocation())
|
||||
if (this.model.isModal()) {
|
||||
panelElement.classList.add('overlay', 'from-top')
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
'use strict'
|
||||
|
||||
const {Emitter, CompositeDisposable} = require('event-kit')
|
||||
const PanelContainerElement = require('./panel-container-element')
|
||||
|
||||
module.exports = class PanelContainer {
|
||||
constructor ({location, dock} = {}) {
|
||||
constructor ({location, dock, viewRegistry} = {}) {
|
||||
this.location = location
|
||||
this.emitter = new Emitter()
|
||||
this.subscriptions = new CompositeDisposable()
|
||||
this.panels = []
|
||||
this.dock = dock
|
||||
this.viewRegistry = viewRegistry
|
||||
}
|
||||
|
||||
destroy () {
|
||||
@@ -18,6 +20,13 @@ module.exports = class PanelContainer {
|
||||
this.emitter.dispose()
|
||||
}
|
||||
|
||||
getElement() {
|
||||
if (!this.element) {
|
||||
this.element = new PanelContainerElement().initialize(this, this.viewRegistry)
|
||||
}
|
||||
return this.element
|
||||
}
|
||||
|
||||
/*
|
||||
Section: Event Subscription
|
||||
*/
|
||||
|
||||
@@ -77,13 +77,13 @@ module.exports = class Workspace extends Model {
|
||||
}
|
||||
|
||||
this.panelContainers = {
|
||||
top: new PanelContainer({location: 'top'}),
|
||||
left: new PanelContainer({location: 'left', dock: this.docks.left}),
|
||||
right: new PanelContainer({location: 'right', dock: this.docks.right}),
|
||||
bottom: new PanelContainer({location: 'bottom', dock: this.docks.bottom}),
|
||||
header: new PanelContainer({location: 'header'}),
|
||||
footer: new PanelContainer({location: 'footer'}),
|
||||
modal: new PanelContainer({location: 'modal'})
|
||||
top: new PanelContainer({viewRegistry: this.viewRegistry, location: 'top'}),
|
||||
left: new PanelContainer({viewRegistry: this.viewRegistry, location: 'left', dock: this.docks.left}),
|
||||
right: new PanelContainer({viewRegistry: this.viewRegistry, location: 'right', dock: this.docks.right}),
|
||||
bottom: new PanelContainer({viewRegistry: this.viewRegistry, location: 'bottom', dock: this.docks.bottom}),
|
||||
header: new PanelContainer({viewRegistry: this.viewRegistry, location: 'header'}),
|
||||
footer: new PanelContainer({viewRegistry: this.viewRegistry, location: 'footer'}),
|
||||
modal: new PanelContainer({viewRegistry: this.viewRegistry, location: 'modal'})
|
||||
}
|
||||
|
||||
this.subscribeToEvents()
|
||||
@@ -144,13 +144,13 @@ module.exports = class Workspace extends Model {
|
||||
}
|
||||
|
||||
this.panelContainers = {
|
||||
top: new PanelContainer({location: 'top'}),
|
||||
left: new PanelContainer({location: 'left', dock: this.docks.left}),
|
||||
right: new PanelContainer({location: 'right', dock: this.docks.right}),
|
||||
bottom: new PanelContainer({location: 'bottom', dock: this.docks.bottom}),
|
||||
header: new PanelContainer({location: 'header'}),
|
||||
footer: new PanelContainer({location: 'footer'}),
|
||||
modal: new PanelContainer({location: 'modal'})
|
||||
top: new PanelContainer({viewRegistry: this.viewRegistry, location: 'top'}),
|
||||
left: new PanelContainer({viewRegistry: this.viewRegistry, location: 'left', dock: this.docks.left}),
|
||||
right: new PanelContainer({viewRegistry: this.viewRegistry, location: 'right', dock: this.docks.right}),
|
||||
bottom: new PanelContainer({viewRegistry: this.viewRegistry, location: 'bottom', dock: this.docks.bottom}),
|
||||
header: new PanelContainer({viewRegistry: this.viewRegistry, location: 'header'}),
|
||||
footer: new PanelContainer({viewRegistry: this.viewRegistry, location: 'footer'}),
|
||||
modal: new PanelContainer({viewRegistry: this.viewRegistry, location: 'modal'})
|
||||
}
|
||||
|
||||
this.originalFontSize = null
|
||||
|
||||
Reference in New Issue
Block a user