         {result} = file
         return if result.selfLink.indexOf(title) is -1
 
-
         if result.items.length > 0
           @loadCollaborationFile file
           log '.............file found', file
-        else
+        else if @amIHost
           rtm.createFile title
+
           rtm.on 'FileCreated', (file) =>
             console.clear()
             log '.............file created', file

      ideViewLength  = 0
      ideViewLength += ideView.tabView.panes.length  for ideView in @ideViews
      delete @generatedPanes[pane.view.hash]
      @serialize()

      @statusBar.showInformation()  if ideViewLength is 0

    ideView.tabView.on 'PaneAdded', (pane) =>
      @registerPane pane

    # ideView.on 'ChangeHappened', (change) =>
    #   @logChange change

  registerPane: (pane) ->
    {view} = pane

    @rtm.getFile file.result.items.first.id

    @rtm.on 'FileLoaded', (doc) =>
      @realTimeDoc = doc

      if @amIHost
        @writeWorkspaceSnapshot()
      else
        @getWorkspaceSnaphot()
        @rtm.on 'MapValueChanged', (map, v) ->
          log '.................', map, v


  writeWorkspaceSnapshot: ->
    return  unless @realTimeDoc

    @rtm.create 'map', @realTimeDoc, 'snapshot', @createWorkspaceSnapshot()


  getWorkspaceSnaphot: ->
    return  unless @realTimeDoc

    snapshot = @rtm.getFromModel @realTimeDoc, 'snapshot'
    log 'workspace snapshot is', snapshot.values()
    return snapshot


  createWorkspaceSnapshot: ->
    panes = {}

    @forEachSubViewInIDEViews_ (pane) ->
      if pane.options.paneType is 'editor'
        unless pane.file.path is 'localfile:/Untitled.txt'
          data = pane.serialize()
          panes[data.hash] = data
      else
        data = pane.serialize()
        panes[data.hash] = data

    return panes


  handleChange: (change) ->
    return  unless @realTimeDoc

    if change.type in [ 'NewPaneCreated', 'PaneRemoved' ]
      if @amIHost
        log 'change detected', change.context
        @writeWorkspaceSnapshot()
