void (@NotNull Content content) { invokeLaterIfNeeded(() -> { ContentManager contentManager = getOrCreateToolWindow().getContentManager(); String name = content.getTabName(); String category = Strings.trimEnd(StringUtil.split(name, " ").get(0), ':'); int index = -1; for (int i = 0; i < presetOrder.size(); i++) { String s = presetOrder.get(i).get(); if (s.equals(category)) { index = i; break; } } Content[] existingContents = contentManager.getContents(); if (index != -1) { MultiMap<String, String> existingCategoriesNames = new MultiMap<>(); for (Content existingContent : existingContents) { String tabName = existingContent.getTabName(); existingCategoriesNames.putValue(Strings.trimEnd(StringUtil.split(tabName, " ").get(0), ':'), tabName); } int place = 0; for (int i = 0; i <= index; i++) { String key = presetOrder.get(i).get(); place += existingCategoriesNames.get(key).size(); } contentManager.addContent(content, place); } else { contentManager.addContent(content); } for (Content existingContent : existingContents) { existingContent.setDisplayName(existingContent.getTabName()); } updateTabDisplayName(content, content.getTabName()); }); }