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
)
23 CGitSwitchDlg::~CGitSwitchDlg()
27 void CGitSwitchDlg::DoDataExchange(CDataExchange
* pDX
)
29 CDialog::DoDataExchange(pDX
);
32 DDX_Check(pDX
,IDC_CHECK_FORCE
,this->m_bForce
);
33 DDX_Check(pDX
,IDC_CHECK_TRACK
,this->m_bTrack
);
34 DDX_Check(pDX
,IDC_CHECK_BRANCH
,this->m_bBranch
);
36 DDX_Text(pDX
,IDC_EDIT_BRANCH
,this->m_NewBranch
);
40 BEGIN_MESSAGE_MAP(CGitSwitchDlg
, CResizableStandAloneDialog
)
43 ON_BN_CLICKED(IDC_CHECK_BRANCH
, &CGitSwitchDlg::OnBnClickedCheckBranch
)
44 ON_BN_CLICKED(IDOK
, &CGitSwitchDlg::OnBnClickedOk
)
45 ON_CBN_SELCHANGE(IDC_COMBOBOXEX_BRANCH
, &CGitSwitchDlg::OnCbnSelchangeComboboxexBranch
)
48 BOOL
CGitSwitchDlg::OnInitDialog()
50 CResizableStandAloneDialog::OnInitDialog();
52 AddAnchor(IDC_GROUP_OPTION
, TOP_LEFT
, TOP_RIGHT
);
54 AddAnchor(IDC_EDIT_BRANCH
, TOP_LEFT
, TOP_RIGHT
);
56 AddAnchor(IDOK
,BOTTOM_RIGHT
);
57 AddAnchor(IDCANCEL
,BOTTOM_RIGHT
);
58 this->AddOthersToAnchor();
60 CHOOSE_VERSION_ADDANCHOR
;
62 EnableSaveRestore(_T("SwitchDlg"));
67 SetDefaultChoose(IDC_RADIO_BRANCH
);
70 this->GetDlgItem(IDC_COMBOBOXEX_VERSION
)->SetWindowTextW(m_Base
);
71 SetDefaultChoose(IDC_RADIO_VERSION
);
74 OnBnClickedCheckBranch();
75 this->GetDlgItem(IDC_CHECK_TRACK
)->EnableWindow(FALSE
);
81 // CCreateBranchTagDlg message handlers
83 void CGitSwitchDlg::OnBnClickedChooseRadioHost()
85 // TODO: Add your control notification handler code here
86 OnBnClickedChooseRadio();
87 OnCbnSelchangeComboboxexBranch();
88 OnBnClickedCheckBranch();
92 void CGitSwitchDlg::OnBnClickedShow()
94 OnBnClickedChooseVersion();
97 void CGitSwitchDlg::OnBnClickedOk()
99 this->UpdateData(TRUE
);
101 // make sure a valid branch has been entered if a new branch is required
102 if ( m_bBranch
&& ( m_NewBranch
.Trim().IsEmpty() || m_NewBranch
.Find(' ') >= 0 ) )
104 // new branch requested but name is empty or contains spaces
105 CMessageBox::Show(NULL
, IDS_B_T_NOTEMPTY
, IDS_TORTOISEGIT
, MB_OK
);
110 //this->m_Version.SaveHistory();
114 void CGitSwitchDlg::OnBnClickedCheckBranch()
116 // TODO: Add your control notification handler code here
117 this->UpdateData(TRUE
);
118 this->UpdateRevsionName();
119 GetDlgItem(IDC_EDIT_BRANCH
)->SetWindowTextW(CString(_T("Branch_"))+this->m_VersionName
);
122 int radio
=GetCheckedRadioButton(IDC_RADIO_BRANCH
,IDC_RADIO_VERSION
);
123 if(radio
==IDC_RADIO_TAGS
|| radio
==IDC_RADIO_VERSION
)
125 this->m_bBranch
=TRUE
;
126 this->UpdateData(FALSE
);
127 this->UpdateRevsionName();
131 this->m_bBranch
=FALSE
;
132 this->UpdateData(FALSE
);
135 this->GetDlgItem(IDC_EDIT_BRANCH
)->EnableWindow(this->m_bBranch
);
138 void CGitSwitchDlg::OnCbnSelchangeComboboxexBranch()
140 // TODO: Add your control notification handler code here
141 int radio
=GetCheckedRadioButton(IDC_RADIO_BRANCH
,IDC_RADIO_VERSION
);
142 if(this->m_ChooseVersioinBranch
.GetString().Left(6)==_T("origin") && radio
==IDC_RADIO_BRANCH
)
143 this->GetDlgItem(IDC_CHECK_TRACK
)->EnableWindow(TRUE
);
145 this->GetDlgItem(IDC_CHECK_TRACK
)->EnableWindow(FALSE
);