/**
   * Copies all the mod files from the profileModDir to the factorioModDir.
   *
   * @param profileModDir The profileDir to copy mods from.
   * @param factorioModDir The factorioDir to copy mods to.
   * @param selectedNode The TreeNode that is currently selected.
   */
  private void copyAllEnabledMods(
      File profileModDir, File factorioModDir, DefaultMutableTreeNode selectedNode) {
    // Let's copy all enabled mods!

    // Get the selected node.
    Enumeration<DefaultMutableTreeNode> children = selectedNode.children(); // Get it's children.
    while (children.hasMoreElements()) {
      DefaultMutableTreeNode node = children.nextElement(); // Get the next element.
      ModManagerWindow.CheckBoxNode checkBox =
          (ModManagerWindow.CheckBoxNode) node.getUserObject(); // Get the checkbox.
      String name = checkBox.getText(); // Get the text from the checkbox.
      if (name.equals("base") || !checkBox.isSelected())
        continue; // If it is the "base" mod, ignore it (it's always on)

      // Get the file with the name of the mod and then copy it from the profile dir to the mods
      // dir.
      File file =
          FileUtils.findFileWithPartName(
              profileModDir, ((ModManagerWindow.CheckBoxNode) node.getUserObject()).getText());
      try {
        Files.copy(
            file.toPath(),
            Paths.get(
                factorioModDir.getPath()
                    + "/"
                    + file.getPath().substring(file.getPath().lastIndexOf('\\'))));
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
  /**
   * Sets the mod information for the selected mod. Also will attempt to display any recent versions
   * of the mod from the factorio mod website.
   *
   * @param node The selected node that contains the mod name and such.
   * @param modInfoList The JList to modify with mod information.
   */
  public void setModInformation(DefaultMutableTreeNode node, JList modInfoList) {
    // Get the checkbox (for its value) and the profile name. Get the actual mod with this.
    ModManagerWindow.CheckBoxNode checkBox = (ModManagerWindow.CheckBoxNode) node.getUserObject();
    String profileName = node.getParent().toString();
    Profile.Mod mod = Profile.getModByNameForProfile(profileName, checkBox.getText());
    this.model.setCurrentlySelectedModName(checkBox.getText());
    this.model.setCurrentlySelectedProfile(profileName);

    // Set up the initial mod information.
    Object[] modInfo = {
      "Mod Name: " + mod.name, "Author: " + mod.info.author, "Version: " + mod.info.version,
    };

    // Set the list model.
    DefaultListModel listModel = new DefaultListModel();
    for (Object obj : modInfo) listModel.addElement(obj);

    modInfoList.setModel(listModel);

    this.getRecentVersionsOfModAsync(mod, modInfoList);
  }