From a3001b2b7226bfdaa57713e2b00754c71937a7cd Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Wed, 17 Aug 2016 13:12:26 +0200 Subject: [PATCH] ui: Added Java project setup UI --- src/lib/CMakeLists.txt | 2 - src/lib/Project.cpp | 4 +- .../component/controller/CodeController.cpp | 13 +- src/lib/settings/CxxProjectSettings.cpp | 37 +++++ src/lib/settings/CxxProjectSettings.h | 3 + src/lib/settings/JavaProjectSettings.cpp | 10 ++ src/lib/settings/JavaProjectSettings.h | 6 +- src/lib/settings/ProjectSettings.cpp | 19 ++- src/lib/settings/ProjectSettings.h | 5 +- .../solution/SolutionParserEclipse.cpp | 0 .../utility/solution/SolutionParserEclipse.h | 11 -- src/lib_gui/qt/window/QtMainWindow.cpp | 9 +- .../project_wizzard/QtProjectWizzard.cpp | 128 ++++++++++++++---- .../window/project_wizzard/QtProjectWizzard.h | 3 + .../QtProjectWizzardContent.cpp | 4 - .../project_wizzard/QtProjectWizzardContent.h | 1 - .../QtProjectWizzardContentData.cpp | 101 ++++---------- .../QtProjectWizzardContentData.h | 10 +- .../QtProjectWizzardContentPaths.cpp | 54 +++++++- .../QtProjectWizzardContentPaths.h | 20 ++- .../QtProjectWizzardContentPreferences.cpp | 3 +- .../QtProjectWizzardContentPreferences.h | 2 +- .../QtProjectWizzardContentSelect.cpp | 25 +++- .../QtProjectWizzardContentSelect.h | 7 +- .../QtProjectWizzardContentSimple.cpp | 6 - .../QtProjectWizzardContentSimple.h | 1 - .../QtProjectWizzardContentSummary.cpp | 4 +- .../QtProjectWizzardContentSummary.h | 2 +- .../QtProjectWizzardWindow.cpp | 3 +- src/test/SettingsTestSuite.h | 12 +- 30 files changed, 329 insertions(+), 176 deletions(-) delete mode 100644 src/lib/utility/solution/SolutionParserEclipse.cpp delete mode 100644 src/lib/utility/solution/SolutionParserEclipse.h diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index c6fac5ff..8a11a5b4 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -315,8 +315,6 @@ add_files( utility/solution/ISolutionParser.h utility/solution/SolutionParserCodeBlocks.cpp utility/solution/SolutionParserCodeBlocks.h - utility/solution/SolutionParserEclipse.cpp - utility/solution/SolutionParserEclipse.h utility/solution/SolutionParserManager.cpp utility/solution/SolutionParserManager.h utility/solution/SolutionParserUtility.cpp diff --git a/src/lib/Project.cpp b/src/lib/Project.cpp index 95ebce43..f7b4e7a5 100644 --- a/src/lib/Project.cpp +++ b/src/lib/Project.cpp @@ -64,7 +64,7 @@ void Project::refresh() { if (allowsRefresh()) { - bool loadedSettings = getProjectSettings()->load(); + bool loadedSettings = getProjectSettings()->reload(); updateFileManager(m_fileManager); @@ -112,7 +112,7 @@ Project::Project(StorageAccessProxy* storageAccessProxy) void Project::load() { const std::shared_ptr projectSettings = getProjectSettings(); - bool loadedSettings = projectSettings->load(); + bool loadedSettings = projectSettings->reload(); if (loadedSettings) { const FilePath projectSettingsPath = projectSettings->getFilePath(); diff --git a/src/lib/component/controller/CodeController.cpp b/src/lib/component/controller/CodeController.cpp index 42b5c4d5..b3ef761f 100644 --- a/src/lib/component/controller/CodeController.cpp +++ b/src/lib/component/controller/CodeController.cpp @@ -47,7 +47,11 @@ void CodeController::handleMessage(MessageActivateAll* message) statsSnippet.locationFile = std::make_shared(FilePath()); statsSnippet.locationFile->isWholeCopy = true; - statsSnippet.title = Application::getInstance()->getCurrentProject()->getProjectSettingsFilePath().withoutExtension().fileName(); + Project* currentProject = Application::getInstance()->getCurrentProject().get(); + if (currentProject) + { + statsSnippet.title = currentProject->getProjectSettingsFilePath().withoutExtension().fileName(); + } std::vector description = getProjectDescription(statsSnippet.locationFile.get()); @@ -662,8 +666,13 @@ std::shared_ptr CodeController::getTokenLocationOfParentScope std::vector CodeController::getProjectDescription(TokenLocationFile* locationFile) const { - std::string description = Application::getInstance()->getCurrentProject()->getDescription(); + Project* currentProject = Application::getInstance()->getCurrentProject().get(); + if (!currentProject) + { + return std::vector(); + } + std::string description = currentProject->getDescription(); if (!description.size()) { return std::vector(); diff --git a/src/lib/settings/CxxProjectSettings.cpp b/src/lib/settings/CxxProjectSettings.cpp index 6d6183e0..10f1738c 100644 --- a/src/lib/settings/CxxProjectSettings.cpp +++ b/src/lib/settings/CxxProjectSettings.cpp @@ -36,6 +36,38 @@ bool CxxProjectSettings::equalsExceptNameAndLocation(const ProjectSettings& othe return false; } +std::vector CxxProjectSettings::getLanguageStandards() const +{ + std::vector standards; + + switch (getLanguage()) + { + case LANGUAGE_CPP: + standards.push_back("1z"); + standards.push_back("14"); + standards.push_back("1y"); + standards.push_back("11"); + standards.push_back("0x"); + standards.push_back("03"); + standards.push_back("98"); + break; + + case LANGUAGE_C: + standards.push_back("1x"); + standards.push_back("11"); + standards.push_back("9x"); + standards.push_back("99"); + standards.push_back("90"); + standards.push_back("89"); + break; + + default: + break; + } + + return standards; +} + std::vector CxxProjectSettings::getHeaderSearchPaths() const { return getPathValues("source/header_search_paths/header_search_path"); @@ -122,3 +154,8 @@ std::vector CxxProjectSettings::getDefaultSourceExtensions() const defaultValues.push_back(".cc"); return defaultValues; } + +std::string CxxProjectSettings::getDefaultStandard() const +{ + return "1z"; +} diff --git a/src/lib/settings/CxxProjectSettings.h b/src/lib/settings/CxxProjectSettings.h index 1a5d718f..fc77de5c 100644 --- a/src/lib/settings/CxxProjectSettings.h +++ b/src/lib/settings/CxxProjectSettings.h @@ -13,6 +13,8 @@ public: virtual bool equalsExceptNameAndLocation(const ProjectSettings& other) const; + virtual std::vector getLanguageStandards() const; + std::vector getHeaderSearchPaths() const; std::vector getAbsoluteHeaderSearchPaths() const; bool setHeaderSearchPaths(const std::vector& headerSearchPaths); @@ -35,6 +37,7 @@ public: private: virtual std::vector getDefaultSourceExtensions() const; + virtual std::string getDefaultStandard() const; }; #endif // CXX_PROJECT_SETTINGS_H diff --git a/src/lib/settings/JavaProjectSettings.cpp b/src/lib/settings/JavaProjectSettings.cpp index 1a90cd6d..bb5bc088 100644 --- a/src/lib/settings/JavaProjectSettings.cpp +++ b/src/lib/settings/JavaProjectSettings.cpp @@ -36,6 +36,11 @@ bool JavaProjectSettings::equalsExceptNameAndLocation(const ProjectSettings& oth return false; } +std::vector JavaProjectSettings::getLanguageStandards() const +{ + return std::vector(1, "8"); +} + std::vector JavaProjectSettings::getClasspaths() const { return getPathValues("source/class_paths/class_path"); @@ -60,3 +65,8 @@ std::vector JavaProjectSettings::getDefaultSourceExtensions() const defaultValues.push_back(".java"); return defaultValues; } + +std::string JavaProjectSettings::getDefaultStandard() const +{ + return "8"; +} diff --git a/src/lib/settings/JavaProjectSettings.h b/src/lib/settings/JavaProjectSettings.h index d1fca82d..865941cc 100644 --- a/src/lib/settings/JavaProjectSettings.h +++ b/src/lib/settings/JavaProjectSettings.h @@ -3,7 +3,8 @@ #include "settings/ProjectSettings.h" -class JavaProjectSettings: public ProjectSettings +class JavaProjectSettings + : public ProjectSettings { public: JavaProjectSettings(); @@ -13,12 +14,15 @@ public: virtual bool equalsExceptNameAndLocation(const ProjectSettings& other) const; + virtual std::vector getLanguageStandards() const; + std::vector getClasspaths() const; std::vector getAbsoluteClasspaths() const; bool setClasspaths(const std::vector& headerSearchPaths); private: virtual std::vector getDefaultSourceExtensions() const; + virtual std::string getDefaultStandard() const; }; #endif // JAVA_PROJECT_SETTINGS_H diff --git a/src/lib/settings/ProjectSettings.cpp b/src/lib/settings/ProjectSettings.cpp index 31816522..532447c8 100644 --- a/src/lib/settings/ProjectSettings.cpp +++ b/src/lib/settings/ProjectSettings.cpp @@ -6,8 +6,8 @@ LanguageType ProjectSettings::getLanguageOfProject(FilePath projectFilePath) { - ProjectSettings tempSettings(projectFilePath); - tempSettings.load(); + ProjectSettings tempSettings; + tempSettings.load(projectFilePath); return tempSettings.getLanguage(); } @@ -40,7 +40,12 @@ bool ProjectSettings::equalsExceptNameAndLocation(const ProjectSettings& other) ); } -bool ProjectSettings::load() +std::vector ProjectSettings::getLanguageStandards() const +{ + return std::vector(); +} + +bool ProjectSettings::reload() { return Settings::load(getFilePath()); } @@ -82,7 +87,7 @@ bool ProjectSettings::setLanguage(LanguageType language) std::string ProjectSettings::getStandard() const { - return getValue("language_settings/standard", "1z"); + return getValue("language_settings/standard", getDefaultStandard()); } bool ProjectSettings::setStandard(const std::string& standard) @@ -152,3 +157,9 @@ std::vector ProjectSettings::getDefaultSourceExtensions() const { return std::vector(); } + +std::string ProjectSettings::getDefaultStandard() const +{ + return ""; +} + diff --git a/src/lib/settings/ProjectSettings.h b/src/lib/settings/ProjectSettings.h index c00b12c3..d1fb607c 100644 --- a/src/lib/settings/ProjectSettings.h +++ b/src/lib/settings/ProjectSettings.h @@ -20,7 +20,9 @@ public: virtual bool equalsExceptNameAndLocation(const ProjectSettings& other) const; - virtual bool load(); + virtual std::vector getLanguageStandards() const; + + bool reload(); std::string getProjectName() const; void setProjectName(const std::string& name); @@ -52,6 +54,7 @@ protected: private: virtual std::vector getDefaultSourceExtensions() const; + virtual std::string getDefaultStandard() const; }; #endif // PROJECT_SETTINGS_H diff --git a/src/lib/utility/solution/SolutionParserEclipse.cpp b/src/lib/utility/solution/SolutionParserEclipse.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/src/lib/utility/solution/SolutionParserEclipse.h b/src/lib/utility/solution/SolutionParserEclipse.h deleted file mode 100644 index b3033583..00000000 --- a/src/lib/utility/solution/SolutionParserEclipse.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef SOLUTION_PARSER_ECLIPSE_H -#define SOLUTION_PARSER_ECLIPSE_H - -#include "ISolutionParser.h" - -class SolutionParserEclipse -{ - -}; - -#endif // SOLUTION_PARSER_ECLIPSE_H diff --git a/src/lib_gui/qt/window/QtMainWindow.cpp b/src/lib_gui/qt/window/QtMainWindow.cpp index 9332de5a..8bc79ec1 100644 --- a/src/lib_gui/qt/window/QtMainWindow.cpp +++ b/src/lib_gui/qt/window/QtMainWindow.cpp @@ -419,8 +419,13 @@ void QtMainWindow::openProject(const QString &path) void QtMainWindow::editProject() { - QtProjectWizzard* wizzard = createWindow(); - wizzard->editProject(Application::getInstance()->getCurrentProject()->getProjectSettingsFilePath()); + Project* currentProject = Application::getInstance()->getCurrentProject().get(); + if (currentProject) + { + QtProjectWizzard* wizzard = createWindow(); + + wizzard->editProject(currentProject->getProjectSettingsFilePath()); + } } void QtMainWindow::find() diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp index edf02a71..4bd72a70 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp @@ -1,7 +1,5 @@ #include "qt/window/project_wizzard/QtProjectWizzard.h" -#include - #include #include #include @@ -21,16 +19,13 @@ #include "settings/CxxProjectSettings.h" #include "settings/JavaProjectSettings.h" #include "utility/file/FileSystem.h" +#include "utility/logging/logging.h" #include "utility/messaging/type/MessageDispatchWhenLicenseValid.h" #include "utility/messaging/type/MessageLoadProject.h" #include "utility/messaging/type/MessageRefresh.h" - -#include "utility/solution/SolutionParserVisualStudio.h" -// #include "utility/solution/SolutionParserCodeBlocks.h" - #include "utility/messaging/type/MessageStatus.h" - -#include "utility/logging/logging.h" +#include "utility/solution/SolutionParserVisualStudio.h" +#include "utility/utilityString.h" #include "Application.h" @@ -101,11 +96,9 @@ void QtProjectWizzard::newProjectFromSolution(const std::string& ideId, const st QtProjectWizzardWindow* window = dynamic_cast(widget); std::string title = "NEW PROJECT FROM "; - title += ideId; + title += utility::toUpperCase(ideId); title += " SOLUTION"; - boost::algorithm::to_upper(title); - window->updateTitle(QString(title.c_str())); window->updateNextButton("Create"); window->setPreviousVisible(m_windowStack.getWindowCount() > 0); @@ -162,11 +155,13 @@ void QtProjectWizzard::editProject(const FilePath& settingsPath) case LANGUAGE_JAVA: settings = std::make_shared(settingsPath); break; + default: + return; } if (settings) { - settings->load(); + settings->reload(); editProject(settings); } } @@ -176,7 +171,20 @@ void QtProjectWizzard::editProject(std::shared_ptr settings) m_settings = settings; m_editing = true; - showSummary(); + switch (m_settings->getLanguage()) + { + case LANGUAGE_JAVA: + showSummaryJava(); + break; + + case LANGUAGE_C: + case LANGUAGE_CPP: + showSummary(); + break; + + default: + break; + } QtProjectWizzardWindow* window = dynamic_cast(m_windowStack.getTopWindow()); if (!window) @@ -334,7 +342,14 @@ void QtProjectWizzard::selectedProjectType(LanguageType languageType, QtProjectW switch (type) { case QtProjectWizzardContentSelect::PROJECT_EMPTY: - m_settings = std::make_shared(); + if (languageType == LANGUAGE_JAVA) + { + m_settings = std::make_shared(); + } + else + { + m_settings = std::make_shared(); + } m_settings->setLanguage(languageType); emptyProject(); break; @@ -376,7 +391,15 @@ void QtProjectWizzard::selectedProjectType(LanguageType languageType, QtProjectW void QtProjectWizzard::emptyProject() { QtProjectWizzardWindow* window = createWindowWithContent(); - connect(window, SIGNAL(next()), this, SLOT(sourcePaths())); + + if (m_settings->getLanguage() == LANGUAGE_JAVA) + { + connect(window, SIGNAL(next()), this, SLOT(sourcePathsJava())); + } + else + { + connect(window, SIGNAL(next()), this, SLOT(sourcePaths())); + } } void QtProjectWizzard::sourcePaths() @@ -487,6 +510,25 @@ void QtProjectWizzard::headerPathsCDBDone() } } +void QtProjectWizzard::sourcePathsJava() +{ + QtProjectWizzardWindow* window = createWindowWithSummary( + [this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary) + { + + QtProjectWizzardContent* source = new QtProjectWizzardContentPathsSourceJava(m_settings, window); + summary->addContent(source, false, false); + connectShowFiles(source); + + summary->addContent(new QtProjectWizzardContentPathsClassJava(m_settings, window), false, false); + + window->setup(); + } + ); + + connect(window, SIGNAL(next()), this, SLOT(showSummaryJava())); +} + void QtProjectWizzard::showFiles(QtProjectWizzardContent* content) { QWidget* widget = m_windowStack.getTopWindow(); @@ -566,17 +608,51 @@ void QtProjectWizzard::showSummary() connect(window, SIGNAL(next()), this, SLOT(createProject())); } +void QtProjectWizzard::showSummaryJava() +{ + QtProjectWizzardWindow* window = createWindowWithSummary( + [this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary) + { + summary->setIsForm(true); + + summary->addContent(new QtProjectWizzardContentData(m_settings, window), false, false); + + QtProjectWizzardContentPathsSourceJava* source = new QtProjectWizzardContentPathsSourceJava(m_settings, window); + summary->addContent(source, false, true); + connectShowFiles(source); + + summary->addContent(new QtProjectWizzardContentPathsClassJava(m_settings, window), false, true); + + summary->addContent(new QtProjectWizzardContentExtensions(m_settings, window), true, false); + summary->addContent(new QtProjectWizzardContentPathsExclude(m_settings, window), true, true); + + window->setup(); + + window->updateTitle("NEW PROJECT - SUMMARY"); + window->updateNextButton("Create"); + } + ); + + connect(window, SIGNAL(next()), this, SLOT(createProject())); +} + void QtProjectWizzard::createProject() { FilePath path = m_settings->getFilePath(); m_settings->save(path); - bool foreceRefreshProject = false; + bool forceRefreshProject = false; if (m_editing) { std::shared_ptr application = Application::getInstance(); - FilePath oldPath = application->getCurrentProject()->getProjectSettingsFilePath(); + FilePath oldPath; + + Project* currentProject = application->getCurrentProject().get(); + if (currentProject) + { + oldPath = currentProject->getProjectSettingsFilePath(); + } if (oldPath.exists() && oldPath != path) { @@ -608,12 +684,12 @@ void QtProjectWizzard::createProject() if (settingsChanged || appSettingsChanged) { - foreceRefreshProject = true; + forceRefreshProject = true; } } MessageDispatchWhenLicenseValid( - std::make_shared(path, foreceRefreshProject) + std::make_shared(path, forceRefreshProject) ).dispatch(); finishWizzard(); @@ -625,11 +701,15 @@ void QtProjectWizzard::savePreferences() if (appSettingsChanged) { - MessageDispatchWhenLicenseValid( - std::make_shared( - Application::getInstance()->getCurrentProject()->getProjectSettingsFilePath(), true - ) - ).dispatch(); + Project* currentProject = Application::getInstance()->getCurrentProject().get(); + if (currentProject) + { + MessageDispatchWhenLicenseValid( + std::make_shared( + currentProject->getProjectSettingsFilePath(), true + ) + ).dispatch(); + } } else { diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h index a90c0ca6..52d7b0c5 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h @@ -82,9 +82,12 @@ private slots: void headerPathsCDB(); void headerPathsCDBDone(); + void sourcePathsJava(); + void showFiles(QtProjectWizzardContent* content); void showSummary(); + void showSummaryJava(); void createProject(); void savePreferences(); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.cpp index 60bcbfcc..f2ca7c51 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.cpp @@ -35,10 +35,6 @@ void QtProjectWizzardContent::populateWindow(QWidget* widget) { } -void QtProjectWizzardContent::populateWindow(QGridLayout* layout) -{ -} - void QtProjectWizzardContent::populateWindow(QGridLayout* layout, int& row) { } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.h index 85532195..6471702c 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContent.h @@ -36,7 +36,6 @@ public: QtProjectWizzardContent(std::shared_ptr settings, QtProjectWizzardWindow* window); virtual void populateWindow(QWidget* widget); - virtual void populateWindow(QGridLayout* layout); virtual void populateWindow(QGridLayout* layout, int& row); virtual void populateForm(QGridLayout* layout, int& row); virtual void windowReady(); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.cpp index 1ce42ed6..a0b1f40d 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.cpp @@ -5,20 +5,20 @@ #include "settings/CxxProjectSettings.h" +#include "utility/logging/logging.h" + QtProjectWizzardContentData::QtProjectWizzardContentData(std::shared_ptr settings, QtProjectWizzardWindow* window) : QtProjectWizzardContent(settings, window) , m_projectName(nullptr) , m_projectFileLocation(nullptr) , m_language(nullptr) - , m_cppStandard(nullptr) - , m_cStandard(nullptr) + , m_standard(nullptr) , m_buildFilePicker(nullptr) { } -void QtProjectWizzardContentData::populateWindow(QGridLayout* layout) +void QtProjectWizzardContentData::populateWindow(QGridLayout* layout, int& row) { - int row = 0; layout->setRowMinimumHeight(0, 15); row++; @@ -47,24 +47,24 @@ void QtProjectWizzardContentData::load() if (m_language) { - if (m_settings->getLanguage() != LANGUAGE_UNKNOWN) + LanguageType type = m_settings->getLanguage(); + + if (type == LANGUAGE_UNKNOWN) { - m_language->setCurrentText(QString::fromStdString(languageTypeToString(m_settings->getLanguage()))); + LOG_ERROR("No language type defined"); + return; } - if (m_settings->getStandard().length() > 0) - { - if (m_language->currentIndex() == 0) // c++ - { - m_cppStandard->setCurrentText(QString::fromStdString(m_settings->getStandard())); - } - else if (m_language->currentIndex() == 1) // c - { - m_cStandard->setCurrentText(QString::fromStdString(m_settings->getStandard())); - } + m_language->setText(languageTypeToString(type).c_str()); - handleSelectionChanged(m_language->currentIndex()); + m_standard->clear(); + std::vector standards = m_settings->getLanguageStandards(); + for (size_t i = 0; i < standards.size(); i++) + { + m_standard->insertItem(i, standards[i].c_str()); } + + m_standard->setCurrentText(QString::fromStdString(m_settings->getStandard())); } } @@ -76,18 +76,9 @@ void QtProjectWizzardContentData::save() m_settings->setProjectFileLocation(m_projectFileLocation->getText().toStdString()); } - if (m_language) + if (m_standard) { - m_settings->setLanguage(stringToLanguageType(m_language->currentText().toStdString())); - - if (m_cppStandard->isVisible()) - { - m_settings->setStandard(m_cppStandard->currentText().toStdString()); - } - else if (m_cStandard->isVisible()) - { - m_settings->setStandard(m_cStandard->currentText().toStdString()); - } + m_settings->setStandard(m_standard->currentText().toStdString()); } } @@ -155,10 +146,7 @@ void QtProjectWizzardContentData::addLanguageAndStandard(QGridLayout* layout, in { QLabel* languageLabel = new QLabel("Language"); languageLabel->setObjectName("label"); - m_language = new QComboBox(); - m_language->insertItem(0, "C++"); - m_language->insertItem(1, "C"); - connect(m_language, SIGNAL(currentIndexChanged(int)), this, SLOT(handleSelectionChanged(int))); + m_language = new QLabel(); layout->addWidget(languageLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight); layout->addWidget(m_language, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft); @@ -166,27 +154,11 @@ void QtProjectWizzardContentData::addLanguageAndStandard(QGridLayout* layout, in QLabel* standardLabel = createFormLabel("Standard"); - - m_cppStandard = new QComboBox(); - m_cppStandard->insertItem(0, "1z"); - m_cppStandard->insertItem(1, "14"); - m_cppStandard->insertItem(2, "1y"); - m_cppStandard->insertItem(3, "11"); - m_cppStandard->insertItem(4, "0x"); - m_cppStandard->insertItem(5, "03"); - m_cppStandard->insertItem(6, "98"); - - m_cStandard = new QComboBox(); - m_cStandard->insertItem(0, "1x"); - m_cStandard->insertItem(1, "11"); - m_cStandard->insertItem(2, "9x"); - m_cStandard->insertItem(3, "99"); - m_cStandard->insertItem(4, "90"); - m_cStandard->insertItem(5, "89"); + m_standard = new QComboBox(); layout->addWidget(standardLabel, row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight); - layout->addWidget(m_cppStandard, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft); - layout->addWidget(m_cStandard, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft); + layout->addWidget(m_standard, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft); + row++; } @@ -199,14 +171,6 @@ void QtProjectWizzardContentData::addBuildFilePicker( m_buildFilePicker = new QtLocationPicker(this); m_buildFilePicker->setFileFilter(filter); - // QPushButton* button = new QPushButton("", this); - // button->setObjectName("refreshButton"); - // button->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac - // button->setToolTip("refresh paths"); - // connect(button, SIGNAL(clicked()), this, SLOT(refreshClicked())); - - // m_buildFilePicker->layout()->addWidget(button); - layout->addWidget(m_buildFilePicker, row, QtProjectWizzardWindow::BACK_COL); row++; @@ -220,25 +184,6 @@ void QtProjectWizzardContentData::addBuildFilePicker( row++; } -void QtProjectWizzardContentData::handleSelectionChanged(int index) -{ - if (!m_language) - { - return; - } - - if (index != 0) - { - m_cStandard->show(); - m_cppStandard->hide(); - } - else - { - m_cppStandard->show(); - m_cStandard->hide(); - } -} - QtProjectWizzardContentDataCDB::QtProjectWizzardContentDataCDB( std::shared_ptr settings, QtProjectWizzardWindow* window) diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.h index c0b915f8..ce552d33 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentData.h @@ -16,7 +16,7 @@ public: QtProjectWizzardContentData(std::shared_ptr settings, QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation - virtual void populateWindow(QGridLayout* layout) override; + virtual void populateWindow(QGridLayout* layout, int& row) override; virtual void populateForm(QGridLayout* layout, int& row) override; virtual void load() override; @@ -33,14 +33,10 @@ protected: QLineEdit* m_projectName; QtLocationPicker* m_projectFileLocation; - QComboBox* m_language; - QComboBox* m_cppStandard; - QComboBox* m_cStandard; + QLabel* m_language; + QComboBox* m_standard; QtLocationPicker* m_buildFilePicker; - -private slots: - void handleSelectionChanged(int index); }; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp index 2b6056af..1c3880b8 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp @@ -5,8 +5,9 @@ #include #include "qt/element/QtDirectoryListBox.h" -#include "settings/CxxProjectSettings.h" #include "settings/ApplicationSettings.h" +#include "settings/CxxProjectSettings.h" +#include "settings/JavaProjectSettings.h" #include "utility/file/FileManager.h" #include "utility/file/FileSystem.h" #include "utility/headerSearch/StandardHeaderDetection.h" @@ -17,12 +18,6 @@ QtProjectWizzardContentPaths::QtProjectWizzardContentPaths(std::shared_ptrsetRowMinimumHeight(row++, 10); @@ -278,6 +273,20 @@ QString QtProjectWizzardContentPathsSource::getFileNamesDescription() const return "files will be indexed."; } +QtProjectWizzardContentPathsSourceJava::QtProjectWizzardContentPathsSourceJava( + std::shared_ptr settings, QtProjectWizzardWindow* window +) + : QtProjectWizzardContentPathsSource(settings, window) +{ + setInfo( + "Source Paths", + "Add all directories or files you want to index. Usually these are all source files of " + "your project or a subset of them.", + "Source Paths define the files and directories that will be indexed by Coati. Usually these are the " + "source files of your project or a subset of them." + ); +} + QtProjectWizzardContentPathsCDBHeader::QtProjectWizzardContentPathsCDBHeader( std::shared_ptr settings, QtProjectWizzardWindow* window ) @@ -452,3 +461,34 @@ void QtProjectWizzardContentPathsFrameworkSearchGlobal::save() ApplicationSettings::getInstance()->setFrameworkSearchPaths(m_list->getList()); ApplicationSettings::getInstance()->save(); } + + +QtProjectWizzardContentPathsClassJava::QtProjectWizzardContentPathsClassJava( + std::shared_ptr settings, QtProjectWizzardWindow* window +) + : QtProjectWizzardContentPaths(settings, window) +{ + setInfo( + "Class Path", + "Paths to .jar files and root directories of .class files your project depends on.", + "Enter the paths to .jar files and root directories of .class files your project depends on." + ); +} + +void QtProjectWizzardContentPathsClassJava::load() +{ + std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); + if (javaSettings) + { + m_list->setList(javaSettings->getClasspaths()); + } +} + +void QtProjectWizzardContentPathsClassJava::save() +{ + std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); + if (javaSettings) + { + javaSettings->setClasspaths(m_list->getList()); + } +} diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h index 17ef535e..39de148c 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.h @@ -20,7 +20,6 @@ public: QtProjectWizzardContentPaths(std::shared_ptr settings, QtProjectWizzardWindow* window); // QtSettingsWindow implementation - virtual void populateWindow(QGridLayout* layout) override; virtual void populateWindow(QGridLayout* layout, int& row) override; virtual void populateForm(QGridLayout* layout, int& row) override; @@ -70,6 +69,13 @@ public: virtual QString getFileNamesDescription() const override; }; +class QtProjectWizzardContentPathsSourceJava + : public QtProjectWizzardContentPathsSource +{ +public: + QtProjectWizzardContentPathsSourceJava(std::shared_ptr settings, QtProjectWizzardWindow* window); +}; + class QtProjectWizzardContentPathsCDBHeader : public QtProjectWizzardContentPathsSource { @@ -138,4 +144,16 @@ public: virtual void save() override; }; + +class QtProjectWizzardContentPathsClassJava + : public QtProjectWizzardContentPaths +{ +public: + QtProjectWizzardContentPathsClassJava(std::shared_ptr settings, QtProjectWizzardWindow* window); + + // QtProjectWizzardContent implementation + virtual void load() override; + virtual void save() override; +}; + #endif // QT_PROJECT_WIZZARD_CONTENT_PATHS_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp index 47f24355..94455bfc 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.cpp @@ -27,9 +27,8 @@ QtProjectWizzardContentPreferences::~QtProjectWizzardContentPreferences() } } -void QtProjectWizzardContentPreferences::populateWindow(QGridLayout* layout) +void QtProjectWizzardContentPreferences::populateWindow(QGridLayout* layout, int& row) { - int row = 0; populateForm(layout, row); } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h index e64c4a68..d7000c71 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPreferences.h @@ -17,7 +17,7 @@ public: ~QtProjectWizzardContentPreferences(); // QtProjectWizzardContent implementation - virtual void populateWindow(QGridLayout* layout) override; + virtual void populateWindow(QGridLayout* layout, int& row) override; virtual void populateForm(QGridLayout* layout, int& row) override; virtual void load() override; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp index 27a7e78b..85129046 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp @@ -10,39 +10,55 @@ #include "utility/solution/SolutionParserManager.h" -QtProjectWizzardContentSelect::QtProjectWizzardContentSelect(std::shared_ptr settings, QtProjectWizzardWindow* window, std::weak_ptr solutionParserManager) +QtProjectWizzardContentSelect::QtProjectWizzardContentSelect( + std::shared_ptr settings, + QtProjectWizzardWindow* window, + std::weak_ptr solutionParserManager +) : QtProjectWizzardContent(settings, window) , m_solutionParserManager(solutionParserManager) { } -void QtProjectWizzardContentSelect::populateWindow(QGridLayout* layout) +void QtProjectWizzardContentSelect::populateWindow(QGridLayout* layout, int& row) { - QPushButton* d = new QPushButton("C++"); - QPushButton* e = new QPushButton("C"); + 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); d->setObjectName("menuButton"); e->setObjectName("menuButton"); + f->setObjectName("menuButton"); d->setCheckable(true); e->setCheckable(true); + f->setCheckable(true); d->setChecked(true); m_languages = new QButtonGroup(); m_languages->addButton(d); m_languages->addButton(e); + m_languages->addButton(f); m_languages->setId(d, 0); m_languages->setId(e, 1); + m_languages->setId(f, 2); connect(m_languages, static_cast(&QButtonGroup::buttonClicked), [this](int id) { + bool isJava = stringToLanguageType(m_languages->checkedButton()->text().toStdString()) == LANGUAGE_JAVA; + m_buttons->setExclusive(false); for (int i = 0; i < m_buttons->buttons().size(); i++) { m_buttons->button(i)->setChecked(false); + + if (i != 0) + { + m_buttons->button(i)->setVisible(!isJava); + } } m_buttons->setExclusive(true); @@ -57,6 +73,7 @@ void QtProjectWizzardContentSelect::populateWindow(QGridLayout* layout) vlayout->addWidget(d); vlayout->addWidget(e); + vlayout->addWidget(f); vlayout->addStretch(); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.h index 3dd6cc73..a535d795 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.h @@ -19,10 +19,11 @@ public: PROJECT_MANAGED = 2 // use this type for all standard parser (parsers that are handled by the parser manager) }; - QtProjectWizzardContentSelect(std::shared_ptr settings, QtProjectWizzardWindow* window, std::weak_ptr solutionParserManager); + QtProjectWizzardContentSelect( + std::shared_ptr settings, QtProjectWizzardWindow* window, std::weak_ptr solutionParserManager); // QtProjectWizzardContent implementation - virtual void populateWindow(QGridLayout* layout) override; + virtual void populateWindow(QGridLayout* layout, int& row) override; virtual void save() override; virtual bool check() override; @@ -32,8 +33,6 @@ public: signals: void selected(LanguageType, QtProjectWizzardContentSelect::ProjectType); - // void selected(unsigned int type); - private: QButtonGroup* m_languages; QButtonGroup* m_buttons; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp index 72fff43d..946e603e 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp @@ -11,12 +11,6 @@ QtProjectWizzardContentSimple::QtProjectWizzardContentSimple(std::shared_ptr settings, QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation - virtual void populateWindow(QGridLayout* layout) override; virtual void populateWindow(QGridLayout* layout, int& row) override; virtual void populateForm(QGridLayout* layout, int& row) override; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp index 896b8780..1a1390ce 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp @@ -27,10 +27,8 @@ void QtProjectWizzardContentSummary::setIsForm(bool isForm) m_isForm = isForm; } -void QtProjectWizzardContentSummary::populateWindow(QGridLayout* layout) +void QtProjectWizzardContentSummary::populateWindow(QGridLayout* layout, int& row) { - int row = 0; - if (m_isForm) { populateForm(layout, row); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.h index 5256abc9..7786abe8 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSummary.h @@ -26,7 +26,7 @@ public: protected: // QtProjectWizzardContent implementation - virtual void populateWindow(QGridLayout* layout) override; + virtual void populateWindow(QGridLayout* layout, int& row) override; virtual void populateForm(QGridLayout* layout, int& row) override; virtual void load() override; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.cpp index 7a862657..882f710c 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardWindow.cpp @@ -40,7 +40,8 @@ void QtProjectWizzardWindow::populateWindow(QWidget* widget) QGridLayout* layout = new QGridLayout(); layout->setContentsMargins(0, 0, 0, 0); - m_content->populateWindow(layout); + int row = 0; + m_content->populateWindow(layout, row); if (layout->columnCount() < 2) { diff --git a/src/test/SettingsTestSuite.h b/src/test/SettingsTestSuite.h index d1469e01..221dfee4 100644 --- a/src/test/SettingsTestSuite.h +++ b/src/test/SettingsTestSuite.h @@ -109,14 +109,14 @@ public: void test_load_project_settings_from_file() { - ProjectSettings settings(FilePath("data/SettingsTestSuite/settings.xml")); - TS_ASSERT(settings.load()); + ProjectSettings settings; + TS_ASSERT(settings.load(FilePath("data/SettingsTestSuite/settings.xml"))); } void test_load_source_path_from_file() { - ProjectSettings settings(FilePath("data/SettingsTestSuite/settings.xml")); - settings.load(); + ProjectSettings settings; + settings.load(FilePath("data/SettingsTestSuite/settings.xml")); std::vector paths = settings.getSourcePaths(); TS_ASSERT_EQUALS(paths.size(), 1); @@ -125,8 +125,8 @@ public: void test_load_header_search_paths_from_file() { - CxxProjectSettings settings(FilePath("data/SettingsTestSuite/settings.xml")); - settings.load(); + CxxProjectSettings settings; + settings.load(FilePath("data/SettingsTestSuite/settings.xml")); std::vector paths = settings.getHeaderSearchPaths(); TS_ASSERT_EQUALS(paths.size(), 2);