OSDN Git Service

Submodule Add Dialog support browse
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / SubmoduleAddDlg.cpp
1 // SubmoduleAddDlg.cpp : implementation file\r
2 //\r
3 \r
4 #include "stdafx.h"\r
5 #include "resource.h"\r
6 #include "SubmoduleAddDlg.h"\r
7 #include "BrowseFolder.h"\r
8 \r
9 // CSubmoduleAddDlg dialog\r
10 \r
11 IMPLEMENT_DYNAMIC(CSubmoduleAddDlg, CResizableStandAloneDialog)\r
12 \r
13 CSubmoduleAddDlg::CSubmoduleAddDlg(CWnd* pParent /*=NULL*/)\r
14         : CResizableStandAloneDialog(CSubmoduleAddDlg::IDD, pParent)\r
15         , m_bBranch(FALSE)\r
16         , m_strBranch(_T(""))\r
17 {\r
18 \r
19 }\r
20 \r
21 CSubmoduleAddDlg::~CSubmoduleAddDlg()\r
22 {\r
23 }\r
24 \r
25 void CSubmoduleAddDlg::DoDataExchange(CDataExchange* pDX)\r
26 {\r
27         CDialog::DoDataExchange(pDX);\r
28         DDX_Control(pDX, IDC_COMBOBOXEX_REPOSITORY, m_Repository);\r
29         DDX_Control(pDX, IDC_COMBOBOXEX_PATH, m_PathCtrl);\r
30         DDX_Check(pDX, IDC_BRANCH_CHECK, m_bBranch);\r
31         DDX_Text(pDX, IDC_SUBMODULE_BRANCH, m_strBranch);\r
32 }\r
33 \r
34 \r
35 BEGIN_MESSAGE_MAP(CSubmoduleAddDlg, CResizableStandAloneDialog)\r
36         ON_COMMAND(IDC_REP_BROWSE,                      OnRepBrowse)\r
37         ON_COMMAND(IDC_BUTTON_PATH_BROWSE,      OnPathBrowse)\r
38         ON_COMMAND(IDC_BRANCH_CHECK,            OnBranchCheck)\r
39 END_MESSAGE_MAP()\r
40 \r
41 \r
42 // CSubmoduleAddDlg message handlers\r
43 \r
44 BOOL CSubmoduleAddDlg::OnInitDialog()\r
45 {\r
46         CResizableStandAloneDialog::OnInitDialog();\r
47 \r
48         AddAnchor(IDOK,BOTTOM_RIGHT);\r
49         AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
50         AddAnchor(IDC_GROUP_SUBMODULE,TOP_LEFT,BOTTOM_RIGHT);\r
51         AddAnchor(IDC_COMBOBOXEX_REPOSITORY,TOP_LEFT,TOP_RIGHT);\r
52         AddAnchor(IDC_COMBOBOXEX_PATH,TOP_LEFT,TOP_RIGHT);\r
53         AddAnchor(IDC_REP_BROWSE,TOP_RIGHT);\r
54         AddAnchor(IDC_BUTTON_PATH_BROWSE,TOP_RIGHT);    \r
55         AddAnchor(IDC_BRANCH_CHECK,BOTTOM_LEFT);\r
56         AddAnchor(IDC_SUBMODULE_BRANCH,BOTTOM_LEFT,BOTTOM_RIGHT);\r
57 \r
58 \r
59         AddOthersToAnchor();\r
60 \r
61         EnableSaveRestore(_T("SubmoduleAddDlg"));\r
62 \r
63         m_Repository.SetURLHistory(true);\r
64         m_PathCtrl.SetPathHistory(true);\r
65 \r
66         m_Repository.LoadHistory(_T("Software\\TortoiseGit\\History\\SubModuleRepoURLS"), _T("url"));\r
67         m_PathCtrl.LoadHistory(_T("Software\\TortoiseGit\\History\\SubModulePath"), _T("url"));\r
68         m_Repository.SetCurSel(0);\r
69 \r
70         \r
71         return TRUE;\r
72 }\r
73 \r
74 void CSubmoduleAddDlg::OnRepBrowse()\r
75 {\r
76         CBrowseFolder browseFolder;\r
77         browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;\r
78         CString strDirectory;\r
79         this->m_Repository.GetWindowTextW(strDirectory);\r
80         if (browseFolder.Show(GetSafeHwnd(), strDirectory) == CBrowseFolder::OK) \r
81         {\r
82                 this->m_Repository.SetWindowTextW(strDirectory);\r
83         }\r
84 }\r
85 void CSubmoduleAddDlg::OnPathBrowse()\r
86 {\r
87         CBrowseFolder browseFolder;\r
88         browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;\r
89         CString strDirectory;\r
90         this->m_PathCtrl.GetWindowTextW(strDirectory);\r
91         if (browseFolder.Show(GetSafeHwnd(), strDirectory) == CBrowseFolder::OK) \r
92         {\r
93                 this->m_PathCtrl.SetWindowTextW(strDirectory);\r
94         }\r
95 }\r
96 void CSubmoduleAddDlg::OnBranchCheck()\r
97 {\r
98         this->UpdateData();\r
99         if(this->m_bBranch)\r
100         {\r
101                 this->GetDlgItem(IDC_SUBMODULE_BRANCH)->ShowWindow(TRUE);               \r
102         }else\r
103         {\r
104                 this->GetDlgItem(IDC_SUBMODULE_BRANCH)->ShowWindow(FALSE);              \r
105         }\r
106 }\r
107 \r
108 void CSubmoduleAddDlg::OnOK()\r
109 {\r
110         m_Repository.SaveHistory();\r
111         m_PathCtrl.SaveHistory();\r
112         __super::OnOK();\r
113 }