boolean (final @NotNull Content content, final boolean dispose) { boolean wasSelected = mySelected == content; int oldIndex = myContents.indexOf(content); if (wasSelected) { removeFromSelection(content); } boolean result = myContents.remove(content); if (dispose) Disposer.dispose(content); ContentManagerEvent e = new ContentManagerEvent(this, content, oldIndex, ContentManagerEvent.ContentOperation.remove); myDispatcher.getMulticaster().contentRemoved(e); Content item = ContainerUtil.getFirstItem(myContents); if (item != null) { setSelectedContent(item); } else { mySelected = null; } return result; }