Drop unused msysgit dialog of installer
[TortoiseGit.git] / src / TortoiseProc / BisectStartDlg.cpp
blob7fd68dbf51f98f0bf47283d721bc6a9d531fbad6
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2011-2013 Sven Strickroth, <email@cs-ware.de>
4 // Copyright (C) 2014 TortoiseGit
6 // with code of PullFetchDlg.cpp
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version 2
11 // of the License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software Foundation,
20 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "stdafx.h"
24 #include "TortoiseProc.h"
25 #include "BisectStartDlg.h"
26 #include "Git.h"
27 #include "LogDlg.h"
28 #include "MessageBox.h"
29 #include "AppUtils.h"
31 IMPLEMENT_DYNAMIC(CBisectStartDlg, CHorizontalResizableStandAloneDialog)
33 CBisectStartDlg::CBisectStartDlg(CWnd* pParent /*=NULL*/)
34 : CHorizontalResizableStandAloneDialog(CBisectStartDlg::IDD, pParent)
38 CBisectStartDlg::~CBisectStartDlg()
42 void CBisectStartDlg::DoDataExchange(CDataExchange* pDX)
44 CHorizontalResizableStandAloneDialog::DoDataExchange(pDX);
45 DDX_Control(pDX, IDC_COMBOBOXEX_GOOD, m_cLastGoodRevision);
46 DDX_Control(pDX, IDC_COMBOBOXEX_BAD, m_cFirstBadRevision);
49 BEGIN_MESSAGE_MAP(CBisectStartDlg, CHorizontalResizableStandAloneDialog)
50 ON_BN_CLICKED(IDOK, &CBisectStartDlg::OnBnClickedOk)
51 ON_BN_CLICKED(IDC_BUTTON_GOOD, &CBisectStartDlg::OnBnClickedButtonGood)
52 ON_BN_CLICKED(IDC_BUTTON_BAD, &CBisectStartDlg::OnBnClickedButtonBad)
53 ON_CBN_SELCHANGE(IDC_COMBOBOXEX_GOOD, &CBisectStartDlg::OnChangedRevision)
54 ON_CBN_SELCHANGE(IDC_COMBOBOXEX_BAD, &CBisectStartDlg::OnChangedRevision)
55 ON_CBN_EDITCHANGE(IDC_COMBOBOXEX_GOOD, &CBisectStartDlg::OnChangedRevision)
56 ON_CBN_EDITCHANGE(IDC_COMBOBOXEX_BAD, &CBisectStartDlg::OnChangedRevision)
57 END_MESSAGE_MAP()
59 BOOL CBisectStartDlg::OnInitDialog()
61 CHorizontalResizableStandAloneDialog::OnInitDialog();
62 CAppUtils::MarkWindowAsUnpinnable(m_hWnd);
64 AddAnchor(IDOK, BOTTOM_RIGHT);
65 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
66 AddAnchor(IDHELP, BOTTOM_RIGHT);
68 AddAnchor(IDC_BUTTON_GOOD, TOP_RIGHT);
69 AddAnchor(IDC_BUTTON_BAD, TOP_RIGHT);
70 AddAnchor(IDC_COMBOBOXEX_GOOD, TOP_LEFT, TOP_RIGHT);
71 AddAnchor(IDC_COMBOBOXEX_BAD, TOP_LEFT, TOP_RIGHT);
73 EnableSaveRestore(_T("BisectStartDlg"));
75 CString sWindowTitle;
76 GetWindowText(sWindowTitle);
77 CAppUtils::SetWindowTitle(m_hWnd, g_Git.m_CurrentDir, sWindowTitle);
79 STRING_VECTOR list;
80 int current = 0;
81 g_Git.GetBranchList(list, &current, CGit::BRANCH_ALL);
82 m_cLastGoodRevision.SetMaxHistoryItems(0x7FFFFFFF);
83 m_cFirstBadRevision.SetMaxHistoryItems(0x7FFFFFFF);
84 for (unsigned int i = 0; i < list.size(); ++i)
86 m_cLastGoodRevision.AddString(list[i]);
87 m_cFirstBadRevision.AddString(list[i]);
89 list.clear();
90 g_Git.GetTagList(list);
91 for (unsigned int i = 0; i < list.size(); ++i)
93 m_cLastGoodRevision.AddString(list[i]);
94 m_cFirstBadRevision.AddString(list[i]);
97 if (m_sLastGood.IsEmpty())
98 m_cLastGoodRevision.SetCurSel(-1);
99 else
100 m_cLastGoodRevision.SetWindowTextW(m_sLastGood);
101 if (m_sFirstBad.IsEmpty())
102 m_cFirstBadRevision.SetCurSel(current);
103 else
104 m_cFirstBadRevision.SetWindowTextW(m_sFirstBad);
106 this->UpdateData(FALSE);
108 // EnDisable OK Button
109 OnChangedRevision();
111 return TRUE;
114 void CBisectStartDlg::OnChangedRevision()
116 this->GetDlgItem(IDOK)->EnableWindow(!(m_cLastGoodRevision.GetString().Trim().IsEmpty() || m_cFirstBadRevision.GetString().Trim().IsEmpty()));
119 void CBisectStartDlg::OnBnClickedOk()
121 CHorizontalResizableStandAloneDialog::UpdateData(TRUE);
123 m_LastGoodRevision = m_cLastGoodRevision.GetString().Trim();
124 m_FirstBadRevision = m_cFirstBadRevision.GetString().Trim();
126 if(m_FirstBadRevision.Find(_T("remotes/")) == 0)
127 m_FirstBadRevision = m_FirstBadRevision.Mid(8);
129 if(m_FirstBadRevision.Find(_T("remotes/")) == 0)
130 m_FirstBadRevision = m_FirstBadRevision.Mid(8);
132 CHorizontalResizableStandAloneDialog::OnOK();
135 void CBisectStartDlg::OnBnClickedButtonGood()
137 // use the git log to allow selection of a version
138 CLogDlg dlg;
139 // tell the dialog to use mode for selecting revisions
140 dlg.SetSelect(true);
141 // only one revision must be selected however
142 dlg.SingleSelection(true);
143 if (dlg.DoModal() == IDOK)
145 // get selected hash if any
146 CString selectedHash = dlg.GetSelectedHash();
147 // load into window, do this even if empty so that it is clear that nothing has been selected
148 m_cLastGoodRevision.SetWindowText(selectedHash);
149 OnChangedRevision();
153 void CBisectStartDlg::OnBnClickedButtonBad()
155 // use the git log to allow selection of a version
156 CLogDlg dlg;
157 // tell the dialog to use mode for selecting revisions
158 dlg.SetSelect(true);
159 // only one revision must be selected however
160 dlg.SingleSelection(true);
161 if (dlg.DoModal() == IDOK)
163 // get selected hash if any
164 CString selectedHash = dlg.GetSelectedHash();
165 // load into window, do this even if empty so that it is clear that nothing has been selected
166 m_cFirstBadRevision.SetWindowText(selectedHash);
167 OnChangedRevision();