added new log filter (for subject)
[TortoiseGit.git] / src / TortoiseProc / SubmoduleAddDlg.cpp
blob029a6438b585107b36e5f0d5a8502e88bd07477c
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
23 #include "stdafx.h"
24 #include "resource.h"
25 #include "SubmoduleAddDlg.h"
26 #include "BrowseFolder.h"
27 #include "MessageBox.h"
28 #include "AppUtils.h"
30 // CSubmoduleAddDlg dialog
32 IMPLEMENT_DYNAMIC(CSubmoduleAddDlg, CHorizontalResizableStandAloneDialog)
34 CSubmoduleAddDlg::CSubmoduleAddDlg(CWnd* pParent /*=NULL*/)
35 : CHorizontalResizableStandAloneDialog(CSubmoduleAddDlg::IDD, pParent)
36 , m_bBranch(FALSE)
37 , m_strBranch(_T(""))
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)
60 END_MESSAGE_MAP()
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);
81 AddOthersToAnchor();
83 EnableSaveRestore(_T("SubmoduleAddDlg"));
85 CString sWindowTitle;
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);
99 return TRUE;
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()
126 this->UpdateData();
127 if(this->m_bBranch)
129 this->GetDlgItem(IDC_SUBMODULE_BRANCH)->ShowWindow(TRUE);
131 else
133 this->GetDlgItem(IDC_SUBMODULE_BRANCH)->ShowWindow(FALSE);
137 void CSubmoduleAddDlg::OnOK()
139 this->UpdateData();
140 if(m_bBranch)
142 m_strBranch.Trim();
143 if(m_strBranch.IsEmpty())
145 CMessageBox::Show(NULL,_T("Branch can't be empty"),_T("TortoiseGit"),MB_OK|MB_ICONERROR);
146 return ;
149 m_Repository.SaveHistory();
150 m_PathCtrl.SaveHistory();
152 this->m_strPath=m_PathCtrl.GetString();
153 this->m_strRepos=m_Repository.GetString();
155 m_strPath.Trim();
156 m_strRepos.Trim();
157 if(m_strPath.IsEmpty())
159 CMessageBox::Show(NULL,_T("Path can't be empty"),_T("TortoiseGit"),MB_OK|MB_ICONERROR);
160 return ;
162 if(m_strRepos.IsEmpty())
164 CMessageBox::Show(NULL,_T("Repository can't be empty"),_T("TortoiseGit"),MB_OK|MB_ICONERROR);
165 return ;
167 __super::OnOK();