       panel.show()
       for editorElement in @panelsByName[name].find(".editor")
         $(editorElement).view().redraw()
-      @panelMenu.children("[name='#{name}']").addClass('active')
+      @makePanelMenuActive(name)
       @activePanelName = name
       @panelToShow = null
     else

  handlePackageEvents: ->
    @subscribe @packageManager, 'package-installed theme-installed', ({name}) =>
      if pack = atom.packages.getLoadedPackage(name)
        @addPanel(name, new InstalledPackageView(pack, @packageManager))

    @subscribe @packageManager, 'package-uninstalled theme-uninstalled', ({name}) =>
      @removePanel(name)

    version: 2
    activePanelName: @activePanelName

  getPackageTitle: ({name}) ->
    _.undasherize(_.uncamelcase(name))

  addPanelMenuSeparator: ->
    @panelMenu.append $$ ->
      @div class: 'panel-menu-separator'

  addCorePanel: (name, iconName, panel) ->
    panelMenuItem = $$ ->
      @li name: name, =>
        @a class: "icon icon-#{iconName}", name
    @addPanel(name, panelMenuItem, panel)

  addPackagePanel: (pack) ->
    panel = new InstalledPackageView(pack, @packageManager)
    title = @getPackageTitle(pack)
    panelMenuItem = $$ ->
      @li name: pack.name, type: 'package', =>
        @a title
    @addPanel(pack.name, panelMenuItem, panel)

  addPanel: (name, panelMenuItem, panel) ->
    @panelMenu.append(panelMenuItem)
    panel.hide()
    @panelsByName[name] = panel
    @showPanel(name) if @getPanelCount() is 1 or @panelToShow is name

  getPanelCount: ->
    _.values(@panelsByName).length

  makePanelMenuActive: (name) ->
    @panelMenu.children('.active').removeClass('active')
    @panelMenu.children("[name='#{name}']").addClass('active')

  showPanel: (name) ->
    if panel = @panelsByName?[name]
