1 // CreateBranchTagDlg.cpp : implementation file
6 #include "TortoiseProc.h"
7 #include "CreateBranchTagDlg.h"
9 #include "Messagebox.h"
11 // CCreateBranchTagDlg dialog
13 IMPLEMENT_DYNAMIC(CCreateBranchTagDlg
, CResizableStandAloneDialog
)
15 CCreateBranchTagDlg::CCreateBranchTagDlg(CWnd
* pParent
/*=NULL*/)
16 : CResizableStandAloneDialog(CCreateBranchTagDlg::IDD
, pParent
),
20 m_bSwitch
= 0; // default switch to checkbox not selected
24 CCreateBranchTagDlg::~CCreateBranchTagDlg()
28 void CCreateBranchTagDlg::DoDataExchange(CDataExchange
* pDX
)
30 CDialog::DoDataExchange(pDX
);
34 DDX_Text(pDX
, IDC_BRANCH_TAG
, this->m_BranchTagName
);
35 DDX_Check(pDX
,IDC_CHECK_FORCE
,this->m_bForce
);
36 DDX_Check(pDX
,IDC_CHECK_TRACK
,this->m_bTrack
);
37 DDX_Check(pDX
,IDC_CHECK_SWITCH
,this->m_bSwitch
);
38 DDX_Text(pDX
, IDC_EDIT_MESSAGE
,this->m_Message
);
43 BEGIN_MESSAGE_MAP(CCreateBranchTagDlg
, CResizableStandAloneDialog
)
45 ON_BN_CLICKED(IDOK
, &CCreateBranchTagDlg::OnBnClickedOk
)
46 ON_CBN_SELCHANGE(IDC_COMBOBOXEX_BRANCH
, &CCreateBranchTagDlg::OnCbnSelchangeComboboxexBranch
)
47 // ON_BN_CLICKED(IDC_BUTTON_BROWSE_REF, &CCreateBranchTagDlg::OnBnClickedButtonBrowseRef)
51 BOOL
CCreateBranchTagDlg::OnInitDialog()
53 CResizableStandAloneDialog::OnInitDialog();
55 CHOOSE_VERSION_ADDANCHOR
;
57 AddAnchor(IDC_GROUP_BRANCH
, TOP_LEFT
, TOP_RIGHT
);
59 AddAnchor(IDC_GROUP_OPTION
, TOP_LEFT
, TOP_RIGHT
);
61 AddAnchor(IDOK
,BOTTOM_RIGHT
);
62 AddAnchor(IDCANCEL
,BOTTOM_RIGHT
);
63 AddAnchor(IDHELP
, BOTTOM_RIGHT
);
64 AddAnchor(IDC_GROUP_MESSAGE
,TOP_LEFT
,BOTTOM_RIGHT
);
65 AddAnchor(IDC_EDIT_MESSAGE
,TOP_LEFT
,BOTTOM_RIGHT
);
67 this->AddOthersToAnchor();
71 this->SetDefaultChoose(IDC_RADIO_HEAD
);
75 this->SetDefaultChoose(IDC_RADIO_VERSION
);
76 this->GetDlgItem(IDC_COMBOBOXEX_VERSION
)->SetWindowTextW(m_Base
);
81 this->GetDlgItem(IDC_CHECK_TRACK
)->EnableWindow(FALSE
);
85 this->SetWindowTextW(_T("Create Tag"));
86 this->GetDlgItem(IDC_LABEL_BRANCH
)->SetWindowTextW(_T("Tag"));
90 this->SetWindowTextW(_T("Create Branch"));
91 this->GetDlgItem(IDC_LABEL_BRANCH
)->SetWindowTextW(_T("Branch"));
92 this->GetDlgItem(IDC_EDIT_MESSAGE
)->EnableWindow(false);
94 // show the switch checkbox if we are a create branch dialog
95 this->GetDlgItem(IDC_CHECK_SWITCH
)->ShowWindow( !m_bIsTag
);
96 CWnd
* pHead
= GetDlgItem(IDC_RADIO_HEAD
);
98 pHead
->GetWindowText( HeadText
);
99 pHead
->SetWindowText( HeadText
+ " (" + g_Git
.GetCurrentBranch() + ")");
100 EnableSaveRestore(_T("BranchTagDlg"));
102 OnCbnSelchangeComboboxexBranch();
107 // CCreateBranchTagDlg message handlers
109 void CCreateBranchTagDlg::OnBnClickedOk()
111 // TODO: Add your control notification handler code here
112 this->UpdateData(TRUE
);
114 this->m_BranchTagName
.Trim();
115 if(this->m_BranchTagName
.IsEmpty() || this->m_BranchTagName
.Find(' ') >= 0 )
117 CMessageBox::Show(NULL
, IDS_B_T_NOTEMPTY
, IDS_TORTOISEGIT
, MB_OK
);
120 this->UpdateRevsionName();
124 void CCreateBranchTagDlg::OnCbnSelchangeComboboxexBranch()
126 // TODO: Add your control notification handler code here
128 if(this->m_ChooseVersioinBranch
.GetString().Left(8)==_T("remotes/"))
130 bool isDefault
= false;
133 CString str
= this->m_OldSelectBranch
;
134 int start
= str
.ReverseFind(_T('/'));
136 str
=str
.Mid(start
+1);
137 if(str
== m_BranchTagName
)
140 if( m_BranchTagName
.IsEmpty() || isDefault
)
142 this->GetDlgItem(IDC_CHECK_TRACK
)->EnableWindow(TRUE
);
144 m_BranchTagName
= m_ChooseVersioinBranch
.GetString();
146 start
= m_BranchTagName
.ReverseFind(_T('/'));
148 m_BranchTagName
= m_BranchTagName
.Mid(start
+1);
154 this->GetDlgItem(IDC_CHECK_TRACK
)->EnableWindow(FALSE
);
157 this->GetDlgItem(IDC_CHECK_TRACK
)->EnableWindow(FALSE
);
159 m_OldSelectBranch
= m_ChooseVersioinBranch
.GetString();
162 void CCreateBranchTagDlg::OnVersionChanged()
164 int radio
=GetCheckedRadioButton(IDC_RADIO_HEAD
,IDC_RADIO_VERSION
);
165 if (radio
== IDC_RADIO_BRANCH
)
166 OnCbnSelchangeComboboxexBranch();
168 GetDlgItem(IDC_CHECK_TRACK
)->EnableWindow(FALSE
);
171 void CCreateBranchTagDlg::OnDestroy()
173 WaitForFinishLoading();
174 __super::OnDestroy();
176 // TODO: Add your message handler code here