1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2007-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 "UrlDiffDlg.h"
22 #include "RepositoryBrowser.h"
23 #include "BrowseFolder.h"
27 IMPLEMENT_DYNAMIC(CUrlDiffDlg
, CResizableStandAloneDialog
)
28 CUrlDiffDlg::CUrlDiffDlg(CWnd
* pParent
/*=NULL*/)
29 : CResizableStandAloneDialog(CUrlDiffDlg::IDD
, pParent
)
31 , Revision(_T("HEAD"))
36 CUrlDiffDlg::~CUrlDiffDlg()
42 void CUrlDiffDlg::DoDataExchange(CDataExchange
* pDX
)
44 CResizableStandAloneDialog::DoDataExchange(pDX
);
45 DDX_Control(pDX
, IDC_URLCOMBO
, m_URLCombo
);
46 DDX_Text(pDX
, IDC_REVISION_NUM
, m_rev
);
50 BEGIN_MESSAGE_MAP(CUrlDiffDlg
, CResizableStandAloneDialog
)
51 ON_BN_CLICKED(IDC_BROWSE
, OnBnClickedBrowse
)
52 ON_BN_CLICKED(IDHELP
, OnBnClickedHelp
)
53 ON_EN_CHANGE(IDC_REVISION_NUM
, &CUrlDiffDlg::OnEnChangeRevisionNum
)
54 ON_BN_CLICKED(IDC_LOG
, &CUrlDiffDlg::OnBnClickedLog
)
55 ON_REGISTERED_MESSAGE(WM_REVSELECTED
, &CUrlDiffDlg::OnRevSelected
)
59 BOOL
CUrlDiffDlg::OnInitDialog()
61 CResizableStandAloneDialog::OnInitDialog();
63 CTSVNPath
svnPath(m_path
);
64 m_bFolder
= svnPath
.IsDirectory();
66 CString url
= svn
.GetURLFromPath(svnPath
);
67 CString sUUID
= svn
.GetUUIDFromPath(svnPath
);
68 m_URLCombo
.SetURLHistory(TRUE
);
69 m_URLCombo
.LoadHistory(_T("Software\\TortoiseGit\\History\\repoURLS\\")+sUUID
, _T("url"));
70 m_URLCombo
.SetCurSel(0);
75 m_URLCombo
.AddString(CTSVNPath(url
).GetUIPathString(), 0);
76 m_URLCombo
.SelectString(-1, CTSVNPath(url
).GetUIPathString());
80 // set head revision as default revision
81 SetRevision(SVNRev::REV_HEAD
);
83 AddAnchor(IDC_URLLABEL
, TOP_LEFT
, TOP_RIGHT
);
84 AddAnchor(IDC_URLCOMBO
, TOP_LEFT
, TOP_RIGHT
);
85 AddAnchor(IDC_BROWSE
, TOP_RIGHT
);
86 AddAnchor(IDC_REVGROUP
, TOP_LEFT
, BOTTOM_RIGHT
);
87 AddAnchor(IDC_REVISION_HEAD
, TOP_LEFT
);
88 AddAnchor(IDC_REVISION_N
, TOP_LEFT
);
89 AddAnchor(IDC_REVISION_NUM
, TOP_LEFT
);
90 AddAnchor(IDC_LOG
, TOP_LEFT
);
91 AddAnchor(IDOK
, BOTTOM_RIGHT
);
92 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
93 AddAnchor(IDHELP
, BOTTOM_RIGHT
);
95 if ((m_pParentWnd
==NULL
)&&(hWndExplorer
))
96 CenterWindow(CWnd::FromHandle(hWndExplorer
));
97 EnableSaveRestore(_T("SwitchDlg"));
101 void CUrlDiffDlg::OnBnClickedBrowse()
105 if (GetCheckedRadioButton(IDC_REVISION_HEAD
, IDC_REVISION_N
) == IDC_REVISION_HEAD
)
107 rev
= SVNRev::REV_HEAD
;
112 rev
= SVNRev::REV_HEAD
;
113 CAppUtils::BrowseRepository(m_URLCombo
, this, rev
);
117 void CUrlDiffDlg::OnOK()
119 if (!UpdateData(TRUE
))
120 return; // don't dismiss dialog (error message already shown by MFC framework)
122 // if head revision, set revision as -1
123 if (GetCheckedRadioButton(IDC_REVISION_HEAD
, IDC_REVISION_N
) == IDC_REVISION_HEAD
)
127 Revision
= SVNRev(m_rev
);
128 if (!Revision
.IsValid())
130 ShowBalloon(IDC_REVISION_NUM
, IDS_ERR_INVALIDREV
);
134 m_URLCombo
.SaveHistory();
135 m_URL
= m_URLCombo
.GetString();
138 CResizableStandAloneDialog::OnOK();
141 void CUrlDiffDlg::OnBnClickedHelp()
146 void CUrlDiffDlg::OnEnChangeRevisionNum()
150 CheckRadioButton(IDC_REVISION_HEAD
, IDC_REVISION_N
, IDC_REVISION_HEAD
);
152 CheckRadioButton(IDC_REVISION_HEAD
, IDC_REVISION_N
, IDC_REVISION_N
);
155 void CUrlDiffDlg::SetRevision(const SVNRev
& rev
)
158 CheckRadioButton(IDC_REVISION_HEAD
, IDC_REVISION_N
, IDC_REVISION_HEAD
);
161 CheckRadioButton(IDC_REVISION_HEAD
, IDC_REVISION_N
, IDC_REVISION_N
);
162 m_rev
= rev
.ToString();
167 void CUrlDiffDlg::OnBnClickedLog()
170 if (::IsWindow(m_pLogDlg
->GetSafeHwnd())&&(m_pLogDlg
->IsWindowVisible()))
172 if (!m_path
.IsEmpty())
175 m_pLogDlg
= new CLogDlg();
176 CRegDWORD reg
= CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100);
177 int limit
= (int)(LONG
)reg
;
178 m_pLogDlg
->SetSelect(true);
179 m_pLogDlg
->m_pNotifyWindow
= this;
180 m_pLogDlg
->m_wParam
= 0;
181 m_pLogDlg
->SetParams(CTSVNPath(m_path
), SVNRev::REV_HEAD
, SVNRev::REV_HEAD
, 1, limit
, TRUE
);
182 m_pLogDlg
->ContinuousSelection(true);
183 m_pLogDlg
->Create(IDD_LOGMESSAGE
, this);
184 m_pLogDlg
->ShowWindow(SW_SHOW
);
186 AfxGetApp()->DoWaitCursor(-1);
189 LPARAM
CUrlDiffDlg::OnRevSelected(WPARAM
/*wParam*/, LPARAM lParam
)
192 temp
.Format(_T("%ld"), lParam
);
193 SetDlgItemText(IDC_REVISION_NUM
, temp
);
194 CheckRadioButton(IDC_REVISION_HEAD
, IDC_REVISION_N
, IDC_REVISION_N
);