private AnAction createToggleAction(String target, @NlsActions.ActionText String text) {
    class A extends IconWithTextAction implements DumbAware, Toggleable {
      @Override
      public void update(@NotNull AnActionEvent e) {
        e.getPresentation().setText(text);
        Toggleable.setSelected(e.getPresentation(), target.equals(myPreviewTarget));
        super.update(e);
      }

      @Override
      public @NotNull ActionUpdateThread getActionUpdateThread() {
        return ActionUpdateThread.BGT;
      }

      @Override
      public void actionPerformed(@NotNull AnActionEvent e) {
        targetChanged(target);
        myToolbar.updateActionsImmediately();
      }
    }
    return new A();
  }
private AnAction createToggleAction(String target, @NlsActions.ActionText String text)