void (final MavenArchetype selected) { ThreadingAssertions.assertEventDispatchThread(); myLoadingIcon.setBackground(RenderingUtil.getBackground(myArchetypesTree)); ((CardLayout)myArchetypesPanel.getLayout()).show(myArchetypesPanel, "loading"); final Object currentUpdaterMarker = new Object(); myCurrentUpdaterMarker = currentUpdaterMarker; ApplicationManager.getApplication().executeOnPooledThread(() -> { final Set<MavenArchetype> archetypes = MavenArchetypeManager.getInstance(findProject()).getArchetypes(); SwingUtilities.invokeLater(() -> { if (currentUpdaterMarker != myCurrentUpdaterMarker) return; // Another updater has been run. ((CardLayout)myArchetypesPanel.getLayout()).show(myArchetypesPanel, "archetypes"); TreeNode root = groupAndSortArchetypes(archetypes); TreeModel model = new DefaultTreeModel(root); myArchetypesTree.setModel(model); if (selected != null) { TreePath path = findNodePath(selected, model, model.getRoot()); if (path != null) { myArchetypesTree.expandPath(path.getParentPath()); TreeUtil.selectPath(myArchetypesTree, path, true); } } updateArchetypeDescription(); }); }); }