BrowseRefs: Context menu enhancements
[TortoiseGit.git] / src / TortoiseProc / RevisionDlg.cpp
blobc4d6ed61f1c95079a9e139d21ce74d10c299841e
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.
19 #include "stdafx.h"
20 #include "TortoiseProc.h"
21 #include "RevisionDlg.h"
22 #include "Balloon.h"
25 IMPLEMENT_DYNAMIC(CRevisionDlg, CDialog)
26 CRevisionDlg::CRevisionDlg(CWnd* pParent /*=NULL*/)
27 : CDialog(CRevisionDlg::IDD, pParent)
28 //, GitRev(_T("HEAD"))
29 , m_bAllowWCRevs(true)
33 CRevisionDlg::~CRevisionDlg()
37 void CRevisionDlg::DoDataExchange(CDataExchange* pDX)
39 CDialog::DoDataExchange(pDX);
40 DDX_Text(pDX, IDC_REVNUM, m_sRevision);
44 BEGIN_MESSAGE_MAP(CRevisionDlg, CDialog)
45 ON_EN_CHANGE(IDC_REVNUM, OnEnChangeRevnum)
46 END_MESSAGE_MAP()
48 BOOL CRevisionDlg::OnInitDialog()
50 CDialog::OnInitDialog();
52 if (IsHead())
54 CheckRadioButton(IDC_NEWEST, IDC_REVISION_N, IDC_NEWEST);
56 else
58 CheckRadioButton(IDC_NEWEST, IDC_REVISION_N, IDC_REVISION_N);
59 CString sRev;
60 if (IsDate())
61 sRev = GetDateString();
62 else
63 sRev.Format(_T("%ld"), (LONG)(*this));
64 SetDlgItemText(IDC_REVNUM, sRev);
66 if ((m_pParentWnd==NULL)&&(hWndExplorer))
67 CenterWindow(CWnd::FromHandle(hWndExplorer));
68 GetDlgItem(IDC_REVNUM)->SetFocus();
69 return FALSE;
72 void CRevisionDlg::OnOK()
74 if (!UpdateData(TRUE))
75 return; // don't dismiss dialog (error message already shown by MFC framework)
77 SVNRev::Create(m_sRevision);
78 // if head revision, set revision as -1
79 if (GetCheckedRadioButton(IDC_NEWEST, IDC_REVISION_N) == IDC_NEWEST)
81 SVNRev::Create(_T("HEAD"));
82 m_sRevision = _T("HEAD");
84 if ((!IsValid())||((!m_bAllowWCRevs)&&(IsPrev() || IsCommitted() || IsBase())))
86 CBalloon::ShowBalloon(
87 this, CBalloon::GetCtrlCentre(this, IDC_REVNUM),
88 m_bAllowWCRevs ? IDS_ERR_INVALIDREV : IDS_ERR_INVALIDREVNOWC, TRUE, IDI_EXCLAMATION);
89 return;
92 UpdateData(FALSE);
94 CDialog::OnOK();
97 void CRevisionDlg::OnEnChangeRevnum()
99 CString sText;
100 GetDlgItemText(IDC_REVNUM, sText);
101 if (sText.IsEmpty())
103 CheckRadioButton(IDC_NEWEST, IDC_REVISION_N, IDC_NEWEST);
105 else
107 CheckRadioButton(IDC_NEWEST, IDC_REVISION_N, IDC_REVISION_N);