OSDN Git Service

Finish Submodule Add Command
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / SubmoduleAddDlg.cpp
index e1c5752..13aa51b 100644 (file)
@@ -4,14 +4,15 @@
 #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
-IMPLEMENT_DYNAMIC(CSubmoduleAddDlg, CDialog)\r
+IMPLEMENT_DYNAMIC(CSubmoduleAddDlg, CResizableStandAloneDialog)\r
 \r
 CSubmoduleAddDlg::CSubmoduleAddDlg(CWnd* pParent /*=NULL*/)\r
-       : CDialog(CSubmoduleAddDlg::IDD, pParent)\r
+       : CResizableStandAloneDialog(CSubmoduleAddDlg::IDD, pParent)\r
        , m_bBranch(FALSE)\r
        , m_strBranch(_T(""))\r
 {\r
@@ -32,8 +33,110 @@ void CSubmoduleAddDlg::DoDataExchange(CDataExchange* pDX)
 }\r
 \r
 \r
-BEGIN_MESSAGE_MAP(CSubmoduleAddDlg, CDialog)\r
+BEGIN_MESSAGE_MAP(CSubmoduleAddDlg, CResizableStandAloneDialog)\r
+       ON_COMMAND(IDC_REP_BROWSE,                      OnRepBrowse)\r
+       ON_COMMAND(IDC_BUTTON_PATH_BROWSE,      OnPathBrowse)\r
+       ON_COMMAND(IDC_BRANCH_CHECK,            OnBranchCheck)\r
 END_MESSAGE_MAP()\r
 \r
 \r
 // CSubmoduleAddDlg message handlers\r
+\r
+BOOL CSubmoduleAddDlg::OnInitDialog()\r
+{\r
+       CResizableStandAloneDialog::OnInitDialog();\r
+\r
+       AddAnchor(IDOK,BOTTOM_RIGHT);\r
+       AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
+       AddAnchor(IDC_GROUP_SUBMODULE,TOP_LEFT,BOTTOM_RIGHT);\r
+       AddAnchor(IDC_COMBOBOXEX_REPOSITORY,TOP_LEFT,TOP_RIGHT);\r
+       AddAnchor(IDC_COMBOBOXEX_PATH,TOP_LEFT,TOP_RIGHT);\r
+       AddAnchor(IDC_REP_BROWSE,TOP_RIGHT);\r
+       AddAnchor(IDC_BUTTON_PATH_BROWSE,TOP_RIGHT);    \r
+       AddAnchor(IDC_BRANCH_CHECK,BOTTOM_LEFT);\r
+       AddAnchor(IDC_SUBMODULE_BRANCH,BOTTOM_LEFT,BOTTOM_RIGHT);\r
+\r
+\r
+       AddOthersToAnchor();\r
+\r
+       EnableSaveRestore(_T("SubmoduleAddDlg"));\r
+\r
+       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
+       this->UpdateData();\r
+       if(this->m_bBranch)\r
+       {\r
+               this->GetDlgItem(IDC_SUBMODULE_BRANCH)->ShowWindow(TRUE);               \r
+       }else\r
+       {\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