public void focusGained(final FocusEvent e) {
   if (e.getOppositeComponent() == null && shouldFocusEditor) {
     shouldFocusEditor = false;
     ToolWindowManager.getInstance(myPanel.getProject()).activateEditorComponent();
     return;
   }
   myPanel.updateItems();
   final List<NavBarItem> items = myPanel.getItems();
   if (!myPanel.isInFloatingMode() && items.size() > 0) {
     myPanel.setContextComponent(items.get(items.size() - 1));
   } else {
     myPanel.setContextComponent(null);
   }
 }
  private void processFocusLost(FocusEvent e) {
    final Component opposite = e.getOppositeComponent();

    if (myPanel.isInFloatingMode()
        && opposite != null
        && DialogWrapper.findInstance(opposite) != null) {
      myPanel.hideHint();
      return;
    }

    final boolean nodePopupInactive = !myPanel.isNodePopupActive();
    boolean childPopupInactive = !JBPopupFactory.getInstance().isChildPopupFocused(myPanel);
    if (nodePopupInactive && childPopupInactive) {
      if (opposite != null
          && opposite != myPanel
          && !myPanel.isAncestorOf(opposite)
          && !e.isTemporary()) {
        myPanel.setContextComponent(null);
        myPanel.hideHint();
      }
    }

    myPanel.updateItems();
  }
 @Override
 public void selectionChanged() {
   myPanel.updateItems();
   myPanel.scrollSelectionToVisible();
 }