OSDN Git Service

merge original branch.
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / SyncDlg.h
1 // TortoiseGit - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2008-2009 - TortoiseGit\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 \r
20 #pragma once\r
21 #include "afxcmn.h"\r
22 #include "afxwin.h"\r
23 \r
24 #include "StandAloneDlg.h"\r
25 #include "HistoryCombo.h"\r
26 #include "MenuButton.h"\r
27 #include "registry.h"\r
28 #include "Balloon.h"\r
29 #include "BranchCombox.h"\r
30 #include "GitLoglist.h"\r
31 // CSyncDlg dialog\r
32 #define IDC_SYNC_TAB 0x1000000\r
33 \r
34 #define IDC_CMD_LOG                     0x1\r
35 #define IDC_IN_LOGLIST          0x2\r
36 #define IDC_IN_CHANGELIST       0x3\r
37 #define IDC_IN_CONFLICT         0x4\r
38 #define IDC_OUT_LOGLIST         0x5\r
39 #define IDC_OUT_CHANGELIST      0x6\r
40 \r
41 class CSyncDlg : public CResizableStandAloneDialog,public CBranchCombox\r
42 {\r
43         DECLARE_DYNAMIC(CSyncDlg)\r
44 \r
45 public:\r
46         CSyncDlg(CWnd* pParent = NULL);   // standard constructor\r
47         virtual ~CSyncDlg();\r
48 \r
49 // Dialog Data\r
50         enum { IDD = IDD_SYNC };\r
51 \r
52         enum { GIT_COMMAND_PUSH,\r
53                    GIT_COMMAND_PULL,\r
54                    GIT_COMMAND_FETCH,\r
55                    GIT_COMMAND_FETCHANDREBASE,\r
56                    GIT_COMMAND_SUBMODULE,\r
57                    GIT_COMMAND_REMOTE\r
58                 };\r
59 protected:\r
60         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
61         BRANCH_COMBOX_EVENT_HANDLE();\r
62 \r
63         int m_CurrentCmd;\r
64 \r
65         CRegDWORD m_regPullButton;\r
66         CRegDWORD m_regPushButton;\r
67         CRegDWORD m_regSubmoduleButton;\r
68 \r
69         CMFCTabCtrl m_ctrlTabCtrl;\r
70 \r
71         CBalloon                        m_tooltips;\r
72         \r
73         BOOL            m_bInited;\r
74         \r
75         CGitLogList     m_OutLogList;\r
76         CGitLogList m_InLogList;\r
77 \r
78         CGitStatusListCtrl m_OutChangeFileList;\r
79         CGitStatusListCtrl m_InChangeFileList;\r
80         CGitStatusListCtrl m_ConflictFileList;\r
81         \r
82         CRichEditCtrl      m_ctrlCmdOut;\r
83 \r
84         CTGitPathList   m_arOutChangeList;\r
85         CTGitPathList   m_arInChangeList;\r
86 \r
87         int                             m_CmdOutCurrentPos;\r
88 \r
89         CWinThread*                             m_pThread;      \r
90 \r
91         void            ParserCmdOutput(TCHAR ch);\r
92 \r
93         virtual void LocalBranchChange(){FetchOutList();};\r
94         virtual void RemoteBranchChange(){FetchOutList();};\r
95         void ShowTab(int windowid)\r
96         {\r
97                 this->m_ctrlTabCtrl.ShowTab(windowid-1);\r
98                 this->m_ctrlTabCtrl.SetActiveTab(windowid-1);\r
99         }\r
100 \r
101         void FetchOutList(bool force=false);\r
102 \r
103         bool IsURL();\r
104 \r
105         void SetRemote(CString remote)\r
106         {\r
107                 if(!remote.IsEmpty())\r
108                 {\r
109                         int index=this->m_ctrlURL.FindStringExact(0,remote);\r
110                         if(index>=0)\r
111                         {\r
112                                 m_ctrlURL.SetCurSel(index);\r
113                                 return;\r
114                         }\r
115                         this->m_ctrlURL.AddString(remote);\r
116                 }\r
117         }\r
118 \r
119         std::vector<CString> m_GitCmdList;\r
120         \r
121         bool m_bAbort;\r
122 \r
123         int  m_GitCmdStatus;\r
124         \r
125         CString m_LogText;\r
126         CString m_OutLocalBranch;\r
127         CString m_OutRemoteBranch;\r
128         \r
129         CString m_oldHash;\r
130 \r
131         void ShowProgressCtrl(bool bShow=true);\r
132         void ShowInputCtrl(bool bShow=true);\r
133         void SwitchToRun(){ShowProgressCtrl(true);ShowInputCtrl(false);EnableControlButton(false);}\r
134         void SwitchToInput(){ShowProgressCtrl(false);ShowInputCtrl(true);}\r
135         \r
136         LRESULT OnProgressUpdateUI(WPARAM wParam,LPARAM lParam);\r
137 \r
138         void UpdateCombox()\r
139         {\r
140                 this->m_strLocalBranch = this->m_ctrlLocalBranch.GetString();\r
141                 this->m_ctrlRemoteBranch.GetWindowText(this->m_strRemoteBranch);\r
142                 this->m_ctrlURL.GetWindowText(this->m_strURL);\r
143                 m_strRemoteBranch=m_strRemoteBranch.Trim();\r
144         }\r
145 \r
146         void AddDiffFileList(CGitStatusListCtrl *pCtrlList, CTGitPathList *pGitList,\r
147                                                         CString &rev1,CString &rev2)\r
148         {\r
149                 g_Git.GetCommitDiffList(rev1,rev2,*pGitList);\r
150                 pCtrlList->m_Rev1=rev1;\r
151                 pCtrlList->m_Rev2=rev2;\r
152                 pCtrlList->Show(0,*pGitList);\r
153                 pCtrlList->SetEmptyString(CString(_T("No changed file")));\r
154                 return;\r
155         }\r
156 \r
157         void PullComplete();\r
158         void FetchComplete();\r
159 \r
160         DECLARE_MESSAGE_MAP()\r
161 public:\r
162         BOOL m_bAutoLoadPuttyKey;\r
163         BOOL m_bForce;\r
164         CString m_strURL;\r
165 \r
166         static UINT ProgressThreadEntry(LPVOID pVoid){ return ((CSyncDlg*)pVoid) ->ProgressThread(); };\r
167         UINT            ProgressThread();\r
168         \r
169         CHistoryCombo m_ctrlURL;\r
170         CButton m_ctrlDumyButton;\r
171         CMenuButton m_ctrlPull;\r
172         CMenuButton m_ctrlPush;\r
173         CMenuButton m_ctrlStatus;\r
174         CMenuButton m_ctrlSubmodule;\r
175         afx_msg void OnBnClickedButtonPull();\r
176         afx_msg void OnBnClickedButtonPush();\r
177         afx_msg void OnBnClickedButtonApply();\r
178         afx_msg void OnBnClickedButtonEmail();\r
179         CProgressCtrl m_ctrlProgress;\r
180         CAnimateCtrl m_ctrlAnimate;\r
181         virtual BOOL OnInitDialog();\r
182         afx_msg void OnBnClickedButtonManage();\r
183         virtual BOOL PreTranslateMessage(MSG* pMsg);\r
184         afx_msg void OnCbenEndeditComboboxexUrl(NMHDR *pNMHDR, LRESULT *pResult);\r
185         afx_msg void OnCbnEditchangeComboboxexUrl();\r
186 \r
187         void EnableControlButton(bool bEnabled=true);\r
188         afx_msg void OnBnClickedButtonCommit();\r
189 protected:\r
190         virtual void OnOK();\r
191 public:\r
192         afx_msg void OnBnClickedButtonSubmodule();\r
193 };\r