Content (@NotNull String contentName, String tabName, String toolwindowTitle, boolean reusable, final @NotNull JComponent component, boolean toOpenInNewTab, boolean isLockable) { Key<Boolean> contentKey = reusable ? REUSABLE_CONTENT_KEY : NOT_REUSABLE_CONTENT_KEY; Content selectedContent = getSelectedContent(); toOpenInNewTab |= selectedContent != null && selectedContent.isPinned(); Content contentToDelete = null; int indexToAdd = -1; if (!toOpenInNewTab && reusable) { List<Content> contents = Arrays.asList(myFindContentManager.getContents()); if (selectedContent != null) { contents = ContainerUtil.append(contents, selectedContent); // Selected content has to be the last (and the best) candidate to be deleted } for (Content content : contents) { if (!content.isPinned() && content.getUserData(contentKey) != null) { UsageView usageView = content.getUserData(NEW_USAGE_VIEW_KEY); if (usageView == null || !usageView.isSearchInProgress()) { contentToDelete = content; indexToAdd = myFindContentManager.getIndexOfContent(contentToDelete); } } } } Content content = ContentFactory.getInstance().createContent(component, contentName, isLockable); content.setTabName(tabName); content.setToolwindowTitle(toolwindowTitle); content.putUserData(contentKey, Boolean.TRUE); content.putUserData(ToolWindow.SHOW_CONTENT_ICON, Boolean.TRUE); myFindContentManager.addContent(content, indexToAdd); if (contentToDelete != null) { myFindContentManager.removeContent(contentToDelete, true); } myFindContentManager.setSelectedContent(content); return content; }