diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp index 2d65ce96287..2202a6c6b26 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp @@ -181,6 +181,13 @@ void JsonWizard::accept() return; } emit filesReady(m_files); + if (!JsonWizardGenerator::allDone(this, &list, &errorMessage)) { + if (!errorMessage.isEmpty()) + QMessageBox::warning(this, tr("Failed to Open Files"), errorMessage); + return; + } + + emit allDone(m_files); } } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard.h b/src/plugins/projectexplorer/jsonwizard/jsonwizard.h index cbb0c3bc584..29b099e2a9b 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizard.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard.h @@ -91,6 +91,7 @@ signals: void preWriteFiles(const JsonWizard::GeneratorFiles &files); // emitted before files are written to disk. void postProcessFiles(const JsonWizard::GeneratorFiles &files); // emitted before files are post-processed. void filesReady(const JsonWizard::GeneratorFiles &files); // emitted just after files are in final state on disk. + void allDone(const JsonWizard::GeneratorFiles &files); // emitted just after the wizard is done with the files. They are ready to be opened. public slots: void accept(); diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp index 458502daa8d..811a52d7102 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp @@ -192,6 +192,14 @@ bool JsonWizardFileGenerator::writeFile(const JsonWizard *wizard, Core::Generate } bool JsonWizardFileGenerator::postWrite(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage) +{ + Q_UNUSED(wizard); + Q_UNUSED(file); + Q_UNUSED(errorMessage); + return true; +} + +bool JsonWizardFileGenerator::allDone(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage) { Q_UNUSED(wizard); if (file->attributes() & Core::GeneratedFile::OpenProjectAttribute) { diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.h b/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.h index 9fc3e66b25c..8e4ec621a6a 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.h @@ -50,6 +50,7 @@ public: bool writeFile(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage); bool postWrite(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage); + bool allDone(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage); private: class File { diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.cpp index 99d94e86172..88e9810aee3 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.cpp @@ -227,6 +227,15 @@ bool JsonWizardGenerator::postWrite(const JsonWizard *wizard, JsonWizard::Genera return true; } +bool JsonWizardGenerator::allDone(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, QString *errorMessage) +{ + for (auto i = files->begin(); i != files->end(); ++i) { + if (!i->generator->allDone(wizard, &(i->file), errorMessage)) + return false; + } + return true; +} + // -------------------------------------------------------------------- // JsonWizardGeneratorFactory: // -------------------------------------------------------------------- diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.h b/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.h index b40a9fa63ac..ed0af4b70c4 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.h @@ -55,6 +55,7 @@ public: virtual bool formatFile(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage); virtual bool writeFile(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage) = 0; virtual bool postWrite(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage) = 0; + virtual bool allDone(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage) = 0; virtual bool canKeepExistingFiles() const { return true; } @@ -64,6 +65,7 @@ public: static bool formatFiles(const JsonWizard *wizard, QList *files, QString *errorMessage); static bool writeFiles(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, QString *errorMessage); static bool postWrite(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, QString *errorMessage); + static bool allDone(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, QString *errorMessage); }; class JsonWizardGeneratorFactory : public QObject