OSDN Git Service

Sync Dialog remote URL support save history
[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                 };\r
58 protected:\r
59         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
60         BRANCH_COMBOX_EVENT_HANDLE();\r
61 \r
62         int m_CurrentCmd;\r
63 \r
64         CRegDWORD m_regPullButton;\r
65         CRegDWORD m_regPushButton;\r
66         CRegDWORD m_regSubmoduleButton;\r
67 \r
68         CMFCTabCtrl m_ctrlTabCtrl;\r
69 \r
70         CBalloon                        m_tooltips;\r
71         \r
72         BOOL            m_bInited;\r
73         \r
74         CGitLogList     m_OutLogList;\r
75         CGitLogList m_InLogList;\r
76 \r
77         CGitStatusListCtrl m_OutChangeFileList;\r
78         CGitStatusListCtrl m_InChangeFileList;\r
79         CGitStatusListCtrl m_ConflictFileList;\r
80         \r
81         CRichEditCtrl      m_ctrlCmdOut;\r
82 \r
83         CTGitPathList   m_arOutChangeList;\r
84         CTGitPathList   m_arInChangeList;\r
85 \r
86         int                             m_CmdOutCurrentPos;\r
87 \r
88         CWinThread*                             m_pThread;      \r
89 \r
90         void            ParserCmdOutput(TCHAR ch);\r
91 \r
92         virtual void LocalBranchChange(){FetchOutList();};\r
93         virtual void RemoteBranchChange(){FetchOutList();};\r
94         void ShowTab(int windowid)\r
95         {\r
96                 this->m_ctrlTabCtrl.ShowTab(windowid-1);\r
97                 this->m_ctrlTabCtrl.SetActiveTab(windowid-1);\r
98         }\r
99 \r
100         void FetchOutList(bool force=false);\r
101 \r
102         bool IsURL();\r
103 \r
104         void SetRemote(CString remote)\r
105         {\r
106                 if(!remote.IsEmpty())\r
107                 {\r
108                         int index=this->m_ctrlURL.FindStringExact(0,remote);\r
109                         if(index>=0)\r
110                         {\r
111                                 m_ctrlURL.SetCurSel(index);\r
112                                 return;\r
113                         }\r
114                         this->m_ctrlURL.AddString(remote);\r
115                 }\r
116         }\r
117 \r
118         std::vector<CString> m_GitCmdList;\r
119         \r
120         bool m_bAbort;\r
121 \r
122         int  m_GitCmdStatus;\r
123         \r
124         CString m_LogText;\r
125         CString m_OutLocalBranch;\r
126         CString m_OutRemoteBranch;\r
127         \r
128         CString m_oldHash;\r
129 \r
130         void ShowProgressCtrl(bool bShow=true);\r
131         void ShowInputCtrl(bool bShow=true);\r
132         void SwitchToRun(){ShowProgressCtrl(true);ShowInputCtrl(false);EnableControlButton(false);}\r
133         void SwitchToInput(){ShowProgressCtrl(false);ShowInputCtrl(true);}\r
134         \r
135         LRESULT OnProgressUpdateUI(WPARAM wParam,LPARAM lParam);\r
136 \r
137         void UpdateCombox()\r
138         {\r
139                 this->m_strLocalBranch = this->m_ctrlLocalBranch.GetString();\r
140                 this->m_ctrlRemoteBranch.GetWindowText(this->m_strRemoteBranch);\r
141                 this->m_ctrlURL.GetWindowText(this->m_strURL);\r
142                 m_strRemoteBranch=m_strRemoteBranch.Trim();\r
143         }\r
144 \r
145         void AddDiffFileList(CGitStatusListCtrl *pCtrlList, CTGitPathList *pGitList,\r
146                                                         CString &rev1,CString &rev2)\r
147         {\r
148                 g_Git.GetCommitDiffList(rev1,rev2,*pGitList);\r
149                 pCtrlList->m_Rev1=rev1;\r
150                 pCtrlList->m_Rev2=rev2;\r
151                 pCtrlList->Show(0,*pGitList);\r
152                 pCtrlList->SetEmptyString(CString(_T("No changed file")));\r
153                 return;\r
154         }\r
155 \r
156         void PullComplete();\r
157         void FetchComplete();\r
158 \r
159         DECLARE_MESSAGE_MAP()\r
160 public:\r
161         BOOL m_bAutoLoadPuttyKey;\r
162         BOOL m_bForce;\r
163         CString m_strURL;\r
164 \r
165         static UINT ProgressThreadEntry(LPVOID pVoid){ return ((CSyncDlg*)pVoid) ->ProgressThread(); };\r
166         UINT            ProgressThread();\r
167         \r
168         CHistoryCombo m_ctrlURL;\r
169         CButton m_ctrlDumyButton;\r
170         CMenuButton m_ctrlPull;\r
171         CMenuButton m_ctrlPush;\r
172         CMenuButton m_ctrlStatus;\r
173         CMenuButton m_ctrlSubmodule;\r
174         afx_msg void OnBnClickedButtonPull();\r
175         afx_msg void OnBnClickedButtonPush();\r
176         afx_msg void OnBnClickedButtonApply();\r
177         afx_msg void OnBnClickedButtonEmail();\r
178         CProgressCtrl m_ctrlProgress;\r
179         CAnimateCtrl m_ctrlAnimate;\r
180         virtual BOOL OnInitDialog();\r
181         afx_msg void OnBnClickedButtonManage();\r
182         virtual BOOL PreTranslateMessage(MSG* pMsg);\r
183         afx_msg void OnCbenEndeditComboboxexUrl(NMHDR *pNMHDR, LRESULT *pResult);\r
184         afx_msg void OnCbnEditchangeComboboxexUrl();\r
185 \r
186         void EnableControlButton(bool bEnabled=true);\r
187         afx_msg void OnBnClickedButtonCommit();\r
188 protected:\r
189         virtual void OnOK();\r
190 public:\r
191         afx_msg void OnBnClickedButtonSubmodule();\r
192 };\r