OSDN Git Service

RebaseDlg: Add New is top option. Disable Edit control after start rebase
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / RebaseDlg.cpp
1 // RebaseDlg.cpp : implementation file\r
2 //\r
3 \r
4 #include "stdafx.h"\r
5 #include "TortoiseProc.h"\r
6 #include "RebaseDlg.h"\r
7 #include "AppUtils.h"\r
8 \r
9 // CRebaseDlg dialog\r
10 \r
11 IMPLEMENT_DYNAMIC(CRebaseDlg, CResizableStandAloneDialog)\r
12 \r
13 CRebaseDlg::CRebaseDlg(CWnd* pParent /*=NULL*/)\r
14         : CResizableStandAloneDialog(CRebaseDlg::IDD, pParent)\r
15     , m_bPickAll(FALSE)\r
16     , m_bSquashAll(FALSE)\r
17     , m_bEditAll(FALSE)\r
18 {\r
19         m_RebaseStage=CHOOSE_BRANCH;\r
20         m_CurrentRebaseIndex=-1;\r
21 }\r
22 \r
23 CRebaseDlg::~CRebaseDlg()\r
24 {\r
25 }\r
26 \r
27 void CRebaseDlg::DoDataExchange(CDataExchange* pDX)\r
28 {\r
29     CDialog::DoDataExchange(pDX);\r
30     DDX_Control(pDX, IDC_REBASE_PROGRESS, m_ProgressBar);\r
31     DDX_Control(pDX, IDC_STATUS_STATIC, m_CtrlStatusText);\r
32     DDX_Check(pDX, IDC_PICK_ALL, m_bPickAll);\r
33     DDX_Check(pDX, IDC_SQUASH_ALL, m_bSquashAll);\r
34     DDX_Check(pDX, IDC_EDIT_ALL, m_bEditAll);\r
35         DDX_Control(pDX, IDC_REBASE_SPLIT, m_wndSplitter);\r
36         DDX_Control(pDX,IDC_COMMIT_LIST,m_CommitList);\r
37         DDX_Control(pDX,IDC_REBASE_COMBOXEX_BRANCH, this->m_BranchCtrl);\r
38         DDX_Control(pDX,IDC_REBASE_COMBOXEX_UPSTREAM,   this->m_UpstreamCtrl);\r
39 \r
40 }\r
41 \r
42 \r
43 BEGIN_MESSAGE_MAP(CRebaseDlg, CResizableStandAloneDialog)\r
44     ON_BN_CLICKED(IDC_PICK_ALL, &CRebaseDlg::OnBnClickedPickAll)\r
45     ON_BN_CLICKED(IDC_SQUASH_ALL, &CRebaseDlg::OnBnClickedSquashAll)\r
46     ON_BN_CLICKED(IDC_EDIT_ALL, &CRebaseDlg::OnBnClickedEditAll)\r
47     ON_BN_CLICKED(IDC_REBASE_SPLIT, &CRebaseDlg::OnBnClickedRebaseSplit)\r
48         ON_BN_CLICKED(IDC_REBASE_CONTINUE,OnBnClickedContinue)\r
49         ON_WM_SIZE()\r
50         ON_CBN_SELCHANGE(IDC_REBASE_COMBOXEX_BRANCH,   &CRebaseDlg::OnCbnSelchangeBranch)\r
51         ON_CBN_SELCHANGE(IDC_REBASE_COMBOXEX_UPSTREAM, &CRebaseDlg::OnCbnSelchangeUpstream)\r
52 END_MESSAGE_MAP()\r
53 \r
54 void CRebaseDlg::AddRebaseAnchor()\r
55 {\r
56         AddAnchor(IDC_REBASE_TAB,TOP_LEFT,BOTTOM_RIGHT);\r
57         AddAnchor(IDC_COMMIT_LIST,TOP_LEFT, TOP_RIGHT);\r
58         AddAnchor(IDC_REBASE_SPLIT,TOP_LEFT, TOP_RIGHT);\r
59         AddAnchor(IDC_STATUS_STATIC, BOTTOM_LEFT,BOTTOM_RIGHT);\r
60         AddAnchor(IDC_REBASE_CONTINUE,BOTTOM_RIGHT);\r
61         AddAnchor(IDC_REBASE_ABORT, BOTTOM_RIGHT);\r
62         AddAnchor(IDC_REBASE_PROGRESS,BOTTOM_LEFT, BOTTOM_RIGHT);\r
63         AddAnchor(IDC_PICK_ALL,TOP_LEFT);\r
64         AddAnchor(IDC_SQUASH_ALL,TOP_LEFT);\r
65         AddAnchor(IDC_EDIT_ALL,TOP_LEFT);       \r
66         AddAnchor(IDC_REBASE_COMBOXEX_UPSTREAM,TOP_LEFT);\r
67         AddAnchor(IDC_REBASE_COMBOXEX_BRANCH,TOP_LEFT);\r
68         AddAnchor(IDC_REBASE_STATIC_UPSTREAM,TOP_LEFT);\r
69         AddAnchor(IDC_REBASE_STATIC_BRANCH,TOP_LEFT);\r
70         \r
71 }\r
72 \r
73 BOOL CRebaseDlg::OnInitDialog()\r
74 {\r
75         CResizableStandAloneDialog::OnInitDialog();\r
76 \r
77         CRect rectDummy;\r
78         //IDC_REBASE_DUMY_TAB\r
79         \r
80         GetClientRect(m_DlgOrigRect);\r
81         m_CommitList.GetClientRect(m_CommitListOrigRect);\r
82 \r
83         CWnd *pwnd=this->GetDlgItem(IDC_REBASE_DUMY_TAB);\r
84         pwnd->GetWindowRect(&rectDummy);\r
85 \r
86         rectDummy.top-=20;\r
87         rectDummy.bottom-=20;\r
88 \r
89         rectDummy.left-=5;\r
90         rectDummy.right-=5;\r
91         \r
92         if (!m_ctrlTabCtrl.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, IDC_REBASE_TAB))\r
93         {\r
94                 TRACE0("Failed to create output tab window\n");\r
95                 return FALSE;      // fail to create\r
96         }\r
97         m_ctrlTabCtrl.SetResizeMode(CMFCTabCtrl::RESIZE_NO);\r
98         // Create output panes:\r
99         //const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;\r
100         DWORD dwStyle =LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | WS_BORDER | WS_TABSTOP |LVS_SINGLESEL |WS_CHILD | WS_VISIBLE;\r
101 \r
102         if (! this->m_FileListCtrl.Create(dwStyle,rectDummy,&this->m_ctrlTabCtrl,0) )\r
103         {\r
104                 TRACE0("Failed to create output windows\n");\r
105                 return FALSE;      // fail to create\r
106         }\r
107 \r
108         if( ! this->m_LogMessageCtrl.Create(_T("Scintilla"),_T("source"),0,rectDummy,&m_ctrlTabCtrl,0,0) )\r
109         {\r
110                 TRACE0("Failed to create log message control");\r
111                 return FALSE;\r
112         }\r
113         m_LogMessageCtrl.Init(0);\r
114 \r
115         dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;\r
116 \r
117         if (!m_wndOutputRebase.Create(_T("Scintilla"),_T("source"),0,rectDummy, &m_ctrlTabCtrl, 0,0) )\r
118         {\r
119                 TRACE0("Failed to create output windows\n");\r
120                 return -1;      // fail to create\r
121         }\r
122         m_wndOutputRebase.Init(0);\r
123         m_wndOutputRebase.Call(SCI_SETREADONLY, TRUE);\r
124         \r
125         m_tooltips.Create(this);\r
126 \r
127         m_FileListCtrl.Init(SVNSLC_COLEXT | SVNSLC_COLSTATUS , _T("RebaseDlg"));\r
128 \r
129         m_ctrlTabCtrl.AddTab(&m_FileListCtrl,_T("Conflict File"));\r
130         m_ctrlTabCtrl.AddTab(&m_LogMessageCtrl,_T("Commit Message"),1);\r
131         m_ctrlTabCtrl.AddTab(&m_wndOutputRebase,_T("Log"),2);\r
132         AddRebaseAnchor();\r
133 \r
134 \r
135         EnableSaveRestore(_T("RebaseDlg"));\r
136 \r
137         DWORD yPos = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\RebaseDlgSizer"));\r
138         RECT rcDlg, rcLogMsg, rcFileList;\r
139         GetClientRect(&rcDlg);\r
140         m_CommitList.GetWindowRect(&rcLogMsg);\r
141         ScreenToClient(&rcLogMsg);\r
142         this->m_ctrlTabCtrl.GetWindowRect(&rcFileList);\r
143         ScreenToClient(&rcFileList);\r
144         if (yPos)\r
145         {\r
146                 RECT rectSplitter;\r
147                 m_wndSplitter.GetWindowRect(&rectSplitter);\r
148                 ScreenToClient(&rectSplitter);\r
149                 int delta = yPos - rectSplitter.top;\r
150                 if ((rcLogMsg.bottom + delta > rcLogMsg.top)&&(rcLogMsg.bottom + delta < rcFileList.bottom - 30))\r
151                 {\r
152                         m_wndSplitter.SetWindowPos(NULL, 0, yPos, 0, 0, SWP_NOSIZE);\r
153                         DoSize(delta);\r
154                 }\r
155         }\r
156 \r
157         if( this->m_RebaseStage == CHOOSE_BRANCH)\r
158         {\r
159                 this->LoadBranchInfo();\r
160 \r
161         }else\r
162         {\r
163                 this->m_BranchCtrl.EnableWindow(FALSE);\r
164                 this->m_UpstreamCtrl.EnableWindow(FALSE);\r
165         }\r
166 \r
167         m_CommitList.m_IsIDReplaceAction = TRUE;\r
168 //      m_CommitList.m_IsOldFirst = TRUE;\r
169         m_CommitList.m_IsRebaseReplaceGraph = TRUE;\r
170 \r
171         m_CommitList.DeleteAllItems();\r
172         m_CommitList.InsertGitColumn();\r
173 \r
174         FetchLogList();\r
175         SetContinueButtonText();\r
176         return TRUE;\r
177 }\r
178 // CRebaseDlg message handlers\r
179 \r
180 void CRebaseDlg::OnBnClickedPickAll()\r
181 {\r
182     // TODO: Add your control notification handler code here\r
183         this->UpdateData();\r
184         if(this->m_bPickAll)\r
185                 this->SetAllRebaseAction(CTGitPath::LOGACTIONS_REBASE_PICK);\r
186 \r
187         this->m_bEditAll=FALSE;\r
188         this->m_bSquashAll=FALSE;\r
189         this->UpdateData(FALSE);\r
190         \r
191 }\r
192 \r
193 void CRebaseDlg::OnBnClickedSquashAll()\r
194 {\r
195     // TODO: Add your control notification handler code here\r
196         this->UpdateData();\r
197         if(this->m_bSquashAll)\r
198                 this->SetAllRebaseAction(CTGitPath::LOGACTIONS_REBASE_SQUASH);\r
199 \r
200         this->m_bEditAll=FALSE;\r
201         this->m_bPickAll=FALSE;\r
202         this->UpdateData(FALSE);\r
203 \r
204 }\r
205 \r
206 void CRebaseDlg::OnBnClickedEditAll()\r
207 {\r
208     // TODO: Add your control notification handler code here\r
209         this->UpdateData();\r
210         if( this->m_bEditAll )\r
211                 this->SetAllRebaseAction(CTGitPath::LOGACTIONS_REBASE_EDIT);\r
212 \r
213         this->m_bPickAll=FALSE;\r
214         this->m_bSquashAll=FALSE;\r
215         this->UpdateData(FALSE);\r
216 \r
217 }\r
218 \r
219 void CRebaseDlg::SetAllRebaseAction(int action)\r
220 {\r
221         for(int i=0;i<this->m_CommitList.m_logEntries.size();i++)\r
222         {\r
223                 m_CommitList.m_logEntries[i].m_Action=action;\r
224         }\r
225         m_CommitList.Invalidate();\r
226 }\r
227 \r
228 void CRebaseDlg::OnBnClickedRebaseSplit()\r
229 {\r
230         this->UpdateData();\r
231     // TODO: Add your control notification handler code here\r
232 }\r
233 \r
234 LRESULT CRebaseDlg::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)\r
235 {\r
236         switch (message) {\r
237         case WM_NOTIFY:\r
238                 if (wParam == IDC_REBASE_SPLIT)\r
239                 { \r
240                         SPC_NMHDR* pHdr = (SPC_NMHDR*) lParam;\r
241                         DoSize(pHdr->delta);\r
242                 }\r
243                 break;\r
244         }\r
245 \r
246         return __super::DefWindowProc(message, wParam, lParam);\r
247 }\r
248 \r
249 void CRebaseDlg::DoSize(int delta)\r
250 {\r
251         \r
252         this->RemoveAllAnchors();\r
253 \r
254         CSplitterControl::ChangeHeight(GetDlgItem(IDC_COMMIT_LIST), delta, CW_TOPALIGN);\r
255         //CSplitterControl::ChangeHeight(GetDlgItem(), delta, CW_TOPALIGN);\r
256         CSplitterControl::ChangeHeight(GetDlgItem(IDC_REBASE_TAB), -delta, CW_BOTTOMALIGN);\r
257         //CSplitterControl::ChangeHeight(GetDlgItem(), -delta, CW_BOTTOMALIGN);\r
258         CSplitterControl::ChangePos(GetDlgItem(IDC_SQUASH_ALL),0,delta);\r
259         CSplitterControl::ChangePos(GetDlgItem(IDC_PICK_ALL),0,delta);\r
260         CSplitterControl::ChangePos(GetDlgItem(IDC_EDIT_ALL),0,delta);\r
261         \r
262         this->AddRebaseAnchor();\r
263         // adjust the minimum size of the dialog to prevent the resizing from\r
264         // moving the list control too far down.\r
265         CRect rcLogMsg;\r
266         m_CommitList.GetClientRect(rcLogMsg);\r
267         SetMinTrackSize(CSize(m_DlgOrigRect.Width(), m_DlgOrigRect.Height()-m_CommitListOrigRect.Height()+rcLogMsg.Height()));\r
268 \r
269         SetSplitterRange();\r
270 //      m_CommitList.Invalidate();\r
271 \r
272 //      GetDlgItem(IDC_LOGMESSAGE)->Invalidate();\r
273 \r
274         this->m_ctrlTabCtrl.Invalidate();\r
275         this->m_CommitList.Invalidate();\r
276         this->m_FileListCtrl.Invalidate();\r
277         this->m_LogMessageCtrl.Invalidate();\r
278 \r
279 }\r
280 \r
281 void CRebaseDlg::SetSplitterRange()\r
282 {\r
283         if ((m_CommitList)&&(m_ctrlTabCtrl))\r
284         {\r
285                 CRect rcTop;\r
286                 m_CommitList.GetWindowRect(rcTop);\r
287                 ScreenToClient(rcTop);\r
288                 CRect rcMiddle;\r
289                 m_ctrlTabCtrl.GetWindowRect(rcMiddle);\r
290                 ScreenToClient(rcMiddle);\r
291                 if (rcMiddle.Height() && rcMiddle.Width())\r
292                         m_wndSplitter.SetRange(rcTop.top+60, rcMiddle.bottom-80);\r
293         }\r
294 }\r
295 \r
296 void CRebaseDlg::OnSize(UINT nType,int cx, int cy)\r
297 {\r
298          // first, let the resizing take place\r
299     __super::OnSize(nType, cx, cy);\r
300 \r
301     //set range\r
302     SetSplitterRange();\r
303 }\r
304 \r
305 void CRebaseDlg::SaveSplitterPos()\r
306 {\r
307         if (!IsIconic())\r
308         {\r
309                 CRegDWORD regPos = CRegDWORD(_T("Software\\TortoiseGit\\TortoiseProc\\ResizableState\\RebaseDlgSizer"));\r
310                 RECT rectSplitter;\r
311                 m_wndSplitter.GetWindowRect(&rectSplitter);\r
312                 ScreenToClient(&rectSplitter);\r
313                 regPos = rectSplitter.top;\r
314         }\r
315 }\r
316 \r
317 void CRebaseDlg::LoadBranchInfo()\r
318 {\r
319         m_BranchCtrl.SetMaxHistoryItems(0x7FFFFFFF);\r
320         m_UpstreamCtrl.SetMaxHistoryItems(0x7FFFFFFF);\r
321 \r
322         STRING_VECTOR list;\r
323         list.clear();\r
324         int current;\r
325         g_Git.GetBranchList(list,&current,CGit::BRANCH_ALL);\r
326         m_BranchCtrl.AddString(list);\r
327         m_UpstreamCtrl.AddString(list);\r
328 \r
329         m_BranchCtrl.SetCurSel(current);\r
330 \r
331         AddBranchToolTips(&m_BranchCtrl);\r
332         AddBranchToolTips(&m_UpstreamCtrl);\r
333 \r
334 }\r
335 \r
336 void CRebaseDlg::OnCbnSelchangeBranch()\r
337 {\r
338         FetchLogList();\r
339 }\r
340 \r
341 void CRebaseDlg::OnCbnSelchangeUpstream()\r
342 {\r
343         FetchLogList();\r
344 }\r
345 \r
346 void CRebaseDlg::FetchLogList()\r
347 {\r
348         m_CommitList.Clear();\r
349         this->m_CommitList.FillGitLog(NULL,0,&m_UpstreamCtrl.GetString(),&m_BranchCtrl.GetString());\r
350         if( m_CommitList.GetItemCount() == 0 )\r
351                 m_CommitList.ShowText(_T("Nothing Rebase"));\r
352 \r
353         CString hash=g_Git.GetHash(m_UpstreamCtrl.GetString());\r
354         \r
355         if(m_CommitList.m_logEntries[m_CommitList.m_logEntries.size()-1].m_ParentHash.size() >=0 )\r
356         {\r
357                 if(hash ==  m_CommitList.m_logEntries[m_CommitList.m_logEntries.size()-1].m_ParentHash[0])\r
358                 {\r
359                         m_CommitList.Clear();\r
360                         m_CommitList.ShowText(_T("Nothing Rebase"));\r
361                 }\r
362         }\r
363         \r
364         m_tooltips.Pop();\r
365         AddBranchToolTips(&this->m_BranchCtrl);\r
366         AddBranchToolTips(&this->m_UpstreamCtrl);\r
367         \r
368         for(int i=0;i<m_CommitList.m_logEntries.size();i++)\r
369         {\r
370                 m_CommitList.m_logEntries[i].m_Action = CTGitPath::LOGACTIONS_REBASE_PICK;\r
371         }\r
372         \r
373         m_CommitList.Invalidate();\r
374 \r
375         if(m_CommitList.m_IsOldFirst)\r
376                 this->m_CurrentRebaseIndex = -1;\r
377         else\r
378                 this->m_CurrentRebaseIndex = m_CommitList.m_logEntries.size();\r
379         \r
380 }\r
381 \r
382 void CRebaseDlg::AddBranchToolTips(CHistoryCombo *pBranch)\r
383 {\r
384         if(pBranch)\r
385         {\r
386                 CString text=pBranch->GetString();\r
387                 CString tooltip;\r
388                 BYTE_VECTOR data;\r
389                 g_Git.GetLog(data,text,NULL,1,0);\r
390                 GitRev rev;\r
391                 rev.ParserFromLog(data);\r
392                 tooltip.Format(_T("CommitHash:%s\nCommit by: %s  %s\n <b>%s</b> \n %s"),\r
393                         rev.m_CommitHash,\r
394                         rev.m_AuthorName,\r
395                         CAppUtils::FormatDateAndTime(rev.m_AuthorDate,DATE_LONGDATE),\r
396                         rev.m_Subject,\r
397                         rev.m_Body);\r
398 \r
399                 pBranch->DisableTooltip();\r
400                 this->m_tooltips.AddTool(pBranch->GetComboBoxCtrl(),tooltip);\r
401         }\r
402 }\r
403 \r
404 BOOL CRebaseDlg::PreTranslateMessage(MSG*pMsg)\r
405 {\r
406         m_tooltips.RelayEvent(pMsg);\r
407         return CResizableStandAloneDialog::PreTranslateMessage(pMsg);\r
408 }\r
409 \r
410 void CRebaseDlg::OnBnClickedContinue()\r
411 {\r
412         GitRev *prevRev,*curRev;\r
413         prevRev=curRev=NULL;\r
414         CRect rect;\r
415         int prevIndex=m_CurrentRebaseIndex;\r
416         \r
417         UpdateCurrentStatus();\r
418 \r
419         if( m_CurrentRebaseIndex >= 0 && m_CurrentRebaseIndex< m_CommitList.m_arShownList.GetSize())\r
420         {\r
421                 prevRev=(GitRev*)m_CommitList.m_arShownList[m_CurrentRebaseIndex];\r
422         }\r
423         \r
424         if(m_CommitList.m_IsOldFirst)\r
425                 m_CurrentRebaseIndex++;\r
426         else\r
427                 m_CurrentRebaseIndex--;\r
428 \r
429         if(m_CurrentRebaseIndex >= 0 && m_CurrentRebaseIndex<m_CommitList.m_arShownList.GetSize())\r
430         {\r
431                 curRev=(GitRev*)m_CommitList.m_arShownList[m_CurrentRebaseIndex];\r
432 \r
433         }\r
434 \r
435         if(prevRev)\r
436         {\r
437                 prevRev->m_Action &= ~ CTGitPath::LOGACTIONS_REBASE_CURRENT;\r
438                 prevRev->m_Action |= CTGitPath::LOGACTIONS_REBASE_DONE;\r
439                 m_CommitList.GetItemRect(prevIndex,&rect,LVIR_BOUNDS);\r
440                 m_CommitList.InvalidateRect(rect);\r
441 \r
442         }\r
443 \r
444         if(curRev)\r
445         {\r
446                 curRev->m_Action |= CTGitPath::LOGACTIONS_REBASE_CURRENT;\r
447                 m_CommitList.GetItemRect(m_CurrentRebaseIndex,&rect,LVIR_BOUNDS);\r
448                 m_CommitList.InvalidateRect(rect);\r
449         }\r
450 \r
451 \r
452         UpdateCurrentStatus();\r
453 \r
454         m_CommitList.EnsureVisible(m_CurrentRebaseIndex,FALSE);\r
455         \r
456         this->SetContinueButtonText();\r
457         this->SetControlEnable();\r
458         UpdateProgress();\r
459 }\r
460 \r
461 void CRebaseDlg::SetContinueButtonText()\r
462 {\r
463         CString Text;\r
464         switch(this->m_RebaseStage)\r
465         {\r
466         case CHOOSE_BRANCH:\r
467         case CHOOSE_COMMIT_PICK_MODE:\r
468                 Text = _T("Start");\r
469                 break;\r
470 \r
471         case REBASE_START:\r
472         case REBASE_CONTINUE:\r
473                 Text = _T("Continue");\r
474                 break;\r
475         case REBASE_ABORT:\r
476         case REBASE_FINISH:\r
477                 Text = _T("Finish");\r
478                 break;\r
479         }\r
480         this->GetDlgItem(IDC_REBASE_CONTINUE)->SetWindowText(Text);\r
481 }\r
482 \r
483 void CRebaseDlg::SetControlEnable()\r
484 {\r
485         switch(this->m_RebaseStage)\r
486         {\r
487         case CHOOSE_BRANCH:\r
488         case CHOOSE_COMMIT_PICK_MODE:\r
489                 \r
490                 this->GetDlgItem(IDC_PICK_ALL)->EnableWindow(TRUE);\r
491                 this->GetDlgItem(IDC_EDIT_ALL)->EnableWindow(TRUE);\r
492                 this->GetDlgItem(IDC_SQUASH_ALL)->EnableWindow(TRUE);\r
493                 this->GetDlgItem(IDC_REBASE_COMBOXEX_BRANCH)->EnableWindow(TRUE);\r
494                 this->GetDlgItem(IDC_REBASE_COMBOXEX_UPSTREAM)->EnableWindow(TRUE);\r
495                 this->m_CommitList.m_IsEnableRebaseMenu=TRUE;\r
496                 break;\r
497 \r
498         case REBASE_START:\r
499         case REBASE_CONTINUE:\r
500         case REBASE_ABORT:\r
501         case REBASE_FINISH:\r
502                 this->GetDlgItem(IDC_PICK_ALL)->EnableWindow(FALSE);\r
503                 this->GetDlgItem(IDC_EDIT_ALL)->EnableWindow(FALSE);\r
504                 this->GetDlgItem(IDC_SQUASH_ALL)->EnableWindow(FALSE);\r
505                 this->GetDlgItem(IDC_REBASE_COMBOXEX_BRANCH)->EnableWindow(FALSE);\r
506                 this->GetDlgItem(IDC_REBASE_COMBOXEX_UPSTREAM)->EnableWindow(FALSE);\r
507                 this->m_CommitList.m_IsEnableRebaseMenu=FALSE;\r
508                 break;\r
509         }\r
510 }\r
511 \r
512 void CRebaseDlg::UpdateProgress()\r
513 {\r
514         int index;\r
515 \r
516         if(m_CommitList.m_IsOldFirst)\r
517                 index = m_CurrentRebaseIndex+1;\r
518         else\r
519                 index = m_CommitList.GetItemCount()-m_CurrentRebaseIndex;\r
520 \r
521         m_ProgressBar.SetRange(1,m_CommitList.GetItemCount());\r
522         m_ProgressBar.SetPos(index);\r
523 \r
524         if(m_CurrentRebaseIndex>0 && m_CurrentRebaseIndex< m_CommitList.GetItemCount())\r
525         {\r
526                 CString text;\r
527                 text.Format(_T("Rebasing...(%d/%d)"),index,m_CommitList.GetItemCount());\r
528                 m_CtrlStatusText.SetWindowText(text);\r
529 \r
530         }\r
531 }\r
532 \r
533 void CRebaseDlg::UpdateCurrentStatus()\r
534 {\r
535         if( m_CurrentRebaseIndex < 0)\r
536         {\r
537                 if(m_CommitList.m_IsOldFirst)\r
538                         m_RebaseStage = CRebaseDlg::REBASE_START;\r
539                 else\r
540                         m_RebaseStage = CRebaseDlg::REBASE_FINISH;\r
541         }\r
542 \r
543         if( m_CurrentRebaseIndex == m_CommitList.m_arShownList.GetSize())\r
544         {\r
545                 if(m_CommitList.m_IsOldFirst)\r
546                         m_RebaseStage = CRebaseDlg::REBASE_FINISH;\r
547                 else\r
548                         m_RebaseStage = CRebaseDlg::REBASE_START;\r
549         }\r
550 \r
551         SetContinueButtonText();\r
552         SetControlEnable();\r
553         UpdateProgress();\r
554 }