Fixed issue #507: Help Spell error and push wrongly link to sync
[TortoiseGit.git] / src / TortoiseProc / GitSwitchDlg.cpp
blob5d84f9dbc853daaed8e1c76eed22cbe663f474b4
1 // GitSwitch.cpp : implementation file
2 //
4 #include "stdafx.h"
5 #include "Git.h"
6 #include "TortoiseProc.h"
7 #include "GitSwitchDlg.h"
10 #include "Messagebox.h"
12 // CGitSwitchDlg dialog
14 IMPLEMENT_DYNAMIC(CGitSwitchDlg, CResizableStandAloneDialog)
16 CGitSwitchDlg::CGitSwitchDlg(CWnd* pParent /*=NULL*/)
17 : CResizableStandAloneDialog(CGitSwitchDlg::IDD, pParent)
18 ,CChooseVersion(this)
20 m_bBranch=FALSE;
21 m_bTrack=FALSE;
22 m_bForce=FALSE;
25 CGitSwitchDlg::~CGitSwitchDlg()
29 void CGitSwitchDlg::DoDataExchange(CDataExchange* pDX)
31 CDialog::DoDataExchange(pDX);
32 CHOOSE_VERSION_DDX;
34 DDX_Check(pDX,IDC_CHECK_FORCE,this->m_bForce);
35 DDX_Check(pDX,IDC_CHECK_TRACK,this->m_bTrack);
36 DDX_Check(pDX,IDC_CHECK_BRANCH,this->m_bBranch);
38 DDX_Text(pDX,IDC_EDIT_BRANCH,this->m_NewBranch);
42 BEGIN_MESSAGE_MAP(CGitSwitchDlg, CResizableStandAloneDialog)
44 CHOOSE_VERSION_EVENT
45 ON_BN_CLICKED(IDC_CHECK_BRANCH, &CGitSwitchDlg::OnBnClickedCheckBranch)
46 ON_BN_CLICKED(IDOK, &CGitSwitchDlg::OnBnClickedOk)
47 ON_CBN_SELCHANGE(IDC_COMBOBOXEX_BRANCH, &CGitSwitchDlg::OnCbnSelchangeComboboxexBranch)
48 ON_WM_DESTROY()
49 END_MESSAGE_MAP()
51 BOOL CGitSwitchDlg::OnInitDialog()
53 CResizableStandAloneDialog::OnInitDialog();
55 AddAnchor(IDC_GROUP_OPTION, TOP_LEFT, TOP_RIGHT);
57 AddAnchor(IDC_EDIT_BRANCH, TOP_LEFT, TOP_RIGHT);
59 AddAnchor(IDOK,BOTTOM_RIGHT);
60 AddAnchor(IDCANCEL,BOTTOM_RIGHT);
62 CHOOSE_VERSION_ADDANCHOR;
63 this->AddOthersToAnchor();
65 EnableSaveRestore(_T("SwitchDlg"));
67 Init();
69 if(m_Base.IsEmpty())
70 SetDefaultChoose(IDC_RADIO_BRANCH);
71 else
73 this->GetDlgItem(IDC_COMBOBOXEX_VERSION)->SetWindowTextW(m_Base);
74 SetDefaultChoose(IDC_RADIO_VERSION);
77 OnBnClickedCheckBranch();
78 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);
80 return TRUE;
84 // CCreateBranchTagDlg message handlers
86 void CGitSwitchDlg::OnBnClickedChooseRadioHost()
88 // TODO: Add your control notification handler code here
89 OnBnClickedChooseRadio();
90 OnCbnSelchangeComboboxexBranch();
91 OnBnClickedCheckBranch();
95 void CGitSwitchDlg::OnBnClickedShow()
97 OnBnClickedChooseVersion();
100 void CGitSwitchDlg::OnBnClickedOk()
102 this->UpdateData(TRUE);
104 // make sure a valid branch has been entered if a new branch is required
105 if ( m_bBranch && ( m_NewBranch.Trim().IsEmpty() || m_NewBranch.Find(' ') >= 0 ) )
107 // new branch requested but name is empty or contains spaces
108 CMessageBox::Show(NULL, IDS_B_T_NOTEMPTY, IDS_TORTOISEGIT, MB_OK);
110 else
112 UpdateRevsionName();
113 //this->m_Version.SaveHistory();
114 OnOK();
117 void CGitSwitchDlg::OnBnClickedCheckBranch()
119 // TODO: Add your control notification handler code here
120 this->UpdateData(TRUE);
121 this->UpdateRevsionName();
123 CString version = m_ChooseVersioinBranch.GetString();
124 if((version.Left(7)==_T("origin/") || version.Left(8)==_T("remotes/")))
126 int start=0;
127 start = version.ReverseFind(_T('/'));
128 if(start>=0)
129 version = version.Mid(start+1);
130 GetDlgItem(IDC_EDIT_BRANCH)->SetWindowTextW(version);
131 }else
132 GetDlgItem(IDC_EDIT_BRANCH)->SetWindowTextW(CString(_T("Branch_"))+this->m_VersionName);
134 #if 0
135 int radio=GetCheckedRadioButton(IDC_RADIO_BRANCH,IDC_RADIO_VERSION);
136 if(radio==IDC_RADIO_TAGS || radio==IDC_RADIO_VERSION)
138 this->m_bBranch=TRUE;
139 this->UpdateData(FALSE);
140 this->UpdateRevsionName();
142 }else
144 this->m_bBranch=FALSE;
145 this->UpdateData(FALSE);
147 #endif
148 this->GetDlgItem(IDC_EDIT_BRANCH)->EnableWindow(this->m_bBranch);
151 void CGitSwitchDlg::OnCbnSelchangeComboboxexBranch()
153 // TODO: Add your control notification handler code here
154 int radio=GetCheckedRadioButton(IDC_RADIO_BRANCH,IDC_RADIO_VERSION);
156 CString version = m_ChooseVersioinBranch.GetString();
157 if((version.Left(7)==_T("origin/") || version.Left(8)==_T("remotes/"))
158 && radio==IDC_RADIO_BRANCH )
160 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(TRUE);
161 int start=0;
162 start = version.ReverseFind(_T('/'));
163 if(start>=0)
164 version = version.Mid(start+1);
165 GetDlgItem(IDC_EDIT_BRANCH)->SetWindowTextW(version);
167 else
168 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);
171 void CGitSwitchDlg::OnDestroy()
173 WaitForFinishLoading();
174 __super::OnDestroy();
176 // TODO: Add your message handler code here