void InterfaceComponent::buttonClicked (juce::Button* button)
{
    if (button == &btnBrowse)
    {
        juce::FileChooser chooser ("Select the folder which contains the code files you want to modularise");
        
        if (chooser.browseForDirectory())
        {
            const juce::File folder (chooser.getResult());

            txtSourceFileFolder.setText (folder.getFullPathName().trim(), juce::sendNotification);
            txtDestinationFolder.setText (folder.getParentDirectory().getFullPathName().trim(), juce::sendNotification);

            files = Modulariser (folder, true).getFiles();

            fileListBox.setSelectedRows (juce::SparseSet<int>());
            fileListBox.updateContent();
        }
    }
    else if (button == &btnRefresh)
    {
        refresh();
    }
    else if (button == &btnGenerate)
    {
        const juce::String srcFolder (txtSourceFileFolder.getText().trim());
        const juce::String destFolder (txtDestinationFolder.getText().trim());

        if (srcFolder.isNotEmpty()
            && destFolder.isNotEmpty()
            && juce::File::isAbsolutePath (srcFolder)
            && juce::File::isAbsolutePath (destFolder))
        {
            Modulariser modulariser (files);

            modulariser.saveTo (juce::File (destFolder),
                                srcFolder,
                                txtModuleFilename.getText().trim(),
                                txtHeaderGuard.getText().trim(),
                                txtNamespace.getText().trim());
        }
    }
}
IRBrowserComponent::TrueStereoPairs IRBrowserComponent::findTrueStereoPairs(const juce::File& file, size_t sampleCount, double sampleRate) const
{
  if (file == juce::File::nonexistent || file.isDirectory())
  {
    return TrueStereoPairs();
  }

  const juce::File directory = file.getParentDirectory();
  if (file == juce::File::nonexistent || file.isDirectory())
  {
    return TrueStereoPairs();
  }

  const juce::String fileNameBody = file.getFileNameWithoutExtension();
  const juce::String fileNameExt = file.getFileExtension();

  // Left => Right
  static std::vector<std::pair<juce::String, juce::String> > pairsLeft;
  if (pairsLeft.empty())
  {
    pairsLeft.push_back(std::make_pair(juce::String("L"),    juce::String("R")));
    pairsLeft.push_back(std::make_pair(juce::String("l"),    juce::String("r")));
    pairsLeft.push_back(std::make_pair(juce::String("Left"), juce::String("Right")));
    pairsLeft.push_back(std::make_pair(juce::String("left"), juce::String("right")));
    pairsLeft.push_back(std::make_pair(juce::String("LEFT"), juce::String("RIGHT")));
  }
  for (size_t i=0; i<pairsLeft.size(); ++i)
  {
    const juce::File matchingFile = checkMatchingTrueStereoFile(fileNameBody,
                                                                fileNameExt,
                                                                directory,
                                                                pairsLeft[i].first,
                                                                pairsLeft[i].second,
                                                                sampleCount,
                                                                sampleRate);
    if (matchingFile != juce::File::nonexistent)
    {
      TrueStereoPairs trueStereoPairs;
      trueStereoPairs.push_back(std::make_pair(file, 0));
      trueStereoPairs.push_back(std::make_pair(file, 1));
      trueStereoPairs.push_back(std::make_pair(matchingFile, 0));
      trueStereoPairs.push_back(std::make_pair(matchingFile, 1));
      return trueStereoPairs;
    }
  }

  static std::vector<std::pair<juce::String, juce::String> > pairsRight;
  if (pairsRight.empty())
  {
    pairsRight.push_back(std::make_pair(juce::String("R"),     juce::String("L")));
    pairsRight.push_back(std::make_pair(juce::String("r"),     juce::String("l")));
    pairsRight.push_back(std::make_pair(juce::String("Right"), juce::String("Left")));
    pairsRight.push_back(std::make_pair(juce::String("right"), juce::String("left")));
    pairsRight.push_back(std::make_pair(juce::String("RIGHT"), juce::String("LEFT")));
  }
  for (size_t i=0; i<pairsRight.size(); ++i)
  {
    const juce::File matchingFile = checkMatchingTrueStereoFile(fileNameBody,
                                                                fileNameExt,
                                                                directory,
                                                                pairsRight[i].first,
                                                                pairsRight[i].second,
                                                                sampleCount,
                                                                sampleRate);
    if (matchingFile != juce::File::nonexistent)
    {
      TrueStereoPairs trueStereoPairs;
      trueStereoPairs.push_back(std::make_pair(matchingFile, 0));
      trueStereoPairs.push_back(std::make_pair(matchingFile, 1));
      trueStereoPairs.push_back(std::make_pair(file, 0));
      trueStereoPairs.push_back(std::make_pair(file, 1));
      return trueStereoPairs;
    }
  }

  return TrueStereoPairs();
}