/**
   * Parse the given file to find all the available libraries in order to fill the pool.
   *
   * @param file The folder to parse
   */
  public final void parseLibraries(final File file) {
    if (file.exists()) {
      final String path = file.getAbsolutePath();

      // Extract some folder.
      if (path.contains("lib") && !file.isDirectory()) {
        final String fileName =
            path.substring(path.lastIndexOf(LIB_FOOTPRINT) + LIB_FOOTPRINT.length());

        // Check if loaded.
        if (this.pool.get(fileName) != null) {
          ConsoleUtils.displayWarning(
              "The library "
                  + fileName
                  + " has been found multiple times."
                  + "Keeping "
                  + this.pool.get(fileName).getAbsolutePath());
        } else {
          ConsoleUtils.displayDebug("Adding to library pool : " + path);

          this.pool.put(fileName, file);
        }
      }

      // Recursive if folder.
      if (file.isDirectory()) {
        final File[] files = file.listFiles(this.filter);
        for (File f : files) {

          // Exclude git and doc folder.
          if (!f.getAbsolutePath().contains(".git") && !f.getAbsolutePath().contains("doc")) {
            this.parseLibraries(f);
          }
        }
      }
    }
  }
  /**
   * Update Class : HomeActivity. HomeActivity : add new Map button to Entity activity
   *
   * @param activity Activity without Entity name (GMapsActivity, OSMActivity)
   * @param entity Entity to add
   */
  protected final void addLaunchActivityButton() {

    // Update HomeActivity
    File file = new File(this.adapter.getHomeActivityPathFile());

    if (file != null && file.isFile()) {
      try {
        String activityName = activity.substring(activity.lastIndexOf('.') + 1);

        String listenerTpl =
            String.format("\t\tthis.findViewById(R.id.%s).setOnClickListener(this);", buttonId);

        String caseTpl =
            String.format(
                "\t\t\tcase R.id.%s:\n\t\t\t\tintent = new Intent(this, %s.class);\n\t\t\t\tbreak;\n",
                buttonId, activityName);

        // Import Activity
        this.updateFileAdd(file, "import", "import", "import " + activity + ";", true);

        this.addButtonToMainXML(activityName, buttonId);

        // If Listener not set
        this.updateFileAdd(
            file,
            "private void initButtons() {",
            "private void initButtons() {",
            listenerTpl,
            false);

        // If case not set
        this.updateFileAdd(
            file, "public void onClick(View v) {", "switch (v.getId()) {", caseTpl, false);
      } catch (IOException e) {
        ConsoleUtils.displayError(e);
      }
    }
  }