void CLogAnalyzerView::ShowTraces(const CString& strComponent, BOOL bShowAll) { tstring strItemText = strComponent; const std::map<tstring, Poco::SharedPtr<CComponent>>& components = m_logger->GetComponents(); std::map<tstring, Poco::SharedPtr<CComponent>>::const_iterator ite = components.find(strItemText); if (ite != components.end()) { const std::vector<Poco::SharedPtr<CTraceLog>>& traceLogs = ite->second->GetTraceLogs(); if (bShowAll) { //Only show the traces you want in list control m_traceList.DeleteAllTraceLog(); for (int i = 0; i < traceLogs.size(); ++i) m_traceList.InsertTraceLog(traceLogs.at(i)); } //Show all traces and go to the first trace log that fits to you want else { Poco::SharedPtr<CUISetting> uiSetting = m_logger->GetActiveUISetting(); int nColumn = 0; int nCurSel = m_comboColumns.GetCurSel(); if (nCurSel == 0) nColumn = -1; //All else { CString strItem; m_comboColumns.GetLBText(nCurSel, strItem); tstring strItemValue = strItem.GetBuffer(strItem.GetLength()); if (!uiSetting.isNull()) { for (int i = 0; i < uiSetting->GetAllColumns().size(); ++i) { if (strItemValue == uiSetting->GetAllColumns().at(i)->m_strRealColumnName) { nColumn = i; break; } } } } m_traceList.SearchText(nColumn, m_strFindContent.GetBuffer(m_strFindContent.GetLength()), m_bMatchCase); } m_strCurrentPage.Format("%d", m_traceList.GetCurrentPage()); m_strTraceCount.Format("Total : %d", m_traceList.GetCount()); UpdateData(FALSE); } }
void CLogAnalyzerView::OnBnClickedButtonOpen() { //Open File if (!m_logger.isNull() && !(m_logger->GetActiveUISetting().isNull())) { if (!m_logger->GetActiveUISetting()->IsAvailable()) if (AfxMessageBox("The UI setting is not available, Do you want to configurate it?", MB_OKCANCEL) == IDOK) { //OnAnalyseSetting(); return; } } CString strFile = _T(""); CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY, _T("Describe Files (*.log)|*.log|All Files (*.*)|*.*||"), NULL); if (dlgFile.DoModal() == IDOK) { strFile = dlgFile.GetPathName(); CString strItem; m_comboSettings.GetLBText(m_comboSettings.GetCurSel(), strItem); CLogAnalyzerApp* app = (CLogAnalyzerApp*)AfxGetApp(); if (app != NULL) { Poco::SharedPtr<CUISetting> currentSelSetting = app->GetUISetting(strItem.GetBuffer(strItem.GetLength())); if (!currentSelSetting.isNull()) { if (!m_logger.isNull() && !m_logger->GetFileName().empty()) { m_logger->ClearAllComponents(); //Open another log file, remove the previous one RemoveItem(); } m_logger->SetActiveUISetting(currentSelSetting); } //Update list control while(m_comboColumns.DeleteString(0)); while(m_traceList.DeleteColumn(0)); m_comboColumns.AddString("All"); //Init list control LV_COLUMN lv; lv.mask = LVCF_TEXT | LVCF_WIDTH; if (!currentSelSetting.isNull()) { int nIndex = 0; //Insert the first column of Line number lv.pszText = "Line"; lv.cx = 50; m_traceList.InsertColumn(nIndex++, &lv); const std::vector<Poco::SharedPtr<CColumnSetting>>& columns = currentSelSetting->GetAllColumns(); for (int i = 0; i < columns.size(); ++i) { if (columns.at(i)->m_bEnable) { lv.pszText = (LPSTR)columns.at(i)->m_strRealColumnName.c_str(); lv.cx = 100; m_traceList.InsertNewColumn(nIndex++, &lv, i); m_comboColumns.AddString(columns.at(i)->m_strRealColumnName.c_str()); } } m_traceList.SetColumnSetting(currentSelSetting->GetAllColumns()); } } m_comboColumns.SetCurSel(0); m_traceList.DeleteAllTraceLog(); m_logger->StartParse(tstring(strFile.GetBuffer(strFile.GetLength()))); CAnalyseProgressDlg dlg(m_logger); dlg.DoModal(); //Update tree view CClassView* pClassView = NULL; GET_CLASS_VIEW(pClassView); if (pClassView != NULL) { HTREEITEM hFile = pClassView->InsertLogFile(strFile); const std::map<tstring, Poco::SharedPtr<CComponent>>& components = m_logger->GetComponents(); std::map<tstring, Poco::SharedPtr<CComponent>>::const_iterator ite = components.begin(); while (ite != components.end()) { pClassView->InsertComponent(hFile, ite->second->GetComponentName().c_str()); ++ite; } pClassView->SetFocus(); } //Update log file information/UI Setting in property panel CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd(); if (pMainFrame != NULL) { Poco::SharedPtr<SLogFileProperty> logFilePro = new SLogFileProperty; logFilePro->m_strFileName = m_logger->GetFileName(); logFilePro->m_nFileSize = m_logger->GetFileSize(); pMainFrame->SetLogFileProperty(logFilePro); pMainFrame->SetCurrentUISettingProperty(m_logger->GetActiveUISetting()); } //Update tab title CLogAnalyzerDoc* pDoc = (CLogAnalyzerDoc*)GetDocument(); if (pDoc) { pDoc->SetTitle(dlgFile.GetFileName()); pDoc->SetDocIdentifier(strFile); } } }