OSDN Git Service

Finish Submodule Add Command
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / SubmoduleAddDlg.cpp
index aae3774..13aa51b 100644 (file)
@@ -4,7 +4,8 @@
 #include "stdafx.h"\r
 #include "resource.h"\r
 #include "SubmoduleAddDlg.h"\r
-\r
+#include "BrowseFolder.h"\r
+#include "MessageBox.h"\r
 \r
 // CSubmoduleAddDlg dialog\r
 \r
@@ -63,14 +64,37 @@ BOOL CSubmoduleAddDlg::OnInitDialog()
        m_Repository.SetURLHistory(true);\r
        m_PathCtrl.SetPathHistory(true);\r
 \r
+       m_Repository.LoadHistory(_T("Software\\TortoiseGit\\History\\SubModuleRepoURLS"), _T("url"));\r
+       m_PathCtrl.LoadHistory(_T("Software\\TortoiseGit\\History\\SubModulePath"), _T("url"));\r
+       m_PathCtrl.SetWindowText(m_strPath);\r
+       m_Repository.SetCurSel(0);\r
+\r
+       GetDlgItem(IDC_GROUP_SUBMODULE)->SetWindowText(CString(_T("Submodule of Project: "))+m_strProject);\r
+       \r
        return TRUE;\r
 }\r
 \r
 void CSubmoduleAddDlg::OnRepBrowse()\r
 {\r
+       CBrowseFolder browseFolder;\r
+       browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;\r
+       CString strDirectory;\r
+       this->m_Repository.GetWindowTextW(strDirectory);\r
+       if (browseFolder.Show(GetSafeHwnd(), strDirectory) == CBrowseFolder::OK) \r
+       {\r
+               this->m_Repository.SetWindowTextW(strDirectory);\r
+       }\r
 }\r
 void CSubmoduleAddDlg::OnPathBrowse()\r
 {\r
+       CBrowseFolder browseFolder;\r
+       browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;\r
+       CString strDirectory;\r
+       this->m_PathCtrl.GetWindowTextW(strDirectory);\r
+       if (browseFolder.Show(GetSafeHwnd(), strDirectory,g_Git.m_CurrentDir) == CBrowseFolder::OK) \r
+       {\r
+               this->m_PathCtrl.SetWindowTextW(strDirectory);\r
+       }\r
 }\r
 void CSubmoduleAddDlg::OnBranchCheck()\r
 {\r
@@ -82,4 +106,37 @@ void CSubmoduleAddDlg::OnBranchCheck()
        {\r
                this->GetDlgItem(IDC_SUBMODULE_BRANCH)->ShowWindow(FALSE);              \r
        }\r
+}\r
+\r
+void CSubmoduleAddDlg::OnOK()\r
+{\r
+       this->UpdateData();\r
+       if(m_bBranch)\r
+       {\r
+               m_strBranch.Trim();\r
+               if(m_strBranch.IsEmpty())\r
+               {\r
+                       CMessageBox::Show(NULL,_T("Branch can't be empty"),_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+                       return ;\r
+               }\r
+       }\r
+       m_Repository.SaveHistory();\r
+       m_PathCtrl.SaveHistory();\r
+\r
+       this->m_strPath=m_PathCtrl.GetString();\r
+       this->m_strRepos=m_Repository.GetString();\r
+\r
+       m_strPath.Trim();\r
+       m_strRepos.Trim();\r
+       if(m_strPath.IsEmpty())\r
+       {\r
+               CMessageBox::Show(NULL,_T("Path can't be empty"),_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+                       return ;\r
+       }\r
+       if(m_strRepos.IsEmpty())\r
+       {\r
+               CMessageBox::Show(NULL,_T("Repository can't be empty"),_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+                       return ;\r
+       }\r
+       __super::OnOK();\r
 }
\ No newline at end of file