1 // GitSwitch.cpp : implementation file
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
)
25 CGitSwitchDlg::~CGitSwitchDlg()
29 void CGitSwitchDlg::DoDataExchange(CDataExchange
* pDX
)
31 CDialog::DoDataExchange(pDX
);
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
)
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
)
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"));
70 SetDefaultChoose(IDC_RADIO_BRANCH
);
73 this->GetDlgItem(IDC_COMBOBOXEX_VERSION
)->SetWindowTextW(m_Base
);
74 SetDefaultChoose(IDC_RADIO_VERSION
);
77 OnBnClickedCheckBranch();
78 this->GetDlgItem(IDC_CHECK_TRACK
)->EnableWindow(FALSE
);
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
);
113 //this->m_Version.SaveHistory();
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/")))
127 start
= version
.ReverseFind(_T('/'));
129 version
= version
.Mid(start
+1);
130 GetDlgItem(IDC_EDIT_BRANCH
)->SetWindowTextW(version
);
132 GetDlgItem(IDC_EDIT_BRANCH
)->SetWindowTextW(CString(_T("Branch_"))+this->m_VersionName
);
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();
144 this->m_bBranch
=FALSE
;
145 this->UpdateData(FALSE
);
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
);
162 start
= version
.ReverseFind(_T('/'));
164 version
= version
.Mid(start
+1);
165 GetDlgItem(IDC_EDIT_BRANCH
)->SetWindowTextW(version
);
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