OSDN Git Service

70f32436d35feda7a03de4dab4d45120471095dd
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / CloneDlg.cpp
1 // CloneDlg.cpp : implementation file\r
2 //\r
3 \r
4 #include "stdafx.h"\r
5 #include "TortoiseProc.h"\r
6 #include "CloneDlg.h"\r
7 #include "BrowseFolder.h"\r
8 #include "MessageBox.h"\r
9 \r
10 // CCloneDlg dialog\r
11 \r
12 IMPLEMENT_DYNCREATE(CCloneDlg, CResizableStandAloneDialog)\r
13 \r
14 CCloneDlg::CCloneDlg(CWnd* pParent /*=NULL*/)\r
15         : CResizableStandAloneDialog(CCloneDlg::IDD, pParent)\r
16         , m_Directory(_T(""))\r
17 {\r
18 \r
19 }\r
20 \r
21 CCloneDlg::~CCloneDlg()\r
22 {\r
23 }\r
24 \r
25 void CCloneDlg::DoDataExchange(CDataExchange* pDX)\r
26 {\r
27         CResizableStandAloneDialog::DoDataExchange(pDX);\r
28         DDX_Control(pDX, IDC_URLCOMBO, m_URLCombo);\r
29         DDX_Text(pDX, IDC_CLONE_DIR, m_Directory);\r
30 }\r
31 \r
32 BOOL CCloneDlg::OnInitDialog()\r
33 {\r
34         CResizableStandAloneDialog::OnInitDialog();\r
35         AddAnchor(IDC_URLCOMBO, TOP_LEFT, TOP_RIGHT);\r
36         AddAnchor(IDC_CLONE_BROWSE_URL, TOP_RIGHT);\r
37         AddAnchor(IDC_CLONE_DIR, TOP_LEFT,TOP_RIGHT);\r
38         AddAnchor(IDC_CLONE_DIR_BROWSE, TOP_RIGHT);\r
39         AddAnchor(IDOK,BOTTOM_RIGHT);\r
40         AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
41 \r
42         m_URLCombo.SetURLHistory(TRUE);\r
43         m_URLCombo.LoadHistory(_T("Software\\TortoiseGit\\History\\repoURLS"), _T("url"));\r
44         if(m_URL.IsEmpty())\r
45                 m_URLCombo.SetCurSel(0);\r
46         else\r
47                 m_URLCombo.SetWindowTextW(m_URL);\r
48 \r
49         CWnd *window=this->GetDlgItem(IDC_CLONE_DIR);\r
50         if(window)\r
51                 SHAutoComplete(window->m_hWnd, SHACF_FILESYSTEM);\r
52         \r
53         return TRUE;  // return TRUE  unless you set the focus to a control\r
54 }\r
55 \r
56 BEGIN_MESSAGE_MAP(CCloneDlg, CResizableStandAloneDialog)\r
57         ON_BN_CLICKED(IDC_CLONE_BROWSE_URL, &CCloneDlg::OnBnClickedCloneBrowseUrl)\r
58         ON_BN_CLICKED(IDC_CLONE_DIR_BROWSE, &CCloneDlg::OnBnClickedCloneDirBrowse)\r
59 END_MESSAGE_MAP()\r
60 \r
61 \r
62 \r
63 // CCloneDlg message handlers\r
64 \r
65 void CCloneDlg::OnOK()\r
66 {\r
67         this->m_URLCombo.GetWindowTextW(m_URL);\r
68         m_URL.Trim();\r
69         UpdateData(TRUE);\r
70         if(m_URL.IsEmpty()||m_Directory.IsEmpty())\r
71         {\r
72                 CMessageBox::Show(NULL,_T("URL or Dir can't empty"),_T("TortiseGit"),MB_OK);\r
73                 return;\r
74         }\r
75         m_URLCombo.SaveHistory();\r
76         CResizableDialog::OnOK();\r
77 \r
78 }\r
79 \r
80 void CCloneDlg::OnCancel()\r
81 {\r
82         CResizableDialog::OnCancel();\r
83 }\r
84 \r
85 void CCloneDlg::OnBnClickedCloneBrowseUrl()\r
86 {\r
87         // TODO: Add your control notification handler code here\r
88         CBrowseFolder browseFolder;\r
89         browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;\r
90         CString strCloneDirectory;\r
91         this->m_URLCombo.GetWindowTextW(strCloneDirectory);\r
92         if (browseFolder.Show(GetSafeHwnd(), strCloneDirectory) == CBrowseFolder::OK) \r
93         {\r
94                 this->m_URLCombo.SetWindowTextW(strCloneDirectory);\r
95         }\r
96 }\r
97 \r
98 void CCloneDlg::OnBnClickedCloneDirBrowse()\r
99 {\r
100         // TODO: Add your control notification handler code here\r
101         CBrowseFolder browseFolder;\r
102         browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;\r
103         CString strCloneDirectory = this->m_Directory;\r
104         if (browseFolder.Show(GetSafeHwnd(), strCloneDirectory) == CBrowseFolder::OK) \r
105         {\r
106                 UpdateData(TRUE);\r
107                 m_Directory = strCloneDirectory;\r
108                 UpdateData(FALSE);\r
109         }\r
110 }\r
111 \r
112 void CCloneDlg::OnEnChangeCloneDir()\r
113 {\r
114         // TODO:  If this is a RICHEDIT control, the control will not\r
115         // send this notification unless you override the CDHtmlDialog::OnInitDialog()\r
116         // function and call CRichEditCtrl().SetEventMask()\r
117         // with the ENM_CHANGE flag ORed into the mask.\r
118 \r
119         // TODO:  Add your control notification handler code here\r
120 }\r