logic: maven project setup

* added option to create a Coati project from a Maven POM file
* show list of indexed file paths in maven project setup
* use FileManager to detect indexed files in project setup (except cdb)
* added Maven path to preferences window and added path detectors.
* fixed: QtDialogView::hideStatusDialog now also hides loader in status bar.
* refactored ProjectType

fortune cookie message = If you continually give, you will continually have.
This commit is contained in:
malte_langkabel
2017-03-08 14:55:42 +01:00
parent d6f3099981
commit 3cbe83f9e6
83 changed files with 1502 additions and 545 deletions
+7
View File
@@ -158,6 +158,8 @@ add_files(
qt/window/project_wizzard/QtProjectWizzardContentExtensions.h
qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp
qt/window/project_wizzard/QtProjectWizzardContentFlags.h
qt/window/project_wizzard/QtProjectWizzardContentPath.cpp
qt/window/project_wizzard/QtProjectWizzardContentPath.h
qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp
qt/window/project_wizzard/QtProjectWizzardContentPaths.h
qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp
@@ -223,6 +225,11 @@ add_files(
utility/path_detector/java_runtime/JavaPathDetectorWindows.cpp
utility/path_detector/java_runtime/JavaPathDetectorWindows.h
utility/path_detector/maven_executable/MavenPathDetectorUnix.cpp
utility/path_detector/maven_executable/MavenPathDetectorUnix.h
utility/path_detector/maven_executable/MavenPathDetectorWindows.cpp
utility/path_detector/maven_executable/MavenPathDetectorWindows.h
utility/path_detector/CombinedPathDetector.cpp
utility/path_detector/CombinedPathDetector.h
utility/path_detector/PathDetector.cpp
@@ -10,6 +10,7 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentData.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentExtensions.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentFlags.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPath.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentPreferences.h"
#include "qt/window/project_wizzard/QtProjectWizzardContentSimple.h"
@@ -48,8 +49,6 @@ QtProjectWizzard::QtProjectWizzard(QWidget* parent)
m_parserManager = std::make_shared<SolutionParserManager>();
// wip
// m_parserManager->pushSolutionParser(std::make_shared<SolutionParserCodeBlocks>());
}
void QtProjectWizzard::showWindow()
@@ -77,19 +76,19 @@ void QtProjectWizzard::newProject()
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentSelect>();
connect(dynamic_cast<QtProjectWizzardContentSelect*>(window->content()),
SIGNAL(selected(LanguageType, QtProjectWizzardContentSelect::ProjectType)),
this, SLOT(selectedProjectType(LanguageType, QtProjectWizzardContentSelect::ProjectType)));
SIGNAL(selected(ProjectType)),
this, SLOT(selectedProjectType(ProjectType)));
window->setNextEnabled(false);
window->setPreviousEnabled(false);
window->updateSubTitle("Type Selection");
}
void QtProjectWizzard::newProjectFromSolution(const std::string& ideId, const std::string& visualStudioSolutionPath)
void QtProjectWizzard::newProjectFromSolution(const std::string& ideId, const std::string& solutionPath)
{
if (m_parserManager->canParseSolution(ideId))
{
std::shared_ptr<ProjectSettings> settings = m_parserManager->getProjectSettings(ideId, visualStudioSolutionPath);
std::shared_ptr<ProjectSettings> settings = m_parserManager->getProjectSettings(ideId, solutionPath);
// this looks rather hacky.. calling the edit project and then setting the title.
editProject(settings);
@@ -136,7 +135,7 @@ void QtProjectWizzard::newProjectFromCDB(const std::string& filePath, const std:
emptyProjectCDBVS();
}
void QtProjectWizzard::refreshProjectFromSolution(const std::string& ideId, const std::string& visualStudioSolutionPath)
void QtProjectWizzard::refreshProjectFromSolution(const std::string& ideId, const std::string& solutionPath)
{
if (m_parserManager->canParseSolution(ideId))
{
@@ -146,7 +145,7 @@ void QtProjectWizzard::refreshProjectFromSolution(const std::string& ideId, cons
window->content()->save();
}
std::shared_ptr<ProjectSettings> settings = m_parserManager->getProjectSettings(ideId, visualStudioSolutionPath);
std::shared_ptr<ProjectSettings> settings = m_parserManager->getProjectSettings(ideId, solutionPath);
std::shared_ptr<CxxProjectSettings> otherCxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(settings);
std::shared_ptr<CxxProjectSettings> ownCxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
@@ -154,7 +153,7 @@ void QtProjectWizzard::refreshProjectFromSolution(const std::string& ideId, cons
{
ownCxxSettings->setSourcePaths(otherCxxSettings->getSourcePaths());
ownCxxSettings->setHeaderSearchPaths(otherCxxSettings->getHeaderSearchPaths());
ownCxxSettings->setVisualStudioSolutionPath(FilePath(visualStudioSolutionPath));
ownCxxSettings->setVisualStudioSolutionPath(FilePath(solutionPath));
}
if (window)
{
@@ -342,67 +341,44 @@ void QtProjectWizzard::windowStackChanged()
}
}
void QtProjectWizzard::selectedProjectType(LanguageType languageType, QtProjectWizzardContentSelect::ProjectType type)
void QtProjectWizzard::selectedProjectType(ProjectType projectType)
{
switch (type)
LanguageType languageType = getLanguageTypeForProjectType(projectType);
switch (projectType)
{
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
if (languageType == LANGUAGE_JAVA)
case PROJECT_C_EMPTY:
case PROJECT_CPP_EMPTY:
m_settings = std::make_shared<CxxProjectSettings>();
if (applicationSettingsContainVisualStudioHeaderSearchPaths())
{
m_settings = std::make_shared<JavaProjectSettings>();
}
else
{
m_settings = std::make_shared<CxxProjectSettings>();
if (applicationSettingsContainVisualStudioHeaderSearchPaths())
{
std::vector<std::string> flags;
flags.push_back("-fms-extensions");
flags.push_back("-fms-compatibility");
flags.push_back("-fms-compatibility-version=19");
std::dynamic_pointer_cast<CxxProjectSettings>(m_settings)->setCompilerFlags(flags);
}
std::vector<std::string> flags;
flags.push_back("-fms-extensions");
flags.push_back("-fms-compatibility");
flags.push_back("-fms-compatibility-version=19");
std::dynamic_pointer_cast<CxxProjectSettings>(m_settings)->setCompilerFlags(flags);
}
m_settings->setLanguage(languageType);
emptyProject();
break;
case QtProjectWizzardContentSelect::PROJECT_MANAGED:
/*{
std::string fileEndings = "(";
for (unsigned int i = 0; i < m_parserManager->getParserCount(); i++)
{
fileEndings += " *" + m_parserManager->getParserFileEnding(i);
}
fileEndings += ")";
QString fileName = QFileDialog::getOpenFileName(
this, tr("Open Solution"), "", fileEndings.c_str()
);
if (!fileName.isNull())
{
for (unsigned int i = 0; i < m_parserManager->getParserCount(); i++)
{
if (fileName.contains(m_parserManager->getParserFileEnding(i).c_str()))
{
newProjectFromSolution(m_parserManager->getParserIdeId(i), fileName.toStdString());
}
}
}
break;
}*/
case PROJECT_CXX_CDB:
m_settings = std::make_shared<CxxProjectSettings>();
m_settings->setLanguage(languageType);
emptyProjectCDB();
break;
case PROJECT_CXX_VS:
m_settings = std::make_shared<CxxProjectSettings>();
m_settings->setLanguage(languageType);
emptyProjectCDBVS();
break;
case QtProjectWizzardContentSelect::PROJECT_CDB:
m_settings = std::make_shared<CxxProjectSettings>();
case PROJECT_JAVA_EMPTY:
m_settings = std::make_shared<JavaProjectSettings>();
m_settings->setLanguage(languageType);
emptyProjectCDB();
emptyProject();
break;
case PROJECT_JAVA_MAVEN:
m_settings = std::make_shared<JavaProjectSettings>();
m_settings->setLanguage(languageType);
emptyProjectJavaMaven();
break;
}
}
@@ -501,6 +477,14 @@ void QtProjectWizzard::emptyProjectCDB()
window->updateSubTitle("Project Data");
}
void QtProjectWizzard::emptyProjectJavaMaven()
{
QtProjectWizzardWindow* window = createWindowWithContent<QtProjectWizzardContentData>();
connect(window, SIGNAL(next()), this, SLOT(sourcePathsJavaMaven()));
window->updateSubTitle("Project Data");
}
void QtProjectWizzard::headerPathsCDB()
{
QtProjectWizzardWindow* window = createWindowWithSummary(
@@ -535,6 +519,27 @@ void QtProjectWizzard::sourcePathsJava()
window->updateSubTitle("Indexed Paths");
}
void QtProjectWizzard::sourcePathsJavaMaven()
{
std::dynamic_pointer_cast<JavaProjectSettings>(m_settings)->setMavenDependenciesDirectory(
"./coati_dependencies/" + utility::replace(m_settings->getProjectName(), " ", "_") + "/maven"
);
QtProjectWizzardWindow* window = createWindowWithSummary(
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
{
summary->addContent(new QtProjectWizzardContentPathSourceMaven(m_settings, window));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathDependenciesMaven(m_settings, window));
window->setup();
}
);
connect(window, SIGNAL(next()), this, SLOT(advancedSettingsJava()));
window->updateSubTitle("Indexed Paths");
}
void QtProjectWizzard::advancedSettingsCxx()
{
QtProjectWizzardWindow* window = createWindowWithSummary(
@@ -577,23 +582,13 @@ void QtProjectWizzard::showSummary()
summary->setIsForm(true);
QtProjectWizzardContentBuildFile* buildFile = new QtProjectWizzardContentBuildFile(m_settings, window);
bool isCDB = buildFile->getType() == QtProjectWizzardContentSelect::PROJECT_CDB;
const bool isCDB = buildFile->getType() == PROJECT_CXX_CDB || buildFile->getType() == PROJECT_CXX_VS;
if (!isCDB)
{
summary->addContent(new QtProjectWizzardContentData(m_settings, window, m_editing));
summary->addSpace();
if (buildFile->getType() == QtProjectWizzardContentSelect::PROJECT_MANAGED)
{
summary->addContent(buildFile);
summary->addSpace();
connect(dynamic_cast<QtProjectWizzardContentBuildFile*>(buildFile),
SIGNAL(refreshVisualStudioSolution(const std::string&, const std::string&)),
this, SLOT(refreshProjectFromSolution(const std::string&, const std::string&)));
}
summary->addContent(new QtProjectWizzardContentPathsSource(m_settings, window));
summary->addContent(new QtProjectWizzardContentExtensions(m_settings, window));
summary->addSpace();
@@ -656,15 +651,31 @@ void QtProjectWizzard::showSummaryJava()
{
summary->setIsForm(true);
bool isMaven = false;
std::shared_ptr<JavaProjectSettings> javaSettings = std::dynamic_pointer_cast<JavaProjectSettings>(m_settings);
if (javaSettings)
{
isMaven = javaSettings->getAbsoluteMavenProjectFilePath().exists();
}
summary->addContent(new QtProjectWizzardContentData(m_settings, window, m_editing));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathsSource(m_settings, window));
summary->addSpace();
if (isMaven)
{
summary->addContent(new QtProjectWizzardContentPathSourceMaven(m_settings, window));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathDependenciesMaven(m_settings, window));
}
else
{
summary->addContent(new QtProjectWizzardContentPathsSource(m_settings, window));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathsClassJava(m_settings, window));
}
summary->addContent(new QtProjectWizzardContentPathsClassJava(m_settings, window));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentExtensions(m_settings, window));
summary->addSpace();
summary->addContent(new QtProjectWizzardContentPathsExclude(m_settings, window));
@@ -33,9 +33,9 @@ public:
public slots:
void newProject();
void newProjectFromSolution(const std::string& ideId, const std::string& visualStudioSolutionPath);
void newProjectFromSolution(const std::string& ideId, const std::string& solutionPath);
void newProjectFromCDB(const std::string& filePath, const std::vector<std::string>& headerPaths);
void refreshProjectFromSolution(const std::string& ideId, const std::string& visualStudioSolutionPath);
void refreshProjectFromSolution(const std::string& ideId, const std::string& solutionPath);
void editProject(const FilePath& settingsPath);
void editProject(std::shared_ptr<ProjectSettings> settings);
@@ -65,7 +65,7 @@ private slots:
void windowStackChanged();
void selectedProjectType(LanguageType languageType, QtProjectWizzardContentSelect::ProjectType type);
void selectedProjectType(ProjectType type);
void emptyProject();
@@ -77,9 +77,12 @@ private slots:
void emptyProjectCDBVS();
void emptyProjectCDB();
void emptyProjectJavaMaven();
void headerPathsCDB();
void sourcePathsJava();
void sourcePathsJavaMaven();
void advancedSettingsCxx();
void advancedSettingsJava();
@@ -134,7 +134,10 @@ QPushButton* QtProjectWizzardContent::addFilesButton(QString name, QGridLayout*
{
QPushButton* button = new QPushButton(name);
button->setObjectName("windowButton");
layout->addWidget(button, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignRight | Qt::AlignTop);
if (layout)
{
layout->addWidget(button, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignRight | Qt::AlignTop);
}
connect(button, SIGNAL(clicked()), this, SLOT(filesButtonClicked()));
return button;
@@ -142,7 +145,7 @@ QPushButton* QtProjectWizzardContent::addFilesButton(QString name, QGridLayout*
void QtProjectWizzardContent::filesButtonClicked()
{
save();
m_window->saveContent();
if (!m_filesDialog)
{
@@ -13,23 +13,12 @@ QtProjectWizzardContentBuildFile::QtProjectWizzardContentBuildFile(
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContent(settings, window)
, m_type(QtProjectWizzardContentSelect::PROJECT_EMPTY)
, m_type(PROJECT_UNKNOWN)
{
std::shared_ptr<CxxProjectSettings> cxxSettings = std::dynamic_pointer_cast<CxxProjectSettings>(m_settings);
if (cxxSettings)
{
if (!cxxSettings->getVisualStudioSolutionPath().empty())
{
m_type = QtProjectWizzardContentSelect::PROJECT_MANAGED;
}
else if (!cxxSettings->getCompilationDatabasePath().empty())
{
m_type = QtProjectWizzardContentSelect::PROJECT_CDB;
}
}
m_type = m_settings->getProjectType();
}
QtProjectWizzardContentSelect::ProjectType QtProjectWizzardContentBuildFile::getType() const
ProjectType QtProjectWizzardContentBuildFile::getType() const
{
return m_type;
}
@@ -41,18 +30,16 @@ void QtProjectWizzardContentBuildFile::populate(QGridLayout* layout, int& row)
switch (m_type)
{
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
name = "Build Text";
filter = "Text (*.txt)";
return;
case QtProjectWizzardContentSelect::PROJECT_MANAGED:
name = "Visual Studio Solution";
filter = "Visual Studio Solution (*.sln)";
break;
case QtProjectWizzardContentSelect::PROJECT_CDB:
name = "Compilation Database";
filter = "JSON Compilation Database (*.json)";
break;
case PROJECT_C_EMPTY:
case PROJECT_CPP_EMPTY:
name = "Build Text";
filter = "Text (*.txt)";
return;
case PROJECT_CXX_VS:
case PROJECT_CXX_CDB:
name = "Compilation Database";
filter = "JSON Compilation Database (*.json)";
break;
}
QLabel* label = createFormLabel(name);
@@ -62,19 +49,6 @@ void QtProjectWizzardContentBuildFile::populate(QGridLayout* layout, int& row)
m_picker->setFileFilter(filter);
m_picker->setRelativeRootDirectory(m_settings->getProjectFileLocation());
QPushButton* button = new QtIconButton(
(ResourcePaths::getGuiPath() + "window/refresh.png").c_str(),
(ResourcePaths::getGuiPath() + "window/refresh_hover.png").c_str());
button->setToolTip("refresh paths");
connect(button, SIGNAL(clicked()), this, SLOT(refreshClicked()));
if (m_type == QtProjectWizzardContentSelect::PROJECT_CDB)
{
button->hide();
}
m_picker->layout()->addWidget(button);
layout->addWidget(m_picker, row, QtProjectWizzardWindow::BACK_COL);
row++;
@@ -87,14 +61,13 @@ void QtProjectWizzardContentBuildFile::load()
{
switch (m_type)
{
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
return;
case QtProjectWizzardContentSelect::PROJECT_MANAGED:
m_picker->setText(QString::fromStdString(cxxSettings->getVisualStudioSolutionPath().str()));
break;
case QtProjectWizzardContentSelect::PROJECT_CDB:
m_picker->setText(QString::fromStdString(cxxSettings->getCompilationDatabasePath().str()));
break;
case PROJECT_C_EMPTY:
case PROJECT_CPP_EMPTY:
return;
case PROJECT_CXX_VS:
case PROJECT_CXX_CDB:
m_picker->setText(QString::fromStdString(cxxSettings->getCompilationDatabasePath().str()));
break;
}
}
}
@@ -106,10 +79,11 @@ void QtProjectWizzardContentBuildFile::save()
{
switch (m_type)
{
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
case QtProjectWizzardContentSelect::PROJECT_MANAGED:
case PROJECT_C_EMPTY:
case PROJECT_CPP_EMPTY:
break;
case QtProjectWizzardContentSelect::PROJECT_CDB:
case PROJECT_CXX_VS:
case PROJECT_CXX_CDB:
{
FilePath path = m_picker->getText().toStdString();
FilePath absPath = m_settings->makePathAbsolute(m_settings->expandPath(path));
@@ -128,10 +102,11 @@ bool QtProjectWizzardContentBuildFile::check()
{
switch (m_type)
{
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
case QtProjectWizzardContentSelect::PROJECT_MANAGED:
break;
case QtProjectWizzardContentSelect::PROJECT_CDB:
case PROJECT_C_EMPTY:
case PROJECT_CPP_EMPTY:
break;
case PROJECT_CXX_VS:
case PROJECT_CXX_CDB:
{
FilePath path = m_picker->getText().toStdString();
FilePath absPath = m_settings->makePathAbsolute(m_settings->expandPath(path));
@@ -147,40 +122,3 @@ bool QtProjectWizzardContentBuildFile::check()
return true;
}
void QtProjectWizzardContentBuildFile::refreshClicked()
{
FilePath path = m_picker->getText().toStdString();
FilePath absPath = m_settings->makePathAbsolute(m_settings->expandPath(path));
if (!absPath.exists())
{
QMessageBox msgBox;
msgBox.setText("Please enter a valid file path.");
msgBox.exec();
return;
}
QMessageBox::StandardButton reply =
QMessageBox::question(
this,
"Refresh Paths",
"Do you really want to refresh from the given file? All changes you have made to the project paths "
"and include paths will be lost.",
QMessageBox::Yes | QMessageBox::No
);
if (reply == QMessageBox::No)
{
return;
}
switch (m_type)
{
case QtProjectWizzardContentSelect::PROJECT_EMPTY:
case QtProjectWizzardContentSelect::PROJECT_CDB:
break;
case QtProjectWizzardContentSelect::PROJECT_MANAGED:
emit refreshVisualStudioSolution("vs", path.str());
break;
}
}
@@ -18,7 +18,7 @@ signals:
public:
QtProjectWizzardContentBuildFile(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
QtProjectWizzardContentSelect::ProjectType getType() const;
ProjectType getType() const;
// QtProjectWizzardContent implementation
virtual void populate(QGridLayout* layout, int& row) override;
@@ -27,13 +27,10 @@ public:
virtual void save() override;
virtual bool check() override;
private slots:
void refreshClicked();
private:
QtLocationPicker* m_picker;
QtProjectWizzardContentSelect::ProjectType m_type;
ProjectType m_type;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_BUILD_FILE_H
@@ -0,0 +1,203 @@
#include "qt/window/project_wizzard/QtProjectWizzardContentPath.h"
#include <QCheckBox>
#include <QComboBox>
#include <QLabel>
#include <QMessageBox>
#include <QVBoxLayout>
#include "component/view/DialogView.h"
#include "qt/element/QtLocationPicker.h"
#include "settings/ApplicationSettings.h"
#include "settings/JavaProjectSettings.h"
#include "utility/file/FileManager.h"
#include "utility/messaging/type/MessageStatus.h"
#include "utility/utilityMaven.h"
#include "utility/ScopedFunctor.h"
#include "Application.h"
QtProjectWizzardContentPath::QtProjectWizzardContentPath(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window)
: QtProjectWizzardContent(settings, window)
, m_makePathRelativeToProjectFileLocation(true)
{
}
void QtProjectWizzardContentPath::populate(QGridLayout* layout, int& row)
{
QLabel* label = createFormLabel(m_titleString);
layout->addWidget(label, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignTop);
if (m_helpString.size() > 0)
{
addHelpButton(m_helpString, layout, row);
}
m_picker = new QtLocationPicker(this);
m_picker->setPickDirectory(true);
if (m_makePathRelativeToProjectFileLocation)
{
m_picker->setRelativeRootDirectory(m_settings->getProjectFileLocation());
}
layout->addWidget(m_picker, row, QtProjectWizzardWindow::BACK_COL);
row++;
}
bool QtProjectWizzardContentPath::check()
{
if (m_picker->getText().isEmpty())
{
QMessageBox msgBox;
msgBox.setText("Please define the location for the \"" + m_titleString + "\".");
msgBox.exec();
return false;
}
return true;
}
void QtProjectWizzardContentPath::setTitleString(const QString& title)
{
m_titleString = title;
}
void QtProjectWizzardContentPath::setHelpString(const QString& help)
{
m_helpString = help;
}
QtProjectWizzardContentPathSourceMaven::QtProjectWizzardContentPathSourceMaven(
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPath(settings, window)
{
setTitleString("Maven Project Root");
setHelpString(
"Enter the root folder of your Maven project (where the main .pom file resides).<br />"
"<br />"
"You can make use of environment variables with ${ENV_VAR}."
);
}
void QtProjectWizzardContentPathSourceMaven::populate(QGridLayout* layout, int& row)
{
QtProjectWizzardContentPath::populate(layout, row);
m_picker->setPickDirectory(false);
m_picker->setFileFilter("POM File (pom.xml)");
QPushButton* filesButton = addFilesButton("show source files", nullptr, row);
m_shouldIndexTests = new QCheckBox("Should Index Tests");
QHBoxLayout* hlayout = new QHBoxLayout();
hlayout->setContentsMargins(0, 0, 0, 0);
hlayout->addWidget(m_shouldIndexTests);
hlayout->addStretch();
hlayout->addWidget(filesButton);
layout->addLayout(hlayout, row, QtProjectWizzardWindow::BACK_COL);
row++;
}
void QtProjectWizzardContentPathSourceMaven::load()
{
std::shared_ptr<JavaProjectSettings> javaSettings = std::dynamic_pointer_cast<JavaProjectSettings>(m_settings);
if (javaSettings)
{
m_picker->setText(QString::fromStdString(javaSettings->getMavenProjectFilePath().str()));
m_shouldIndexTests->setChecked(javaSettings->getShouldIndexMavenTests());
}
}
void QtProjectWizzardContentPathSourceMaven::save()
{
std::shared_ptr<JavaProjectSettings> javaSettings = std::dynamic_pointer_cast<JavaProjectSettings>(m_settings);
if (javaSettings)
{
javaSettings->setMavenProjectFilePath(m_picker->getText().toStdString());
javaSettings->setShouldIndexMavenTests(m_shouldIndexTests->isChecked());
}
}
std::vector<std::string> QtProjectWizzardContentPathSourceMaven::getFileNames() const
{
std::shared_ptr<JavaProjectSettings> javaSettings = std::dynamic_pointer_cast<JavaProjectSettings>(m_settings);
const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath();
const FilePath mavenProjectRoot = javaSettings->getAbsoluteMavenProjectFilePath().parentDirectory();
std::vector<std::string> list;
const bool success = utility::mavenGenerateSources(mavenPath, mavenProjectRoot);
if (!success)
{
const std::string dialogMessage =
"Coati was unable to locate Maven on this machine.\n"
"Please make sure to provide the correct Maven Path in the preferences.";
MessageStatus(dialogMessage, true, false).dispatch();
Application::getInstance()->handleDialog(dialogMessage);
}
else
{
const std::vector<FilePath> sourceDirectories = utility::mavenGetAllDirectoriesFromEffectivePom(
mavenPath,
mavenProjectRoot,
javaSettings->getShouldIndexMavenTests()
);
FileManager fileManager;
fileManager.setPaths(
sourceDirectories,
std::vector<FilePath>(), // we don't need to specify header paths here
m_settings->getAbsoluteExcludePaths(),
m_settings->getSourceExtensions()
);
const FilePath projectPath = m_settings->getProjectFileLocation();
for (FilePath path: fileManager.getSourceFilePaths())
{
if (projectPath.exists())
{
path = path.relativeTo(projectPath);
}
list.push_back(path.str());
}
}
return list;
}
QtProjectWizzardContentPathDependenciesMaven::QtProjectWizzardContentPathDependenciesMaven(
std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window
)
: QtProjectWizzardContentPath(settings, window)
{
setTitleString("Intermediate Dependencies Directory");
setHelpString(
"This directory is used to temporarily download and store the dependencies (e.g. .jar files) of the Maven project while it is indexed.<br />"
"<br />"
"You can make use of environment variables with ${ENV_VAR}."
);
}
void QtProjectWizzardContentPathDependenciesMaven::load()
{
std::shared_ptr<JavaProjectSettings> javaSettings = std::dynamic_pointer_cast<JavaProjectSettings>(m_settings);
if (javaSettings)
{
m_picker->setText(QString::fromStdString(javaSettings->getMavenDependenciesDirectory().str()));
}
}
void QtProjectWizzardContentPathDependenciesMaven::save()
{
std::shared_ptr<JavaProjectSettings> javaSettings = std::dynamic_pointer_cast<JavaProjectSettings>(m_settings);
if (javaSettings)
{
javaSettings->setMavenDependenciesDirectory(m_picker->getText().toStdString());
}
}
@@ -0,0 +1,69 @@
#ifndef QT_PROJECT_WIZZARD_CONTENT_PATH_H
#define QT_PROJECT_WIZZARD_CONTENT_PATH_H
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
#include "utility/path_detector/CombinedPathDetector.h"
class QCheckBox;
class QComboBox;
class QPushButton;
class QtLocationPicker;
class QtProjectWizzardContentPath
: public QtProjectWizzardContent
{
Q_OBJECT
public:
QtProjectWizzardContentPath(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
// QtSettingsWindow implementation
virtual void populate(QGridLayout* layout, int& row) override;
virtual bool check() override;
protected:
void setTitleString(const QString& title);
void setHelpString(const QString& help);
QtLocationPicker* m_picker;
bool m_makePathRelativeToProjectFileLocation;
private:
QString m_titleString;
QString m_helpString;
};
class QtProjectWizzardContentPathSourceMaven
: public QtProjectWizzardContentPath
{
public:
QtProjectWizzardContentPathSourceMaven(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
// QtSettingsWindow implementation
virtual void populate(QGridLayout* layout, int& row) override;
// QtProjectWizzardContent implementation
virtual void load() override;
virtual void save() override;
virtual std::vector<std::string> getFileNames() const override;
private:
QCheckBox* m_shouldIndexTests;
};
class QtProjectWizzardContentPathDependenciesMaven
: public QtProjectWizzardContentPath
{
public:
QtProjectWizzardContentPathDependenciesMaven(std::shared_ptr<ProjectSettings> settings, QtProjectWizzardWindow* window);
// QtProjectWizzardContent implementation
virtual void load() override;
virtual void save() override;
};
#endif // QT_PROJECT_WIZZARD_CONTENT_PATH_H
@@ -172,33 +172,19 @@ void QtProjectWizzardContentPathsSource::save()
std::vector<std::string> QtProjectWizzardContentPathsSource::getFileNames() const
{
std::vector<FilePath> sourcePaths = m_settings->getAbsoluteSourcePaths();
std::vector<FilePath> excludePaths = m_settings->getAbsoluteExcludePaths();
std::vector<std::string> extensions = m_settings->getSourceExtensions();
FileManager fileManager;
fileManager.setPaths(
m_settings->getAbsoluteSourcePaths(),
std::vector<FilePath>(), // we don't need to specify header paths here
m_settings->getAbsoluteExcludePaths(),
m_settings->getSourceExtensions()
);
std::vector<FileInfo> fileInfos = FileSystem::getFileInfosFromPaths(sourcePaths, extensions);
FilePath projectPath = m_settings->getProjectFileLocation();
const FilePath projectPath = m_settings->getProjectFileLocation();
std::vector<std::string> list;
for (const FileInfo& info : fileInfos)
for (FilePath path: fileManager.getSourceFilePaths())
{
FilePath path = info.path;
bool excluded = false;
for (FilePath p : excludePaths)
{
if (p == path || p.contains(path))
{
excluded = true;
break;
}
}
if (excluded)
{
continue;
}
if (projectPath.exists())
{
path = path.relativeTo(projectPath);
@@ -143,7 +143,6 @@ public:
virtual void save() override;
};
class QtProjectWizzardContentPathsClassJava
: public QtProjectWizzardContentPaths
{
@@ -113,25 +113,20 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
// jvm library path
m_javaPath = new QtLocationPicker(this);
#ifdef _WIN32
QString filter = "JVM Library (jvm.dll)";
#elif __APPLE__
QString filter = "JLI or JVM Library (libjli.dylib libjvm.dylib)";
#else
QString filter = "JVM Library (libjvm.so)";
#endif
m_javaPath->setFileFilter(filter);
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
{
m_javaPath->setFileFilter("JVM Library (jvm.dll)");
m_javaPath->setPlaceholderText("<jre_path>/bin/client/jvm.dll");
}
else if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
m_javaPath->setFileFilter("JLI or JVM Library (libjli.dylib libjvm.dylib)");
m_javaPath->setPlaceholderText("<jre_path>/Contents/Home/jre/lib/jli/libjli.dylib");
}
else
{
m_javaPath->setFileFilter("JVM Library (libjvm.so)");
m_javaPath->setPlaceholderText("<jre_path>/bin/<arch>/server/libjvm.so");
}
@@ -152,6 +147,7 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
javaVersionString += "Java 8";
addHelpButton((
"Only required for indexing Java projects.\n"
"Provide the location of the jvm library inside the installation of your " + javaVersionString +
" runtime environment (for information on how to set these take a look at "
"<a href=\"https://coati.io/documentation/#FindingJavaRuntimeLibraryLocation\">"
@@ -168,6 +164,37 @@ void QtProjectWizzardContentPreferences::populate(QGridLayout* layout, int& row)
"allocated by the indexer's JVM. A value of -1 ignores this setting.", layout, row);
layout->setRowMinimumHeight(row - 1, 30);
// maven path
m_mavenPath = new QtLocationPicker(this);
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
{
m_mavenPath->setFileFilter("Maven command (mvn.cmd)");
m_mavenPath->setPlaceholderText("<maven_path>/bin/mvn.cmd");
}
else if (QSysInfo::macVersion() != QSysInfo::MV_None)
{
// todo: add filter here
// todo: add placeholder here
}
else
{
// todo: add filter here
// todo: add placeholder here
}
addLabelAndWidget("Maven Path", m_mavenPath, layout, row);
addHelpButton(
"Only required for indexing projects using Maven.\n"
"Provide the location of the Maven executable. You can also use the auto detection below."
, layout, row
);
row++;
m_mavenPathDetector = utility::getMavenExecutablePathDetector();
addMavenPathDetection(layout, row);
addGap(layout, row);
// C/C++
@@ -214,6 +241,11 @@ void QtProjectWizzardContentPreferences::load()
}
m_jvmMaximumMemory->setText(QString::number(appSettings->getJavaMaximumMemory()));
if (m_mavenPath)
{
m_mavenPath->setText(QString::fromStdString(appSettings->getMavenPath()));
}
}
void QtProjectWizzardContentPreferences::save()
@@ -253,6 +285,11 @@ void QtProjectWizzardContentPreferences::save()
int jvmMaximumMemory = m_jvmMaximumMemory->text().toInt();
if (jvmMaximumMemory) appSettings->setJavaMaximumMemory(jvmMaximumMemory);
if (m_mavenPath)
{
appSettings->setMavenPath(m_mavenPath->getText().toStdString());
}
}
bool QtProjectWizzardContentPreferences::check()
@@ -265,7 +302,6 @@ void QtProjectWizzardContentPreferences::colorSchemeChanged(int index)
MessageSwitchColorScheme(m_colorSchemePaths[index]).dispatch();
}
void QtProjectWizzardContentPreferences::javaPathDetectionClicked()
{
std::vector<FilePath> paths = m_javaPathDetector->getPaths(m_javaPathDetectorBox->currentText().toStdString());
@@ -275,6 +311,15 @@ void QtProjectWizzardContentPreferences::javaPathDetectionClicked()
}
}
void QtProjectWizzardContentPreferences::mavenPathDetectionClicked()
{
std::vector<FilePath> paths = m_mavenPathDetector->getPaths(m_mavenPathDetectorBox->currentText().toStdString());
if (!paths.empty())
{
m_mavenPath->setText(paths.front().str().c_str());
}
}
void QtProjectWizzardContentPreferences::loggingEnabledChanged()
{
m_verboseIndexerLoggingEnabled->setEnabled(m_loggingEnabled->isChecked());
@@ -314,6 +359,40 @@ void QtProjectWizzardContentPreferences::addJavaPathDetection(QGridLayout* layou
row++;
}
void QtProjectWizzardContentPreferences::addMavenPathDetection(QGridLayout* layout, int& row)
{
std::vector<std::string> detectorNames = m_mavenPathDetector->getWorkingDetectorNames();
if (detectorNames.empty())
{
return;
}
QLabel* label = new QLabel("Auto detection from:");
m_mavenPathDetectorBox = new QComboBox();
for (const std::string& detectorName: detectorNames)
{
m_mavenPathDetectorBox->addItem(detectorName.c_str());
}
QPushButton* button = new QPushButton("detect");
button->setObjectName("windowButton");
connect(button, SIGNAL(clicked()), this, SLOT(mavenPathDetectionClicked()));
QHBoxLayout* hlayout = new QHBoxLayout();
hlayout->setContentsMargins(0, 0, 0, 0);
hlayout->addWidget(label);
hlayout->addWidget(m_mavenPathDetectorBox);
hlayout->addWidget(button);
QWidget* detectionWidget = new QWidget();
detectionWidget->setLayout(hlayout);
layout->addWidget(detectionWidget, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop);
row++;
}
void QtProjectWizzardContentPreferences::addTitle(QString title, QGridLayout* layout, int& row)
{
layout->addWidget(createFormTitle(title), row++, QtProjectWizzardWindow::FRONT_COL, Qt::AlignLeft);
@@ -29,10 +29,12 @@ public:
private slots:
void colorSchemeChanged(int index);
void javaPathDetectionClicked();
void mavenPathDetectionClicked();
void loggingEnabledChanged();
private:
void addJavaPathDetection(QGridLayout* layout, int& row);
void addMavenPathDetection(QGridLayout* layout, int& row);
void addTitle(QString title, QGridLayout* layout, int& row);
void addLabelAndWidget(
@@ -63,8 +65,12 @@ private:
QComboBox* m_threads;
std::shared_ptr<CombinedPathDetector> m_javaPathDetector;
std::shared_ptr<CombinedPathDetector> m_mavenPathDetector;
QComboBox* m_javaPathDetectorBox;
QComboBox* m_mavenPathDetectorBox;
QtLocationPicker* m_javaPath;
QtLocationPicker* m_mavenPath;
QLineEdit* m_jvmMaximumMemory;
};
@@ -7,6 +7,7 @@
#include "qt/window/project_wizzard/QtProjectWizzardWindow.h"
#include "utility/ResourcePaths.h"
#include "utility/utilityString.h"
#include "utility/solution/SolutionParserManager.h"
@@ -22,45 +23,82 @@ QtProjectWizzardContentSelect::QtProjectWizzardContentSelect(
void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
{
QPushButton* d = new QPushButton(languageTypeToString(LANGUAGE_CPP).c_str(), this);
QPushButton* e = new QPushButton(languageTypeToString(LANGUAGE_C).c_str(), this);
QPushButton* f = new QPushButton(languageTypeToString(LANGUAGE_JAVA).c_str(), this);
struct ProjectInfo
{
ProjectInfo(ProjectType type) :type(type) {}
const ProjectType type;
};
d->setObjectName("menuButton");
e->setObjectName("menuButton");
f->setObjectName("menuButton");
// define which kind of projects are available for each language
std::map<LanguageType, std::vector<ProjectInfo>> projectInfos;
projectInfos[LANGUAGE_C].push_back(ProjectInfo(PROJECT_C_EMPTY));
projectInfos[LANGUAGE_C].push_back(ProjectInfo(PROJECT_CXX_CDB));
projectInfos[LANGUAGE_C].push_back(ProjectInfo(PROJECT_CXX_VS));
projectInfos[LANGUAGE_CPP].push_back(ProjectInfo(PROJECT_CPP_EMPTY));
projectInfos[LANGUAGE_CPP].push_back(ProjectInfo(PROJECT_CXX_CDB));
projectInfos[LANGUAGE_CPP].push_back(ProjectInfo(PROJECT_CXX_VS));
projectInfos[LANGUAGE_JAVA].push_back(ProjectInfo(PROJECT_JAVA_EMPTY));
projectInfos[LANGUAGE_JAVA].push_back(ProjectInfo(PROJECT_JAVA_MAVEN));
d->setCheckable(true);
e->setCheckable(true);
f->setCheckable(true);
// define which icons should be used for which kind of project
m_projectTypeIconName[PROJECT_C_EMPTY] = "empty_icon";
m_projectTypeIconName[PROJECT_CPP_EMPTY] = "empty_icon";
m_projectTypeIconName[PROJECT_CXX_CDB] = "cdb_icon";
m_projectTypeIconName[PROJECT_CXX_VS] = "vs_icon";
m_projectTypeIconName[PROJECT_JAVA_EMPTY] = "empty_icon";
m_projectTypeIconName[PROJECT_JAVA_MAVEN] = "empty_icon";
d->setChecked(true);
// define descriptions for each kind of project
m_projectTypeDescriptions[PROJECT_C_EMPTY] = "Create a new Coati project by defining which C files will be indexed.";
m_projectTypeDescriptions[PROJECT_CPP_EMPTY] = "Create a new Coati project by defining which C++ files will be indexed.";
m_projectTypeDescriptions[PROJECT_CXX_CDB] = "Create a project from an existing Compilation Database (compile_commands.json). They can be created from Make and "
"CMake projects. Have a look at the <a href=\"https://coati.io/documentation/#CreateAProjectFromCompilationDatabase\">"
"documentation</a> to find out more.";
m_projectTypeDescriptions[PROJECT_CXX_VS] = "Create a new project from an existing Visual Studio Solution file. "
"<b>Note: Requires a running Visual Studio instance with the "
"<a href=\"https://coati.io/documentation/index.html#VisualStudio\">Visual Studio plugin</a> installed.";
m_projectTypeDescriptions[PROJECT_JAVA_EMPTY] = "Create a new Coati project by defining which Java files will be indexed.";
m_projectTypeDescriptions[PROJECT_JAVA_MAVEN] = "Create a new project from an existing Maven project.";
QVBoxLayout* vlayout = new QVBoxLayout();
vlayout->setContentsMargins(0, 30, 0, 0);
vlayout->setSpacing(10);
m_languages = new QButtonGroup();
m_languages->addButton(d);
m_languages->addButton(e);
m_languages->addButton(f);
for (auto it: projectInfos)
{
QPushButton* b = new QPushButton(languageTypeToString(it.first).c_str(), this);
b->setObjectName("menuButton");
b->setCheckable(true);
b->setProperty("language_type", it.first);
m_languages->addButton(b);
vlayout->addWidget(b);
}
m_languages->setId(d, 0);
m_languages->setId(e, 1);
m_languages->setId(f, 2);
vlayout->addStretch();
layout->addLayout(vlayout, 0, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
connect(m_languages, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
[this](int id)
connect(m_languages, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),
[this](QAbstractButton* button)
{
bool isJava = stringToLanguageType(m_languages->checkedButton()->text().toStdString()) == LANGUAGE_JAVA;
m_buttons->setExclusive(false);
for (int i = 0; i < m_buttons->buttons().size(); i++)
LanguageType selectedLanguage = LANGUAGE_UNKNOWN;
bool ok = false;
int languageTypeInt = button->property("language_type").toInt(&ok);
if (ok)
{
m_buttons->button(i)->setChecked(false);
selectedLanguage = LanguageType(languageTypeInt);
}
if (i != 0)
for (auto it: m_buttons)
{
it.second->setExclusive(false);
for (QAbstractButton* button: it.second->buttons())
{
m_buttons->button(i)->setVisible(!isJava);
button->setChecked(false);
button->setVisible(it.first == selectedLanguage);
}
it.second->setExclusive(true);
}
m_buttons->setExclusive(true);
m_window->setNextEnabled(false);
m_title->setText("Project Types - " + m_languages->checkedButton()->text());
@@ -68,94 +106,46 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
}
);
QVBoxLayout* vlayout = new QVBoxLayout();
vlayout->setContentsMargins(0, 30, 0, 0);
vlayout->setSpacing(10);
vlayout->addWidget(d);
vlayout->addWidget(e);
vlayout->addWidget(f);
vlayout->addStretch();
layout->addLayout(vlayout, 0, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
QToolButton* a = createProjectButton(
"Empty Project", (ResourcePaths::getGuiPath() + "icon/empty_icon.png").c_str());
QToolButton* c = createProjectButton(
"from Compilation\nDatabase", (ResourcePaths::getGuiPath() + "icon/cdb_icon.png").c_str());
m_solutionDescription.push_back("Create a new Coati project by defining what files will be indexed.");
m_solutionDescription.push_back(
"Create a project from an existing Compilation Database (compile_commands.json). They can be created from Make and "
"CMake projects. Have a look at the <a href=\"https://coati.io/documentation/#CreateAProjectFromCompilationDatabase\">"
"documentation</a> to find out more.");
m_buttons = new QButtonGroup(this);
m_buttons->addButton(a);
m_buttons->addButton(c);
m_buttons->setId(a, PROJECT_EMPTY);
m_buttons->setId(c, PROJECT_CDB);
QHBoxLayout* hlayout = new QHBoxLayout();
hlayout->addWidget(a);
hlayout->addWidget(c);
unsigned int runningId = 2;
std::shared_ptr<SolutionParserManager> manager = m_solutionParserManager.lock();
if (manager != NULL)
for (auto languageIt: projectInfos)
{
for (unsigned int i = 0; i < manager->getParserCount(); i++)
QButtonGroup* projectButtons = new QButtonGroup(this);
for (auto projectIt: languageIt.second)
{
std::string name = manager->getParserButtonText(i);
QToolButton* button = createProjectButton(name.c_str(),
(ResourcePaths::getGuiPath() + manager->getIconPath(i)).c_str());
m_buttons->addButton(button);
m_solutionDescription.push_back(manager->getParserDescription(i));
hlayout->addWidget(button);
m_buttons->setId(button, runningId);
runningId++;
QToolButton* b = createProjectButton(
utility::insertLineBreaksAtBlankSpaces(projectTypeToString(projectIt.type), 15).c_str(),
(ResourcePaths::getGuiPath() + "icon/" + m_projectTypeIconName[projectIt.type] + ".png").c_str()
);
b->setProperty("project_type", int(projectIt.type));
projectButtons->addButton(b);
hlayout->addWidget(b);
}
m_buttons[languageIt.first] = projectButtons;
}
// Add vs solution button
for (auto it: m_buttons)
{
std::string name = "Visual Studio";
connect(it.second, static_cast<void(QButtonGroup::*)(QAbstractButton*)>(&QButtonGroup::buttonClicked),
[this](QAbstractButton* button)
{
ProjectType selectedProject = PROJECT_UNKNOWN;
bool ok = false;
int projectTypeInt = button->property("project_type").toInt(&ok);
if (ok)
{
selectedProject = ProjectType(projectTypeInt);
}
QToolButton* button = createProjectButton(name.c_str(),
(ResourcePaths::getGuiPath() + "icon/vs_icon.png").c_str());
m_description->setText(m_projectTypeDescriptions[selectedProject].c_str());
m_buttons->addButton(button);
m_solutionDescription.push_back("Create a new project from an existing Visual Studio Solution file. "
"<b>Note: Requires a running Visual Studio instance with the "
"<a href=\"https://coati.io/documentation/index.html#VisualStudio\">Visual Studio plugin</a> installed.");
hlayout->addWidget(button);
m_buttons->setId(button, runningId);
runningId++;
m_window->setNextEnabled(true);
}
);
}
connect(m_buttons, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
[this](int id)
{
m_description->setText(m_solutionDescription[id].c_str());
m_window->setNextEnabled(true);
}
);
QFrame* container = new QFrame();
container->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
container->setObjectName("projectContainer");
@@ -169,7 +159,7 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
m_description->setObjectName("projectDescription");
layout->addWidget(m_description, 1, QtProjectWizzardWindow::BACK_COL);
m_title = new QLabel("Project Types - " + m_languages->checkedButton()->text());
m_title = new QLabel("Project Types");
m_title->setObjectName("projectTitle");
layout->addWidget(m_title, 0, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft | Qt::AlignTop);
@@ -179,26 +169,44 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
layout->setColumnStretch(QtProjectWizzardWindow::FRONT_COL, 0);
layout->setColumnStretch(QtProjectWizzardWindow::BACK_COL, 1);
layout->setHorizontalSpacing(0);
m_languages->buttons().first()->click();
}
void QtProjectWizzardContentSelect::save()
{
ProjectType type;
switch (m_buttons->checkedId())
for (auto it: m_buttons)
{
case 0: type = PROJECT_EMPTY; break;
case 1: type = PROJECT_CDB; break;
case 2: type = PROJECT_MANAGED; break;
default: type = PROJECT_MANAGED; break;
if (QAbstractButton* b = it.second->checkedButton())
{
bool ok = false;
int projectType = b->property("project_type").toInt(&ok);
if (ok)
{
type = ProjectType(projectType);
break;
}
}
}
emit selected(stringToLanguageType(m_languages->checkedButton()->text().toStdString()), type);
emit selected(type);
}
bool QtProjectWizzardContentSelect::check()
{
if (m_buttons->checkedId() == -1)
bool projectChosen = false;
for (auto it: m_buttons)
{
if (it.second->checkedId() != -1)
{
projectChosen = true;
break;
}
}
if (!projectChosen)
{
QMessageBox msgBox;
msgBox.setText("Please choose a method of creating a new project.");
@@ -12,13 +12,6 @@ class QtProjectWizzardContentSelect
Q_OBJECT
public:
enum ProjectType : int
{
PROJECT_EMPTY = 0,
PROJECT_CDB = 1,
PROJECT_MANAGED = 2 // use this type for all standard parser (parsers that are handled by the parser manager)
};
QtProjectWizzardContentSelect(
std::shared_ptr<ProjectSettings> settings,
QtProjectWizzardWindow* window,
@@ -31,18 +24,17 @@ public:
virtual bool check() override;
signals:
void selected(LanguageType, QtProjectWizzardContentSelect::ProjectType);
void selected(ProjectType);
private:
QButtonGroup* m_languages;
QButtonGroup* m_buttons;
std::map<LanguageType, QButtonGroup*> m_buttons;
QLabel* m_title;
QLabel* m_description;
std::vector<std::string> m_projectTypeNames;
std::vector<std::string> m_projectTypeDescriptions;
std::vector<std::string> m_projectTypeIconPaths;
std::map<ProjectType, std::string> m_projectTypeIconName;
std::map<ProjectType, std::string> m_projectTypeDescriptions;
std::weak_ptr<SolutionParserManager> m_solutionParserManager;
std::vector<std::string> m_solutionDescription;
@@ -40,6 +40,11 @@ void QtProjectWizzardWindow::setPreferredSize(QSize size)
m_preferredSize = size;
}
void QtProjectWizzardWindow::saveContent()
{
m_content->save();
}
void QtProjectWizzardWindow::populateWindow(QWidget* widget)
{
QGridLayout* layout = new QGridLayout();
@@ -80,7 +85,7 @@ void QtProjectWizzardWindow::windowReady()
void QtProjectWizzardWindow::handleNext()
{
m_content->save();
saveContent();
if (m_content->check())
{
@@ -20,6 +20,8 @@ public:
void setPreferredSize(QSize size);
void saveContent();
static const int FRONT_COL = 0;
static const int HELP_COL = 1;
static const int LINE_COL = 2;
@@ -0,0 +1,25 @@
#include "utility/path_detector/maven_executable/MavenPathDetectorUnix.h"
#include "utility/utilityApp.h"
MavenPathDetectorUnix::MavenPathDetectorUnix()
: PathDetector("Maven for Unix")
{
}
MavenPathDetectorUnix::~MavenPathDetectorUnix()
{
}
std::vector<FilePath> MavenPathDetectorUnix::getPaths() const
{
std::string command = "which mvn";
FilePath mavenPath(utility::executeProcess(command.c_str()));
std::vector<FilePath> paths;
if (mavenPath.exists())
{
paths.push_back(mavenPath);
}
return paths;
}
@@ -0,0 +1,15 @@
#ifndef MAVEN_PATH_DETECTOR_UNIX_H
#define MAVEN_PATH_DETECTOR_UNIX_H
#include "utility/path_detector/PathDetector.h"
class MavenPathDetectorUnix: public PathDetector
{
public:
MavenPathDetectorUnix();
virtual ~MavenPathDetectorUnix();
virtual std::vector<FilePath> getPaths() const;
};
#endif // MAVEN_PATH_DETECTOR_UNIX_H
@@ -0,0 +1,25 @@
#include "utility/path_detector/maven_executable/MavenPathDetectorWindows.h"
#include "utility/utilityApp.h"
MavenPathDetectorWindows::MavenPathDetectorWindows()
: PathDetector("Maven for Windows")
{
}
MavenPathDetectorWindows::~MavenPathDetectorWindows()
{
}
std::vector<FilePath> MavenPathDetectorWindows::getPaths() const
{
std::string command = "cmd /k where mvn.cmd && exit";
FilePath mavenPath(utility::executeProcess(command.c_str()));
std::vector<FilePath> paths;
if (mavenPath.exists())
{
paths.push_back(mavenPath);
}
return paths;
}
@@ -0,0 +1,15 @@
#ifndef MAVEN_PATH_DETECTOR_WINDOWS_H
#define MAVEN_PATH_DETECTOR_WINDOWS_H
#include "utility/path_detector/PathDetector.h"
class MavenPathDetectorWindows: public PathDetector
{
public:
MavenPathDetectorWindows();
virtual ~MavenPathDetectorWindows();
virtual std::vector<FilePath> getPaths() const;
};
#endif // MAVEN_PATH_DETECTOR_WINDOWS_H
+8 -2
View File
@@ -5,11 +5,17 @@
#include "utility/utilityString.h"
std::string utility::executeProcess(const char *cmd)
std::string utility::executeProcess(const std::string& command, const std::string& workingDirectory)
{
QProcess process;
process.setProcessChannelMode(QProcess::MergedChannels);
process.start(cmd);
if (!workingDirectory.empty())
{
process.setWorkingDirectory(workingDirectory.c_str());
}
process.start(command.c_str());
process.waitForFinished();
std::string processoutput = process.readAll().toStdString();
process.close();
+2 -3
View File
@@ -1,17 +1,16 @@
#ifndef UTILITY_APP_H
#define UTILITY_APP_H
#include <QProcess>
#include <string>
#include "utility/ApplicationArchitectureType.h"
namespace utility
{
std::string executeProcess(const char* cmd);
std::string executeProcess(const std::string& command, const std::string& workingDirectory = "");
ApplicationArchitectureType getApplicationArchitectureType();
}
#endif // UTILITY_APP_H
@@ -6,6 +6,9 @@
#include "utility/path_detector/java_runtime/JavaPathDetectorMac.h"
#include "utility/path_detector/java_runtime/JavaPathDetectorWindows.h"
#include "utility/path_detector/maven_executable/MavenPathDetectorUnix.h"
#include "utility/path_detector/maven_executable/MavenPathDetectorWindows.h"
#include "utility/path_detector/cxx_header/CxxFrameworkPathDetector.h"
#include "utility/path_detector/cxx_header/CxxHeaderPathDetector.h"
#include "utility/path_detector/cxx_header/CxxVsHeaderPathDetector.h"
@@ -29,6 +32,21 @@ std::shared_ptr<CombinedPathDetector> utility::getJavaRuntimePathDetector()
return combinedDetector;
}
std::shared_ptr<CombinedPathDetector> utility::getMavenExecutablePathDetector()
{
std::shared_ptr<CombinedPathDetector> combinedDetector = std::make_shared<CombinedPathDetector>();
if (QSysInfo::windowsVersion() != QSysInfo::WV_None)
{
combinedDetector->addDetector(std::make_shared<MavenPathDetectorWindows>());
}
else
{
combinedDetector->addDetector(std::make_shared<MavenPathDetectorUnix>());
}
return combinedDetector;
}
std::shared_ptr<CombinedPathDetector> utility::getCxxVsHeaderPathDetector()
{
std::shared_ptr<CombinedPathDetector> combinedDetector = std::make_shared<CombinedPathDetector>();
@@ -6,6 +6,7 @@
namespace utility
{
std::shared_ptr<CombinedPathDetector> getJavaRuntimePathDetector();
std::shared_ptr<CombinedPathDetector> getMavenExecutablePathDetector();
std::shared_ptr<CombinedPathDetector> getCxxVsHeaderPathDetector();
std::shared_ptr<CombinedPathDetector> getCxxHeaderPathDetector();