1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
4 // Copyright (C) 2008-2012 - TortoiseGit
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "TortoiseProc.h"
22 #include "ExportDlg.h"
24 #include "Messagebox.h"
25 #include "PathUtils.h"
26 #include "BrowseFolder.h"
30 IMPLEMENT_DYNAMIC(CExportDlg
, CHorizontalResizableStandAloneDialog
)
31 CExportDlg::CExportDlg(CWnd
* pParent
/*=NULL*/)
32 : CHorizontalResizableStandAloneDialog(CExportDlg::IDD
, pParent
)
33 , CChooseVersion(this)
34 , m_Revision(_T("HEAD"))
35 , m_strExportDirectory(_T(""))
36 , m_sExportDirOrig(_T(""))
37 , m_bNoExternals(FALSE
)
42 CExportDlg::~CExportDlg()
48 void CExportDlg::DoDataExchange(CDataExchange
* pDX
)
50 CHorizontalResizableStandAloneDialog::DoDataExchange(pDX
);
51 DDX_Text(pDX
, IDC_CHECKOUTDIRECTORY
, m_strExportDirectory
);
52 DDX_Control(pDX
, IDC_CHECKOUTDIRECTORY
, m_cCheckoutEdit
);
59 BEGIN_MESSAGE_MAP(CExportDlg
, CHorizontalResizableStandAloneDialog
)
60 ON_BN_CLICKED(IDC_CHECKOUTDIRECTORY_BROWSE
, OnBnClickedCheckoutdirectoryBrowse
)
61 ON_EN_CHANGE(IDC_CHECKOUTDIRECTORY
, OnEnChangeCheckoutdirectory
)
62 ON_BN_CLICKED(IDHELP
, OnBnClickedHelp
)
68 BOOL
CExportDlg::OnInitDialog()
70 CHorizontalResizableStandAloneDialog::OnInitDialog();
71 CAppUtils::MarkWindowAsUnpinnable(m_hWnd
);
73 m_sExportDirOrig
= m_strExportDirectory
;
74 m_bAutoCreateTargetName
= !PathIsDirectoryEmpty(m_sExportDirOrig
);
76 AddAnchor(IDC_REPOGROUP
, TOP_LEFT
, TOP_RIGHT
);
77 AddAnchor(IDC_EXPORT_CHECKOUTDIR
, TOP_LEFT
);
78 AddAnchor(IDC_CHECKOUTDIRECTORY_BROWSE
, TOP_RIGHT
);
79 AddAnchor(IDC_CHECKOUTDIRECTORY
, TOP_LEFT
, TOP_RIGHT
);
81 AddAnchor(IDOK
, BOTTOM_RIGHT
);
82 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
83 AddAnchor(IDHELP
, BOTTOM_RIGHT
);
85 AdjustControlSize(IDC_RADIO_HEAD
);
86 AdjustControlSize(IDC_RADIO_BRANCH
);
87 AdjustControlSize(IDC_RADIO_TAGS
);
88 AdjustControlSize(IDC_RADIO_VERSION
);
91 GetWindowText(sWindowTitle
);
92 CAppUtils::SetWindowTitle(m_hWnd
, g_Git
.m_CurrentDir
, sWindowTitle
);
94 CHOOSE_VERSION_ADDANCHOR
;
95 this->AddOthersToAnchor();
97 if(this->m_Revision
.IsEmpty())
99 SetDefaultChoose(IDC_RADIO_HEAD
);
103 SetDefaultChoose(IDC_RADIO_VERSION
);
104 this->GetDlgItem(IDC_COMBOBOXEX_VERSION
)->SetWindowTextW(m_Revision
);
107 m_tooltips
.Create(this);
108 m_tooltips
.AddTool(IDC_CHECKOUTDIRECTORY
, IDS_CHECKOUT_TT_DIR
);
110 SHAutoComplete(GetDlgItem(IDC_CHECKOUTDIRECTORY
)->m_hWnd
, SHACF_FILESYSTEM
);
112 if ((m_pParentWnd
==NULL
)&&(hWndExplorer
))
113 CenterWindow(CWnd::FromHandle(hWndExplorer
));
114 EnableSaveRestore(_T("ExportDlg"));
118 void CExportDlg::OnOK()
120 if (!UpdateData(TRUE
))
121 return; // don't dismiss dialog (error message already shown by MFC framework)
123 // check it the export path is a valid windows path
126 if (m_VersionName
.IsEmpty())
128 m_tooltips
.ShowBalloon(IDC_COMBOBOXEX_VERSION
, IDS_ERR_INVALIDREV
, IDS_ERR_ERROR
, TTI_ERROR
);
132 m_bAutoCreateTargetName
= false;
134 // m_URLCombo.SaveHistory();
135 // m_URL = m_URLCombo.GetString();
138 if(::PathFileExists(this->m_strExportDirectory
))
140 if(::PathIsDirectory(m_strExportDirectory
))
142 CMessageBox::Show(NULL
, IDS_PROCEXPORTERRFOLDER
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
146 sMessage
.Format(IDS_PROC_OVERWRITE_CONFIRM
, m_strExportDirectory
);
147 if (CMessageBox::Show(NULL
, sMessage
, _T("TortoiseGit"), MB_YESNO
| MB_ICONQUESTION
| MB_DEFBUTTON2
) != IDYES
)
152 else if (m_strExportDirectory
.IsEmpty())
154 CMessageBox::Show(NULL
, IDS_PROC_NOZIPFILE
, IDS_APPNAME
, MB_OK
| MB_ICONERROR
);
159 CHorizontalResizableStandAloneDialog::OnOK();
162 void CExportDlg::OnBnClickedBrowse()
164 m_tooltips
.Pop(); // hide the tooltips
168 void CExportDlg::OnBnClickedCheckoutdirectoryBrowse()
170 m_tooltips
.Pop(); // hide the tooltips
172 // Create a folder browser dialog. If the user selects OK, we should update
173 // the local data members with values from the controls, copy the checkout
174 // directory from the browse folder, then restore the local values into the
177 this->UpdateRevsionName();
178 CFileDialog
dlg(FALSE
, _T("zip"), this->m_VersionName
, OFN_HIDEREADONLY
| OFN_OVERWRITEPROMPT
, _T("*.zip"));
180 if(dlg
.DoModal()==IDOK
)
183 m_strExportDirectory
= dlg
.GetPathName();
188 BOOL
CExportDlg::PreTranslateMessage(MSG
* pMsg
)
190 m_tooltips
.RelayEvent(pMsg
);
191 return CHorizontalResizableStandAloneDialog::PreTranslateMessage(pMsg
);
194 void CExportDlg::OnEnChangeCheckoutdirectory()
197 DialogEnableWindow(IDOK
, !m_strExportDirectory
.IsEmpty());
200 void CExportDlg::OnBnClickedHelp()
205 void CExportDlg::OnBnClickedShowlog()
207 m_tooltips
.Pop(); // hide the tooltips
211 void CExportDlg::OnCbnSelchangeEolcombo()
215 void CExportDlg::OnCbnEditchangeUrlcombo()
217 if (!m_bAutoCreateTargetName
)
219 if (m_sExportDirOrig
.IsEmpty())
221 // find out what to use as the checkout directory name
223 m_URLCombo
.GetWindowText(m_URL
);
226 CString name
= CAppUtils::GetProjectNameFromURL(m_URL
);
227 m_strExportDirectory
= m_sExportDirOrig
+_T('\\')+name
;
231 void CExportDlg::OnDestroy()
233 WaitForFinishLoading();
234 __super::OnDestroy();