   #############################
 
   connect: =>
-    console.log 'Connected!'
+    # console.log 'Connected!'
     @loadBrowser()
 
   connecting: =>
-    console.log 'Connecting...'
+    # console.log 'Connecting...'
 
   disconnect: =>
-    console.log 'Disconnected from server.'
+    # console.log 'Disconnected from server.'
+    bootbox.alert 'Disconnected from server.'
+    @clearEditor()
 
   connect_failed: =>
-    console.log 'Connection to server failed.'
+    # console.log 'Connection to server failed.'
+    bootbox.alert 'Connection to server failed.'
 
   error: =>
-    console.log 'An unknown error occurred.'
+    # console.log 'An unknown error occurred.'
+    bootbox.alert 'An unknown error occurred.'
 
   reconnect_failed: =>
-    console.log 'Unable to reconnect to server.'
+    # console.log 'Unable to reconnect to server.'
+    bootbox.alert 'Unable to reconnect to server.'
 
   reconnect: =>
     # console.log 'Reconnected!'
 
   reconnecting: =>
-    console.log 'Attempting to reconnect...'+    # console.log 'Attempting to reconnect...'

  new_object: (obj) =>
    obj.children = []

    insertChild = (o, p) =>
      if p.id == o.parent_id
        p.children.push new TreeNode o, @, p.level+1
        return true
      else
        added = false
        for child in p.children()
          added = insertChild(o, child)
          break if added
        return added

    for o in @objects()
      break if insertChild obj, o

  rm_object: (id) =>
    removeChild = (id, p) =>
      [match] = (child for child in p.children() when child.id is id)
      if match?
        p.children.remove match
        return true
      else
        removed = false
        for child in p.children()
          removed = removeChild(id, child)
          break if removed
        return removed

    for o in @objects()
      break if removeChild id, o

  object_parent_changed: (spec) =>
    console.log 'TODO: object parent changed:', spec

  object_name_changed: (spec) =>
    o = @findInTree spec.id


  # triggered by clicking a tab's close button
  closeTab: (tab, event) =>
    if tab.dirty()
      bootbox.confirm "Are you sure you want to close this #{tab.type}?  Your unsaved changes will be lost.", (close) =>
        @removeTab(tab) if close
    else
      @removeTab tab

    event.stopPropagation()

