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

Go to the SVN repository for this file.

1 /* $Id: validate_panel.cpp 47479 2023-05-02 13:24:02Z 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: Igor Filippov
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 #include <objmgr/util/sequence.hpp>
34 
40 
45 
48 
51 
52 // for validator response commands
53 
59 #include <gui/objutils/utils.hpp>
60 
63 
65 
66 // For compilers that support precompilation, includes "wx/wx.h".
67 #include "wx/wxprec.h"
68 
69 #ifdef __BORLANDC__
70 #pragma hdrstop
71 #endif
72 
73 #ifndef WX_PRECOMP
74 #include "wx/wx.h"
75 #endif
76 
77 #include "wx/imaglist.h"
78 #include <wx/display.h>
79 #include <wx/filename.h>
80 
81 
84 
85 /*
86  * CValidatePanel type definition
87  */
88 
90 
91 
92 /*
93  * CValidatePanel event table definition
94  */
95 
96 BEGIN_EVENT_TABLE( CValidatePanel, wxPanel )
97 
103  EVT_CHILD_FOCUS(CValidatePanel::OnChildFocus)
104 
106 
108  ON_EVENT(CProjectViewEvent, CViewEvent::eProjectChanged, &CValidatePanel::x_OnDataChanged)
110 
111 /*
112  * CValidatePanel constructors
113  */
114 
116  : m_Workbench(nullptr)
117 {
118  Init();
119 }
120 
121 CValidatePanel::CValidatePanel( wxWindow* parent, IWorkbench* wb, CRef<CUser_object> params,
122  wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
123  : m_Workbench(wb), m_params(params), m_SelectionClient(new CSelectionClient("Validate Errors"))
124 {
125  Init();
126  Create( parent, id, pos, size, style );
127 
129  if (sel_srv) sel_srv->AttachClient(m_SelectionClient);
131 }
132 
133 
134 /*
135  * CValidatePanel creator
136  */
137 
138 bool CValidatePanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
139 {
140  wxPanel::Create( parent, id, pos, size, style );
141 
142  CreateControls();
143  Centre();
144  return true;
145 }
146 
147 
148 /*
149  * CValidatePanel destructor
150  */
151 
153 {
156  if (sel_srv) sel_srv->DetachClient(m_SelectionClient);
158  }
159 
161 
163  SetCursor(wxCursor(wxNullCursor));
164  wxSetCursor(wxNullCursor);
165 }
166 
167 void CValidatePanel::OnChildFocus(wxChildFocusEvent& evt)
168 {
171  if (sel_srv) sel_srv->OnActiveClientChanged(m_SelectionClient);
172  }
173 }
174 
175 /*
176  * Member initialisation
177  */
178 
180 {
181  m_ErrorListCtrl = nullptr;
182  m_SummaryText = nullptr;
183  m_Modified = nullptr;
184  m_Severity = nullptr;
185  m_Filter = nullptr;
186 }
187 
188 /*
189  * Control creation for CValidatePanel
190  */
191 
193 {
194 ////@begin CValidatePanel content construction
195  // Generated by DialogBlocks, 18/10/2016 11:02:51 (unregistered)
196 
197  wxPanel* itemPanel2 = this;
198 
199  wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
200  itemPanel2->SetSizer(itemBoxSizer3);
201 
202  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
203  itemBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_LEFT|wxALL, 5);
204 
205  wxStaticBox* itemStaticBoxSizer7Static = new wxStaticBox(itemPanel2, wxID_ANY, _("Status"));
206  wxStaticBoxSizer* itemStaticBoxSizer7 = new wxStaticBoxSizer(itemStaticBoxSizer7Static, wxVERTICAL);
207  itemBoxSizer4->Add(itemStaticBoxSizer7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
208 
209  m_SummaryText = new wxStaticText( itemPanel2, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxSize(450, -1), 0 );
210  itemStaticBoxSizer7->Add(m_SummaryText, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
211 
212  m_Modified = new wxStaticText( itemPanel2, wxID_STATIC, wxEmptyString, wxDefaultPosition, wxSize(450, -1), 0 );
213  itemStaticBoxSizer7->Add(m_Modified, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
214 
215  wxStaticText* itemStaticText5 = new wxStaticText( itemPanel2, wxID_STATIC, _("Severity"), wxDefaultPosition, wxDefaultSize, 0 );
216  itemBoxSizer4->Add(itemStaticText5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
217 
218  wxArrayString m_SeverityStrings;
219  m_SeverityStrings.Add(_("INFO"));
220  m_SeverityStrings.Add(_("WARN"));
221  m_SeverityStrings.Add(_("ERROR"));
222  m_SeverityStrings.Add(_("REJECT"));
223  m_Severity = new wxChoice( itemPanel2, ID_VALIDATE_FRAME_SEVERITY, wxDefaultPosition, wxDefaultSize, m_SeverityStrings, 0 );
224  m_Severity->SetStringSelection(_("INFO"));
225  itemBoxSizer4->Add(m_Severity, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
226 
227  wxStaticText* itemStaticText7 = new wxStaticText( itemPanel2, wxID_STATIC, _("Filter"), wxDefaultPosition, wxDefaultSize, 0 );
228  itemBoxSizer4->Add(itemStaticText7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
229 
230  wxArrayString m_FilterStrings;
231  m_FilterStrings.Add(_("ALL"));
232  m_Filter = new wxChoice( itemPanel2, ID_VALIDATE_FRAME_ERRCODE, wxDefaultPosition, wxSize(200, -1), m_FilterStrings, 0 );
233  m_Filter->SetStringSelection(_("ALL"));
234  itemBoxSizer4->Add(m_Filter, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
235 
236  m_ErrorListCtrl = new CErrorListCtrl( itemPanel2, ID_VALIDATE_FRAME_TEXTCTRL, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_HRULES | wxLC_VRULES | wxLC_VIRTUAL);
237  itemBoxSizer3->Add(m_ErrorListCtrl, 1, wxGROW|wxALL, 5);
238 
239  if (!RunningInsideNCBI())
240  {
241  m_ErrorListCtrl->Bind(wxEVT_MOTION, &CValidatePanel::OnMouseMove, this);
242  }
243 
244 ////@end CValidatePanel content construction
245 }
246 
247 /*
248  * Should we show tooltips?
249  */
250 
252 {
253  return true;
254 }
255 
256 /*
257  * Get bitmap resources
258  */
259 
260 wxBitmap CValidatePanel::GetBitmapResource( const wxString& name )
261 {
262  // Bitmap retrieval
263 ////@begin CValidatePanel bitmap retrieval
264  wxUnusedVar(name);
265  return wxNullBitmap;
266 ////@end CValidatePanel bitmap retrieval
267 }
268 
269 /*
270  * Get icon resources
271  */
272 
273 wxIcon CValidatePanel::GetIconResource( const wxString& name )
274 {
275  // Icon retrieval
276 ////@begin CValidatePanel icon retrieval
277  wxUnusedVar(name);
278  return wxNullIcon;
279 ////@end CValidatePanel icon retrieval
280 }
281 
283 {
284  if (!m_Workbench || !m_Scope)
285  return;
286 
288  if (!srv)
289  return;
290  CRef<CGBWorkspace> ws = srv->GetGBWorkspace();
291  if (!ws)
292  return;
293  CGBDocument* doc = dynamic_cast<CGBDocument*>(ws->GetProjectFromScope(*m_Scope));
294  if (!doc)
295  return;
296  doc->AddListener(this);
297 }
298 
300 {
301  if (!m_Workbench || !m_Scope)
302  return;
303 
305  if (!srv)
306  return;
307  CRef<CGBWorkspace> ws = srv->GetGBWorkspace();
308  if (!ws)
309  return;
310  CGBDocument* doc = dynamic_cast<CGBDocument*>(ws->GetProjectFromScope(*m_Scope));
311  if (!doc)
312  return;
313  doc->RemoveListener(this);
314 }
315 
317 {
318  string statusText;
319  m_errs.Reset();
320 
322  if (!m_errs) {
323  statusText = "Validation failed!";
324  }
325  else if (m_errs->GetData().size() == 0) {
326  m_errs.Reset();
327  statusText = "Validation complete, no errors found!";
328  }
329 
330  x_UpdateList(statusText);
334  if (sel_srv) sel_srv->AttachClient(m_SelectionClient);
336  }
337 
338 //#ifdef NCBI_OS_MSWIN
339  if (m_IsBusy)
340  {
341  wxEndBusyCursor();
342  m_IsBusy = false;
343  }
344 //#endif
345 }
346 
347 void CValidatePanel::OnJobFailed(const string& errMsg, CJobAdapter&)
348 {
349  string statusText = "Failed: ";
350  m_errs.Reset();
351 
352  if (!errMsg.empty())
353  statusText += errMsg;
354  else
355  statusText += "Unknown fatal error";
356 
357  x_UpdateList(statusText);
361  if (sel_srv) sel_srv->AttachClient(m_SelectionClient);
363  }
364 
365 //#ifdef NCBI_OS_MSWIN
366  if (m_IsBusy)
367  {
368  wxEndBusyCursor();
369  m_IsBusy = false;
370  }
371 //#endif
372 }
373 
375 {
376 //#ifdef NCBI_OS_MSWIN
377  if (!m_IsBusy)
378  {
379  wxBeginBusyCursor();
380  m_IsBusy = true;
381  }
382 //#endif
384  {
386  if (sel_srv) sel_srv->DetachClient(m_SelectionClient);
387  TConstScopedObjects objs;
390  }
392 
393  m_errs.Reset();
395  m_Modified->SetLabel(wxEmptyString);
396 
398 
399  if (m_objects.empty()){
400  x_UpdateList("No objects");
401 //#ifdef NCBI_OS_MSWIN
402  if (m_IsBusy)
403  {
404  wxEndBusyCursor();
405  m_IsBusy = false;
406  }
407 //#endif
408  return;
409  }
410  m_Scope = m_objects.front().scope;
411 
412  TConstScopedObjects main_objects;
413  main_objects.push_back(m_objects.back());
414 
416  CIRef<IProjectView> pTextView(prjSrv->FindView(*(m_objects.back().object), "Text View"));
417  if (pTextView)
418  {
419  m_FlatFileCtrl.Reset(dynamic_cast<IFlatFileCtrl*>(pTextView.GetPointerOrNull()));
420  }
421 
422 
423  string statusText = "Validating...";
424 
425  try {
427  _ASSERT(srv);
428  CRef<CGBWorkspace> ws = srv->GetGBWorkspace();
429  CGBDocument* doc = 0;
430  if (ws)
431  doc = dynamic_cast<CGBDocument*>(ws->GetProjectFromScope(*m_objects.front().scope));
432 
433  if (doc)
434  m_WorkDir = doc->GetWorkDir();
435 
437  if (doc)
438  {
439  job->SetDataLocker(new CWeakExecuteGuard(doc->GetUndoManager()));
440  }
441 
442  m_JobAdapter.Reset(new CJobAdapter(*this));
443  m_JobAdapter->Start(*job);
444  } catch( CAppJobException& e ){
446  statusText = "Validation failed!";
447  LOG_POST( Error
448  << "CTableDataValidate failed to start job: "
449  << e.GetMsg()
450  );
451  LOG_POST(e.ReportAll());
452  }
453 
454  if (!statusText.empty())
455  x_UpdateList(statusText);
456 }
457 
459 {
460  EDiagSev sev = eDiag_Info;
461  switch (m_Severity->GetSelection())
462  {
463  case 0:
464  sev = eDiag_Info;
465  break;
466  case 1:
467  sev = eDiag_Warning;
468  break;
469  case 2:
470  sev = eDiag_Error;
471  break;
472  case 3:
473  sev = eDiag_Critical;
474  break;
475  default:
476  break;
477  }
478 
479  return valitem.GetSeverity() >= sev;
480 }
481 
483 {
484  string errcode = m_Filter->GetStringSelection().ToStdString();
485  return errcode == "ALL" || NStr::EqualNocase(errcode, valitem.GetErrCode());
486 }
487 
488 void CValidatePanel::x_UpdateList(const string &statusText)
489 {
490  if (!m_errs)
491  {
492  m_SummaryText->SetLabel(statusText);
493  m_Filter->Clear();
494  m_Filter->AppendString(wxT("ALL"));
495  m_Filter->SetSelection(0);
496  x_DisplayList();
497  return;
498  }
499 
500  set<string> err_codes;
501  for (size_t row = 0; row < m_errs->GetData().size(); ++row)
502  {
504  if (!error)
505  continue;
506  err_codes.insert(error->GetErrCode());
507  }
508 
509  m_Filter->Clear();
510  m_Filter->AppendString(wxT("ALL"));
511  ITERATE(set<string>, it, err_codes)
512  {
513  m_Filter->AppendString(ToWxString(*it));
514  }
515  m_Filter->SetSelection(0);
516  x_DisplayList();
517 }
518 
520 {
521  m_visible.clear();
522 
523  if (!m_errs) {
524  CRef<CErrorData> data(new CErrorData());
525  m_ErrorListCtrl->SetData(data);
526  return;
527  }
528 
529  CSeq_entry_Handle seh;
531  m_Scope->GetAllTSEs(tses, CScope::eAllTSEs);
532  if (!tses.empty())
533  seh = tses.front();
534 
535 
536  CRef<CErrorData> data(new CErrorData());
537  auto& tbl_data = data->SetData();
538  map<EDiagSev, size_t> err_counts;
539 
540  for (size_t row = 0; row < m_errs->GetData().size(); ++row) {
542  if (!error)
543  continue;
544 
545  if (!x_MatchFilter(*error))
546  continue;
547 
548  err_counts[error->GetSeverity()]++;
549  if (!x_MatchSeverity(*error))
550  continue;
551 
552  string severity = CValidErrItem::ConvertSeverity(error->GetSeverity());
553  if (error->GetSeverity() == eDiag_Critical)
554  severity = "Reject"; // per GB-6508
555 
556  string accession = error->CanGetAccnver() ? error->GetAccnver() : kEmptyStr;
557  string title = (error->CanGetErrorGroup() ? error->GetErrorGroup() + " " : kEmptyStr) + (error->CanGetErrorName() ? error->GetErrorName() : kEmptyStr);
558  string msg = error->CanGetMsg() ? error->GetMsg() + "; " : kEmptyStr;
559  msg += error->CanGetObjDesc() ? error->GetObjDesc() : kEmptyStr;
560 
561  tbl_data.emplace_back(severity, accession, title, msg);
562  size_t item_index = tbl_data.size() - 1;
563 
564  const CSerialObject& obj = error->GetObject();
565  unsigned int err_code = error->GetErrIndex();
566 
567  if (!RunningInsideNCBI()) {
568  if (valedit::IsEditable(err_code, obj, seh)) {
569  tbl_data[item_index].m_ImgIndex = 3;
570  }
571  if (x_IsSelectable(&obj)) {
572  tbl_data[item_index].m_Selectable = true;
573  }
574  }
575 
576  m_visible.push_back(row);
577  }
578 
579  data->Finalize();
580  m_ErrorListCtrl->SetData(data);
581 
582  string msg = "INFO: " + NStr::NumericToString(err_counts[eDiag_Info]) + " "
583  + "WARNING: " + NStr::NumericToString(err_counts[eDiag_Warning]) + " "
584  + "ERROR: " + NStr::NumericToString(err_counts[eDiag_Error]) + " "
585  + "REJECT: " + NStr::NumericToString(err_counts[eDiag_Critical]);
586 
587  m_SummaryText->SetLabel(ToWxString(msg));
588 }
589 
591 {
592  const CSeqdesc *seqdesc = dynamic_cast<const CSeqdesc *>(obj);
593  if (seqdesc)
594  return true;
595  const CSeq_feat *seqfeat = dynamic_cast<const CSeq_feat *>(obj);
596  if (seqfeat)
597  return true;
598  const CGapEdit *gap = dynamic_cast<const CGapEdit *>(obj);
599  if (gap)
600  return true;
601  const CPrimaryEdit *primary = dynamic_cast<const CPrimaryEdit *>(obj);
602  if (primary)
603  return true;
604  const CSeqdescTitleEdit *defline = dynamic_cast<const CSeqdescTitleEdit *>(obj);
605  if (defline)
606  return true;
607  return false;
608 }
609 
610 void CValidatePanel::OnValidatorSeveritySelected( wxCommandEvent& event )
611 {
612  x_DisplayList();
613 }
614 
615 void CValidatePanel::OnErrcodeChoiceSelected( wxCommandEvent& event )
616 {
617  x_DisplayList();
618 }
619 
621 {
622  if (!id)
623  return nullptr;
624 
626 
627  CRef<CGBWorkspace> ws = prjSrv->GetGBWorkspace();
628  if (!ws)
629  return nullptr;
630 
631  CGBDocument* doc = dynamic_cast<CGBDocument*>(ws->GetProjectFromScope(*m_Scope));
632  if (!doc)
633  return nullptr;
634 
635  CIRef<IProjectView> prj_view;
636  const vector< CIRef<IProjectView> >& views = doc->GetViews();
637 
638  for (const auto & view : views)
639  {
640  if (view->GetLabel(IProjectView::eType) == "Graphical Sequence View")
641  {
642  prj_view = view;
643  break;
644  }
645  }
646  if (!prj_view)
647  return nullptr;
648 
650  prj_view->GetMainObject(objects);
651  CConstRef<CSeq_id> other_id(dynamic_cast<const CSeq_id*>(objects.front().object.GetPointer()));
652  if (!other_id || !sequence::IsSameBioseq(*id, *other_id, m_Scope))
653  {
654  SConstScopedObject obj(ConstRef(id.GetPointer()), m_Scope);
655  prj_view->SetOrigObject(obj);
656  }
657  return prj_view.GetPointer();
658 }
659 
660 void CValidatePanel::OnListItemSelected(wxListEvent& event)
661 {
662  long item = event.GetIndex();
663  if (item >= m_visible.size() || !m_errs)
664  return;
665 
666  long index = m_ErrorListCtrl->GetActualIndex(item);
667 
669  const CSerialObject& obj = error->GetObject();
670 
671  wxPoint p = m_ErrorListCtrl->ScreenToClient(wxGetMousePosition());
672  if (p.x < m_ErrorListCtrl->GetColumnWidth(0) && !RunningInsideNCBI()) {
673 
674  CSeq_entry_Handle seh;
676  m_Scope->GetAllTSEs(tses, CScope::eAllTSEs);
677  if (!tses.empty())
678  seh = tses.front();
679  unsigned int err_code = error->GetErrIndex();
680  if (valedit::IsEditable(err_code, obj, seh)) {
681  OnListItemActivated(event);
682  return;
683  }
684  }
685 
686  string accession = error->GetAccession();
687  CBioseq_Handle bsh;
688  CRef<CSeq_id> id;
689  try
690  {
691  id.Reset(new CSeq_id(accession, CSeq_id::fParse_Default));
692  bsh = m_Scope->GetBioseqHandle(*id);
693  }
694  catch (const CException&) {}
695 
696  if (m_FlatFileCtrl && bsh) {
697  try {
698  m_FlatFileCtrl->SetPosition(bsh, &obj);
699  }
700  catch (const CException&) {}
701  }
702 
704  if (gs_view)
705  {
706  CGraphicPanel* panel = dynamic_cast<CGraphicPanel*>(gs_view->GetWindow());
707  if (panel)
708  {
709  CSeqGraphicWidget* widget = panel->GetWidget();
710  if (widget && bsh && bsh == widget->GetCurrentBioseq())
711  {
712  const CSeq_feat* feat = dynamic_cast<const CSeq_feat*>(&obj);
713  if (feat && feat->IsSetLocation())
715  }
716  }
717  }
718 
720  {
721  TConstScopedObjects objs;
722  objs.push_back(SConstScopedObject(&obj, m_Scope));
724  }
725 }
726 
727 
728 void CValidatePanel::OnListItemActivated(wxListEvent& event)
729 {
730  long item = event.GetIndex();
731  if (item >= m_visible.size() || !m_errs)
732  return;
733 
734  long index = m_ErrorListCtrl->GetActualIndex(item);
737 }
738 
740 {
741  const CSerialObject& obj = error->GetObject();
742  unsigned int err_code = error->GetErrIndex();
743 
744  const CBioseq *bioseq = dynamic_cast<const CBioseq *>(&obj);
745  const CBioseq_set* bioseq_set = dynamic_cast<const CBioseq_set *>(&obj);
746  const CSeq_feat* f = dynamic_cast<const CSeq_feat *>(&obj);
747  const CSeqdesc* d = dynamic_cast<const CSeqdesc *>(&obj);
748  const CSeq_align *align = dynamic_cast<const CSeq_align *>(&obj);
749 
750  CSeq_entry_Handle seh;
751 
752  if (bioseq) {
753  CBioseq_Handle bsh = m_Scope->GetBioseqHandle(*bioseq);
754  seh = bsh.GetParentEntry();
755  }
756  if (bioseq_set) {
757  CBioseq_set_Handle bsh = m_Scope->GetBioseq_setHandle(*bioseq_set);
758  seh = bsh.GetParentEntry();
759  }
760  if (f && f->IsSetLocation())
761  {
762  CBioseq_Handle bsh = m_Scope->GetBioseqHandle(f->GetLocation());
763  if (bsh)
764  seh = bsh.GetSeq_entry_Handle();
765  }
766  if (d) {
768  }
769  if (align) {
770  auto num_rows = align->CheckNumRows();
771  for (auto row = 0; row < num_rows; row++)
772  {
773  const CSeq_id& id = align->GetSeq_id(row);
774  CBioseq_Handle bsh = m_Scope->GetBioseqHandle(id);
775  if (bsh)
776  {
777  seh = bsh.GetTopLevelEntry();
778  if (seh)
779  break;
780  }
781  }
782  }
783 
784  if (!seh)
785  {
787  m_Scope->GetAllTSEs(tses, CScope::eAllTSEs);
788  if (!tses.empty())
789  seh = tses.front();
790  }
791 
792  if (seh) {
793  valedit::LaunchEditor(err_code, obj, seh, m_Workbench);
794  }
795 }
796 
797 void CValidatePanel::OnListItemRightClick(wxListEvent& event)
798 {
799  if (!RunningInsideNCBI())
800  return;
801 
802  long item = event.GetIndex();
803  if (item >= m_visible.size() || !m_errs)
804  return;
805 
806  long index = m_ErrorListCtrl->GetActualIndex(item);
807 
808  CSeq_entry_Handle seh;
810  CValidErrItem::TErrIndex err_index = error->GetErrIndex();
811 
812  string description = error->GetErrCode();
813 
815  m_Scope->GetAllTSEs(tses, CScope::eAllTSEs);
816 
817  if (!tses.empty())
818  seh = tses.front();
819 
820  if (!seh)
821  return;
822 
823  wxString msg;
824  msg << "Suppress " << description << "?";
825  int answer = wxMessageBox(msg, wxT("Supress validator test"), wxYES_NO | wxICON_QUESTION, this);
826  if (answer != wxYES)
827  return;
828 
829 
831  CRef<CSeqdesc> suppress(new CSeqdesc());
832  for (CSeqdesc_CI desc_it(seh, CSeqdesc::e_User); desc_it; ++desc_it)
833  {
834  if (desc_it->GetUser().GetObjectType() == CUser_object::eObjectType_ValidationSuppression)
835  {
836  suppress->Assign(*desc_it);
837  validator::CValidErrorFormat::AddSuppression(suppress->SetUser(), err_index);
838  cmd.Reset(new CCmdChangeSeqdesc(seh, *desc_it, *suppress));
839  break;
840  }
841  }
842 
843  if (!cmd)
844  {
846  validator::CValidErrorFormat::AddSuppression(suppress->SetUser(), err_index);
847  cmd.Reset(new CCmdCreateDesc(seh, *suppress));
848  }
849 
850 
852  if (!srv)
853  return;
854 
855  CRef<CGBWorkspace> ws = srv->GetGBWorkspace();
856  if (!ws)
857  return;
858 
859  CGBDocument* doc = dynamic_cast<CGBDocument*>(ws->GetProjectFromScope(*m_Scope));
860  if (!doc)
861  return;
862  ICommandProccessor* cmdProcessor = &doc->GetUndoManager();
863  cmdProcessor->Execute(cmd);
864 }
865 
867 {
868  if (m_visible.empty() || !m_errs)
869  return;
870 
871  for ( long item = 0; item < m_ErrorListCtrl->GetItemCount(); ++item) {
872  long index = m_ErrorListCtrl->GetActualIndex(item);
874  if (error) {
875  string accession = error->GetAccession();
876 
877  CSeq_id acc_id(accession, CSeq_id::fParse_Default);
878 
879  CBioseq_Handle bsh;
880  try {
881  bsh = m_Scope->GetBioseqHandle(acc_id);
882  }
883  catch (const CException&) {}
884  catch (const exception&) {}
885 
886  if (bsh) {
887  selected.insert(bsh);
888  }
889  }
890  }
891 }
892 
894 {
895  if (m_objects.empty()) return;
897  const CSeq_submit* sub = dynamic_cast<const CSeq_submit*>((*it).object.GetPointer());
898  if (sub) {
899  seq_submit.Reset(sub);
900  }
901  if (!top_seq_entry) {
902  CSeq_entry_Handle seh;
903  try
904  {
906  } catch(exception &) {}
907  if (seh) {
908  top_seq_entry = seh;
909  if (seq_submit) {
910  break;
911  }
912  }
913  }
914  }
915 }
916 
917 string CValidatePanel::GetItemText(long item) const
918 {
919  return m_ErrorListCtrl->GetItemText(item);
920 }
921 
923 {
924  if (!evt)
925  return;
926  CProjectViewEvent *prj_evt = dynamic_cast<CProjectViewEvent*>(evt);
927  if (!prj_evt)
928  return;
929 
930  switch (prj_evt->GetSubtype())
931  {
933  m_Modified->SetLabel(_("Data has been modified, please refresh"));
934  Refresh();
935  break;
937  //LoadData();
938  m_Modified->SetLabel(_("Current project has been removed."));
939  Refresh();
940  break;
941  default:
942  break;
943  }
944 }
945 
946 void CValidatePanel::OnMouseMove( wxMouseEvent &event )
947 {
948  wxPoint p = event.GetPosition();
949  if (m_ErrorListCtrl->GetItemCount() < 1)
950  {
951  event.Skip();
952  return;
953  }
954 
955  wxRect rect0;
956  m_ErrorListCtrl->GetItemRect(0, rect0);
957  long item = p.y / rect0.GetHeight();
958 #if defined(__WXMSW__)
959  item--;
960 #endif
961  item += m_ErrorListCtrl->GetTopItem();
962 
963  if (item < 0 || item >= m_ErrorListCtrl->GetItemCount())
964  {
965  SetCursor(wxCursor(wxNullCursor));
966  wxSetCursor(wxNullCursor);
967  event.Skip();
968  return;
969  }
970  long index = m_ErrorListCtrl->GetActualIndex(item);
971 
972 
973  if (index >= m_visible.size() || !m_errs)
974  {
975  SetCursor(wxCursor(wxNullCursor));
976  wxSetCursor(wxNullCursor);
977  event.Skip();
978  return;
979  }
980 
982  const CSerialObject& obj = error->GetObject();
983 
984  bool hand_cursor = false;
985  if (!RunningInsideNCBI())
986  {
987  if (p.x < m_ErrorListCtrl->GetColumnWidth(0))
988  {
989  CSeq_entry_Handle seh;
991  m_Scope->GetAllTSEs(tses, CScope::eAllTSEs);
992  if (!tses.empty())
993  seh = tses.front();
994  unsigned int err_code = error->GetErrIndex();
995  if (valedit::IsEditable(err_code, obj, seh))
996  {
997  hand_cursor = true;
998  }
999  }
1000  else if ( x_IsSelectable(&obj) )
1001  {
1002  hand_cursor = true;
1003  }
1004  }
1005  if (hand_cursor)
1006  {
1007  SetCursor(wxCursor(wxCURSOR_HAND));
1008  wxSetCursor(wxCursor(wxCURSOR_HAND));
1009  }
1010  else
1011  {
1012  SetCursor(wxCursor(wxNullCursor));
1013  wxSetCursor(wxNullCursor);
1014  }
1015 
1016  event.Skip();
1017 }
1018 
1020 {
1021  m_objects.clear();
1023  {
1024  CConstRef<CSeq_submit> submit;
1025  CRef<CScope> scope(m_ProjectHandle->GetScope());
1026 
1027  if (m_ProjectItem->IsSetItem() && m_ProjectItem->GetItem().IsSubmit())
1028  submit.Reset(&m_ProjectItem->GetItem().GetSubmit());
1029 
1030 
1031  if (submit)
1032  {
1033  if (submit->IsSetData() && submit->GetData().IsEntrys())
1034  {
1035  for (auto entry : submit->GetData().GetEntrys())
1036  {
1037  if (entry)
1038  {
1039  m_objects.push_back(SConstScopedObject(entry, scope));
1040  }
1041  }
1042  }
1043  m_objects.push_back(SConstScopedObject(submit, scope));
1044  }
1045  else if (m_ProjectItem->IsSetItem() && m_ProjectItem->GetItem().IsEntry())
1046  {
1047  m_objects.push_back(SConstScopedObject(&m_ProjectItem->GetItem().GetEntry(), scope));
1048  }
1049  }
1050  else
1051  {
1053  if (!sel_srv)
1054  return;
1055  sel_srv->GetActiveObjects(m_objects);
1056  if (m_objects.empty())
1057  {
1059  }
1060  }
1061 }
1062 
1064 
CSeq_entry_Handle GetSeqEntryForSeqdesc(CRef< CScope > scope, const CSeqdesc &seq_desc)
IAppJobListener Interface for components that need to be notified about changes in Jobs.
CBioseq_Handle –.
CBioseq_set_Handle –.
TErrorData & SetData()
string GetItemText(long item) const
void SetData(CRef< CErrorData > error_data)
long GetActualIndex(long item) const
CEventHandler.
CEvent - generic event implementation TODO TODO - Attachments.
Definition: event.hpp:86
CGBDocument.
Definition: document.hpp:113
wxString GetWorkDir() const
Definition: document.cpp:1364
virtual const TViews & GetViews(void) const
Retrieve the existing views for this class.
Definition: document.cpp:388
CUndoManager & GetUndoManager()
Definition: document.hpp:158
CSeqGraphicWidget * GetWidget()
CObjectFor –.
Definition: ncbiobj.hpp:2335
CObject –.
Definition: ncbiobj.hpp:180
CProjectService - a service providing API for operations with Workspaces and Projects.
CProjectViewEvent.
Definition: document.hpp:62
EEventSubtype GetSubtype() const
Definition: document.hpp:96
void SetSelectedObjects(TConstScopedObjects &objs)
void ZoomOnRange(TSeqRange range, TZoomFlag flag)
virtual objects::CBioseq_Handle GetCurrentBioseq() override
TDim CheckNumRows(void) const
Validatiors.
Definition: Seq_align.cpp:73
const CSeq_id & GetSeq_id(TDim row) const
Get seq-id (the first one if segments have different ids).
Definition: Seq_align.cpp:317
CSeq_entry_Handle –.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
CSeqdesc_CI –.
Definition: seqdesc_ci.hpp:65
Base class for all serializable objects.
Definition: serialbase.hpp:150
void SetObjectType(EObjectType obj_type)
@ eObjectType_ValidationSuppression
EDiagSev GetSeverity(void) const
static const string ConvertSeverity(EDiagSev sev)
const string GetErrCode(void) const
static bool ShowToolTips()
Should we show tooltips?
void OnErrcodeChoiceSelected(wxCommandEvent &event)
CRef< CJobAdapter > m_JobAdapter
CRef< CObjectFor< objects::CValidError::TErrs > > m_errs
IWorkbench * m_Workbench
objects::CGBProjectHandle * m_ProjectHandle
void OnChildFocus(wxChildFocusEvent &evt)
objects::CProjectItem * m_ProjectItem
string GetItemText(long item) const
void OnListItemActivated(wxListEvent &event)
bool x_IsSelectable(const CSerialObject *obj)
void Init()
Initialises member variables.
void x_LaunchEditor(CRef< objects::CValidErrItem > error)
void OnListItemRightClick(wxListEvent &event)
void OnListItemSelected(wxListEvent &event)
void x_DisplayList(void)
void OnValidatorSeveritySelected(wxCommandEvent &event)
CErrorListCtrl * m_ErrorListCtrl
IProjectView * x_FindGraphicalSequenceView(CRef< objects::CSeq_id > id)
CIRef< IFlatFileCtrl > m_FlatFileCtrl
void LoadData(void)
CRef< objects::CUser_object > m_params
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void CreateControls()
Creates the controls and sizers.
void GetSelected(set< objects::CBioseq_Handle > &selected)
wxChoice * m_Filter
void x_GetObjectsFromProjectItem()
TConstScopedObjects m_objects
virtual ~CValidatePanel()
Destructor.
void x_ConnectListener(void)
vector< size_t > m_visible
void GetTopSeqAndSeqSubmit(objects::CSeq_entry_Handle &top_seq_entry, CConstRef< objects::CSeq_submit > &seq_submit)
wxChoice * m_Severity
virtual void OnJobResult(CObject *result, CJobAdapter &adapter)
void x_DisconnectListener(void)
CRef< objects::CScope > m_Scope
void OnMouseMove(wxMouseEvent &event)
wxStaticText * m_SummaryText
void x_UpdateList(const string &statusText)
bool m_SelectionClientAttached
bool Create(wxWindow *parent, wxWindowID id=17001, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxSUNKEN_BORDER|wxTAB_TRAVERSAL)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
bool x_MatchFilter(const objects::CValidErrItem &valitem) const
CRef< CSelectionClient > m_SelectionClient
virtual void OnJobFailed(const string &, CJobAdapter &adapter)
bool x_MatchSeverity(const objects::CValidErrItem &valitem) const
void x_OnDataChanged(CEvent *evt)
wxStaticText * m_Modified
CValidatePanel()
Constructors.
Undo/Redo interface for editing operations.
virtual void Execute(IEditCommand *command, wxWindow *window=0)=0
class IProjectView defines the abstract interface for views observing projects.
virtual wxWindow * GetWindow()=0
returns a pointer to the wxWindow representing the client
IWorkbench is the central interface in the application framework.
Definition: workbench.hpp:113
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
bool IsEditable(int err_code, const CSerialObject &obj, objects::CSeq_entry_Handle seh)
void LaunchEditor(int err_code, const CSerialObject &obj, objects::CSeq_entry_Handle seh, IWorkbench *wb)
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
IMPLEMENT_CLASS(CFloatingFrame, CFloatingFrameBaseClass) const static long kFloatFrameStyle
CFloatingFrame.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
EDiagSev
Severity level for the posted diagnostics.
Definition: ncbidiag.hpp:650
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
@ eDiag_Info
Informational message.
Definition: ncbidiag.hpp:651
@ eDiag_Error
Error message.
Definition: ncbidiag.hpp:653
@ eDiag_Warning
Warning message.
Definition: ncbidiag.hpp:652
@ eDiag_Critical
Critical error message.
Definition: ncbidiag.hpp:654
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
CIRef< T > GetServiceByType()
retrieves a typed reference to a service, the name of C++ type is used as the name of the service.
Definition: service.hpp:91
objects::CSeq_entry_Handle GetTopSeqEntryFromScopedObject(SConstScopedObject &obj)
Definition: utils.cpp:2542
virtual void RemoveListener(CEventHandler *listener)
Remove a listener.
void Cancel()
Definition: job_adapter.cpp:48
#define ON_EVENT(type, id, handler)
#define END_EVENT_MAP()
Ends definition of Command Map.
#define BEGIN_EVENT_MAP(thisClass, baseClass)
Begins definition of Command Map for CEventHandler-derived class.
virtual void AddListener(CEventHandler *listener, int pool_name=ePool_Default)
Add a listener.
void Start(IAppJob &job)
Definition: job_adapter.cpp:42
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
@ fParse_Default
By default in ParseIDs and IsValid, allow raw parsable non-numeric accessions and plausible local acc...
Definition: Seq_id.hpp:102
TRange GetTotalRange(void) const
Definition: Seq_loc.hpp:913
bool IsSameBioseq(const CSeq_id &id1, const CSeq_id &id2, CScope *scope, CScope::EGetBioseqFlag get_flag=CScope::eGetBioseq_All)
Determines if two CSeq_ids represent the same CBioseq.
vector< CSeq_entry_Handle > TTSE_Handles
Definition: scope.hpp:634
@ eAllTSEs
Definition: scope.hpp:632
CSeq_entry_Handle GetParentEntry(void) const
Get parent Seq-entry handle.
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
CSeq_entry_Handle GetParentEntry(void) const
Return a handle for the parent seq-entry of the bioseq.
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
CConstRef< C > ConstRef(const C *object)
Template function for conversion of const object pointer to CConstRef.
Definition: ncbiobj.hpp:2024
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
T & GetData(void)
Get data as a reference.
Definition: ncbiobj.hpp:2346
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define kEmptyStr
Definition: ncbistr.hpp:123
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5352
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
bool IsSetLocation(void) const
feature made from Check if a value has been assigned to Location data member.
Definition: Seq_feat_.hpp:1105
TUser & SetUser(void)
Select the variant.
Definition: Seqdesc_.cpp:390
@ e_User
user defined object
Definition: Seqdesc_.hpp:124
bool IsSetData(void) const
Check if a value has been assigned to Data data member.
const TEntrys & GetEntrys(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
bool IsEntrys(void) const
Check if variant Entrys is selected.
unsigned int TErrIndex
END_EVENT_TABLE()
void GetViewObjects(IWorkbench *workbench, TConstScopedObjects &objects)
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
static static static wxID_ANY
#define _ASSERT
else result
Definition: token2.c:20
USING_SCOPE(objects)
#define ID_VALIDATE_FRAME_ERRCODE
#define ID_VALIDATE_FRAME_SEVERITY
#define ID_VALIDATE_FRAME_TEXTCTRL
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
bool RunningInsideNCBI()
Definition: wx_utils.cpp:1335
Modified on Wed Nov 29 02:18:42 2023 by modify_doxy.py rev. 669887