CreateBranchTag: Enable track option when creating a branch based on a remote
[TortoiseGit.git] / src / TortoiseProc / CreateBranchTagDlg.cpp
blobea8cbc874cfcf74060f1749c3c3abfa8a0b117f1
1 // CreateBranchTagDlg.cpp : implementation file
2 //
4 #include "stdafx.h"
5 #include "Git.h"
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),
17 CChooseVersion(this)
19 m_bIsTag=0;
20 m_bSwitch = 0; // default switch to checkbox not selected
23 CCreateBranchTagDlg::~CCreateBranchTagDlg()
27 void CCreateBranchTagDlg::DoDataExchange(CDataExchange* pDX)
29 CDialog::DoDataExchange(pDX);
31 CHOOSE_VERSION_DDX;
33 DDX_Text(pDX, IDC_BRANCH_TAG, this->m_BranchTagName);
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_SWITCH,this->m_bSwitch);
41 BEGIN_MESSAGE_MAP(CCreateBranchTagDlg, CResizableStandAloneDialog)
42 CHOOSE_VERSION_EVENT
43 ON_BN_CLICKED(IDOK, &CCreateBranchTagDlg::OnBnClickedOk)
44 ON_CBN_SELCHANGE(IDC_COMBOBOXEX_BRANCH, &CCreateBranchTagDlg::OnCbnSelchangeComboboxexBranch)
45 END_MESSAGE_MAP()
47 BOOL CCreateBranchTagDlg::OnInitDialog()
49 CResizableStandAloneDialog::OnInitDialog();
51 CHOOSE_VERSION_ADDANCHOR;
53 AddAnchor(IDC_GROUP_BRANCH, TOP_LEFT, TOP_RIGHT);
55 AddAnchor(IDC_GROUP_OPTION, TOP_LEFT, TOP_RIGHT);
57 AddAnchor(IDOK,BOTTOM_RIGHT);
58 AddAnchor(IDCANCEL,BOTTOM_RIGHT);
60 this->AddOthersToAnchor();
62 if(m_Base.IsEmpty())
64 this->SetDefaultChoose(IDC_RADIO_HEAD);
66 }else
68 this->SetDefaultChoose(IDC_RADIO_VERSION);
69 this->GetDlgItem(IDC_COMBOBOXEX_VERSION)->SetWindowTextW(m_Base);
72 Init();
74 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);
76 if(this->m_bIsTag)
78 this->SetWindowTextW(_T("Create Tag"));
79 this->GetDlgItem(IDC_LABEL_BRANCH)->SetWindowTextW(_T("Tag"));
81 else
83 this->SetWindowTextW(_T("Create Branch"));
84 this->GetDlgItem(IDC_LABEL_BRANCH)->SetWindowTextW(_T("Branch"));
86 // show the switch checkbox if we are a create branch dialog
87 this->GetDlgItem(IDC_CHECK_SWITCH)->ShowWindow( !m_bIsTag );
88 CWnd* pHead = GetDlgItem(IDC_RADIO_HEAD);
89 CString HeadText;
90 pHead->GetWindowText( HeadText );
91 pHead->SetWindowText( HeadText + " (" + g_Git.GetCurrentBranch() + ")");
92 EnableSaveRestore(_T("BranchTagDlg"));
94 OnCbnSelchangeComboboxexBranch();
95 return TRUE;
99 // CCreateBranchTagDlg message handlers
101 void CCreateBranchTagDlg::OnBnClickedOk()
103 // TODO: Add your control notification handler code here
104 this->UpdateData(TRUE);
106 this->m_BranchTagName.Trim();
107 if(this->m_BranchTagName.IsEmpty() || this->m_BranchTagName.Find(' ') >= 0 )
109 CMessageBox::Show(NULL, IDS_B_T_NOTEMPTY, IDS_TORTOISEGIT, MB_OK);
110 return;
112 this->UpdateRevsionName();
113 OnOK();
116 void CCreateBranchTagDlg::OnCbnSelchangeComboboxexBranch()
118 // TODO: Add your control notification handler code here
120 if(this->m_ChooseVersioinBranch.GetString().Left(8)==_T("remotes/"))
121 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(TRUE);
122 else
123 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);
125 if(this->m_bIsTag)
126 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);