void (@NotNull JPanel panel) { var addButton = ToolbarDecorator.findAddButton(panel); var removeButton = ToolbarDecorator.findRemoveButton(panel); var editButton = ToolbarDecorator.findEditButton(panel); var upButton = ToolbarDecorator.findUpButton(panel); var downButton = ToolbarDecorator.findDownButton(panel); Stream.of(addButton, removeButton, editButton, upButton, downButton) .filter(it -> it != null) .forEach(it -> it.addCustomUpdater(e -> myIsEnabled)); if (removeButton != null) { removeButton.addCustomUpdater(e -> { List<T> selection = getSelection(); if (selection.isEmpty()) return false; for (T t : selection) { if (!canDeleteElement(t)) return false; } return true; }); } }