1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2011 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 // SubmoduleAddDlg.cpp : implementation file
25 #include "SubmoduleAddDlg.h"
26 #include "BrowseFolder.h"
27 #include "MessageBox.h"
30 // CSubmoduleAddDlg dialog
32 IMPLEMENT_DYNAMIC(CSubmoduleAddDlg
, CHorizontalResizableStandAloneDialog
)
34 CSubmoduleAddDlg::CSubmoduleAddDlg(CWnd
* pParent
/*=NULL*/)
35 : CHorizontalResizableStandAloneDialog(CSubmoduleAddDlg::IDD
, pParent
)
42 CSubmoduleAddDlg::~CSubmoduleAddDlg()
46 void CSubmoduleAddDlg::DoDataExchange(CDataExchange
* pDX
)
48 CDialog::DoDataExchange(pDX
);
49 DDX_Control(pDX
, IDC_COMBOBOXEX_REPOSITORY
, m_Repository
);
50 DDX_Control(pDX
, IDC_COMBOBOXEX_PATH
, m_PathCtrl
);
51 DDX_Check(pDX
, IDC_BRANCH_CHECK
, m_bBranch
);
52 DDX_Text(pDX
, IDC_SUBMODULE_BRANCH
, m_strBranch
);
56 BEGIN_MESSAGE_MAP(CSubmoduleAddDlg
, CHorizontalResizableStandAloneDialog
)
57 ON_COMMAND(IDC_REP_BROWSE
, OnRepBrowse
)
58 ON_COMMAND(IDC_BUTTON_PATH_BROWSE
, OnPathBrowse
)
59 ON_COMMAND(IDC_BRANCH_CHECK
, OnBranchCheck
)
63 // CSubmoduleAddDlg message handlers
65 BOOL
CSubmoduleAddDlg::OnInitDialog()
67 CHorizontalResizableStandAloneDialog::OnInitDialog();
68 CAppUtils::MarkWindowAsUnpinnable(m_hWnd
);
70 AddAnchor(IDOK
,BOTTOM_RIGHT
);
71 AddAnchor(IDCANCEL
,BOTTOM_RIGHT
);
72 AddAnchor(IDC_GROUP_SUBMODULE
,TOP_LEFT
,BOTTOM_RIGHT
);
73 AddAnchor(IDC_COMBOBOXEX_REPOSITORY
,TOP_LEFT
,TOP_RIGHT
);
74 AddAnchor(IDC_COMBOBOXEX_PATH
,TOP_LEFT
,TOP_RIGHT
);
75 AddAnchor(IDC_REP_BROWSE
,TOP_RIGHT
);
76 AddAnchor(IDC_BUTTON_PATH_BROWSE
,TOP_RIGHT
);
77 AddAnchor(IDC_BRANCH_CHECK
,BOTTOM_LEFT
);
78 AddAnchor(IDC_SUBMODULE_BRANCH
,BOTTOM_LEFT
,BOTTOM_RIGHT
);
79 AddAnchor(IDHELP
, BOTTOM_RIGHT
);
83 EnableSaveRestore(_T("SubmoduleAddDlg"));
86 GetWindowText(sWindowTitle
);
87 CAppUtils::SetWindowTitle(m_hWnd
, (g_Git
.m_CurrentDir
+ _T("\\") + m_strPath
).TrimRight('\\'), sWindowTitle
);
89 m_Repository
.SetURLHistory(true);
90 m_PathCtrl
.SetPathHistory(true);
92 m_Repository
.LoadHistory(_T("Software\\TortoiseGit\\History\\SubModuleRepoURLS"), _T("url"));
93 m_PathCtrl
.LoadHistory(_T("Software\\TortoiseGit\\History\\SubModulePath"), _T("url"));
94 m_PathCtrl
.SetWindowText(m_strPath
);
95 m_Repository
.SetCurSel(0);
97 GetDlgItem(IDC_GROUP_SUBMODULE
)->SetWindowText(CString(_T("Submodule of Project: "))+m_strProject
);
102 void CSubmoduleAddDlg::OnRepBrowse()
104 CBrowseFolder browseFolder
;
105 browseFolder
.m_style
= BIF_EDITBOX
| BIF_NEWDIALOGSTYLE
| BIF_RETURNFSANCESTORS
| BIF_RETURNONLYFSDIRS
;
106 CString strDirectory
;
107 this->m_Repository
.GetWindowTextW(strDirectory
);
108 if (browseFolder
.Show(GetSafeHwnd(), strDirectory
) == CBrowseFolder::OK
)
110 this->m_Repository
.SetWindowTextW(strDirectory
);
113 void CSubmoduleAddDlg::OnPathBrowse()
115 CBrowseFolder browseFolder
;
116 browseFolder
.m_style
= BIF_EDITBOX
| BIF_NEWDIALOGSTYLE
| BIF_RETURNFSANCESTORS
| BIF_RETURNONLYFSDIRS
;
117 CString strDirectory
;
118 this->m_PathCtrl
.GetWindowTextW(strDirectory
);
119 if (browseFolder
.Show(GetSafeHwnd(), strDirectory
,g_Git
.m_CurrentDir
) == CBrowseFolder::OK
)
121 this->m_PathCtrl
.SetWindowTextW(strDirectory
);
124 void CSubmoduleAddDlg::OnBranchCheck()
129 this->GetDlgItem(IDC_SUBMODULE_BRANCH
)->ShowWindow(TRUE
);
132 this->GetDlgItem(IDC_SUBMODULE_BRANCH
)->ShowWindow(FALSE
);
136 void CSubmoduleAddDlg::OnOK()
142 if(m_strBranch
.IsEmpty())
144 CMessageBox::Show(NULL
,_T("Branch can't be empty"),_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
148 m_Repository
.SaveHistory();
149 m_PathCtrl
.SaveHistory();
151 this->m_strPath
=m_PathCtrl
.GetString();
152 this->m_strRepos
=m_Repository
.GetString();
156 if(m_strPath
.IsEmpty())
158 CMessageBox::Show(NULL
,_T("Path can't be empty"),_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);
161 if(m_strRepos
.IsEmpty())
163 CMessageBox::Show(NULL
,_T("Repository can't be empty"),_T("TortoiseGit"),MB_OK
|MB_ICONERROR
);