@Override
    public final void update(final AnActionEvent event) {
      final Presentation presentation = event.getPresentation();

      final DataContext dataContext = event.getDataContext();
      final HierarchyBrowserBaseEx browser =
          (HierarchyBrowserBaseEx) dataContext.getData(myBrowserDataKey);
      if (browser == null) {
        presentation.setVisible(false);
        presentation.setEnabled(false);
        return;
      }

      presentation.setVisible(true);

      final PsiElement selectedElement = browser.getSelectedElement();
      if (selectedElement == null || !browser.isApplicableElement(selectedElement)) {
        presentation.setEnabled(false);
        presentation.setVisible(false);
        return;
      }

      presentation.setEnabled(isEnabled(browser, selectedElement));
      String nonDefaultText = getNonDefaultText(browser, selectedElement);
      if (nonDefaultText != null) {
        presentation.setText(nonDefaultText);
      }
    }
  public void update(final AnActionEvent event) {
    super.update(event);

    final Presentation presentation = event.getPresentation();
    final DataContext context = event.getDataContext();
    Module module = (Module) context.getData(LangDataKeys.MODULE.getName());
    PsiFile currentFile = (PsiFile) context.getData(LangDataKeys.PSI_FILE.getName());
    Editor editor = (Editor) context.getData(PlatformDataKeys.EDITOR.getName());
    // VirtualFile currentFile = (VirtualFile)
    // context.getData(PlatformDataKeys.VIRTUAL_FILE.getName());
    if (currentFile != null && editor != null) {
      boolean isSSFile =
          currentFile
              .getFileType()
              .getDefaultExtension()
              .equals(SilverStripeFileType.DEFAULT_EXTENSION);
      SelectionModel selectionModel = editor.getSelectionModel();
      String selectedText = selectionModel.getSelectedText();
      this.selectedText = selectedText;
      this.selectonModel = selectionModel;
      this.editor = editor;
      this.currentFile = currentFile;
      if (selectedText == null) {
        presentation.setEnabled(false);
      }
      if (!isSSFile) {
        presentation.setEnabled(false);
        presentation.setVisible(false);
      }
    } else {
      presentation.setEnabled(false);
      presentation.setVisible(false);
    }
  }
    @Override
    public final void actionPerformed(final AnActionEvent event) {
      final DataContext dataContext = event.getDataContext();
      final HierarchyBrowserBaseEx browser =
          (HierarchyBrowserBaseEx) dataContext.getData(myBrowserDataKey);
      if (browser == null) return;

      final PsiElement selectedElement = browser.getSelectedElement();
      if (selectedElement == null || !browser.isApplicableElement(selectedElement)) return;

      final String currentViewType = browser.myCurrentViewType;
      Disposer.dispose(browser);
      final HierarchyProvider provider =
          BrowseHierarchyActionBase.findProvider(
              myProviderLanguageExtension,
              selectedElement,
              selectedElement.getContainingFile(),
              event.getDataContext());
      final HierarchyBrowser newBrowser =
          BrowseHierarchyActionBase.createAndAddToPanel(
              selectedElement.getProject(), provider, selectedElement);
      ApplicationManager.getApplication()
          .invokeLater(
              () ->
                  ((HierarchyBrowserBaseEx) newBrowser)
                      .changeView(correctViewType(browser, currentViewType)));
    }