SyncDlg: Make check if local branch fast-fowards to remote branch work again
[TortoiseGit.git] / src / TortoiseProc / SubmoduleAddDlg.cpp
blobaef4d943987383779b79fc6bcdbdd3692bc3105c
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - 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);
80 AddOthersToAnchor();
82 AdjustControlSize(IDC_BRANCH_CHECK);
84 EnableSaveRestore(_T("SubmoduleAddDlg"));
86 CString sWindowTitle;
87 GetWindowText(sWindowTitle);
88 CAppUtils::SetWindowTitle(m_hWnd, (g_Git.m_CurrentDir + _T("\\") + m_strPath).TrimRight('\\'), sWindowTitle);
90 m_Repository.SetURLHistory(true);
91 m_PathCtrl.SetPathHistory(true);
93 m_Repository.LoadHistory(_T("Software\\TortoiseGit\\History\\SubModuleRepoURLS"), _T("url"));
94 m_PathCtrl.LoadHistory(_T("Software\\TortoiseGit\\History\\SubModulePath"), _T("url"));
95 m_PathCtrl.SetWindowText(m_strPath);
96 m_Repository.SetCurSel(0);
98 GetDlgItem(IDC_GROUP_SUBMODULE)->SetWindowText(CString(_T("Submodule of Project: "))+m_strProject);
100 m_tooltips.Create(this);
102 return TRUE;
105 void CSubmoduleAddDlg::OnRepBrowse()
107 CBrowseFolder browseFolder;
108 browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
109 CString strDirectory;
110 this->m_Repository.GetWindowTextW(strDirectory);
111 if (browseFolder.Show(GetSafeHwnd(), strDirectory) == CBrowseFolder::OK)
113 this->m_Repository.SetWindowTextW(strDirectory);
116 void CSubmoduleAddDlg::OnPathBrowse()
118 CBrowseFolder browseFolder;
119 browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
120 CString strDirectory;
121 this->m_PathCtrl.GetWindowTextW(strDirectory);
122 if (browseFolder.Show(GetSafeHwnd(), strDirectory,g_Git.m_CurrentDir) == CBrowseFolder::OK)
124 this->m_PathCtrl.SetWindowTextW(strDirectory);
127 void CSubmoduleAddDlg::OnBranchCheck()
129 this->UpdateData();
130 if(this->m_bBranch)
132 this->GetDlgItem(IDC_SUBMODULE_BRANCH)->ShowWindow(TRUE);
134 else
136 this->GetDlgItem(IDC_SUBMODULE_BRANCH)->ShowWindow(FALSE);
140 void CSubmoduleAddDlg::OnOK()
142 this->UpdateData();
143 if(m_bBranch)
145 m_strBranch.Trim();
146 if(m_strBranch.IsEmpty())
148 m_tooltips.ShowBalloon(IDC_SUBMODULE_BRANCH, IDS_ERR_MISSINGVALUE, IDS_ERR_ERROR, TTI_ERROR);
149 return;
152 m_Repository.SaveHistory();
153 m_PathCtrl.SaveHistory();
155 this->m_strPath=m_PathCtrl.GetString();
156 this->m_strRepos=m_Repository.GetString();
158 m_strPath.Trim();
159 m_strRepos.Trim();
160 if(m_strPath.IsEmpty())
162 m_tooltips.ShowBalloon(IDC_COMBOBOXEX_PATH, IDS_ERR_MISSINGVALUE, IDS_ERR_ERROR, TTI_ERROR);
163 return;
165 if(m_strRepos.IsEmpty())
167 m_tooltips.ShowBalloon(IDC_COMBOBOXEX_REPOSITORY, IDS_ERR_MISSINGVALUE, IDS_ERR_ERROR, TTI_ERROR);
168 return;
170 __super::OnOK();