OSDN Git Service

Fix issue 17 Switch should default branch to current branch
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / PushDlg.cpp
1 // PushDlg.cpp : implementation file\r
2 //\r
3 \r
4 #include "stdafx.h"\r
5 #include "TortoiseProc.h"\r
6 #include "PushDlg.h"\r
7 \r
8 #include "Git.h"\r
9 // CPushDlg dialog\r
10 \r
11 IMPLEMENT_DYNAMIC(CPushDlg, CResizableStandAloneDialog)\r
12 \r
13 CPushDlg::CPushDlg(CWnd* pParent /*=NULL*/)\r
14         : CResizableStandAloneDialog(CPushDlg::IDD, pParent)\r
15 {\r
16 \r
17 }\r
18 \r
19 CPushDlg::~CPushDlg()\r
20 {\r
21 }\r
22 \r
23 void CPushDlg::DoDataExchange(CDataExchange* pDX)\r
24 {\r
25         CResizableStandAloneDialog::DoDataExchange(pDX);\r
26         DDX_Control(pDX, IDC_BRANCH_REMOTE, this->m_BranchRemote);\r
27         DDX_Control(pDX, IDC_BRANCH_SOURCE, this->m_BranchSource);\r
28         DDX_Control(pDX, IDC_REMOTE, this->m_Remote);\r
29         DDX_Control(pDX, IDC_URL, this->m_RemoteURL);\r
30         DDX_Check(pDX,IDC_FORCE,this->m_bForce);\r
31         DDX_Check(pDX,IDC_PACK,this->m_bPack);\r
32         DDX_Check(pDX,IDC_TAGS,this->m_bTags);\r
33 \r
34 }\r
35 \r
36 \r
37 BEGIN_MESSAGE_MAP(CPushDlg, CResizableStandAloneDialog)\r
38         ON_BN_CLICKED(IDC_RD_REMOTE, &CPushDlg::OnBnClickedRd)\r
39         ON_BN_CLICKED(IDC_RD_URL, &CPushDlg::OnBnClickedRd)\r
40         ON_CBN_SELCHANGE(IDC_BRANCH_SOURCE, &CPushDlg::OnCbnSelchangeBranchSource)\r
41         ON_BN_CLICKED(IDOK, &CPushDlg::OnBnClickedOk)\r
42 END_MESSAGE_MAP()\r
43 \r
44 BOOL CPushDlg::OnInitDialog()\r
45 {\r
46         CResizableStandAloneDialog::OnInitDialog();\r
47         \r
48         AddAnchor(IDC_BRANCH_REMOTE, TOP_RIGHT);\r
49         AddAnchor(IDC_BRANCH_SOURCE, TOP_LEFT);\r
50 \r
51         AddAnchor(IDC_REMOTE, TOP_LEFT, TOP_RIGHT);\r
52         AddAnchor(IDC_URL, TOP_LEFT,TOP_RIGHT);\r
53 \r
54         AddAnchor(IDC_URL_GROUP, TOP_LEFT,TOP_RIGHT);\r
55         AddAnchor(IDC_OPTION_GROUP, TOP_LEFT,TOP_RIGHT);\r
56         AddAnchor(IDC_BRANCH_GROUP, TOP_LEFT,TOP_RIGHT);\r
57 \r
58         AddAnchor(IDC_STATIC_REMOTE, TOP_RIGHT);\r
59 \r
60         AddAnchor(IDOK,BOTTOM_RIGHT);\r
61         AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
62 \r
63         EnableSaveRestore(_T("PushDlg"));\r
64 \r
65         m_RemoteURL.SetURLHistory(TRUE);\r
66         m_RemoteURL.LoadHistory(_T("Software\\TortoiseGit\\History\\PushURLS"), _T("url"));\r
67         m_RemoteURL.SetCurSel(0);\r
68 \r
69         m_RemoteURL.EnableWindow(FALSE);\r
70         CheckRadioButton(IDC_RD_REMOTE,IDC_RD_URL,IDC_RD_REMOTE);\r
71 \r
72         STRING_VECTOR list;\r
73 \r
74         if(!g_Git.GetRemoteList(list))\r
75         {       \r
76                 for(unsigned int i=0;i<list.size();i++)\r
77                         m_Remote.AddString(list[i]);\r
78         }\r
79 \r
80         int current=0;\r
81         list.clear();\r
82         if(!g_Git.GetBranchList(list,&current))\r
83         {\r
84                 for(unsigned int i=0;i<list.size();i++)\r
85                         m_BranchSource.AddString(list[i]);\r
86         }\r
87         m_BranchSource.SetCurSel(current);\r
88         \r
89         m_BranchRemote.LoadHistory(_T("Software\\TortoiseGit\\History\\RemoteBranch"), _T("branch"));\r
90         m_BranchRemote.SetCurSel(0);\r
91 \r
92         //m_BranchRemote.SetWindowTextW(m_BranchSource.GetString());\r
93 \r
94         \r
95         return TRUE;\r
96 }\r
97 \r
98 // CPushDlg message handlers\r
99 \r
100 void CPushDlg::OnBnClickedRd()\r
101 {\r
102         // TODO: Add your control notification handler code here\r
103         // TODO: Add your control notification handler code here\r
104         if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_REMOTE)\r
105         {\r
106                 m_Remote.EnableWindow(TRUE);\r
107                 m_RemoteURL.EnableWindow(FALSE);;\r
108         }\r
109         if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_URL)\r
110         {\r
111                 m_Remote.EnableWindow(FALSE);\r
112                 m_RemoteURL.EnableWindow(TRUE);\r
113         }\r
114 }\r
115 \r
116 \r
117 void CPushDlg::OnCbnSelchangeBranchSource()\r
118 {\r
119         // TODO: Add your control notification handler code here\r
120         m_BranchRemote.SetWindowTextW(m_BranchSource.GetString());\r
121 }\r
122 \r
123 void CPushDlg::OnBnClickedOk()\r
124 {\r
125         // TODO: Add your control notification handler code here\r
126         CResizableStandAloneDialog::UpdateData(TRUE);\r
127 \r
128         if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_REMOTE)\r
129         {\r
130                 m_URL=m_Remote.GetString();\r
131         }\r
132         if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_URL)\r
133         {\r
134                 m_URL=m_RemoteURL.GetString();\r
135         }\r
136 \r
137         this->m_BranchRemoteName=m_BranchRemote.GetString();\r
138         this->m_BranchSourceName=m_BranchSource.GetString();\r
139 \r
140         this->m_RemoteURL.SaveHistory();\r
141         this->m_BranchRemote.SaveHistory();\r
142         CResizableStandAloneDialog::OnOK();\r
143 }\r