mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Serialize docks
This commit is contained in:
@@ -38,6 +38,7 @@ Panel = require './panel'
|
||||
PaneContainer = require './pane-container'
|
||||
PaneAxis = require './pane-axis'
|
||||
Pane = require './pane'
|
||||
Dock = require './dock'
|
||||
Project = require './project'
|
||||
TextEditor = require './text-editor'
|
||||
TextBuffer = require 'text-buffer'
|
||||
@@ -254,6 +255,7 @@ class AtomEnvironment extends Model
|
||||
@deserializers.add(PaneContainer)
|
||||
@deserializers.add(PaneAxis)
|
||||
@deserializers.add(Pane)
|
||||
@deserializers.add(Dock)
|
||||
@deserializers.add(Project)
|
||||
@deserializers.add(TextEditor)
|
||||
@deserializers.add(TextBuffer)
|
||||
|
||||
18
src/dock.js
18
src/dock.js
@@ -304,6 +304,24 @@ module.exports = class Dock {
|
||||
return initialSize == null ? DEFAULT_INITIAL_SIZE : initialSize
|
||||
}
|
||||
|
||||
serialize () {
|
||||
return {
|
||||
deserializer: 'Dock',
|
||||
size: this.state.size,
|
||||
paneContainer: this.paneContainer.serialize(),
|
||||
open: this.state.open
|
||||
}
|
||||
}
|
||||
|
||||
deserialize (serialized, deserializerManager) {
|
||||
this.paneContainer.deserialize(serialized.paneContainer, deserializerManager)
|
||||
this.setState({
|
||||
size: serialized.size,
|
||||
// If no items could be deserialized, we don't want to show the dock (even if it was open last time)
|
||||
open: serialized.open && (this.paneContainer.getPaneItems().length > 0)
|
||||
})
|
||||
}
|
||||
|
||||
// PaneContainer-delegating methods
|
||||
|
||||
getPanes () {
|
||||
|
||||
@@ -154,7 +154,12 @@ module.exports = class Workspace extends Model {
|
||||
deserializer: 'Workspace',
|
||||
paneContainer: this.paneContainer.serialize(),
|
||||
packagesWithActiveGrammars: this.getPackageNamesWithActiveGrammars(),
|
||||
destroyedItemURIs: this.destroyedItemURIs.slice()
|
||||
destroyedItemURIs: this.destroyedItemURIs.slice(),
|
||||
docks: {
|
||||
left: this.docks.left.serialize(),
|
||||
right: this.docks.right.serialize(),
|
||||
bottom: this.docks.bottom.serialize()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +175,13 @@ module.exports = class Workspace extends Model {
|
||||
if (state.destroyedItemURIs != null) {
|
||||
this.destroyedItemURIs = state.destroyedItemURIs
|
||||
}
|
||||
return this.paneContainer.deserialize(state.paneContainer, deserializerManager)
|
||||
this.paneContainer.deserialize(state.paneContainer, deserializerManager)
|
||||
for (let location in this.docks) {
|
||||
const serialized = state.docks && state.docks[location]
|
||||
if (serialized) {
|
||||
this.docks[location].deserialize(serialized, deserializerManager)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getPackageNamesWithActiveGrammars () {
|
||||
|
||||
Reference in New Issue
Block a user