OSDN Git Service

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