OSDN Git Service

d7b56f156087b2bed47ef994dc7ffdc256504361
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / CreateBranchTagDlg.cpp
1 // CreateBranchTagDlg.cpp : implementation file\r
2 //\r
3 \r
4 #include "stdafx.h"\r
5 #include "Git.h"\r
6 #include "TortoiseProc.h"\r
7 #include "CreateBranchTagDlg.h"\r
8 \r
9 #include "Messagebox.h"\r
10 \r
11 // CCreateBranchTagDlg dialog\r
12 \r
13 IMPLEMENT_DYNAMIC(CCreateBranchTagDlg, CResizableStandAloneDialog)\r
14 \r
15 CCreateBranchTagDlg::CCreateBranchTagDlg(CWnd* pParent /*=NULL*/)\r
16         : CResizableStandAloneDialog(CCreateBranchTagDlg::IDD, pParent),\r
17         CChooseVersion(this)\r
18 {\r
19         m_bIsTag=0;\r
20         m_bSwitch = 0;  // default switch to checkbox not selected\r
21 }\r
22 \r
23 CCreateBranchTagDlg::~CCreateBranchTagDlg()\r
24 {\r
25 }\r
26 \r
27 void CCreateBranchTagDlg::DoDataExchange(CDataExchange* pDX)\r
28 {\r
29         CDialog::DoDataExchange(pDX);\r
30 \r
31         CHOOSE_VERSION_DDX;\r
32 \r
33         DDX_Text(pDX, IDC_BRANCH_TAG, this->m_BranchTagName);\r
34         DDX_Check(pDX,IDC_CHECK_FORCE,this->m_bForce);\r
35         DDX_Check(pDX,IDC_CHECK_TRACK,this->m_bTrack);\r
36         DDX_Check(pDX,IDC_CHECK_SWITCH,this->m_bSwitch);\r
37 \r
38 }\r
39 \r
40 \r
41 BEGIN_MESSAGE_MAP(CCreateBranchTagDlg, CResizableStandAloneDialog)\r
42         CHOOSE_VERSION_EVENT\r
43         ON_BN_CLICKED(IDOK, &CCreateBranchTagDlg::OnBnClickedOk)\r
44         ON_CBN_SELCHANGE(IDC_COMBOBOXEX_BRANCH, &CCreateBranchTagDlg::OnCbnSelchangeComboboxexBranch)\r
45 END_MESSAGE_MAP()\r
46 \r
47 BOOL CCreateBranchTagDlg::OnInitDialog()\r
48 {\r
49         CResizableStandAloneDialog::OnInitDialog();\r
50 \r
51         CHOOSE_VERSION_ADDANCHOR;\r
52 \r
53         AddAnchor(IDC_GROUP_BRANCH, TOP_LEFT, TOP_RIGHT);\r
54         \r
55         AddAnchor(IDC_GROUP_OPTION, TOP_LEFT, TOP_RIGHT);\r
56 \r
57         AddAnchor(IDOK,BOTTOM_RIGHT);\r
58         AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
59 \r
60         this->AddOthersToAnchor();\r
61 \r
62         if(m_Base.IsEmpty())\r
63         {\r
64                 this->SetDefaultChoose(IDC_RADIO_HEAD);\r
65         \r
66         }else\r
67         {\r
68                 this->SetDefaultChoose(IDC_RADIO_VERSION);\r
69                 this->GetDlgItem(IDC_COMBOBOXEX_VERSION)->SetWindowTextW(m_Base);\r
70         }\r
71 \r
72         Init();\r
73 \r
74         this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);\r
75 \r
76         if(this->m_bIsTag)\r
77         {\r
78                 this->SetWindowTextW(_T("Create Tag"));\r
79                 this->GetDlgItem(IDC_LABEL_BRANCH)->SetWindowTextW(_T("Tag"));\r
80         }\r
81         else\r
82         {\r
83                 this->SetWindowTextW(_T("Create Branch"));\r
84                 this->GetDlgItem(IDC_LABEL_BRANCH)->SetWindowTextW(_T("Branch"));\r
85         }\r
86         // show the switch checkbox if we are a create branch dialog\r
87         this->GetDlgItem(IDC_CHECK_SWITCH)->ShowWindow( !m_bIsTag );\r
88         CWnd* pHead = GetDlgItem(IDC_RADIO_HEAD);\r
89         CString HeadText;\r
90         pHead->GetWindowText( HeadText ); \r
91         pHead->SetWindowText( HeadText + " (" + g_Git.GetCurrentBranch() + ")");\r
92         EnableSaveRestore(_T("BranchTagDlg"));\r
93         return TRUE;\r
94 \r
95 \r
96 }\r
97 // CCreateBranchTagDlg message handlers\r
98 \r
99 void CCreateBranchTagDlg::OnBnClickedOk()\r
100 {\r
101         // TODO: Add your control notification handler code here\r
102         this->UpdateData(TRUE);\r
103 \r
104         this->m_BranchTagName.Trim();\r
105         if(this->m_BranchTagName.IsEmpty()  ||  this->m_BranchTagName.Find(' ') >= 0 )\r
106         {\r
107                 CMessageBox::Show(NULL, IDS_B_T_NOTEMPTY, IDS_TORTOISEGIT, MB_OK);\r
108                 return;\r
109         }\r
110         this->UpdateRevsionName();\r
111         OnOK();\r
112 }\r
113 \r
114 void CCreateBranchTagDlg::OnCbnSelchangeComboboxexBranch()\r
115 {\r
116         // TODO: Add your control notification handler code here\r
117         \r
118         if(this->m_ChooseVersioinBranch.GetString().Left(6)==_T("origin"))\r
119                 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(TRUE);\r
120         else\r
121                 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);\r
122 \r
123         if(this->m_bIsTag)\r
124                 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);\r
125 }\r