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 "RevisionRangeDlg.h"
24 IMPLEMENT_DYNAMIC(CRevisionRangeDlg
, CStandAloneDialog
)
26 CRevisionRangeDlg::CRevisionRangeDlg(CWnd
* pParent
/*=NULL*/)
27 : CStandAloneDialog(CRevisionRangeDlg::IDD
, pParent
)
28 , m_bAllowWCRevs(true)
29 , m_StartRev(_T("HEAD"))
30 , m_EndRev(_T("HEAD"))
34 CRevisionRangeDlg::~CRevisionRangeDlg()
38 void CRevisionRangeDlg::DoDataExchange(CDataExchange
* pDX
)
40 CStandAloneDialog::DoDataExchange(pDX
);
41 DDX_Text(pDX
, IDC_REVNUM
, m_sStartRevision
);
42 DDX_Text(pDX
, IDC_REVNUM2
, m_sEndRevision
);
46 BEGIN_MESSAGE_MAP(CRevisionRangeDlg
, CStandAloneDialog
)
47 ON_EN_CHANGE(IDC_REVNUM
, OnEnChangeRevnum
)
48 ON_EN_CHANGE(IDC_REVNUM2
, OnEnChangeRevnum2
)
51 BOOL
CRevisionRangeDlg::OnInitDialog()
53 CStandAloneDialog::OnInitDialog();
55 if (m_StartRev
.IsHead())
57 CheckRadioButton(IDC_NEWEST
, IDC_REVISION_N
, IDC_NEWEST
);
61 CheckRadioButton(IDC_NEWEST
, IDC_REVISION_N
, IDC_REVISION_N
);
63 if (m_StartRev
.IsDate())
64 sRev
= m_StartRev
.GetDateString();
66 sRev
.Format(_T("%ld"), (LONG
)(m_StartRev
));
67 SetDlgItemText(IDC_REVNUM
, sRev
);
69 if (m_EndRev
.IsHead())
71 CheckRadioButton(IDC_NEWEST2
, IDC_REVISION_N2
, IDC_NEWEST2
);
75 CheckRadioButton(IDC_NEWEST2
, IDC_REVISION_N2
, IDC_REVISION_N2
);
77 if (m_EndRev
.IsDate())
78 sRev
= m_EndRev
.GetDateString();
80 sRev
.Format(_T("%ld"), (LONG
)(m_EndRev
));
81 SetDlgItemText(IDC_REVNUM2
, sRev
);
84 if ((m_pParentWnd
==NULL
)&&(hWndExplorer
))
85 CenterWindow(CWnd::FromHandle(hWndExplorer
));
86 GetDlgItem(IDC_REVNUM
)->SetFocus();
90 void CRevisionRangeDlg::OnOK()
92 if (!UpdateData(TRUE
))
93 return; // don't dismiss dialog (error message already shown by MFC framework)
95 m_StartRev
= SVNRev(m_sStartRevision
);
96 if (GetCheckedRadioButton(IDC_NEWEST
, IDC_REVISION_N
) == IDC_NEWEST
)
98 m_StartRev
= SVNRev(_T("HEAD"));
99 m_sStartRevision
= _T("HEAD");
101 if ((!m_StartRev
.IsValid())||((!m_bAllowWCRevs
)&&(m_StartRev
.IsPrev() || m_StartRev
.IsCommitted() || m_StartRev
.IsBase())))
103 ShowBalloon(IDC_REVNUM
, m_bAllowWCRevs
? IDS_ERR_INVALIDREV
: IDS_ERR_INVALIDREVNOWC
);
107 m_EndRev
= SVNRev(m_sEndRevision
);
108 if (GetCheckedRadioButton(IDC_NEWEST2
, IDC_REVISION_N2
) == IDC_NEWEST2
)
110 m_EndRev
= SVNRev(_T("HEAD"));
111 m_sEndRevision
= _T("HEAD");
113 if ((!m_EndRev
.IsValid())||((!m_bAllowWCRevs
)&&(m_EndRev
.IsPrev() || m_EndRev
.IsCommitted() || m_EndRev
.IsBase())))
115 ShowBalloon(IDC_REVNUM2
, m_bAllowWCRevs
? IDS_ERR_INVALIDREV
: IDS_ERR_INVALIDREVNOWC
);
121 CStandAloneDialog::OnOK();
124 void CRevisionRangeDlg::OnEnChangeRevnum()
127 GetDlgItemText(IDC_REVNUM
, sText
);
130 CheckRadioButton(IDC_NEWEST
, IDC_REVISION_N
, IDC_NEWEST
);
134 CheckRadioButton(IDC_NEWEST
, IDC_REVISION_N
, IDC_REVISION_N
);
138 void CRevisionRangeDlg::OnEnChangeRevnum2()
141 GetDlgItemText(IDC_REVNUM2
, sText
);
144 CheckRadioButton(IDC_NEWEST2
, IDC_REVISION_N2
, IDC_NEWEST2
);
148 CheckRadioButton(IDC_NEWEST2
, IDC_REVISION_N2
, IDC_REVISION_N2
);