1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - TortoiseSVN
\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
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
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
20 #include "TortoiseProc.h"
\r
21 #include "messagebox.h"
\r
23 #include "Registry.h"
\r
24 #include "DeleteUnversionedDlg.h"
\r
26 IMPLEMENT_DYNAMIC(CDeleteUnversionedDlg, CResizableStandAloneDialog)
\r
27 CDeleteUnversionedDlg::CDeleteUnversionedDlg(CWnd* pParent /*=NULL*/)
\r
28 : CResizableStandAloneDialog(CDeleteUnversionedDlg::IDD, pParent)
\r
29 , m_bSelectAll(TRUE)
\r
30 , m_bThreadRunning(FALSE)
\r
31 , m_bCancelled(false)
\r
35 CDeleteUnversionedDlg::~CDeleteUnversionedDlg()
\r
39 void CDeleteUnversionedDlg::DoDataExchange(CDataExchange* pDX)
\r
41 CResizableStandAloneDialog::DoDataExchange(pDX);
\r
42 DDX_Control(pDX, IDC_ITEMLIST, m_StatusList);
\r
43 DDX_Check(pDX, IDC_SELECTALL, m_bSelectAll);
\r
44 DDX_Control(pDX, IDC_SELECTALL, m_SelectAll);
\r
48 BEGIN_MESSAGE_MAP(CDeleteUnversionedDlg, CResizableStandAloneDialog)
\r
49 ON_BN_CLICKED(IDC_SELECTALL, OnBnClickedSelectall)
\r
50 ON_REGISTERED_MESSAGE(CSVNStatusListCtrl::SVNSLNM_NEEDSREFRESH, OnSVNStatusListCtrlNeedsRefresh)
\r
55 BOOL CDeleteUnversionedDlg::OnInitDialog()
\r
57 CResizableStandAloneDialog::OnInitDialog();
\r
59 m_StatusList.Init(SVNSLC_COLEXT | SVNSLC_COLSTATUS, _T("DeleteUnversionedDlg"), 0, true);
\r
60 m_StatusList.SetUnversionedRecurse(true);
\r
61 m_StatusList.PutUnversionedLast(false);
\r
62 m_StatusList.CheckChildrenWithParent(true);
\r
63 m_StatusList.SetConfirmButton((CButton*)GetDlgItem(IDOK));
\r
64 m_StatusList.SetSelectButton(&m_SelectAll);
\r
65 m_StatusList.SetCancelBool(&m_bCancelled);
\r
66 m_StatusList.SetBackgroundImage(IDI_DELUNVERSIONED_BKG);
\r
68 GetWindowText(m_sWindowTitle);
\r
70 AdjustControlSize(IDC_SELECTALL);
\r
72 AddAnchor(IDC_ITEMLIST, TOP_LEFT, BOTTOM_RIGHT);
\r
73 AddAnchor(IDC_SELECTALL, BOTTOM_LEFT);
\r
74 AddAnchor(IDOK, BOTTOM_RIGHT);
\r
75 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
\r
77 CenterWindow(CWnd::FromHandle(hWndExplorer));
\r
78 EnableSaveRestore(_T("DeleteUnversionedDlg"));
\r
80 // first start a thread to obtain the file list with the status without
\r
81 // blocking the dialog
\r
82 if (AfxBeginThread(StatusThreadEntry, this)==0)
\r
84 CMessageBox::Show(this->m_hWnd, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
86 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
91 UINT CDeleteUnversionedDlg::StatusThreadEntry(LPVOID pVoid)
\r
93 return ((CDeleteUnversionedDlg*)pVoid)->StatusThread();
\r
96 UINT CDeleteUnversionedDlg::StatusThread()
\r
98 // get the status of all selected file/folders recursively
\r
99 // and show the ones which are unversioned/ignored to the user
\r
100 // in a list control.
\r
101 DialogEnableWindow(IDOK, false);
\r
102 m_bCancelled = false;
\r
104 if (!m_StatusList.GetStatus(m_pathList, false, true))
\r
106 m_StatusList.SetEmptyString(m_StatusList.GetLastErrorMessage());
\r
108 m_StatusList.Show(SVNSLC_SHOWUNVERSIONED | SVNSLC_SHOWIGNORED,
\r
109 SVNSLC_SHOWUNVERSIONED | SVNSLC_SHOWIGNORED);
\r
111 CTSVNPath commonDir = m_StatusList.GetCommonDirectory(false);
\r
112 SetWindowText(m_sWindowTitle + _T(" - ") + commonDir.GetWinPathString());
\r
114 InterlockedExchange(&m_bThreadRunning, FALSE);
\r
120 void CDeleteUnversionedDlg::OnOK()
\r
122 if (m_bThreadRunning)
\r
124 // save only the files the user has selected into the temporary file
\r
125 m_StatusList.WriteCheckedNamesToPathList(m_pathList);
\r
127 CResizableStandAloneDialog::OnOK();
\r
130 void CDeleteUnversionedDlg::OnCancel()
\r
132 m_bCancelled = true;
\r
133 if (m_bThreadRunning)
\r
136 CResizableStandAloneDialog::OnCancel();
\r
139 void CDeleteUnversionedDlg::OnBnClickedSelectall()
\r
141 UINT state = (m_SelectAll.GetState() & 0x0003);
\r
142 if (state == BST_INDETERMINATE)
\r
144 // It is not at all useful to manually place the checkbox into the indeterminate state...
\r
145 // We will force this on to the unchecked state
\r
146 state = BST_UNCHECKED;
\r
147 m_SelectAll.SetCheck(state);
\r
149 theApp.DoWaitCursor(1);
\r
150 m_StatusList.SelectAll(state == BST_CHECKED);
\r
151 theApp.DoWaitCursor(-1);
\r
154 BOOL CDeleteUnversionedDlg::PreTranslateMessage(MSG* pMsg)
\r
156 if (pMsg->message == WM_KEYDOWN)
\r
158 switch (pMsg->wParam)
\r
162 if (GetAsyncKeyState(VK_CONTROL)&0x8000)
\r
164 if ( GetDlgItem(IDOK)->IsWindowEnabled() )
\r
166 PostMessage(WM_COMMAND, IDOK);
\r
174 if (!m_bThreadRunning)
\r
176 if (AfxBeginThread(StatusThreadEntry, this)==0)
\r
178 CMessageBox::Show(this->m_hWnd, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r
181 InterlockedExchange(&m_bThreadRunning, TRUE);
\r
188 return CResizableStandAloneDialog::PreTranslateMessage(pMsg);
\r
191 LRESULT CDeleteUnversionedDlg::OnSVNStatusListCtrlNeedsRefresh(WPARAM, LPARAM)
\r
193 if (AfxBeginThread(StatusThreadEntry, this)==0)
\r
195 CMessageBox::Show(this->m_hWnd, IDS_ERR_THREADSTARTFAILED, IDS_APPNAME, MB_OK | MB_ICONERROR);
\r