Insert new workspaceView into the dom


#1

I’m developing a package that needs to be able to take a serialized workspace and load it into atom.

I have the workspace and workspaceView setup code working:

atom.workspace = Workspace.deserialize data.workspace
atom.workspaceView = new WorkspaceView atom.workspace

But I have been unable to find the correct method for re-rendering the atom workspaceView.

The atom test code calls atom.workspaceView.attachToDom() which doesn’t exist.

What is the proper way to achieve this.


#2

attachToDom is definided here:


#3

Ok, so that is a jasmine test specific method that just puts the content into the test environments dom.

So what method is there for having atom re-insert the workspaceView frag into the dom?

That is without having to use atom.reload()


#4

Does this work?


#5

No, using the code in my OP, nothing changes. I assume it’s because my new WorkspaceView isn’t in the dom yet.

By the way, I appreciate the help.


#6

Using the method atom uses during boot(specifically deserialization & dom insertion), produces undesired results: src/atom.coffee#L269

The left is a normal editor, the right was deserialized from the workspace on the left and inserted into the dom using the aforementioned method.


#7

So my temporary solution until I find the proper method for this is fairly strait forward but not at all scalable.

atom.workspace = Workspace.deserialize data.workspace
atom.workspaceView = new WorkspaceView atom.workspace

$(atom.workspaceViewSelector).html atom.workspaceView

if atom.packages.isPackageLoaded('status-bar')
  if atom.packages.isPackageActive('status-bar')
    atom.packages.loadedPackages['status-bar'].deactivate()
    atom.packages.loadedPackages['status-bar'].activate()

if atom.packages.isPackageLoaded('tabs')
   if atom.packages.isPackageActive('tabs')
     atom.packages.loadedPackages['tabs'].deactivate()
     atom.packages.loadedPackages['tabs'].activate()