NCBI C++ ToolKit
report_loader_errors.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: report_loader_errors.cpp 47661 2024-02-06 03:39:10Z ucko $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Authors: Roman Katargin
27 */
28 
29 
30 #include <ncbi_pch.hpp>
31 
33 
35 
37 
38 #include <wx/txtstrm.h>
39 #include <wx/filename.h>
40 
43 
44 void CReportLoaderErrors::x_UpdateHTMLResults(const wxString& object,
45  objects::ILineErrorListener* errCont,
46  const string& exception, const string& error_msg, const wxString& objectName)
47 {
48  if ((!errCont || errCont->Count() == 0) && exception.empty() && error_msg.empty())
49  return;
50 
51  wxTextOutputStream os(m_Strstrm);
52  os << wxT("<h5>") << objectName << wxT(" ") << object << wxT("</h5>");
53 
54  if (errCont && errCont->Count() > 0) {
55  for (size_t i = 0; i < errCont->Count(); ++i) {
56  const ILineError& lerror = errCont->GetError(i);
57  os << wxT("Line ") << lerror.Line() << wxT(". ") << wxString::FromUTF8(lerror.Message().c_str()) << wxT("<br />");
58  }
59  }
60 
61  if (!exception.empty()) {
62  os << wxT("<font color=\"red\">") << wxString::FromUTF8(exception.c_str()) << wxT("</font><br />");
63  }
64 
65  if (!error_msg.empty()) {
66  os << wxT("<font color=\"red\">") << wxString::FromUTF8(error_msg.c_str()) << wxT("</font><br />");
67  }
68 }
69 
70 void CReportLoaderErrors::x_ShowErrorsDlg(const wxString& title)
71 {
72  wxString html = m_Strstrm.GetString();
73  if (!html.IsEmpty()) {
74  CJobResultsDlg dlg;
75  dlg.SetHTML(html);
76  dlg.SetWorkDir(m_WorkDir);
77  dlg.Create(NULL, wxID_ANY, title);
78  dlg.ShowModal();
79  }
80 }
81 
82 
83 void CReportLoaderErrorsEx::x_UpdateHTMLResults(const wxString& object, objects::CObjtoolsListener* errCont,
84  const string& exception, const string& error_msg, const wxString& objectName)
85 {
86  if ((!errCont || errCont->Count() == 0) && exception.empty() && error_msg.empty())
87  return;
88 
89  wxTextOutputStream os(m_Strstrm);
90  os << wxT("<h5>") << objectName << wxT(" ") << object << wxT("</h5>");
91 
92  if (errCont && errCont->Count() > 0) {
93  for (size_t i = 0; i < errCont->Count(); ++i) {
94  const IObjtoolsMessage& msg = errCont->GetMessage(i);
95  os << wxString(CNcbiDiag::SeverityName(msg.GetSeverity())) << wxT(": ") << wxString::FromUTF8(msg.GetText().c_str()) << wxT("<br />");
96  }
97  }
98 
99  if (!exception.empty()) {
100  os << wxT("<font color=\"red\">") << wxString::FromUTF8(exception.c_str()) << wxT("</font><br />");
101  }
102 
103  if (!error_msg.empty()) {
104  os << wxT("<font color=\"red\">") << wxString::FromUTF8(error_msg.c_str()) << wxT("</font><br />");
105  }
106 }
107 
108 void CReportLoaderErrorsEx::x_ShowErrorsDlg(const wxString& title)
109 {
110  wxString html = m_Strstrm.GetString();
111  if (!html.IsEmpty()) {
112  CJobResultsDlg dlg;
113  dlg.SetHTML(html);
114  dlg.SetWorkDir(m_WorkDir);
115  dlg.Create(NULL, wxID_ANY, title);
116  dlg.ShowModal();
117  }
118 }
119 
120 
void SetHTML(wxString value)
void SetWorkDir(const wxString &workDir)
bool Create(wxWindow *parent, wxWindowID id=10049, const wxString &caption=_("Job Results"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
wxStringOutputStream m_Strstrm
void x_UpdateHTMLResults(const wxString &object, objects::CObjtoolsListener *errCont, const string &exception="", const string &error_msg="", const wxString &objectName=wxT("File:"))
void x_ShowErrorsDlg(const wxString &title)
void x_ShowErrorsDlg(const wxString &title)
void x_UpdateHTMLResults(const wxString &object, objects::ILineErrorListener *errCont, const string &exception="", const string &error_msg="", const wxString &objectName=wxT("File:"))
wxStringOutputStream m_Strstrm
virtual string Message() const
Definition: line_error.cpp:110
virtual unsigned int Line(void) const =0
#define NULL
Definition: ncbistd.hpp:225
static const char * SeverityName(EDiagSev sev)
Get a common symbolic name for the severity levels.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
int i
#define wxT(x)
Definition: muParser.cpp:41
USING_SCOPE(objects)
static static static wxID_ANY
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
Modified on Wed Sep 04 14:59:45 2024 by modify_doxy.py rev. 669887