record (ServiceView mainView, ContentManager contentManager, Collection<ServiceViewContributor<?>> rootContributors, String toolWindowId) { @Unmodifiable @NotNull List<ServiceView> getServiceViews() { List<ServiceView> views = ContainerUtil.mapNotNull(contentManager.getContents(), ServiceViewManagerImpl::getServiceView); if (views.isEmpty()) return new SmartList<>(mainView); if (!views.contains(mainView)) { views = ContainerUtil.prepend(views, mainView); } return views; } private void processAllModels(Consumer<? super ServiceViewModel> consumer) { List<ServiceViewModel> models = ContainerUtil.map(getServiceViews(), ServiceView::getModel); ServiceViewModel model = ContainerUtil.getFirstItem(models); if (model != null) { model.getInvoker().invokeLater(() -> { for (ServiceViewModel viewModel : models) { consumer.accept(viewModel); } }); } } }