1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2011 Sven Strickroth, <email@cs-ware.de>
5 // with code of PullFetchDlg.cpp
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software Foundation,
19 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "TortoiseProc.h"
24 #include "BisectStartDlg.h"
27 #include "MessageBox.h"
30 IMPLEMENT_DYNAMIC(CBisectStartDlg
, CHorizontalResizableStandAloneDialog
)
32 CBisectStartDlg::CBisectStartDlg(CWnd
* pParent
/*=NULL*/)
33 : CHorizontalResizableStandAloneDialog(CBisectStartDlg::IDD
, pParent
)
37 CBisectStartDlg::~CBisectStartDlg()
41 void CBisectStartDlg::DoDataExchange(CDataExchange
* pDX
)
43 CHorizontalResizableStandAloneDialog::DoDataExchange(pDX
);
44 DDX_Control(pDX
, IDC_COMBOBOXEX_GOOD
, m_cLastGoodRevision
);
45 DDX_Control(pDX
, IDC_COMBOBOXEX_BAD
, m_cFirstBadRevision
);
48 BEGIN_MESSAGE_MAP(CBisectStartDlg
, CHorizontalResizableStandAloneDialog
)
49 ON_BN_CLICKED(IDOK
, &CBisectStartDlg::OnBnClickedOk
)
50 ON_BN_CLICKED(IDC_BUTTON_GOOD
, &CBisectStartDlg::OnBnClickedButtonGood
)
51 ON_BN_CLICKED(IDC_BUTTON_BAD
, &CBisectStartDlg::OnBnClickedButtonBad
)
54 BOOL
CBisectStartDlg::OnInitDialog()
56 CHorizontalResizableStandAloneDialog::OnInitDialog();
57 CAppUtils::MarkWindowAsUnpinnable(m_hWnd
);
59 AddAnchor(IDOK
, BOTTOM_RIGHT
);
60 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
61 AddAnchor(IDHELP
, BOTTOM_RIGHT
);
63 AddAnchor(IDC_BUTTON_GOOD
, TOP_RIGHT
);
64 AddAnchor(IDC_BUTTON_BAD
, TOP_RIGHT
);
65 AddAnchor(IDC_COMBOBOXEX_GOOD
, TOP_LEFT
, TOP_RIGHT
);
66 AddAnchor(IDC_COMBOBOXEX_BAD
, TOP_LEFT
, TOP_RIGHT
);
68 EnableSaveRestore(_T("BisectStartDlg"));
71 GetWindowText(sWindowTitle
);
72 CAppUtils::SetWindowTitle(m_hWnd
, g_Git
.m_CurrentDir
, sWindowTitle
);
76 g_Git
.GetBranchList(list
, ¤t
, CGit::BRANCH_ALL
);
77 m_cLastGoodRevision
.SetMaxHistoryItems(0x7FFFFFFF);
78 m_cFirstBadRevision
.SetMaxHistoryItems(0x7FFFFFFF);
79 for (unsigned int i
= 0; i
< list
.size(); i
++)
81 m_cLastGoodRevision
.AddString(list
[i
]);
82 m_cFirstBadRevision
.AddString(list
[i
]);
85 this->UpdateData(FALSE
);
90 void CBisectStartDlg::OnBnClickedOk()
92 CHorizontalResizableStandAloneDialog::UpdateData(TRUE
);
94 m_LastGoodRevision
= m_cLastGoodRevision
.GetString();
95 m_FirstBadRevision
= m_cFirstBadRevision
.GetString();
97 if(m_FirstBadRevision
.Find(_T("remotes/")) == 0)
98 m_FirstBadRevision
= m_FirstBadRevision
.Mid(8);
100 if(m_FirstBadRevision
.Find(_T("remotes/")) == 0)
101 m_FirstBadRevision
= m_FirstBadRevision
.Mid(8);
103 CHorizontalResizableStandAloneDialog::OnOK();
106 void CBisectStartDlg::OnBnClickedButtonGood()
108 // use the git log to allow selection of a version
110 // tell the dialog to use mode for selecting revisions
112 // only one revision must be selected however
113 dlg
.SingleSelection(true);
114 if (dlg
.DoModal() == IDOK
)
116 // get selected hash if any
117 CString selectedHash
= dlg
.GetSelectedHash();
118 // load into window, do this even if empty so that it is clear that nothing has been selected
119 m_cLastGoodRevision
.SetWindowText(selectedHash
);
123 void CBisectStartDlg::OnBnClickedButtonBad()
125 // use the git log to allow selection of a version
127 // tell the dialog to use mode for selecting revisions
129 // only one revision must be selected however
130 dlg
.SingleSelection(true);
131 if (dlg
.DoModal() == IDOK
)
133 // get selected hash if any
134 CString selectedHash
= dlg
.GetSelectedHash();
135 // load into window, do this even if empty so that it is clear that nothing has been selected
136 m_cFirstBadRevision
.SetWindowText(selectedHash
);