DeleteRemoteTagDlg: Allow to delete multiple tags at once
[TortoiseGit.git] / src / TortoiseProc / GitProgressDlg.h
bloba56f97807a2e4292a65486c80b7c207f31ab776a
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - TortoiseGit
4 // Copyright (C) 2003-2008 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #pragma once
22 #include "StandAloneDlg.h"
23 #include "TGitPath.h"
24 #include "ProjectProperties.h"
25 #include "Git.h"
26 #include "GitStatus.h"
27 #include "Colors.h"
28 //#include "..\IBugTraqProvider\IBugTraqProvider_h.h"
29 #include "afxwin.h"
30 #include "Win7.h"
32 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);
34 /**
35 * \ingroup TortoiseProc
36 * Options which can be used to configure the way the dialog box works
38 typedef enum
40 ProgOptNone = 0,
41 ProgOptRecursive = 0x01,
42 ProgOptNonRecursive = 0x00,
43 /// Don't actually do the merge - just practice it
44 ProgOptDryRun = 0x04,
45 ProgOptIgnoreExternals = 0x08,
46 ProgOptKeeplocks = 0x10,
47 /// for locking this means steal the lock, for unlocking it means breaking the lock
48 ProgOptLockForce = 0x20,
49 ProgOptSwitchAfterCopy = 0x40,
50 ProgOptIncludeIgnored = 0x80,
51 ProgOptIgnoreAncestry = 0x100,
52 ProgOptEolDefault = 0x200,
53 ProgOptEolCRLF = 0x400,
54 ProgOptEolLF = 0x800,
55 ProgOptEolCR = 0x1000,
56 ProgOptSkipConflictCheck = 0x2000,
57 ProgOptRecordOnly = 0x4000
58 } ProgressOptions;
60 typedef enum
62 CLOSE_MANUAL = 0,
63 CLOSE_NOERRORS,
64 CLOSE_NOCONFLICTS,
65 CLOSE_NOMERGES,
66 CLOSE_LOCAL
67 } ProgressCloseOptions;
69 #define WM_SHOWCONFLICTRESOLVER (WM_APP + 100)
71 typedef enum
73 git_wc_notify_add,
74 git_wc_notify_sendmail_start,
75 git_wc_notify_sendmail_error,
76 git_wc_notify_sendmail_retry,
77 git_wc_notify_sendmail_done,
78 git_wc_notify_resolved,
79 git_wc_notify_revert,
81 }git_wc_notify_action_t;
82 typedef enum
84 SENDMAIL_ATTACHMENT =0x1,
85 SENDMAIL_COMBINED =0x2,
86 SENDMAIL_MAPI =0x4
88 /**
89 * \ingroup TortoiseProc
90 * Handles different Subversion commands and shows the notify messages
91 * in a listbox. Since several Subversion commands have similar notify
92 * messages they are grouped together in this single class.
94 class CGitProgressDlg : public CResizableStandAloneDialog
96 public:
97 typedef enum
99 GitProgress_Add,
100 GitProgress_Checkout,
101 GitProgress_Copy,
102 GitProgress_Export,
103 GitProgress_Rename,
104 GitProgress_Resolve,
105 GitProgress_Revert,
106 GitProgress_Switch,
107 GitProgress_SendMail,
108 } Command;
111 DECLARE_DYNAMIC(CGitProgressDlg)
113 public:
115 CGitProgressDlg(CWnd* pParent = NULL);
116 virtual ~CGitProgressDlg();
119 void SetCommand(Command cmd) {m_Command = cmd;}
120 void SetAutoClose(DWORD ac) {m_dwCloseOnEnd = ac;}
121 void SetOptions(DWORD opts) {m_options = opts;}
122 void SetPathList(const CTGitPathList& pathList) {m_targetPathList = pathList;}
123 void SetUrl(const CString& url) {m_url.SetFromUnknown(url);}
124 void SetSecondUrl(const CString& url) {m_url2.SetFromUnknown(url);}
125 void SetCommitMessage(const CString& msg) {m_sMessage = msg;}
127 // void SetRevision(const GitRev& rev) {m_Revision = rev;}
128 // void SetRevisionEnd(const GitRev& rev) {m_RevisionEnd = rev;}
130 void SetDiffOptions(const CString& opts) {m_diffoptions = opts;}
131 void SetSendMailOption(CString &TO, CString &CC,CString &Subject,DWORD flags){m_SendMailTO=TO;m_SendMailSubject=Subject; m_SendMailCC=CC;this->m_SendMailFlags = flags;}
132 void SetDepth(git_depth_t depth = git_depth_unknown) {m_depth = depth;}
133 void SetPegRevision(GitRev pegrev = GitRev()) {m_pegRev = pegrev;}
134 void SetProjectProperties(ProjectProperties props) {m_ProjectProperties = props;}
135 void SetChangeList(const CString& changelist, bool keepchangelist) {m_changelist = changelist; m_keepchangelist = keepchangelist;}
136 void SetSelectedList(const CTGitPathList& selPaths);
137 // void SetRevisionRanges(const GitRevRangeArray& revArray) {m_revisionArray = revArray;}
138 // void SetBugTraqProvider(const CComPtr<IBugTraqProvider> pBugtraqProvider) { m_BugTraqProvider = pBugtraqProvider;}
140 * If the number of items for which the operation is done on is known
141 * beforehand, that number can be set here. It is then used to show a more
142 * accurate progress bar during the operation.
144 void SetItemCount(long count) {if(count) m_itemCountTotal = count;}
146 bool SetBackgroundImage(UINT nID);
148 bool DidErrorsOccur() {return m_bErrorsOccurred;}
150 enum { IDD = IDD_SVNPROGRESS };
152 private:
153 class NotificationData
155 public:
156 NotificationData()
157 : color(::GetSysColor(COLOR_WINDOWTEXT))
159 git_wc_notify_action_t action;
160 #if 0
161 action((git_wc_notify_action_t)-1),
162 kind(git_node_none),
163 content_state(git_wc_notify_state_inapplicable),
164 prop_state(git_wc_notify_state_inapplicable),
165 rev(0),
167 bConflictedActionItem(false),
168 bAuxItem(false)
170 // lock_state(git_wc_notify_lock_state_unchanged)
172 // merge_range.end = 0;
173 // merge_range.start = 0;
175 #endif
176 public:
177 // The text we put into the first column (the Git action for normal items, just text for aux items)
178 CString sActionColumnText;
179 CTGitPath path;
180 CTGitPath basepath;
181 // CString changelistname;
183 /// git_wc_notify_action_t action;
184 // git_node_kind_t kind;
185 // CString mime_type;
186 // git_wc_notify_state_t content_state;
187 // git_wc_notify_state_t prop_state;
188 // git_wc_notify_lock_state_t lock_state;
189 // git_merge_range_t merge_range;
190 git_revnum_t rev;
191 COLORREF color;
192 // CString owner; ///< lock owner
193 bool bConflictedActionItem; // Is this item a conflict?
194 bool bAuxItem; // Set if this item is not a true 'Git action'
195 CString sPathColumnText;
198 protected:
200 //Need update in the future implement the virtual methods from Git base class
201 virtual BOOL Notify(const CTGitPath& path,
202 git_wc_notify_action_t action,
203 int status = 0,
204 CString *strErr =NULL
206 git_node_kind_t kind, const CString& mime_type,
207 git_wc_notify_state_t content_state,
208 git_wc_notify_state_t prop_state, LONG rev,
209 const git_lock_t * lock, git_wc_notify_lock_state_t lock_state,
210 const CString& changelistname,
211 git_merge_range_t * range,
212 git_error_t * err, apr_pool_t * pool*/
215 // virtual git_wc_conflict_choice_t ConflictResolveCallback(const git_wc_conflict_description_t *description, CString& mergedfile);
216 virtual BOOL OnInitDialog();
217 virtual BOOL Cancel();
218 virtual void OnCancel();
219 virtual BOOL PreTranslateMessage(MSG* pMsg);
220 virtual void DoDataExchange(CDataExchange* pDX);
222 afx_msg void OnNMCustomdrawSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
223 afx_msg void OnLvnGetdispinfoSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
224 afx_msg void OnNMDblclkSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
225 afx_msg void OnBnClickedLogbutton();
226 afx_msg void OnBnClickedOk();
227 afx_msg void OnBnClickedNoninteractive();
228 afx_msg void OnHdnItemclickSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
229 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
230 afx_msg void OnClose();
231 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
232 afx_msg LRESULT OnGitProgress(WPARAM wParam, LPARAM lParam);
233 afx_msg void OnTimer(UINT_PTR nIDEvent);
234 afx_msg void OnEnSetfocusInfotext();
235 afx_msg void OnLvnBegindragSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
236 afx_msg void OnSize(UINT nType, int cx, int cy);
237 afx_msg LRESULT OnTaskbarBtnCreated(WPARAM wParam, LPARAM lParam);
238 LRESULT OnShowConflictResolver(WPARAM, LPARAM);
240 DECLARE_MESSAGE_MAP()
242 void Sort();
243 static bool SortCompare(const NotificationData* pElem1, const NotificationData* pElem2);
245 static BOOL m_bAscending;
246 static int m_nSortedColumn;
247 CStringList m_ExtStack;
249 private:
250 static UINT ProgressThreadEntry(LPVOID pVoid);
251 UINT ProgressThread();
252 virtual void OnOK();
253 void ReportGitError();
254 void ReportError(const CString& sError);
255 void ReportWarning(const CString& sWarning);
256 void ReportNotification(const CString& sNotification);
257 void ReportCmd(const CString& sCmd);
258 void ReportString(CString sMessage, const CString& sMsgKind, COLORREF color = ::GetSysColor(COLOR_WINDOWTEXT));
259 void AddItemToList();
260 CString BuildInfoString();
261 CString GetPathFromColumnText(const CString& sColumnText);
264 * Resizes the columns of the progress list so that the headings are visible.
266 void ResizeColumns();
268 /// Predicate function to tell us if a notification data item is auxiliary or not
269 static bool NotificationDataIsAux(const NotificationData* pData);
271 // the commands to execute
272 bool CmdAdd(CString& sWindowTitle, bool& localoperation);
273 bool CmdCheckout(CString& sWindowTitle, bool& localoperation);
274 bool CmdCopy(CString& sWindowTitle, bool& localoperation);
275 bool CmdExport(CString& sWindowTitle, bool& localoperation);
276 bool CmdRename(CString& sWindowTitle, bool& localoperation);
277 bool CmdResolve(CString& sWindowTitle, bool& localoperation);
278 bool CmdRevert(CString& sWindowTitle, bool& localoperation);
279 bool CmdSwitch(CString& sWindowTitle, bool& localoperation);
280 bool CmdSendMail(CString& sWindowTitle, bool& localoperation);
282 private:
283 typedef std::map<CStringA, git_revnum_t> StringRevMap;
284 typedef std::vector<NotificationData *> NotificationDataVect;
287 CString m_mergedfile;
288 NotificationDataVect m_arData;
290 CWinThread* m_pThread;
291 volatile LONG m_bThreadRunning;
293 ProjectProperties m_ProjectProperties;
294 CListCtrl m_ProgList;
295 Command m_Command;
296 int m_options; // Use values from the ProgressOptions enum
297 git_depth_t m_depth;
298 CTGitPathList m_targetPathList;
299 CTGitPathList m_selectedPaths;
300 CTGitPath m_url;
301 CTGitPath m_url2;
302 CString m_sMessage;
303 CString m_diffoptions;
304 GitRev m_Revision;
305 GitRev m_RevisionEnd;
306 GitRev m_pegRev;
307 // GitRevRangeArray m_revisionArray;
308 CString m_changelist;
309 bool m_keepchangelist;
311 DWORD m_dwCloseOnEnd;
313 CTGitPath m_basePath;
314 StringRevMap m_UpdateStartRevMap;
315 StringRevMap m_FinishedRevMap;
317 TCHAR m_columnbuf[MAX_PATH];
319 BOOL m_bCancelled;
320 int m_nConflicts;
321 bool m_bErrorsOccurred;
322 bool m_bMergesAddsDeletesOccurred;
324 int iFirstResized;
325 BOOL bSecondResized;
326 int nEnsureVisibleCount;
328 CString m_sTotalBytesTransferred;
330 CColors m_Colors;
332 bool m_bFinishedItemAdded;
333 bool m_bLastVisible;
335 int m_itemCount;
336 int m_itemCountTotal;
338 bool m_AlwaysConflicted;
340 DWORD m_SendMailFlags;
341 CString m_SendMailTO;
342 CString m_SendMailCC;
343 CString m_SendMailSubject;
345 /// CComPtr<IBugTraqProvider> m_BugTraqProvider;
346 CComPtr<ITaskbarList3> m_pTaskbarList;
348 // some strings different methods can use
349 CString sDryRun;
350 CString sRecordOnly;