OSDN Git Service

Push dialog: Save last remote name.
[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 #include "registry.h"\r
10 // CPushDlg dialog\r
11 \r
12 IMPLEMENT_DYNAMIC(CPushDlg, CResizableStandAloneDialog)\r
13 \r
14 CPushDlg::CPushDlg(CWnd* pParent /*=NULL*/)\r
15         : CResizableStandAloneDialog(CPushDlg::IDD, pParent)\r
16 {\r
17 \r
18 }\r
19 \r
20 CPushDlg::~CPushDlg()\r
21 {\r
22 }\r
23 \r
24 void CPushDlg::DoDataExchange(CDataExchange* pDX)\r
25 {\r
26         CResizableStandAloneDialog::DoDataExchange(pDX);\r
27         DDX_Control(pDX, IDC_BRANCH_REMOTE, this->m_BranchRemote);\r
28         DDX_Control(pDX, IDC_BRANCH_SOURCE, this->m_BranchSource);\r
29         DDX_Control(pDX, IDC_REMOTE, this->m_Remote);\r
30         DDX_Control(pDX, IDC_URL, this->m_RemoteURL);\r
31         DDX_Check(pDX,IDC_FORCE,this->m_bForce);\r
32         DDX_Check(pDX,IDC_PACK,this->m_bPack);\r
33         DDX_Check(pDX,IDC_TAGS,this->m_bTags);\r
34 \r
35 }\r
36 \r
37 \r
38 BEGIN_MESSAGE_MAP(CPushDlg, CResizableStandAloneDialog)\r
39         ON_BN_CLICKED(IDC_RD_REMOTE, &CPushDlg::OnBnClickedRd)\r
40         ON_BN_CLICKED(IDC_RD_URL, &CPushDlg::OnBnClickedRd)\r
41         ON_CBN_SELCHANGE(IDC_BRANCH_SOURCE, &CPushDlg::OnCbnSelchangeBranchSource)\r
42         ON_BN_CLICKED(IDOK, &CPushDlg::OnBnClickedOk)\r
43 END_MESSAGE_MAP()\r
44 \r
45 BOOL CPushDlg::OnInitDialog()\r
46 {\r
47         CResizableStandAloneDialog::OnInitDialog();\r
48         \r
49         AddAnchor(IDOK,BOTTOM_RIGHT);\r
50         AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
51         AddAnchor(IDC_BRANCH_GROUP, TOP_LEFT,TOP_RIGHT);\r
52         AddAnchor(IDC_STATIC_REMOTE, TOP_RIGHT);\r
53         AddAnchor(IDC_STATIC_SOURCE, TOP_LEFT);\r
54 \r
55         AddAnchor(IDC_BRANCH_REMOTE, TOP_RIGHT);\r
56         AddAnchor(IDC_BRANCH_SOURCE, TOP_LEFT);\r
57 \r
58         AddAnchor(IDC_URL_GROUP, TOP_LEFT,TOP_RIGHT);\r
59         AddAnchor(IDC_RD_REMOTE, TOP_LEFT);\r
60         AddAnchor(IDC_RD_URL, TOP_LEFT);\r
61 \r
62         AddAnchor(IDC_REMOTE, TOP_LEFT, TOP_RIGHT);\r
63         \r
64         AddAnchor(IDC_URL, TOP_LEFT,TOP_RIGHT);\r
65 \r
66         AddAnchor(IDC_OPTION_GROUP, TOP_LEFT,TOP_RIGHT);\r
67         \r
68         AddAnchor(IDC_FORCE, TOP_LEFT);\r
69         AddAnchor(IDC_PACK, TOP_LEFT);\r
70         AddAnchor(IDC_TAGS, TOP_LEFT);\r
71 \r
72 \r
73         AddOthersToAnchor();\r
74 \r
75 \r
76         EnableSaveRestore(_T("PushDlg"));\r
77 \r
78         m_RemoteURL.SetURLHistory(TRUE);\r
79         \r
80         CString WorkingDir=g_Git.m_CurrentDir;\r
81         WorkingDir.Replace(_T(':'),_T('_'));\r
82         m_RemoteURL.LoadHistory(CString(_T("Software\\TortoiseGit\\History\\PushURLS\\"))+WorkingDir, _T("url"));\r
83         m_RemoteURL.SetCurSel(0);\r
84 \r
85         m_RemoteURL.EnableWindow(FALSE);\r
86         CheckRadioButton(IDC_RD_REMOTE,IDC_RD_URL,IDC_RD_REMOTE);\r
87 \r
88         STRING_VECTOR list;\r
89         CRegString remote(CString(_T("Software\\TortoiseGit\\History\\PushRemote\\")+WorkingDir));\r
90         m_RemoteReg = remote;\r
91         int sel=0;\r
92 \r
93         if(!g_Git.GetRemoteList(list))\r
94         {       \r
95                 for(unsigned int i=0;i<list.size();i++)\r
96                 {\r
97                         m_Remote.AddString(list[i]);\r
98                         if(list[i] == remote)\r
99                                 sel = i;\r
100                 }\r
101         }\r
102         m_Remote.SetCurSel(sel);\r
103 \r
104         int current=0;\r
105         list.clear();\r
106         if(!g_Git.GetBranchList(list,&current))\r
107         {\r
108                 for(unsigned int i=0;i<list.size();i++)\r
109                         m_BranchSource.AddString(list[i]);\r
110         }\r
111         m_BranchSource.SetCurSel(current);\r
112         \r
113         m_BranchRemote.LoadHistory(CString(_T("Software\\TortoiseGit\\History\\RemoteBranch\\"))+WorkingDir, _T("branch"));\r
114         m_BranchRemote.SetCurSel(0);\r
115 \r
116         //m_BranchRemote.SetWindowTextW(m_BranchSource.GetString());\r
117 \r
118         \r
119         return TRUE;\r
120 }\r
121 \r
122 // CPushDlg message handlers\r
123 \r
124 void CPushDlg::OnBnClickedRd()\r
125 {\r
126         // TODO: Add your control notification handler code here\r
127         // TODO: Add your control notification handler code here\r
128         if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_REMOTE)\r
129         {\r
130                 m_Remote.EnableWindow(TRUE);\r
131                 m_RemoteURL.EnableWindow(FALSE);;\r
132         }\r
133         if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_URL)\r
134         {\r
135                 m_Remote.EnableWindow(FALSE);\r
136                 m_RemoteURL.EnableWindow(TRUE);\r
137         }\r
138 }\r
139 \r
140 \r
141 void CPushDlg::OnCbnSelchangeBranchSource()\r
142 {\r
143         // TODO: Add your control notification handler code here\r
144         m_BranchRemote.SetWindowTextW(m_BranchSource.GetString());\r
145 }\r
146 \r
147 void CPushDlg::OnBnClickedOk()\r
148 {\r
149         // TODO: Add your control notification handler code here\r
150         CResizableStandAloneDialog::UpdateData(TRUE);\r
151 \r
152         if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_REMOTE)\r
153         {\r
154                 m_URL=m_Remote.GetString();\r
155         }\r
156         if( GetCheckedRadioButton(IDC_RD_REMOTE,IDC_RD_URL) == IDC_RD_URL)\r
157         {\r
158                 m_URL=m_RemoteURL.GetString();\r
159         }\r
160 \r
161         this->m_BranchRemoteName=m_BranchRemote.GetString();\r
162         this->m_BranchSourceName=m_BranchSource.GetString();\r
163 \r
164         this->m_RemoteURL.SaveHistory();\r
165         this->m_BranchRemote.SaveHistory();\r
166         \r
167         m_RemoteReg = m_Remote.GetString();\r
168 \r
169         CResizableStandAloneDialog::OnOK();\r
170 }\r