private void doScheduleStructureRequest(final Runnable r) {
    ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(TOOL_WINDOW_ID);
    if (toolWindow == null) return;

    MavenUtil.invokeLater(myProject, () -> {
      List<String> files = MavenProjectsManager.getInstance(myProject).getState().originalFiles;
      boolean hasMavenProjects = files != null && !files.isEmpty();
      if (toolWindow.isAvailable() != hasMavenProjects) {
        MavenLog.LOG.info("Set MavenToolWindow availability: " + hasMavenProjects);
        toolWindow.setAvailable(hasMavenProjects);
        if (hasMavenProjects
            && myProject.getUserData(ExternalSystemDataKeys.NEWLY_CREATED_PROJECT) == null) {
          toolWindow.activate(null);
        }
      }

      boolean shouldCreate = myStructure == null;
      if (shouldCreate) {
        initStructure();
      }

      r.run();

      if (shouldCreate) {
        TreeState.createFrom(myState.treeState).applyTo(myTree);
      }
    });
  }
private void doScheduleStructureRequest(final Runnable r)