Merge branch 'restructure-tree'
[TortoiseGit.git] / src / TortoiseProc / UpdateDlg.cpp
bloba28296f6a29ca4e45fc4b5c683fe3a0455aaeb89
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2007 - 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 "UpdateDlg.h"
22 #include "registry.h"
25 IMPLEMENT_DYNAMIC(CUpdateDlg, CStandAloneDialog)
26 CUpdateDlg::CUpdateDlg(CWnd* pParent /*=NULL*/)
27 : CStandAloneDialog(CUpdateDlg::IDD, pParent)
28 , Revision(_T("HEAD"))
29 , m_bNoExternals(FALSE)
30 , m_pLogDlg(NULL)
34 CUpdateDlg::~CUpdateDlg()
36 if (m_pLogDlg)
37 delete m_pLogDlg;
40 void CUpdateDlg::DoDataExchange(CDataExchange* pDX)
42 CStandAloneDialog::DoDataExchange(pDX);
43 DDX_Text(pDX, IDC_REVNUM, m_sRevision);
44 DDX_Check(pDX, IDC_NOEXTERNALS, m_bNoExternals);
45 DDX_Control(pDX, IDC_DEPTH, m_depthCombo);
49 BEGIN_MESSAGE_MAP(CUpdateDlg, CStandAloneDialog)
50 ON_BN_CLICKED(IDC_LOG, OnBnClickedShowLog)
51 ON_REGISTERED_MESSAGE(WM_REVSELECTED, OnRevSelected)
52 ON_EN_CHANGE(IDC_REVNUM, &CUpdateDlg::OnEnChangeRevnum)
53 END_MESSAGE_MAP()
55 BOOL CUpdateDlg::OnInitDialog()
57 CStandAloneDialog::OnInitDialog();
59 AdjustControlSize(IDC_NEWEST);
60 AdjustControlSize(IDC_REVISION_N);
61 AdjustControlSize(IDC_NOEXTERNALS);
63 m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_WORKING)));
64 m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_INFINITE)));
65 m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_IMMEDIATE)));
66 m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_FILES)));
67 m_depthCombo.AddString(CString(MAKEINTRESOURCE(IDS_SVN_DEPTH_EMPTY)));
68 m_depthCombo.SetCurSel(0);
70 CheckRadioButton(IDC_NEWEST, IDC_REVISION_N, IDC_NEWEST);
71 GetDlgItem(IDC_REVNUM)->SetFocus();
72 if ((m_pParentWnd==NULL)&&(hWndExplorer))
73 CenterWindow(CWnd::FromHandle(hWndExplorer));
74 return FALSE;
77 void CUpdateDlg::OnOK()
79 if (!UpdateData(TRUE))
80 return; // don't dismiss dialog (error message already shown by MFC framework)
82 Revision = SVNRev(m_sRevision);
83 if (GetCheckedRadioButton(IDC_NEWEST, IDC_REVISION_N) == IDC_NEWEST)
85 Revision = SVNRev(_T("HEAD"));
87 if (!Revision.IsValid())
89 ShowBalloon(IDC_REVNUM, IDS_ERR_INVALIDREV);
90 return;
92 switch (m_depthCombo.GetCurSel())
94 case 0:
95 m_depth = svn_depth_unknown;
96 break;
97 case 1:
98 m_depth = svn_depth_infinity;
99 break;
100 case 2:
101 m_depth = svn_depth_immediates;
102 break;
103 case 3:
104 m_depth = svn_depth_files;
105 break;
106 case 4:
107 m_depth = svn_depth_empty;
108 break;
109 default:
110 m_depth = svn_depth_empty;
111 break;
114 UpdateData(FALSE);
116 CStandAloneDialog::OnOK();
119 void CUpdateDlg::OnBnClickedShowLog()
121 UpdateData(TRUE);
122 if (::IsWindow(m_pLogDlg->GetSafeHwnd())&&(m_pLogDlg->IsWindowVisible()))
123 return;
124 if (!m_wcPath.IsEmpty())
126 delete m_pLogDlg;
127 m_pLogDlg = new CLogDlg();
128 CRegDWORD reg = CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100);
129 int limit = (int)(LONG)reg;
130 m_pLogDlg->SetSelect(true);
131 m_pLogDlg->m_pNotifyWindow = this;
132 m_pLogDlg->m_wParam = 0;
133 m_pLogDlg->SetParams(m_wcPath, SVNRev::REV_HEAD, SVNRev::REV_HEAD, 1, limit, TRUE);
134 m_pLogDlg->ContinuousSelection(true);
135 m_pLogDlg->Create(IDD_LOGMESSAGE, this);
136 m_pLogDlg->ShowWindow(SW_SHOW);
138 AfxGetApp()->DoWaitCursor(-1);
141 LPARAM CUpdateDlg::OnRevSelected(WPARAM /*wParam*/, LPARAM lParam)
143 CString temp;
144 temp.Format(_T("%ld"), lParam);
145 SetDlgItemText(IDC_REVNUM, temp);
146 CheckRadioButton(IDC_NEWEST, IDC_REVISION_N, IDC_REVISION_N);
147 return 0;
150 void CUpdateDlg::OnEnChangeRevnum()
152 UpdateData();
153 if (m_sRevision.IsEmpty())
154 CheckRadioButton(IDC_NEWEST, IDC_REVISION_N, IDC_NEWEST);
155 else
156 CheckRadioButton(IDC_NEWEST, IDC_REVISION_N, IDC_REVISION_N);