@Override
  public JComponent createCustomComponent(Presentation presentation) {
    // this component cannot be stored right here because of action system architecture:
    // one action can be shown on multiple toolbars simultaneously
    JCheckBox checkBox = new JCheckBox();
    checkBox.setOpaque(false);

    checkBox.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            JCheckBox checkBox = (JCheckBox) e.getSource();
            ActionToolbar actionToolbar = UIUtil.getParentOfType(ActionToolbar.class, checkBox);
            DataContext dataContext =
                actionToolbar != null
                    ? actionToolbar.getToolbarDataContext()
                    : DataManager.getInstance().getDataContext(checkBox);
            CheckboxAction.this.actionPerformed(
                new AnActionEvent(
                    null,
                    dataContext,
                    ActionPlaces.UNKNOWN,
                    CheckboxAction.this.getTemplatePresentation(),
                    ActionManager.getInstance(),
                    0));
          }
        });

    return checkBox;
  }
  GitManualPushToBranch(
      @NotNull Collection<GitRepository> repositories, @NotNull final Runnable performOnRefresh) {
    super();
    myRepositories = repositories;

    myManualPush = new JCheckBox("Push current branch to alternative branch: ", false);
    myManualPush.setMnemonic('b');

    myDestBranchTextField = new JTextField(20);

    myComment =
        new JBLabel("This will apply to all selected repositories", UIUtil.ComponentStyle.SMALL);

    myRefreshAction =
        new GitPushLogRefreshAction() {
          @Override
          public void actionPerformed(AnActionEvent e) {
            performOnRefresh.run();
          }
        };
    myRefreshButton =
        new ActionButton(
            myRefreshAction,
            myRefreshAction.getTemplatePresentation(),
            myRefreshAction.getTemplatePresentation().getText(),
            ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE);
    myRefreshButton.setFocusable(true);
    final ShortcutSet shortcutSet =
        ActionManager.getInstance().getAction(IdeActions.ACTION_REFRESH).getShortcutSet();
    myRefreshAction.registerCustomShortcutSet(shortcutSet, myRefreshButton);

    myRemoteSelector = new RemoteSelector(getRemotesWithCommonNames(repositories));
    myRemoteSelectorComponent = myRemoteSelector.createComponent();

    setDefaultComponentsEnabledState(myManualPush.isSelected());
    myManualPush.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            boolean isManualPushSelected = myManualPush.isSelected();
            setDefaultComponentsEnabledState(isManualPushSelected);
            if (isManualPushSelected) {
              myDestBranchTextField.requestFocus();
              myDestBranchTextField.selectAll();
            }
          }
        });

    layoutComponents();
  }
  private void addCheckbox(final JPanel panel, final TreeAction action) {
    String text =
        action instanceof FileStructureFilter
            ? ((FileStructureFilter) action).getCheckBoxText()
            : action instanceof FileStructureNodeProvider
                ? ((FileStructureNodeProvider) action).getCheckBoxText()
                : null;

    if (text == null) return;

    Shortcut[] shortcuts =
        action instanceof FileStructureFilter
            ? ((FileStructureFilter) action).getShortcut()
            : ((FileStructureNodeProvider) action).getShortcut();

    final JCheckBox chkFilter = new JCheckBox();
    UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, chkFilter);

    final boolean selected = getDefaultValue(action);
    chkFilter.setSelected(selected);
    myTreeActionsOwner.setActionIncluded(
        action, action instanceof FileStructureFilter ? !selected : selected);
    chkFilter.addActionListener(
        new ActionListener() {
          public void actionPerformed(final ActionEvent e) {
            final boolean state = chkFilter.isSelected();
            if (!myAutoClicked.contains(chkFilter)) {
              saveState(action, state);
            }
            myTreeActionsOwner.setActionIncluded(
                action, action instanceof FileStructureFilter ? !state : state);
            // final String filter = mySpeedSearch.isPopupActive() ?
            // mySpeedSearch.getEnteredPrefix() : null;
            // mySpeedSearch.hidePopup();
            Object selection =
                ContainerUtil.getFirstItem(myAbstractTreeBuilder.getSelectedElements());
            if (selection instanceof FilteringTreeStructure.FilteringNode) {
              selection = ((FilteringTreeStructure.FilteringNode) selection).getDelegate();
            }
            myTreeStructure.rebuildTree();
            myFilteringStructure.rebuild();

            final Object sel = selection;
            final Runnable runnable =
                new Runnable() {
                  public void run() {
                    ApplicationManager.getApplication()
                        .runReadAction(
                            new Runnable() {
                              @Override
                              public void run() {
                                myAbstractTreeBuilder
                                    .refilter(sel, true, false)
                                    .doWhenProcessed(
                                        new Runnable() {
                                          @Override
                                          public void run() {
                                            if (mySpeedSearch.isPopupActive()) {
                                              mySpeedSearch.refreshSelection();
                                            }
                                          }
                                        });
                              }
                            });
                  }
                };
            if (ApplicationManager.getApplication().isUnitTestMode()) {
              runnable.run();
            } else {
              ApplicationManager.getApplication().invokeLater(runnable);
            }
          }
        });
    chkFilter.setFocusable(false);

    if (shortcuts.length > 0) {
      text += " (" + KeymapUtil.getShortcutText(shortcuts[0]) + ")";
      new AnAction() {
        public void actionPerformed(final AnActionEvent e) {
          chkFilter.doClick();
        }
      }.registerCustomShortcutSet(new CustomShortcutSet(shortcuts), myTree);
    }
    chkFilter.setText(text);
    panel.add(chkFilter);
    myCheckBoxes.put(action.getClass(), chkFilter);
  }