void (@NotNull IdeFrameImpl movedFrame, int newIndex) { for (int i = 0, count = getTabCount(); i < count; i++) { IdeFrameImpl tabFrame = (IdeFrameImpl)getTabAt(i).getObject(); if (tabFrame != myNativeWindow) { WindowTabsComponent tabsComponent = Objects.requireNonNull(MacWinTabsHandlerV2.getTabsComponent(MacWinTabsHandlerV2.getTabsContainer(tabFrame))); tabsComponent.reorderTabs(myIndexes); } } Runnable action = () -> Foundation.executeOnMainThread(true, false, () -> { ID window = MacUtil.getWindowFromJavaWindow(movedFrame); ID tabGroup = Foundation.invoke(window, "tabGroup"); Foundation.invoke(tabGroup, "removeWindow:", window); Foundation.invoke(tabGroup, "insertWindow:atIndex:", window, newIndex); Foundation.invoke(tabGroup, "setSelectedWindow:", window); }); if (movedFrame == myNativeWindow) { action.run(); } else { ApplicationManager.getApplication().invokeLater(action); } }