logic: Show unknown progress dialog when refreshing (issue 341)
* refactored dialog handling * Application always provides a DialogView instance bug id = 341
This commit is contained in:
@@ -133,7 +133,7 @@ std::shared_ptr<DialogView> Application::getDialogView()
|
||||
return m_componentManager->getDialogView();
|
||||
}
|
||||
|
||||
return std::shared_ptr<DialogView>();
|
||||
return std::make_shared<DialogView>(nullptr);
|
||||
}
|
||||
|
||||
bool Application::isInTrial() const
|
||||
|
||||
@@ -9,11 +9,11 @@ DialogView::~DialogView()
|
||||
{
|
||||
}
|
||||
|
||||
void DialogView::showStatusDialog(const std::string& title, const std::string& message)
|
||||
void DialogView::showUnknownProgressDialog(const std::string& title, const std::string& message)
|
||||
{
|
||||
}
|
||||
|
||||
void DialogView::hideStatusDialog()
|
||||
void DialogView::hideUnknownProgressDialog()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ public:
|
||||
DialogView(StorageAccess* storageAccess);
|
||||
virtual ~DialogView();
|
||||
|
||||
virtual void showStatusDialog(const std::string& title, const std::string& message);
|
||||
virtual void hideStatusDialog();
|
||||
virtual void showUnknownProgressDialog(const std::string& title, const std::string& message);
|
||||
virtual void hideUnknownProgressDialog();
|
||||
|
||||
virtual void showProgressDialog(const std::string& title, const std::string& message, int progress);
|
||||
virtual void hideProgressDialog();
|
||||
|
||||
@@ -16,10 +16,8 @@ TaskCleanStorage::TaskCleanStorage(
|
||||
|
||||
void TaskCleanStorage::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
if (std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView())
|
||||
{
|
||||
dialogView->showStatusDialog("Clearing Files", std::to_string(m_filePaths.size()) + " Files");
|
||||
}
|
||||
Application::getInstance()->getDialogView()->showUnknownProgressDialog(
|
||||
"Clearing Files", std::to_string(m_filePaths.size()) + " Files");
|
||||
|
||||
m_start = utility::durationStart();
|
||||
|
||||
@@ -33,10 +31,8 @@ Task::TaskState TaskCleanStorage::doUpdate(std::shared_ptr<Blackboard> blackboar
|
||||
{
|
||||
m_storage->clearFileElements(m_filePaths, [=](int progress)
|
||||
{
|
||||
if (std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView())
|
||||
{
|
||||
dialogView->showProgressDialog("Clearing", std::to_string(m_filePaths.size()) + " Files", progress);
|
||||
}
|
||||
Application::getInstance()->getDialogView()->showProgressDialog(
|
||||
"Clearing", std::to_string(m_filePaths.size()) + " Files", progress);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -48,10 +44,8 @@ Task::TaskState TaskCleanStorage::doUpdate(std::shared_ptr<Blackboard> blackboar
|
||||
void TaskCleanStorage::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
blackboard->set("clear_time", utility::duration(m_start));
|
||||
if (std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView())
|
||||
{
|
||||
dialogView->hideProgressDialog();
|
||||
}
|
||||
|
||||
Application::getInstance()->getDialogView()->hideProgressDialog();
|
||||
}
|
||||
|
||||
void TaskCleanStorage::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
|
||||
@@ -32,22 +32,13 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
|
||||
if (dialogView)
|
||||
{
|
||||
dialogView->showStatusDialog("Finish Indexing", "Optimizing database");
|
||||
}
|
||||
dialogView->showUnknownProgressDialog("Finish Indexing", "Optimizing database");
|
||||
m_storage->optimizeMemory();
|
||||
|
||||
if (dialogView)
|
||||
{
|
||||
dialogView->showStatusDialog("Finish Indexing", "Building caches");
|
||||
}
|
||||
dialogView->showUnknownProgressDialog("Finish Indexing", "Building caches");
|
||||
m_storage->buildCaches();
|
||||
|
||||
if (dialogView)
|
||||
{
|
||||
dialogView->hideStatusDialog();
|
||||
}
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
MessageFinishedParsing().dispatch();
|
||||
|
||||
float time = utility::duration(start);
|
||||
@@ -72,19 +63,15 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
int sourceFileCount = 0;
|
||||
blackboard->get("source_file_count", sourceFileCount);
|
||||
|
||||
if (dialogView)
|
||||
{
|
||||
StorageStats stats = m_storageAccess->getStorageStats();
|
||||
|
||||
dialogView->finishedIndexingDialog(
|
||||
indexedSourceFileCount,
|
||||
sourceFileCount,
|
||||
stats.completedFileCount,
|
||||
stats.fileCount,
|
||||
time,
|
||||
m_storageAccess->getErrorCount()
|
||||
);
|
||||
}
|
||||
StorageStats stats = m_storageAccess->getStorageStats();
|
||||
dialogView->finishedIndexingDialog(
|
||||
indexedSourceFileCount,
|
||||
sourceFileCount,
|
||||
stats.completedFileCount,
|
||||
stats.fileCount,
|
||||
time,
|
||||
m_storageAccess->getErrorCount()
|
||||
);
|
||||
|
||||
return STATE_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -22,10 +22,8 @@ void TaskShowStatusDialog::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
|
||||
Task::TaskState TaskShowStatusDialog::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
if (std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView())
|
||||
{
|
||||
dialogView->showStatusDialog(m_title, m_message);
|
||||
}
|
||||
Application::getInstance()->getDialogView()->showUnknownProgressDialog(m_title, m_message);
|
||||
|
||||
return STATE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "project/Project.h"
|
||||
|
||||
#include "Application.h"
|
||||
#include "component/view/DialogView.h"
|
||||
#include "data/access/StorageAccessProxy.h"
|
||||
#include "data/indexer/IndexerCommand.h"
|
||||
@@ -32,14 +33,13 @@
|
||||
#include "utility/scheduling/TaskGroupParallel.h"
|
||||
#include "utility/scheduling/TaskReturnSuccessWhile.h"
|
||||
#include "utility/scheduling/TaskSetValue.h"
|
||||
#include "utility/ScopedFunctor.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityApp.h"
|
||||
#include "utility/utilityString.h"
|
||||
#include "utility/Version.h"
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
Project::Project(std::shared_ptr<ProjectSettings> settings, StorageAccessProxy* storageAccessProxy)
|
||||
: m_settings(settings)
|
||||
, m_storageAccessProxy(storageAccessProxy)
|
||||
@@ -101,12 +101,14 @@ bool Project::refresh(bool forceRefresh)
|
||||
break;
|
||||
}
|
||||
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
|
||||
if (!forceRefresh && needsFullRefresh && question.size() && Application::getInstance()->hasGUI())
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Yes");
|
||||
options.push_back("No");
|
||||
int result = Application::getInstance()->getDialogView()->confirm(question, options);
|
||||
int result = dialogView->confirm(question, options);
|
||||
|
||||
if (result == 1)
|
||||
{
|
||||
@@ -118,13 +120,21 @@ bool Project::refresh(bool forceRefresh)
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Ok");
|
||||
Application::getInstance()->getDialogView()->confirm("You can't refresh the project in trial mode, please unlock with a license key.", options);
|
||||
dialogView->confirm("You can't refresh the project in trial mode, please unlock with a license key.", options);
|
||||
|
||||
MessageDispatchWhenLicenseValid(std::make_shared<MessageRefresh>()).dispatch();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Processing Files");
|
||||
|
||||
ScopedFunctor dialogHider([&dialogView](){
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
});
|
||||
|
||||
|
||||
if (m_state == PROJECT_STATE_NEEDS_MIGRATION)
|
||||
{
|
||||
m_settings->migrate();
|
||||
@@ -365,6 +375,8 @@ bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh)
|
||||
options.preprocessorOnlyVisible = hasCXXSourceGroup;
|
||||
options.preprocessorOnly = false;
|
||||
|
||||
Application::getInstance()->getDialogView()->hideUnknownProgressDialog();
|
||||
|
||||
options = Application::getInstance()->getDialogView()->startIndexingDialog(
|
||||
filesToClean.size(), filesToIndex.size(), allSourceFilePaths.size(), options);
|
||||
|
||||
@@ -465,7 +477,7 @@ void Project::buildIndex(const std::set<FilePath>& filesToClean, bool fullRefres
|
||||
taskParserWrapper->setTask(taskParallelIndexing);
|
||||
|
||||
// add tasks for indexing and merging
|
||||
for (size_t i = 0; i < indexerThreadCount && i < indexerCommandList->size(); i++)
|
||||
for (int i = 0; i < indexerThreadCount && size_t(i) < indexerCommandList->size(); i++)
|
||||
{
|
||||
taskParallelIndexing->addChildTasks(
|
||||
std::make_shared<TaskDecoratorRepeat>(TaskDecoratorRepeat::CONDITION_WHILE_SUCCESS, Task::STATE_SUCCESS)->addChildTask(
|
||||
|
||||
@@ -25,7 +25,7 @@ QtDialogView::~QtDialogView()
|
||||
m_resultReady = true;
|
||||
}
|
||||
|
||||
void QtDialogView::showStatusDialog(const std::string& title, const std::string& message)
|
||||
void QtDialogView::showUnknownProgressDialog(const std::string& title, const std::string& message)
|
||||
{
|
||||
MessageStatus(title + ": " + message, false, true).dispatch();
|
||||
|
||||
@@ -33,12 +33,12 @@ void QtDialogView::showStatusDialog(const std::string& title, const std::string&
|
||||
[=]()
|
||||
{
|
||||
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
|
||||
if (!window || window->getType() != QtIndexingDialog::DIALOG_STATUS)
|
||||
if (!window || window->getType() != QtIndexingDialog::DIALOG_UNKNOWN_PROGRESS)
|
||||
{
|
||||
m_windowStack.clearWindows();
|
||||
|
||||
window = createWindow<QtIndexingDialog>();
|
||||
window->setupStatus();
|
||||
window->setupUnknownProgress();
|
||||
}
|
||||
|
||||
window->updateTitle(title.c_str());
|
||||
@@ -49,7 +49,7 @@ void QtDialogView::showStatusDialog(const std::string& title, const std::string&
|
||||
);
|
||||
}
|
||||
|
||||
void QtDialogView::hideStatusDialog()
|
||||
void QtDialogView::hideUnknownProgressDialog()
|
||||
{
|
||||
MessageStatus("", false, false).dispatch();
|
||||
|
||||
@@ -57,7 +57,7 @@ void QtDialogView::hideStatusDialog()
|
||||
[=]()
|
||||
{
|
||||
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
|
||||
if (window && window->getType() == QtIndexingDialog::DIALOG_STATUS)
|
||||
if (window && window->getType() == QtIndexingDialog::DIALOG_UNKNOWN_PROGRESS)
|
||||
{
|
||||
m_windowStack.popWindow();
|
||||
}
|
||||
@@ -127,7 +127,7 @@ DialogView::IndexingOptions QtDialogView::startIndexingDialog(
|
||||
result = o;
|
||||
m_resultReady = true;
|
||||
|
||||
setUIBlocked(false);
|
||||
setUIBlocked(o.startIndexing);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -254,7 +254,7 @@ void QtDialogView::handleMessage(MessageInterruptTasks* message)
|
||||
QtIndexingDialog* window = dynamic_cast<QtIndexingDialog*>(m_windowStack.getTopWindow());
|
||||
if (window && window->getType() == QtIndexingDialog::DIALOG_INDEXING)
|
||||
{
|
||||
showStatusDialog("Interrupting Indexing", "Waiting for indexer\nthreads to finish");
|
||||
showUnknownProgressDialog("Interrupting Indexing", "Waiting for indexer\nthreads to finish");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -28,8 +28,8 @@ public:
|
||||
QtDialogView(QtMainWindow* mainWindow, StorageAccess* storageAccess);
|
||||
virtual ~QtDialogView();
|
||||
|
||||
virtual void showStatusDialog(const std::string& title, const std::string& message) override;
|
||||
virtual void hideStatusDialog() override;
|
||||
virtual void showUnknownProgressDialog(const std::string& title, const std::string& message) override;
|
||||
virtual void hideUnknownProgressDialog() override;
|
||||
|
||||
virtual void showProgressDialog(const std::string& title, const std::string& message, int progress) override;
|
||||
virtual void hideProgressDialog() override;
|
||||
|
||||
@@ -194,9 +194,9 @@ void QtIndexingDialog::setupReport(
|
||||
finishSetup();
|
||||
}
|
||||
|
||||
void QtIndexingDialog::setupStatus()
|
||||
void QtIndexingDialog::setupUnknownProgress()
|
||||
{
|
||||
setType(DIALOG_STATUS);
|
||||
setType(DIALOG_UNKNOWN_PROGRESS);
|
||||
|
||||
QBoxLayout* layout = createLayout();
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
enum DialogType
|
||||
{
|
||||
DIALOG_MESSAGE,
|
||||
DIALOG_STATUS,
|
||||
DIALOG_UNKNOWN_PROGRESS,
|
||||
DIALOG_PROGRESS,
|
||||
DIALOG_INDEXING
|
||||
};
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
void setupReport(
|
||||
size_t indexedFileCount, size_t totalIndexedFileCount, size_t completedFileCount, size_t totalFileCount, float time);
|
||||
|
||||
void setupStatus();
|
||||
void setupUnknownProgress();
|
||||
void setupProgress();
|
||||
|
||||
void updateMessage(QString message);
|
||||
|
||||
@@ -128,8 +128,9 @@ std::vector<std::string> QtProjectWizzardContentPathSourceMaven::getFileNames()
|
||||
const FilePath mavenProjectRoot = javaSettings->getAbsoluteMavenProjectFilePath().parentDirectory();
|
||||
|
||||
std::vector<std::string> list;
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
|
||||
Application::getInstance()->getDialogView()->showStatusDialog("Preparing Project", "Maven\nGenerating Source Files");
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nGenerating Source Files");
|
||||
const bool success = utility::mavenGenerateSources(mavenPath, mavenProjectRoot);
|
||||
if (!success)
|
||||
{
|
||||
@@ -143,7 +144,7 @@ std::vector<std::string> QtProjectWizzardContentPathSourceMaven::getFileNames()
|
||||
}
|
||||
else
|
||||
{
|
||||
Application::getInstance()->getDialogView()->showStatusDialog("Preparing Project", "Maven\nFetching Source Directories");
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nFetching Source Directories");
|
||||
const std::vector<FilePath> sourceDirectories = utility::mavenGetAllDirectoriesFromEffectivePom(
|
||||
mavenPath,
|
||||
mavenProjectRoot,
|
||||
@@ -169,7 +170,7 @@ std::vector<std::string> QtProjectWizzardContentPathSourceMaven::getFileNames()
|
||||
list.push_back(path.str());
|
||||
}
|
||||
}
|
||||
Application::getInstance()->getDialogView()->hideStatusDialog();
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "project/SourceGroupJava.h"
|
||||
|
||||
#include "Application.h"
|
||||
#include "component/view/DialogView.h"
|
||||
#include "data/indexer/IndexerCommandJava.h"
|
||||
#include "data/parser/java/JavaEnvironmentFactory.h"
|
||||
@@ -14,8 +15,6 @@
|
||||
#include "utility/utilityMaven.h"
|
||||
#include "utility/utilityString.h"
|
||||
#include "utility/utility.h"
|
||||
#include "Application.h"
|
||||
|
||||
|
||||
SourceGroupJava::SourceGroupJava(std::shared_ptr<SourceGroupSettingsJava> settings)
|
||||
: m_settings(settings)
|
||||
@@ -51,21 +50,14 @@ void SourceGroupJava::fetchAllSourceFilePaths()
|
||||
std::vector<FilePath> sourcePaths;
|
||||
if (m_settings->getAbsoluteMavenProjectFilePath().exists())
|
||||
{
|
||||
std::shared_ptr<Application> application = Application::getInstance();
|
||||
|
||||
if (application && application->hasGUI())
|
||||
{
|
||||
application->getDialogView()->showStatusDialog("Preparing Project", "Maven\nFetching Source Directories");
|
||||
}
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nFetching Source Directories");
|
||||
|
||||
const FilePath mavenPath(ApplicationSettings::getInstance()->getMavenPath());
|
||||
const FilePath projectRootPath = m_settings->getAbsoluteMavenProjectFilePath().parentDirectory();
|
||||
sourcePaths = utility::mavenGetAllDirectoriesFromEffectivePom(mavenPath, projectRootPath, m_settings->getShouldIndexMavenTests());
|
||||
|
||||
if (application && application->hasGUI())
|
||||
{
|
||||
application->getDialogView()->hideStatusDialog();
|
||||
}
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -166,40 +158,28 @@ bool SourceGroupJava::prepareMavenData()
|
||||
const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath();
|
||||
const FilePath projectRootPath = m_settings->getAbsoluteMavenProjectFilePath().parentDirectory();
|
||||
|
||||
ScopedFunctor dialogHider;
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nGenerating Source Files");
|
||||
|
||||
std::shared_ptr<Application> application = Application::getInstance();
|
||||
|
||||
if (application && application->hasGUI())
|
||||
{
|
||||
// this makes sure to hide the dialog when leaving this method.
|
||||
dialogHider = ScopedFunctor([](){
|
||||
Application::getInstance()->getDialogView()->hideStatusDialog();
|
||||
});
|
||||
Application::getInstance()->getDialogView()->showStatusDialog("Preparing Project", "Maven\nGenerating Source Files");
|
||||
}
|
||||
ScopedFunctor dialogHider([&dialogView](){
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
});
|
||||
|
||||
bool success = utility::mavenGenerateSources(mavenPath, projectRootPath);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
if (application && application->hasGUI())
|
||||
{
|
||||
const std::string dialogMessage =
|
||||
"Sourcetrail was unable to locate Maven on this machine.\n"
|
||||
"Please make sure to provide the correct Maven Path in the preferences.";
|
||||
const std::string dialogMessage =
|
||||
"Sourcetrail 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();
|
||||
MessageStatus(dialogMessage, true, false).dispatch();
|
||||
|
||||
Application::getInstance()->handleDialog(dialogMessage);
|
||||
}
|
||||
Application::getInstance()->handleDialog(dialogMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (application && application->hasGUI())
|
||||
{
|
||||
Application::getInstance()->getDialogView()->showStatusDialog("Preparing Project", "Maven\nExporting Dependencies");
|
||||
}
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nExporting Dependencies");
|
||||
|
||||
utility::mavenCopyDependencies(
|
||||
mavenPath, projectRootPath, m_settings->getAbsoluteMavenDependenciesDirectory()
|
||||
@@ -247,13 +227,13 @@ std::vector<FilePath> SourceGroupJava::getClassPath()
|
||||
|
||||
std::set<FilePath> SourceGroupJava::fetchRootDirectories()
|
||||
{
|
||||
if (std::shared_ptr<Application> application = Application::getInstance())
|
||||
{
|
||||
if (application->hasGUI())
|
||||
{
|
||||
application->getDialogView()->showStatusDialog("Preparing Project", "Gathering Root\nDirectories");
|
||||
}
|
||||
}
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Gathering Root\nDirectories");
|
||||
|
||||
ScopedFunctor dialogHider([&dialogView](){
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
});
|
||||
|
||||
std::set<FilePath> rootDirectories;
|
||||
|
||||
std::shared_ptr<JavaEnvironment> javaEnvironment = JavaEnvironmentFactory::getInstance()->createEnvironment();
|
||||
@@ -289,10 +269,5 @@ std::set<FilePath> SourceGroupJava::fetchRootDirectories()
|
||||
}
|
||||
}
|
||||
|
||||
if (Application::getInstance()->hasGUI())
|
||||
{
|
||||
Application::getInstance()->getDialogView()->hideStatusDialog();
|
||||
}
|
||||
|
||||
return rootDirectories;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user