1 |
26 |
unneback |
//####COPYRIGHTBEGIN####
|
2 |
|
|
//
|
3 |
|
|
// ----------------------------------------------------------------------------
|
4 |
|
|
// Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
|
5 |
|
|
//
|
6 |
|
|
// This program is part of the eCos host tools.
|
7 |
|
|
//
|
8 |
|
|
// This program is free software; you can redistribute it and/or modify it
|
9 |
|
|
// under the terms of the GNU General Public License as published by the Free
|
10 |
|
|
// Software Foundation; either version 2 of the License, or (at your option)
|
11 |
|
|
// any later version.
|
12 |
|
|
//
|
13 |
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
14 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
15 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
16 |
|
|
// more details.
|
17 |
|
|
//
|
18 |
|
|
// You should have received a copy of the GNU General Public License along with
|
19 |
|
|
// this program; if not, write to the Free Software Foundation, Inc.,
|
20 |
|
|
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
21 |
|
|
//
|
22 |
|
|
// ----------------------------------------------------------------------------
|
23 |
|
|
//
|
24 |
|
|
//####COPYRIGHTEND####
|
25 |
|
|
// SummaryPage.cpp : implementation file
|
26 |
|
|
//
|
27 |
|
|
|
28 |
|
|
#include "stdafx.h"
|
29 |
|
|
#include "SummaryPage.h"
|
30 |
|
|
#include "eCosTest.h"
|
31 |
|
|
#include "RunTestsSheet.h"
|
32 |
|
|
#include <windowsx.h> // for GET_X_LPARAM, GET_Y_LPARAM
|
33 |
|
|
|
34 |
|
|
#ifdef _DEBUG
|
35 |
|
|
#define new DEBUG_NEW
|
36 |
|
|
#undef THIS_FILE
|
37 |
|
|
static char THIS_FILE[] = __FILE__;
|
38 |
|
|
#endif
|
39 |
|
|
|
40 |
|
|
LPCTSTR CSummaryPage::arpszCols[]={_T("Time"), _T("Host"), _T( "Platform"), _T("Executable"), _T("Status"), _T("Size"), _T("Download"), _T("Elapsed"), _T("Execution")};
|
41 |
|
|
const int CSummaryPage::nCols=sizeof CSummaryPage::arpszCols/sizeof CSummaryPage::arpszCols[0];
|
42 |
|
|
|
43 |
|
|
/////////////////////////////////////////////////////////////////////////////
|
44 |
|
|
// CSummaryPage property page
|
45 |
|
|
|
46 |
|
|
IMPLEMENT_DYNCREATE(CSummaryPage, CeCosPropertyPage)
|
47 |
|
|
|
48 |
|
|
CSummaryPage::CSummaryPage() : CeCosPropertyPage(IDD_TT_SUMMARY_PAGE)
|
49 |
|
|
{
|
50 |
|
|
//{{AFX_DATA_INIT(CSummaryPage)
|
51 |
|
|
// NOTE: the ClassWizard will add member initialization here
|
52 |
|
|
//}}AFX_DATA_INIT
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
CSummaryPage::~CSummaryPage()
|
56 |
|
|
{
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
void CSummaryPage::DoDataExchange(CDataExchange* pDX)
|
60 |
|
|
{
|
61 |
|
|
CeCosPropertyPage::DoDataExchange(pDX);
|
62 |
|
|
//{{AFX_DATA_MAP(CSummaryPage)
|
63 |
|
|
DDX_Control(pDX, IDC_TT_LIST, m_List);
|
64 |
|
|
//}}AFX_DATA_MAP
|
65 |
|
|
}
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
BEGIN_MESSAGE_MAP(CSummaryPage, CeCosPropertyPage)
|
69 |
|
|
//{{AFX_MSG_MAP(CSummaryPage)
|
70 |
|
|
ON_NOTIFY(NM_RCLICK, IDC_TT_LIST, OnRclickList)
|
71 |
|
|
ON_COMMAND(IDC_TT_CLEAR, OnClear)
|
72 |
|
|
ON_NOTIFY(LVN_COLUMNCLICK, IDC_TT_LIST, OnColumnclickList)
|
73 |
|
|
ON_WM_SIZE()
|
74 |
|
|
ON_COMMAND(ID_TT_EDIT_SAVE, OnEditSave)
|
75 |
|
|
//}}AFX_MSG_MAP
|
76 |
|
|
END_MESSAGE_MAP()
|
77 |
|
|
|
78 |
|
|
/////////////////////////////////////////////////////////////////////////////
|
79 |
|
|
// CSummaryPage message handlers
|
80 |
|
|
|
81 |
|
|
void CSummaryPage::AddResult(CeCosTest *pTest)
|
82 |
|
|
{
|
83 |
|
|
const CString strResult((LPCTSTR)pTest->ResultString(false));
|
84 |
|
|
int nLength=strResult.GetLength();
|
85 |
|
|
CString arstr[8];
|
86 |
|
|
CString strTime,strDate;
|
87 |
|
|
TRACE(_T("%s\n"),strResult);
|
88 |
|
|
// 1999-05-28 10:29:28 nan:0 TX39-jmr3904-sim tx39-jmr3904sim-libc10-signal2.exe Fail 0k/1108k D=0.0/0.0 Total=9.3 E=0.6/300.0
|
89 |
|
|
_stscanf(strResult,_T("%s %s %s %s %s %s %s %s %s %s"),strDate.GetBuffer(1+nLength),strTime.GetBuffer(1+nLength),arstr[0].GetBuffer(1+nLength),arstr[1].GetBuffer(1+nLength),arstr[2].GetBuffer(1+nLength),arstr[3].GetBuffer(1+nLength),arstr[4].GetBuffer(1+nLength),arstr[5].GetBuffer(1+nLength),arstr[6].GetBuffer(1+nLength),arstr[7].GetBuffer(1+nLength));
|
90 |
|
|
// Remove before '=' in time fields
|
91 |
|
|
for(int i=5;i<8;i++){
|
92 |
|
|
TCHAR *pch=_tcschr(arstr[i],_TCHAR('='));
|
93 |
|
|
if(pch){
|
94 |
|
|
arstr[i]=pch+1;
|
95 |
|
|
}
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
strDate.ReleaseBuffer();
|
99 |
|
|
strTime.ReleaseBuffer();
|
100 |
|
|
strDate+=_TCHAR(' ');
|
101 |
|
|
strDate+=strTime;
|
102 |
|
|
int nItem=m_List.GetItemCount();
|
103 |
|
|
m_List.InsertItem(nItem,strDate);
|
104 |
|
|
m_List.SetItemData(nItem,nItem);// to support sorting
|
105 |
|
|
for(i=0;i<8;i++){
|
106 |
|
|
m_List.SetItemText(nItem,1+i,arstr[i]);
|
107 |
|
|
arstr[i].ReleaseBuffer();
|
108 |
|
|
}
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
BOOL CSummaryPage::OnInitDialog()
|
112 |
|
|
{
|
113 |
|
|
m_nLastCol=0x7fffffff;
|
114 |
|
|
CeCosPropertyPage::OnInitDialog();
|
115 |
|
|
|
116 |
|
|
CRect rect;
|
117 |
|
|
m_List.GetClientRect(rect);
|
118 |
|
|
for(int i=0;i<nCols;i++){
|
119 |
|
|
m_List.InsertColumn(i,arpszCols[i]);
|
120 |
|
|
}
|
121 |
|
|
ListView_SetExtendedListViewStyle(m_List.GetSafeHwnd(),LVS_EX_FULLROWSELECT);
|
122 |
|
|
for(i=0;i<nCols;i++){
|
123 |
|
|
m_List.SetColumnWidth(i,rect.Width()/nCols);
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
127 |
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
128 |
|
|
}
|
129 |
|
|
|
130 |
|
|
void CSummaryPage::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult)
|
131 |
|
|
{
|
132 |
|
|
UNUSED_ALWAYS(pNMHDR);
|
133 |
|
|
if(m_List.GetItemCount()>0){
|
134 |
|
|
CMenu menu;
|
135 |
|
|
menu.LoadMenu(IDR_TT_CONTEXTMENU1);
|
136 |
|
|
DWORD dwPos=GetMessagePos();
|
137 |
|
|
|
138 |
|
|
CMenu *pPopup=menu.GetSubMenu(0);
|
139 |
|
|
pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, MAKEPOINTS(dwPos).x,MAKEPOINTS(dwPos).y,this);
|
140 |
|
|
}
|
141 |
|
|
*pResult = 0;
|
142 |
|
|
}
|
143 |
|
|
|
144 |
|
|
void CSummaryPage::OnClear()
|
145 |
|
|
{
|
146 |
|
|
m_List.DeleteAllItems();
|
147 |
|
|
}
|
148 |
|
|
|
149 |
|
|
int CSummaryPage::CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
|
150 |
|
|
{
|
151 |
|
|
CSummaryPage *pPage=(CSummaryPage *)lParamSort;
|
152 |
|
|
CString str1,str2;
|
153 |
|
|
int nCol=pPage->m_nLastCol&0x7fffffff;
|
154 |
|
|
str1=pPage->m_List.GetItemText(lParam1,nCol);
|
155 |
|
|
str2=pPage->m_List.GetItemText(lParam2,nCol);
|
156 |
|
|
int rc=str1.Compare(str2);
|
157 |
|
|
if(rc && (pPage->m_nLastCol&0x80000000)){
|
158 |
|
|
rc^=0x80000000;
|
159 |
|
|
}
|
160 |
|
|
return rc;
|
161 |
|
|
}
|
162 |
|
|
|
163 |
|
|
void CSummaryPage::OnColumnclickList(NMHDR* pNMHDR, LRESULT* pResult)
|
164 |
|
|
{
|
165 |
|
|
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
|
166 |
|
|
LPARAM nCol=pNMListView->iSubItem;
|
167 |
|
|
if((nCol&0x7fffffff)==(0x7fffffff&m_nLastCol)){
|
168 |
|
|
m_nLastCol=m_nLastCol^0x80000000;
|
169 |
|
|
} else {
|
170 |
|
|
m_nLastCol=nCol;
|
171 |
|
|
}
|
172 |
|
|
m_List.SortItems(CompareFunc,(LPARAM)this);
|
173 |
|
|
for(int i=m_List.GetItemCount()-1;i>=0;--i){
|
174 |
|
|
m_List.SetItemData(i,i);
|
175 |
|
|
}
|
176 |
|
|
*pResult = 0;
|
177 |
|
|
}
|
178 |
|
|
|
179 |
|
|
void CSummaryPage::OnSize(UINT nType, int cx, int cy)
|
180 |
|
|
{
|
181 |
|
|
CeCosPropertyPage::OnSize(nType, cx, cy);
|
182 |
|
|
float arProp[nCols]; // to preserve column propertions
|
183 |
|
|
if(m_List){
|
184 |
|
|
CRect rect;
|
185 |
|
|
m_List.GetClientRect(rect);
|
186 |
|
|
float fWidth=(float)rect.Width();
|
187 |
|
|
for(int i=0;i<nCols;i++){
|
188 |
|
|
arProp[i]=float(m_List.GetColumnWidth(i))/fWidth;
|
189 |
|
|
}
|
190 |
|
|
((CRunTestsSheet*)GetParent())->MoveWindow(GetDlgItem(IDC_TT_LIST),CRunTestsSheet::Stretch);
|
191 |
|
|
m_List.GetClientRect(rect);
|
192 |
|
|
fWidth=(float)rect.Width();
|
193 |
|
|
for(i=0;i<nCols;i++){
|
194 |
|
|
m_List.SetColumnWidth(i,(int)(0.5+fWidth*arProp[i]));
|
195 |
|
|
}
|
196 |
|
|
}
|
197 |
|
|
}
|
198 |
|
|
|
199 |
|
|
void CSummaryPage::OnEditSave()
|
200 |
|
|
{
|
201 |
|
|
CFileDialog dlg( FALSE, _T("log"), _T("Output"), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
202 |
|
|
_T("Log Files (*.log)|*.log|All Files (*.*)|*.*||"));
|
203 |
|
|
if(IDOK==dlg.DoModal()){
|
204 |
|
|
TRY
|
205 |
|
|
{
|
206 |
|
|
CStdioFile f( dlg.GetPathName(), CFile::modeCreate | CFile::modeWrite );
|
207 |
|
|
CString str;
|
208 |
|
|
int arColWidth[nCols];
|
209 |
|
|
for(int nCol=0;nCol<nCols;nCol++){
|
210 |
|
|
int &w=arColWidth[nCol];
|
211 |
|
|
w=_tcslen(arpszCols[nCol]);
|
212 |
|
|
for(int nItem=0;nItem<m_List.GetItemCount();nItem++){
|
213 |
|
|
w=max(w,m_List.GetItemText(nItem,nCol).GetLength());
|
214 |
|
|
}
|
215 |
|
|
TRACE(_T("max[%d]=%d\n"),nCol,w);
|
216 |
|
|
}
|
217 |
|
|
|
218 |
|
|
for(nCol=0;nCol<nCols;nCol++){
|
219 |
|
|
const CString &strItem=arpszCols[nCol];
|
220 |
|
|
str+=strItem;
|
221 |
|
|
if(nCol<nCols-1){
|
222 |
|
|
CString strTab(_TCHAR(' '),1+arColWidth[nCol]-strItem.GetLength());
|
223 |
|
|
str+=strTab;
|
224 |
|
|
}
|
225 |
|
|
}
|
226 |
|
|
str+=_TCHAR('\n');
|
227 |
|
|
f.WriteString(str);
|
228 |
|
|
for(int nItem=0;nItem<m_List.GetItemCount();nItem++){
|
229 |
|
|
CString str;
|
230 |
|
|
for(int nCol=0;nCol<nCols;nCol++){
|
231 |
|
|
const CString strItem=m_List.GetItemText(nItem,nCol);
|
232 |
|
|
str+=strItem;
|
233 |
|
|
if(nCol<nCols-1){
|
234 |
|
|
CString strTab(_TCHAR(' '),1+arColWidth[nCol]-strItem.GetLength());
|
235 |
|
|
str+=strTab;
|
236 |
|
|
}
|
237 |
|
|
}
|
238 |
|
|
str+=_TCHAR('\n');
|
239 |
|
|
f.WriteString(str);
|
240 |
|
|
}
|
241 |
|
|
f.Close();
|
242 |
|
|
}
|
243 |
|
|
CATCH( CFileException, e )
|
244 |
|
|
{
|
245 |
|
|
MessageBox(_T("Failed to write file"));
|
246 |
|
|
}
|
247 |
|
|
END_CATCH
|
248 |
|
|
}
|
249 |
|
|
|
250 |
|
|
}
|