DefaultActionGroup (Collection<? extends JButton> buttons, JButton defaultButton, boolean isPrincipal) { final DefaultActionGroup result = new DefaultActionGroup(); if (EXPAND_OPTION_BUTTONS) { DefaultActionGroup options = null; for (JButton jb : buttons) { if (jb instanceof JBOptionButton ob) { final Action[] opts = ob.getOptions(); if (opts != null) { for (Action a : opts) { if (a == null) { continue; } AnAction anAct = _createActionFromButton(a, ob, true); if (anAct == null) { continue; } if (options == null) { options = new DefaultActionGroup(); } options.add(anAct); } } } } if (options != null) { result.add(options); } } for (JButton jb : buttons) { final AnAction anAct = _createActionFromButton(jb.getAction(), jb, false); if (anAct != null) { if (jb == defaultButton) { TouchbarActionCustomizations.setDefault(anAct, true); } result.add(anAct); } } if (isPrincipal) { TouchbarActionCustomizations.setPrincipal(result, true); } return result; }