OSDN Git Service

b99e5459a686c1cf30c7d2bf431ef2db78271d53
[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 = 1;  // default switch to checkbox 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         if(m_Base.IsEmpty())\r
61         {\r
62                 this->SetDefaultChoose(IDC_RADIO_HEAD);\r
63         \r
64         }else\r
65         {\r
66                 this->SetDefaultChoose(IDC_RADIO_VERSION);\r
67                 this->GetDlgItem(IDC_COMBOBOXEX_VERSION)->SetWindowTextW(m_Base);\r
68         }\r
69 \r
70         Init();\r
71 \r
72         this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);\r
73 \r
74         if(this->m_bIsTag)\r
75         {\r
76                 this->SetWindowTextW(_T("Create Tag"));\r
77                 this->GetDlgItem(IDC_LABEL_BRANCH)->SetWindowTextW(_T("Tag"));\r
78         }\r
79         else\r
80         {\r
81                 this->SetWindowTextW(_T("Create Branch"));\r
82                 this->GetDlgItem(IDC_LABEL_BRANCH)->SetWindowTextW(_T("Branch"));\r
83         }\r
84         // show the switch checkbox if we are a create branch dialog\r
85         this->GetDlgItem(IDC_CHECK_SWITCH)->ShowWindow( !m_bIsTag );\r
86         CWnd* pHead = GetDlgItem(IDC_RADIO_HEAD);\r
87         CString HeadText;\r
88         pHead->GetWindowText( HeadText ); \r
89         pHead->SetWindowText( HeadText + " (" + g_Git.GetCurrentBranch() + ")");\r
90         EnableSaveRestore(_T("BranchTagDlg"));\r
91         return TRUE;\r
92 \r
93 \r
94 }\r
95 // CCreateBranchTagDlg message handlers\r
96 \r
97 void CCreateBranchTagDlg::OnBnClickedOk()\r
98 {\r
99         // TODO: Add your control notification handler code here\r
100         this->UpdateData(TRUE);\r
101 \r
102         this->m_BranchTagName.Trim();\r
103         if(this->m_BranchTagName.IsEmpty()  ||  this->m_BranchTagName.Find(' ') >= 0 )\r
104         {\r
105                 CMessageBox::Show(NULL, IDS_B_T_NOTEMPTY, IDS_TORTOISEGIT, MB_OK);\r
106                 return;\r
107         }\r
108         this->UpdateRevsionName();\r
109         OnOK();\r
110 }\r
111 \r
112 void CCreateBranchTagDlg::OnCbnSelchangeComboboxexBranch()\r
113 {\r
114         // TODO: Add your control notification handler code here\r
115         \r
116         if(this->m_ChooseVersioinBranch.GetString().Left(6)==_T("origin"))\r
117                 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(TRUE);\r
118         else\r
119                 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);\r
120 \r
121         if(this->m_bIsTag)\r
122                 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);\r
123 }\r