OSDN Git Service

Setting dialog, remote list work.
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / RevisionDlg.cpp
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseSVN\r
4 \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
9 \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
14 \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
18 //\r
19 #include "stdafx.h"\r
20 #include "TortoiseProc.h"\r
21 #include "RevisionDlg.h"\r
22 #include "Balloon.h"\r
23 \r
24 \r
25 IMPLEMENT_DYNAMIC(CRevisionDlg, CDialog)\r
26 CRevisionDlg::CRevisionDlg(CWnd* pParent /*=NULL*/)\r
27         : CDialog(CRevisionDlg::IDD, pParent)\r
28         //, GitRev(_T("HEAD"))\r
29         , m_bAllowWCRevs(true)\r
30 {\r
31 }\r
32 \r
33 CRevisionDlg::~CRevisionDlg()\r
34 {\r
35 }\r
36 \r
37 void CRevisionDlg::DoDataExchange(CDataExchange* pDX)\r
38 {\r
39         CDialog::DoDataExchange(pDX);\r
40         DDX_Text(pDX, IDC_REVNUM, m_sRevision);\r
41 }\r
42 \r
43 \r
44 BEGIN_MESSAGE_MAP(CRevisionDlg, CDialog)\r
45         ON_EN_CHANGE(IDC_REVNUM, OnEnChangeRevnum)\r
46 END_MESSAGE_MAP()\r
47 \r
48 BOOL CRevisionDlg::OnInitDialog()\r
49 {\r
50         CDialog::OnInitDialog();\r
51 \r
52         if (IsHead())\r
53         {\r
54                 CheckRadioButton(IDC_NEWEST, IDC_REVISION_N, IDC_NEWEST);\r
55         }\r
56         else\r
57         {\r
58                 CheckRadioButton(IDC_NEWEST, IDC_REVISION_N, IDC_REVISION_N);\r
59                 CString sRev;\r
60                 if (IsDate())\r
61                         sRev = GetDateString();\r
62                 else\r
63                         sRev.Format(_T("%ld"), (LONG)(*this));\r
64                 SetDlgItemText(IDC_REVNUM, sRev);\r
65         }\r
66         if ((m_pParentWnd==NULL)&&(hWndExplorer))\r
67                 CenterWindow(CWnd::FromHandle(hWndExplorer));\r
68         GetDlgItem(IDC_REVNUM)->SetFocus();\r
69         return FALSE;\r
70 }\r
71 \r
72 void CRevisionDlg::OnOK()\r
73 {\r
74         if (!UpdateData(TRUE))\r
75                 return; // don't dismiss dialog (error message already shown by MFC framework)\r
76 \r
77         SVNRev::Create(m_sRevision);\r
78         // if head revision, set revision as -1\r
79         if (GetCheckedRadioButton(IDC_NEWEST, IDC_REVISION_N) == IDC_NEWEST)\r
80         {\r
81                 SVNRev::Create(_T("HEAD"));\r
82                 m_sRevision = _T("HEAD");\r
83         }\r
84         if ((!IsValid())||((!m_bAllowWCRevs)&&(IsPrev() || IsCommitted() || IsBase())))\r
85         {\r
86                 CBalloon::ShowBalloon(\r
87                         this, CBalloon::GetCtrlCentre(this, IDC_REVNUM),\r
88                         m_bAllowWCRevs ? IDS_ERR_INVALIDREV : IDS_ERR_INVALIDREVNOWC, TRUE, IDI_EXCLAMATION);\r
89                 return;\r
90         }\r
91 \r
92         UpdateData(FALSE);\r
93 \r
94         CDialog::OnOK();\r
95 }\r
96 \r
97 void CRevisionDlg::OnEnChangeRevnum()\r
98 {\r
99         CString sText;\r
100         GetDlgItemText(IDC_REVNUM, sText);\r
101         if (sText.IsEmpty())\r
102         {\r
103                 CheckRadioButton(IDC_NEWEST, IDC_REVISION_N, IDC_NEWEST);\r
104         }\r
105         else\r
106         {\r
107                 CheckRadioButton(IDC_NEWEST, IDC_REVISION_N, IDC_REVISION_N);\r
108         }\r
109 }\r