OSDN Git Service

e11f84945ae0b358879e8a8e13ff252dda5ef857
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / GitSwitchDlg.cpp
1 // GitSwitch.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 "GitSwitchDlg.h"\r
8 \r
9 \r
10 #include "Messagebox.h"\r
11 \r
12 // CGitSwitchDlg dialog\r
13 \r
14 IMPLEMENT_DYNAMIC(CGitSwitchDlg, CResizableStandAloneDialog)\r
15 \r
16 CGitSwitchDlg::CGitSwitchDlg(CWnd* pParent /*=NULL*/)\r
17         : CResizableStandAloneDialog(CGitSwitchDlg::IDD, pParent)\r
18         ,CChooseVersion(this)\r
19 {\r
20         m_bBranch=FALSE;\r
21 }\r
22 \r
23 CGitSwitchDlg::~CGitSwitchDlg()\r
24 {\r
25 }\r
26 \r
27 void CGitSwitchDlg::DoDataExchange(CDataExchange* pDX)\r
28 {\r
29         CDialog::DoDataExchange(pDX);\r
30         CHOOSE_VERSION_DDX;\r
31                                 \r
32         DDX_Check(pDX,IDC_CHECK_FORCE,this->m_bForce);\r
33         DDX_Check(pDX,IDC_CHECK_TRACK,this->m_bTrack);\r
34         DDX_Check(pDX,IDC_CHECK_BRANCH,this->m_bBranch);\r
35 \r
36         DDX_Text(pDX,IDC_EDIT_BRANCH,this->m_NewBranch);\r
37 }\r
38 \r
39 \r
40 BEGIN_MESSAGE_MAP(CGitSwitchDlg, CResizableStandAloneDialog)\r
41 \r
42         CHOOSE_VERSION_EVENT\r
43         ON_BN_CLICKED(IDC_CHECK_BRANCH, &CGitSwitchDlg::OnBnClickedCheckBranch)\r
44         ON_BN_CLICKED(IDOK, &CGitSwitchDlg::OnBnClickedOk)\r
45         ON_CBN_SELCHANGE(IDC_COMBOBOXEX_BRANCH, &CGitSwitchDlg::OnCbnSelchangeComboboxexBranch)\r
46 END_MESSAGE_MAP()\r
47 \r
48 BOOL CGitSwitchDlg::OnInitDialog()\r
49 {\r
50         CResizableStandAloneDialog::OnInitDialog();\r
51 \r
52         AddAnchor(IDC_GROUP_OPTION, TOP_LEFT, TOP_RIGHT);\r
53 \r
54         AddAnchor(IDC_EDIT_BRANCH, TOP_LEFT, TOP_RIGHT);\r
55 \r
56         AddAnchor(IDOK,BOTTOM_RIGHT);\r
57         AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
58 \r
59         \r
60         CHOOSE_VERSION_ADDANCHOR;\r
61         Init();\r
62 \r
63         EnableSaveRestore(_T("SwitchDlg"));\r
64 \r
65         if(m_Base.IsEmpty())\r
66                 SetDefaultChoose(IDC_RADIO_BRANCH);\r
67         else\r
68         {\r
69                 this->GetDlgItem(IDC_COMBOBOXEX_VERSION)->SetWindowTextW(m_Base);\r
70                 SetDefaultChoose(IDC_RADIO_VERSION);\r
71         }\r
72 \r
73         OnBnClickedCheckBranch();\r
74         this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);\r
75 \r
76         return TRUE;\r
77 \r
78 \r
79 }\r
80 // CCreateBranchTagDlg message handlers\r
81 \r
82 void CGitSwitchDlg::OnBnClickedChooseRadioHost()\r
83 {\r
84         // TODO: Add your control notification handler code here\r
85         OnBnClickedChooseRadio();\r
86         OnCbnSelchangeComboboxexBranch();\r
87         OnBnClickedCheckBranch();\r
88         \r
89 }\r
90 \r
91 void CGitSwitchDlg::OnBnClickedOk()\r
92 {\r
93         this->UpdateData(TRUE);\r
94         \r
95         // make sure a valid branch has been entered if a new branch is required\r
96         if ( m_bBranch  &&  ( m_NewBranch.Trim().IsEmpty() ||  m_NewBranch.Find(' ') >= 0 ) )\r
97         {\r
98                 // new branch requested but name is empty or contains spaces\r
99                 CMessageBox::Show(NULL, IDS_B_T_NOTEMPTY, IDS_TORTOISEGIT, MB_OK);\r
100         }\r
101         else\r
102         {\r
103                 UpdateRevsionName();\r
104                 //this->m_Version.SaveHistory();\r
105                 OnOK();\r
106         }\r
107 }\r
108 void CGitSwitchDlg::OnBnClickedCheckBranch()\r
109 {\r
110         // TODO: Add your control notification handler code here\r
111         this->UpdateData(TRUE);\r
112         this->UpdateRevsionName();\r
113         GetDlgItem(IDC_EDIT_BRANCH)->SetWindowTextW(CString(_T("Branch_"))+this->m_VersionName);\r
114 \r
115 #if 0   \r
116         int radio=GetCheckedRadioButton(IDC_RADIO_BRANCH,IDC_RADIO_VERSION);\r
117         if(radio==IDC_RADIO_TAGS || radio==IDC_RADIO_VERSION)\r
118         {\r
119                 this->m_bBranch=TRUE;\r
120                 this->UpdateData(FALSE);\r
121                 this->UpdateRevsionName();\r
122                 \r
123         }else\r
124         {\r
125                 this->m_bBranch=FALSE;\r
126                 this->UpdateData(FALSE);\r
127         }\r
128 #endif\r
129         this->GetDlgItem(IDC_EDIT_BRANCH)->EnableWindow(this->m_bBranch);\r
130 }\r
131 \r
132 void CGitSwitchDlg::OnCbnSelchangeComboboxexBranch()\r
133 {\r
134         // TODO: Add your control notification handler code here\r
135         int radio=GetCheckedRadioButton(IDC_RADIO_BRANCH,IDC_RADIO_VERSION);\r
136         if(this->m_ChooseVersioinBranch.GetString().Left(6)==_T("origin") && radio==IDC_RADIO_BRANCH )\r
137                 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(TRUE);\r
138         else\r
139                 this->GetDlgItem(IDC_CHECK_TRACK)->EnableWindow(FALSE);\r
140 }\r