summaryrefslogtreecommitdiff
path: root/ui/gui_status_handler.h
blob: 3cc0a6bf13d298b38f363b8102a65976f075b2af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// **************************************************************************
// * This file is part of the FreeFileSync project. It is distributed under *
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html       *
// * Copyright (C) ZenJu (zenju AT gmx DOT de) - All Rights Reserved        *
// **************************************************************************

#ifndef GUISTATUSHANDLER_H_INCLUDED
#define GUISTATUSHANDLER_H_INCLUDED

#include <wx/event.h>
#include <zen/error_log.h>
#include <wx/stopwatch.h>
#include "progress_indicator.h"
#include "../lib/status_handler.h"
#include "../lib/process_xml.h"
#include "main_dlg.h"

class SyncStatus;
class wxCommandEvent;

//Exception class used to abort the "compare" and "sync" process
class GuiAbortProcess {};

//classes handling sync and compare error as well as status information
class CompareStatusHandler : private wxEvtHandler, public zen::StatusHandler
{
public:
    CompareStatusHandler(MainDialog& dlg);
    ~CompareStatusHandler();

    virtual void initNewPhase     (int objectsTotal, zen::Int64 dataTotal, Phase phaseID);
    virtual void forceUiRefresh();

    virtual Response reportError(const std::wstring& text);
    virtual void reportFatalError(const std::wstring& errorMessage);
    virtual void reportWarning(const std::wstring& warningMessage, bool& warningActive);

private:
    void OnKeyPressed(wxKeyEvent& event);
    void OnAbortCompare(wxCommandEvent& event); //handle abort button click
    virtual void abortThisProcess(); //throw GuiAbortProcess

    MainDialog& mainDlg;
    bool ignoreErrors;
};


class SyncStatusHandler : public zen::StatusHandler
{
public:
    SyncStatusHandler(MainDialog* parentDlg,
                      xmlAccess::OnGuiError handleError,
                      const std::wstring& jobName,
                      const std::wstring& execWhenFinished,
                      std::vector<std::wstring>& execFinishedHistory);
    ~SyncStatusHandler();

    virtual void initNewPhase     (int objectsTotal, zen::Int64 dataTotal, Phase phaseID);
    virtual void updateProcessedData(int objectsDelta, zen::Int64 dataDelta);
    virtual void reportInfo(const std::wstring& text);
    virtual void forceUiRefresh();

    virtual Response reportError(const std::wstring& text);
    virtual void reportFatalError(const std::wstring& errorMessage);
    virtual void reportWarning(const std::wstring& warningMessage, bool& warningActive);

private:
    virtual void abortThisProcess(); //throw GuiAbortProcess

    MainDialog* parentDlg_;
    SyncStatus syncStatusFrame; //the window managed by SyncStatus has longer lifetime than this handler!
    xmlAccess::OnGuiError handleError_;
    zen::ErrorLog errorLog;
    const std::wstring jobName_;
    wxStopWatch totalTime;
};


#endif // GUISTATUSHANDLER_H_INCLUDED
bgstack15