1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
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 #include "TortoiseProc.h"
21 #include "ExportDlg.h"
23 #include "Messagebox.h"
24 #include "PathUtils.h"
25 #include "BrowseFolder.h"
29 IMPLEMENT_DYNAMIC(CExportDlg
, CResizableStandAloneDialog
)
30 CExportDlg::CExportDlg(CWnd
* pParent
/*=NULL*/)
31 : CResizableStandAloneDialog(CExportDlg::IDD
, pParent
)
32 , CChooseVersion(this)
33 , m_Revision(_T("HEAD"))
34 , m_strExportDirectory(_T(""))
35 , m_sExportDirOrig(_T(""))
36 , m_bNoExternals(FALSE
)
41 CExportDlg::~CExportDlg()
47 void CExportDlg::DoDataExchange(CDataExchange
* pDX
)
49 CResizableStandAloneDialog::DoDataExchange(pDX
);
50 DDX_Text(pDX
, IDC_CHECKOUTDIRECTORY
, m_strExportDirectory
);
51 DDX_Control(pDX
, IDC_CHECKOUTDIRECTORY
, m_cCheckoutEdit
);
58 BEGIN_MESSAGE_MAP(CExportDlg
, CResizableStandAloneDialog
)
59 ON_REGISTERED_MESSAGE(WM_REVSELECTED
, OnRevSelected
)
60 ON_BN_CLICKED(IDC_CHECKOUTDIRECTORY_BROWSE
, OnBnClickedCheckoutdirectoryBrowse
)
61 ON_EN_CHANGE(IDC_CHECKOUTDIRECTORY
, OnEnChangeCheckoutdirectory
)
62 ON_BN_CLICKED(IDHELP
, OnBnClickedHelp
)
67 BOOL
CExportDlg::OnInitDialog()
69 CResizableStandAloneDialog::OnInitDialog();
71 m_sExportDirOrig
= m_strExportDirectory
;
72 m_bAutoCreateTargetName
= !PathIsDirectoryEmpty(m_sExportDirOrig
);
74 AddAnchor(IDC_REPOGROUP
, TOP_LEFT
, TOP_RIGHT
);
75 AddAnchor(IDC_EXPORT_CHECKOUTDIR
, TOP_LEFT
);
76 AddAnchor(IDC_CHECKOUTDIRECTORY
, TOP_LEFT
, TOP_RIGHT
);
78 AddAnchor(IDOK
, BOTTOM_RIGHT
);
79 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
80 AddAnchor(IDHELP
, BOTTOM_RIGHT
);
82 CHOOSE_VERSION_ADDANCHOR
;
84 if(this->m_Revision
.IsEmpty())
86 SetDefaultChoose(IDC_RADIO_HEAD
);
90 SetDefaultChoose(IDC_RADIO_VERSION
);
91 this->GetDlgItem(IDC_COMBOBOXEX_VERSION
)->SetWindowTextW(m_Revision
);
94 m_tooltips
.Create(this);
95 m_tooltips
.AddTool(IDC_CHECKOUTDIRECTORY
, IDS_CHECKOUT_TT_DIR
);
97 SHAutoComplete(GetDlgItem(IDC_CHECKOUTDIRECTORY
)->m_hWnd
, SHACF_FILESYSTEM
);
99 if ((m_pParentWnd
==NULL
)&&(hWndExplorer
))
100 CenterWindow(CWnd::FromHandle(hWndExplorer
));
101 EnableSaveRestore(_T("ExportDlg"));
105 void CExportDlg::OnOK()
107 if (!UpdateData(TRUE
))
108 return; // don't dismiss dialog (error message already shown by MFC framework)
110 // check it the export path is a valid windows path
113 if (m_VersionName
.IsEmpty())
115 ShowBalloon(IDC_REVISION_NUM
, IDS_ERR_INVALIDREV
);
119 m_bAutoCreateTargetName
= false;
121 // m_URLCombo.SaveHistory();
122 // m_URL = m_URLCombo.GetString();
126 CResizableStandAloneDialog::OnOK();
129 void CExportDlg::OnBnClickedBrowse()
131 m_tooltips
.Pop(); // hide the tooltips
135 void CExportDlg::OnBnClickedCheckoutdirectoryBrowse()
137 m_tooltips
.Pop(); // hide the tooltips
139 // Create a folder browser dialog. If the user selects OK, we should update
140 // the local data members with values from the controls, copy the checkout
141 // directory from the browse folder, then restore the local values into the
144 this->UpdateRevsionName();
145 CFileDialog
dlg(FALSE
,_T("Zip"),this->m_VersionName
,OFN_HIDEREADONLY
| OFN_OVERWRITEPROMPT
,
148 if(dlg
.DoModal()==IDOK
)
151 m_strExportDirectory
= dlg
.GetPathName();
156 BOOL
CExportDlg::PreTranslateMessage(MSG
* pMsg
)
158 m_tooltips
.RelayEvent(pMsg
);
159 return CResizableStandAloneDialog::PreTranslateMessage(pMsg
);
162 void CExportDlg::OnEnChangeCheckoutdirectory()
165 DialogEnableWindow(IDOK
, !m_strExportDirectory
.IsEmpty());
168 void CExportDlg::OnBnClickedHelp()
173 void CExportDlg::OnBnClickedShowlog()
175 m_tooltips
.Pop(); // hide the tooltips
179 LPARAM
CExportDlg::OnRevSelected(WPARAM
/*wParam*/, LPARAM lParam
)
182 temp
.Format(_T("%ld"), lParam
);
183 SetDlgItemText(IDC_REVISION_NUM
, temp
);
184 CheckRadioButton(IDC_REVISION_HEAD
, IDC_REVISION_N
, IDC_REVISION_N
);
188 void CExportDlg::OnEnChangeRevisionNum()
191 if (m_sRevision
.IsEmpty())
192 CheckRadioButton(IDC_REVISION_HEAD
, IDC_REVISION_N
, IDC_REVISION_HEAD
);
194 CheckRadioButton(IDC_REVISION_HEAD
, IDC_REVISION_N
, IDC_REVISION_N
);
197 void CExportDlg::OnCbnSelchangeEolcombo()
201 void CExportDlg::SetRevision(const CString
& rev
)
204 CheckRadioButton(IDC_REVISION_HEAD
, IDC_REVISION_N
, IDC_REVISION_HEAD
);
207 CheckRadioButton(IDC_REVISION_HEAD
, IDC_REVISION_N
, IDC_REVISION_N
);
209 sRev
.Format(_T("%s"), rev
);
210 SetDlgItemText(IDC_REVISION_NUM
, sRev
);
214 void CExportDlg::OnCbnEditchangeUrlcombo()
216 if (!m_bAutoCreateTargetName
)
218 if (m_sExportDirOrig
.IsEmpty())
220 // find out what to use as the checkout directory name
222 m_URLCombo
.GetWindowText(m_URL
);
225 CString name
= CAppUtils::GetProjectNameFromURL(m_URL
);
226 m_strExportDirectory
= m_sExportDirOrig
+_T('\\')+name
;