src: Moved path prefilling to ApplicationSettingsPrefiller

* added subdirectory for all source group settings related files
This commit is contained in:
Eberhard Graether
2019-07-16 14:29:34 +02:00
parent 086c19f25e
commit 70febae55b
61 changed files with 239 additions and 195 deletions
+18 -138
View File
@@ -3,37 +3,37 @@
#include <csignal>
#include "Application.h"
#include "LanguagePackageCxx.h"
#include "LanguagePackageJava.h"
#include "LanguagePackageManager.h"
#include "SourceGroupFactory.h"
#include "SourceGroupFactoryModuleCxx.h"
#include "SourceGroupFactoryModuleJava.h"
#include "SourceGroupFactoryModulePython.h"
#include "SourceGroupFactoryModuleCustom.h"
#include "QtNetworkFactory.h"
#include "QtApplication.h"
#include "QtCoreApplication.h"
#include "utilityQt.h"
#include "QtViewFactory.h"
#include "ApplicationSettings.h"
#include "ApplicationSettingsPrefiller.h"
#include "CommandLineParser.h"
#include "ConsoleLogger.h"
#include "FileLogger.h"
#include "LanguagePackageCxx.h"
#include "LanguagePackageJava.h"
#include "LanguagePackageManager.h"
#include "logging.h"
#include "LogManager.h"
#include "MessageIndexingInterrupted.h"
#include "MessageLoadProject.h"
#include "MessageStatus.h"
#include "productVersion.h"
#include "QtNetworkFactory.h"
#include "QtApplication.h"
#include "QtCoreApplication.h"
#include "QtViewFactory.h"
#include "ResourcePaths.h"
#include "ScopedFunctor.h"
#include "SourceGroupFactory.h"
#include "SourceGroupFactoryModuleCxx.h"
#include "SourceGroupFactoryModuleJava.h"
#include "SourceGroupFactoryModulePython.h"
#include "SourceGroupFactoryModuleCustom.h"
#include "TextAccess.h"
#include "UserPaths.h"
#include "utility.h"
#include "utilityApp.h"
#include "utilityPathDetection.h"
#include "utilityQt.h"
#include "Version.h"
#include "productVersion.h"
void signalHandler(int signum)
{
@@ -57,127 +57,6 @@ void setupLogging()
logManager->addLogger(fileLogger);
}
void prefillJavaRuntimePath()
{
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
if (!settings->getHasPrefilledJavaPath())
{
LOG_INFO("Prefilling Java path");
std::shared_ptr<CombinedPathDetector> javaPathDetector = utility::getJavaRuntimePathDetector();
std::vector<FilePath> paths = javaPathDetector->getPaths();
if (!paths.empty())
{
MessageStatus(L"Ran Java runtime path detection, found: " + paths.front().wstr()).dispatch();
settings->setJavaPath(paths.front());
settings->save();
}
else
{
MessageStatus(L"Ran Java runtime path detection, no path found.").dispatch();
}
}
settings->setHasPrefilledJavaPath(true);
}
void prefillJreSystemLibraryPaths()
{
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
if (!settings->getHasPrefilledJreSystemLibraryPaths())
{
LOG_INFO("Prefilling JRE system library path");
std::shared_ptr<CombinedPathDetector> jreSystemLibraryPathsDetector = utility::getJreSystemLibraryPathsDetector();
std::vector<FilePath> paths = jreSystemLibraryPathsDetector->getPaths();
if (!paths.empty())
{
MessageStatus(L"Ran JRE system library path detection, found: " + paths.front().wstr()).dispatch();
settings->setJreSystemLibraryPaths(paths);
settings->save();
}
else
{
MessageStatus(L"Ran JRE system library path detection, no path found.").dispatch();
}
}
settings->setHasPrefilledJreSystemLibraryPaths(true);
}
void prefillMavenExecutablePath()
{
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
if (!settings->getHasPrefilledMavenPath())
{
LOG_INFO("Prefilling Maven path");
std::shared_ptr<CombinedPathDetector> mavenPathDetector = utility::getMavenExecutablePathDetector();
std::vector<FilePath> paths = mavenPathDetector->getPaths();
if (!paths.empty())
{
MessageStatus(L"Ran Maven executable path detection, found: " + paths.front().wstr()).dispatch();
settings->setMavenPath(paths.front());
settings->save();
}
else
{
MessageStatus(L"Ran Maven executable path detection, no path found.").dispatch();
}
}
settings->setHasPrefilledMavenPath(true);
}
void prefillCxxHeaderPaths()
{
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
if (!settings->getHasPrefilledHeaderSearchPaths())
{
LOG_INFO("Prefilling header search paths");
std::shared_ptr<CombinedPathDetector> cxxHeaderDetector = utility::getCxxHeaderPathDetector();
std::vector<FilePath> paths = cxxHeaderDetector->getPaths();
if (!paths.empty())
{
MessageStatus(L"Ran C/C++ header path detection, found " + std::to_wstring(paths.size()) + L" path" +
(paths.size() == 1 ? L"" : L"s")).dispatch();
settings->setHeaderSearchPaths(paths);
settings->save();
}
}
settings->setHasPrefilledHeaderSearchPaths(true);
}
void prefillCxxFrameworkPaths()
{
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
if (!settings->getHasPrefilledFrameworkSearchPaths())
{
LOG_INFO("Prefilling framework search paths");
std::shared_ptr<CombinedPathDetector> cxxFrameworkDetector = utility::getCxxFrameworkPathDetector();
std::vector<FilePath> paths = cxxFrameworkDetector->getPaths();
if (!paths.empty())
{
MessageStatus(L"Ran C/C++ framework path detection, found " + std::to_wstring(paths.size()) + L" path" +
(paths.size() == 1 ? L"" : L"s")).dispatch();
settings->setFrameworkSearchPaths(paths);
settings->save();
}
}
settings->setHasPrefilledFrameworkSearchPaths(true);
}
void prefillPaths()
{
prefillJavaRuntimePath();
prefillMavenExecutablePath();
prefillJreSystemLibraryPaths();
prefillCxxHeaderPaths();
prefillCxxFrameworkPaths();
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
settings->save();
}
void addLanguagePackages()
{
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleCxx>());
@@ -282,7 +161,7 @@ int main(int argc, char *argv[])
appSettings->save();
}
prefillPaths();
ApplicationSettingsPrefiller::prefillPaths(appSettings);
addLanguagePackages();
signal(SIGINT, signalHandler);
@@ -341,7 +220,8 @@ int main(int argc, char *argv[])
Application::destroyInstance();
});
prefillPaths();
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
ApplicationSettingsPrefiller::prefillPaths(appSettings);
addLanguagePackages();
utility::loadFontsFromDirectory(ResourcePaths::getFontsPath(), L".otf");