1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - TortoiseSVN
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
20 #include "TortoiseProc.h"
\r
21 #include "ExportDlg.h"
\r
23 #include "Messagebox.h"
\r
24 #include "PathUtils.h"
\r
25 #include "BrowseFolder.h"
\r
26 #include "AppUtils.h"
\r
29 IMPLEMENT_DYNAMIC(CExportDlg, CResizableStandAloneDialog)
\r
30 CExportDlg::CExportDlg(CWnd* pParent /*=NULL*/)
\r
31 : CResizableStandAloneDialog(CExportDlg::IDD, pParent)
\r
32 , CChooseVersion(this)
\r
33 , m_Revision(_T("HEAD"))
\r
34 , m_strExportDirectory(_T(""))
\r
35 , m_sExportDirOrig(_T(""))
\r
36 , m_bNoExternals(FALSE)
\r
41 CExportDlg::~CExportDlg()
\r
47 void CExportDlg::DoDataExchange(CDataExchange* pDX)
\r
49 CResizableStandAloneDialog::DoDataExchange(pDX);
\r
50 DDX_Text(pDX, IDC_CHECKOUTDIRECTORY, m_strExportDirectory);
\r
51 DDX_Control(pDX, IDC_CHECKOUTDIRECTORY, m_cCheckoutEdit);
\r
58 BEGIN_MESSAGE_MAP(CExportDlg, CResizableStandAloneDialog)
\r
59 ON_REGISTERED_MESSAGE(WM_REVSELECTED, OnRevSelected)
\r
60 ON_BN_CLICKED(IDC_CHECKOUTDIRECTORY_BROWSE, OnBnClickedCheckoutdirectoryBrowse)
\r
61 ON_EN_CHANGE(IDC_CHECKOUTDIRECTORY, OnEnChangeCheckoutdirectory)
\r
62 ON_BN_CLICKED(IDHELP, OnBnClickedHelp)
\r
64 CHOOSE_VERSION_EVENT
\r
67 BOOL CExportDlg::OnInitDialog()
\r
69 CResizableStandAloneDialog::OnInitDialog();
\r
71 m_sExportDirOrig = m_strExportDirectory;
\r
72 m_bAutoCreateTargetName = !PathIsDirectoryEmpty(m_sExportDirOrig);
\r
74 AddAnchor(IDC_REPOGROUP, TOP_LEFT, TOP_RIGHT);
\r
75 AddAnchor(IDC_EXPORT_CHECKOUTDIR, TOP_LEFT);
\r
76 AddAnchor(IDC_CHECKOUTDIRECTORY, TOP_LEFT, TOP_RIGHT);
\r
78 AddAnchor(IDOK, BOTTOM_RIGHT);
\r
79 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
\r
80 AddAnchor(IDHELP, BOTTOM_RIGHT);
\r
82 CHOOSE_VERSION_ADDANCHOR;
\r
84 if(this->m_Revision.IsEmpty())
\r
86 SetDefaultChoose(IDC_RADIO_HEAD);
\r
90 SetDefaultChoose(IDC_RADIO_VERSION);
\r
91 this->GetDlgItem(IDC_COMBOBOXEX_VERSION)->SetWindowTextW(m_Revision);
\r
94 m_tooltips.Create(this);
\r
95 m_tooltips.AddTool(IDC_CHECKOUTDIRECTORY, IDS_CHECKOUT_TT_DIR);
\r
97 SHAutoComplete(GetDlgItem(IDC_CHECKOUTDIRECTORY)->m_hWnd, SHACF_FILESYSTEM);
\r
99 if ((m_pParentWnd==NULL)&&(hWndExplorer))
\r
100 CenterWindow(CWnd::FromHandle(hWndExplorer));
\r
101 EnableSaveRestore(_T("ExportDlg"));
\r
105 void CExportDlg::OnOK()
\r
107 if (!UpdateData(TRUE))
\r
108 return; // don't dismiss dialog (error message already shown by MFC framework)
\r
110 // check it the export path is a valid windows path
\r
111 UpdateRevsionName();
\r
113 if (m_VersionName.IsEmpty())
\r
115 ShowBalloon(IDC_REVISION_NUM, IDS_ERR_INVALIDREV);
\r
119 m_bAutoCreateTargetName = false;
\r
121 // m_URLCombo.SaveHistory();
\r
122 // m_URL = m_URLCombo.GetString();
\r
126 CResizableStandAloneDialog::OnOK();
\r
129 void CExportDlg::OnBnClickedBrowse()
\r
131 m_tooltips.Pop(); // hide the tooltips
\r
135 void CExportDlg::OnBnClickedCheckoutdirectoryBrowse()
\r
137 m_tooltips.Pop(); // hide the tooltips
\r
139 // Create a folder browser dialog. If the user selects OK, we should update
\r
140 // the local data members with values from the controls, copy the checkout
\r
141 // directory from the browse folder, then restore the local values into the
\r
142 // dialog controls.
\r
144 this->UpdateRevsionName();
\r
145 CFileDialog dlg(FALSE,_T("Zip"),this->m_VersionName,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
\r
148 if(dlg.DoModal()==IDOK)
\r
151 m_strExportDirectory = dlg.GetPathName();
\r
156 BOOL CExportDlg::PreTranslateMessage(MSG* pMsg)
\r
158 m_tooltips.RelayEvent(pMsg);
\r
159 return CResizableStandAloneDialog::PreTranslateMessage(pMsg);
\r
162 void CExportDlg::OnEnChangeCheckoutdirectory()
\r
165 DialogEnableWindow(IDOK, !m_strExportDirectory.IsEmpty());
\r
168 void CExportDlg::OnBnClickedHelp()
\r
173 void CExportDlg::OnBnClickedShowlog()
\r
175 m_tooltips.Pop(); // hide the tooltips
\r
179 LPARAM CExportDlg::OnRevSelected(WPARAM /*wParam*/, LPARAM lParam)
\r
182 temp.Format(_T("%ld"), lParam);
\r
183 SetDlgItemText(IDC_REVISION_NUM, temp);
\r
184 CheckRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N, IDC_REVISION_N);
\r
188 void CExportDlg::OnEnChangeRevisionNum()
\r
191 if (m_sRevision.IsEmpty())
\r
192 CheckRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N, IDC_REVISION_HEAD);
\r
194 CheckRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N, IDC_REVISION_N);
\r
197 void CExportDlg::OnCbnSelchangeEolcombo()
\r
201 void CExportDlg::SetRevision(const CString& rev)
\r
203 if (rev==_T("HEAD"))
\r
204 CheckRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N, IDC_REVISION_HEAD);
\r
207 CheckRadioButton(IDC_REVISION_HEAD, IDC_REVISION_N, IDC_REVISION_N);
\r
209 sRev.Format(_T("%s"), rev);
\r
210 SetDlgItemText(IDC_REVISION_NUM, sRev);
\r
214 void CExportDlg::OnCbnEditchangeUrlcombo()
\r
216 if (!m_bAutoCreateTargetName)
\r
218 if (m_sExportDirOrig.IsEmpty())
\r
220 // find out what to use as the checkout directory name
\r
222 m_URLCombo.GetWindowText(m_URL);
\r
223 if (m_URL.IsEmpty())
\r
225 CString name = CAppUtils::GetProjectNameFromURL(m_URL);
\r
226 m_strExportDirectory = m_sExportDirOrig+_T('\\')+name;
\r