ui/logic/data: refreshing only source files that have been updated

This change adds the refresh component that allows for refreshing the source code via UI or shortcut. If automatic
refreshing is activated via the UI, the code is refreshed anytime the window gets focus. The contents of all the
updated source files get removed from Storage, before reparsing them. File dependencies are not respected yet.
This commit is contained in:
Eberhard Graether
2015-02-03 14:27:39 +01:00
parent e17341fc43
commit 1690479b0e
52 changed files with 1145 additions and 92 deletions
+11
View File
@@ -3,11 +3,13 @@
#include "component/Component.h"
#include "component/controller/CodeController.h"
#include "component/controller/GraphController.h"
#include "component/controller/RefreshController.h"
#include "component/controller/SearchController.h"
#include "component/controller/StatusBarController.h"
#include "component/controller/UndoRedoController.h"
#include "component/view/CodeView.h"
#include "component/view/GraphView.h"
#include "component/view/RefreshView.h"
#include "component/view/SearchView.h"
#include "component/view/StatusBarView.h"
#include "component/view/UndoRedoView.h"
@@ -47,6 +49,15 @@ std::shared_ptr<Component> ComponentFactory::createGraphComponent()
return component;
}
std::shared_ptr<Component> ComponentFactory::createRefreshComponent()
{
std::shared_ptr<View> view = m_viewFactory->createRefreshView(m_viewLayout);
std::shared_ptr<RefreshController> controller = std::make_shared<RefreshController>();
std::shared_ptr<Component> component = std::make_shared<Component>(view, controller);
return component;
}
std::shared_ptr<Component> ComponentFactory::createSearchComponent()
{
std::shared_ptr<SearchView> view = m_viewFactory->createSearchView(m_viewLayout);
+1
View File
@@ -21,6 +21,7 @@ public:
std::shared_ptr<Component> createCodeComponent();
std::shared_ptr<Component> createGraphComponent();
std::shared_ptr<Component> createRefreshComponent();
std::shared_ptr<Component> createSearchComponent();
std::shared_ptr<Component> createStatusBarComponent();
std::shared_ptr<Component> createUndoRedoComponent();
+6 -3
View File
@@ -24,14 +24,17 @@ void ComponentManager::setup()
std::shared_ptr<Component> codeComponent = m_componentFactory->createCodeComponent();
m_components.push_back(codeComponent);
std::shared_ptr<Component> undoRedoComponent = m_componentFactory->createUndoRedoComponent();
m_components.push_back(undoRedoComponent);
std::shared_ptr<Component> refreshComponent = m_componentFactory->createRefreshComponent();
m_components.push_back(refreshComponent);
std::shared_ptr<Component> searchComponent = m_componentFactory->createSearchComponent();
m_components.push_back(searchComponent);
std::shared_ptr<Component> statusBarComponent = m_componentFactory->createStatusBarComponent();
m_components.push_back(statusBarComponent);
std::shared_ptr<Component> undoRedoComponent = m_componentFactory->createUndoRedoComponent();
m_components.push_back(undoRedoComponent);
}
ComponentManager::ComponentManager()
@@ -0,0 +1,35 @@
#include "component/controller/RefreshController.h"
#include "component/view/RefreshView.h"
RefreshController::RefreshController()
: m_autoRefreshEnabled(false)
{
}
RefreshController::~RefreshController()
{
}
void RefreshController::handleMessage(MessageAutoRefreshChanged* message)
{
m_autoRefreshEnabled = message->enabled;
}
void RefreshController::handleMessage(MessageRefresh* message)
{
getView()->refreshView();
}
void RefreshController::handleMessage(MessageWindowFocus* message)
{
if (m_autoRefreshEnabled)
{
MessageRefresh().dispatch();
}
}
RefreshView* RefreshController::getView()
{
return Controller::getView<RefreshView>();
}
@@ -0,0 +1,32 @@
#ifndef REFRESH_CONTROLLER_H
#define REFRESH_CONTROLLER_H
#include "component/controller/Controller.h"
#include "utility/messaging/MessageListener.h"
#include "utility/messaging/type/MessageAutoRefreshChanged.h"
#include "utility/messaging/type/MessageRefresh.h"
#include "utility/messaging/type/MessageWindowFocus.h"
class RefreshView;
class RefreshController
: public Controller
, public MessageListener<MessageAutoRefreshChanged>
, public MessageListener<MessageRefresh>
, public MessageListener<MessageWindowFocus>
{
public:
RefreshController();
virtual ~RefreshController();
private:
virtual void handleMessage(MessageAutoRefreshChanged* message);
virtual void handleMessage(MessageRefresh* message);
virtual void handleMessage(MessageWindowFocus* message);
RefreshView* getView();
bool m_autoRefreshEnabled;
};
#endif // REFRESH_CONTROLLER_H
@@ -28,6 +28,7 @@ void StatusBarController::handleMessage(MessageFinishedParsing* message)
{
std::stringstream ss;
ss << "Parsing Finished: ";
ss << message->fileCount << " files, ";
ss << std::setprecision(2) << message->parseTime << " seconds, ";
ss << message->errorCount << " error(s)";
+22
View File
@@ -0,0 +1,22 @@
#include "component/view/RefreshView.h"
#include "component/controller/RefreshController.h"
RefreshView::RefreshView(ViewLayout* viewLayout)
: View(viewLayout, Vec2i(100, 100))
{
}
RefreshView::~RefreshView()
{
}
std::string RefreshView::getName() const
{
return "RefreshView";
}
RefreshController* RefreshView::getController()
{
return View::getController<RefreshController>();
}
+21
View File
@@ -0,0 +1,21 @@
#ifndef REFRESH_VIEW_H
#define REFRESH_VIEW_H
#include "component/view/View.h"
class RefreshController;
class RefreshView
: public View
{
public:
RefreshView(ViewLayout* viewLayout);
virtual ~RefreshView();
virtual std::string getName() const;
private:
RefreshController* getController();
};
#endif // REFRESH_VIEW_H
+2
View File
@@ -6,6 +6,7 @@
class CodeView;
class GraphView;
class MainView;
class RefreshView;
class SearchView;
class StatusBarView;
class UndoRedoView;
@@ -20,6 +21,7 @@ public:
virtual std::shared_ptr<MainView> createMainView() const = 0;
virtual std::shared_ptr<CodeView> createCodeView(ViewLayout* viewLayout) const = 0;
virtual std::shared_ptr<GraphView> createGraphView(ViewLayout* viewLayout) const = 0;
virtual std::shared_ptr<RefreshView> createRefreshView(ViewLayout* viewLayout) const = 0;
virtual std::shared_ptr<SearchView> createSearchView(ViewLayout* viewLayout) const = 0;
virtual std::shared_ptr<StatusBarView> createStatusBarView(ViewLayout* viewLayout) const = 0;
virtual std::shared_ptr<UndoRedoView> createUndoRedoView(ViewLayout* viewLayout) const = 0;