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

Go to the SVN repository for this file.

1 /* $Id: attrib_table_column_id_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: Bob Falk
27  */
28 
29 
30 #include <ncbi_pch.hpp>
35 
48 #include <gui/utils/app_popup.hpp>
51 
61 
62 #include <wx/dialog.h>
63 #include <wx/imaglist.h>
64 #include <wx/richtext/richtextctrl.h>
65 
66 
68 
69 /*!
70  * CAttribTableColumnIdPanel type definition
71  */
72 
73 IMPLEMENT_DYNAMIC_CLASS( CAttribTableColumnIdPanel, wxPanel )
74 
75 
76 /*!
77  * CAttribTableColumnIdPanel event table definition
78  */
79 
80 BEGIN_EVENT_TABLE( CAttribTableColumnIdPanel, wxPanel )
81 
82 ////@begin CAttribTableColumnIdPanel event table entries
84 
86 
88 
90 
92 
94 
96 
98 
100 
102 
104 
106 
108 
110 
112 
114 
116 
118 
120 
122 
124 
126 
128 
130 
131  EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_UPDATE_STRUCTCOMMENT_FIELD, CAttribTableColumnIdPanel::ProcessUpdateStructCommentEvent)
132 
133  EVT_CHOICEBOOK_PAGE_CHANGED(wxID_ANY, CAttribTableColumnIdPanel::OnPageChanged)
134 
135 ////@end CAttribTableColumnIdPanel event table entries
137 
138 
140 
141 /*!
142  * CAttribTableColumnIdPanel constructors
143  */
144 
146 {
147  Init();
148 }
149 
150 CAttribTableColumnIdPanel::CAttribTableColumnIdPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
151 {
152  Init();
153  Create(parent, id, pos, size, style);
154 }
155 
156 
157 /*!
158  * CAttribTableColumnIdPanel creator
159  */
160 
161 bool CAttribTableColumnIdPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
162 {
163 ////@begin CAttribTableColumnIdPanel creation
164  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
165  wxPanel::Create( parent, id, pos, size, style );
166 
167  CreateControls();
168  if (GetSizer())
169  {
170  GetSizer()->SetSizeHints(this);
171  }
172  Centre();
173 ////@end CAttribTableColumnIdPanel creation
174  return true;
175 }
176 
177 
178 /*!
179  * CAttribTableColumnIdPanel destructor
180  */
181 
183 {
184 ////@begin CAttribTableColumnIdPanel destruction
185 ////@end CAttribTableColumnIdPanel destruction
186 }
187 
188 
189 /*!
190  * Member initialisation
191  */
192 
194 {
195 ////@begin CAttribTableColumnIdPanel member initialisation
201  m_MatchType = NULL;
202  m_Replace = NULL;
203  m_Append = NULL;
204  m_Prefix = NULL;
205  m_LeaveOld = NULL;
206  m_AddQual = NULL;
207  m_Semicolon = NULL;
208  m_Space = NULL;
209  m_Colon = NULL;
210  m_Comma = NULL;
213  m_EraseValue = NULL;
217 
218  m_Fields = NULL;
219  m_FieldsSize.Set(0,0);
220  m_CurrentColumnIdx = -1;
221  m_Constraint = NULL;
222 ////@end CAttribTableColumnIdPanel member initialisation
223 }
224 
225 
226 /*!
227  * Control creation for CAttribTableColumnIdPanel
228  */
229 
231 {
232  ////@begin CAttribTableColumnIdPanel content construction
233  CAttribTableColumnIdPanel* itemPanel1 = this;
234 
235  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
236  itemPanel1->SetSizer(itemBoxSizer2);
237 
238  wxStaticText* itemStaticText3 = new wxStaticText(itemPanel1, wxID_STATIC, _("Set or Verify Type Information for each Table Column"), wxDefaultPosition, wxDefaultSize, 0);
239  itemStaticText3->SetFont(wxFont(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("Tahoma")));
240  itemBoxSizer2->Add(itemStaticText3, 0, wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT | wxTOP, 5);
241 
242  m_ColumnPropertiesSizer = new wxStaticBox(itemPanel1, wxID_ANY, _("Column Properties"));
243  wxStaticBoxSizer* itemStaticBoxSizer5 = new wxStaticBoxSizer(m_ColumnPropertiesSizer, wxVERTICAL);
244  itemBoxSizer2->Add(itemStaticBoxSizer5, 1, wxEXPAND | wxLEFT |wxRIGHT |wxBOTTOM, 5);
245 
246  wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxHORIZONTAL);
247  itemStaticBoxSizer5->Add(itemBoxSizer7, 0, wxEXPAND | wxALL, 0);
248 
249  m_ColumnNameStaticTxt = new wxStaticText(itemStaticBoxSizer5->GetStaticBox(), wxID_STATIC, _("Name:"), wxDefaultPosition, wxDefaultSize, 0);
250  m_ColumnNameStaticTxt->Enable(false);
251  itemBoxSizer7->Add(m_ColumnNameStaticTxt, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
252 
253  m_ColumnNameTxtCtrl = new wxTextCtrl(itemStaticBoxSizer5->GetStaticBox(), ID_COLUMNNAMETXT, wxEmptyString, wxDefaultPosition, wxSize(200, -1), 0);
254  m_ColumnNameTxtCtrl->Enable(false);
255  itemBoxSizer7->Add(m_ColumnNameTxtCtrl, 1, wxALIGN_CENTER_VERTICAL| wxALL, 5);
256 
257  m_SkipFormatBtn = new wxCheckBox(itemStaticBoxSizer5->GetStaticBox(), ID_SKIPBTN, _("Skip Column"), wxDefaultPosition, wxDefaultSize, 0);
258  m_SkipFormatBtn->SetValue(false);
259  m_SkipFormatBtn->Enable(false);
260  itemBoxSizer7->Add(m_SkipFormatBtn, 0, wxALIGN_CENTER_VERTICAL| wxALL, 5);
261 
262  m_MatchColumn = new wxCheckBox(itemStaticBoxSizer5->GetStaticBox(), ID_MATCH_COLUMN, _("Match Column"), wxDefaultPosition, wxDefaultSize, 0);
263  m_MatchColumn->Enable(false);
264  itemBoxSizer7->Add(m_MatchColumn, 0, wxALIGN_CENTER_VERTICAL | wxTOP|wxBOTTOM|wxRIGHT, 5);
265 
266  wxArrayString m_MatchTypeStrings;
267  m_MatchTypeStrings.Add(_("&SeqID"));
268  m_MatchTypeStrings.Add(_("&Taxname"));
269  m_MatchTypeStrings.Add(_("&Other"));
270  m_MatchType = new wxRadioBox(itemStaticBoxSizer5->GetStaticBox(), ID_MATCHTYPE, wxEmptyString, wxDefaultPosition, wxDefaultSize, m_MatchTypeStrings, 1, wxRA_SPECIFY_ROWS);
271  m_MatchType->SetSelection(0);
272  itemBoxSizer7->Add(m_MatchType, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
273 
274  wxStaticBox* qual_box = new wxStaticBox(itemStaticBoxSizer5->GetStaticBox(), wxID_ANY, wxEmptyString);
275  wxStaticBoxSizer* itemStaticBoxSizer14 = new wxStaticBoxSizer(qual_box, wxHORIZONTAL);
276  itemStaticBoxSizer5->Add(itemStaticBoxSizer14, 1, wxEXPAND | wxLEFT|wxRIGHT|wxBOTTOM, 5);
277 
278  vector<CFieldNamePanel::EFieldType> field_types;
279  field_types.push_back(CFieldNamePanel::eFieldType_Taxname);
280  field_types.push_back(CFieldNamePanel::eFieldType_Source);
281  field_types.push_back(CFieldNamePanel::eFieldType_Feature);
282  field_types.push_back(CFieldNamePanel::eFieldType_CDSGeneProt);
283  field_types.push_back(CFieldNamePanel::eFieldType_RNA);
284  field_types.push_back(CFieldNamePanel::eFieldType_MolInfo);
285  field_types.push_back(CFieldNamePanel::eFieldType_Misc);
286  field_types.push_back(CFieldNamePanel::eFieldType_Pub);
287  field_types.push_back(CFieldNamePanel::eFieldType_StructuredComment);
288  field_types.push_back(CFieldNamePanel::eFieldType_DBLink);
289 
290  m_Fields = new CFieldChoicePanel(itemStaticBoxSizer14->GetStaticBox(), field_types, false, false, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
291  itemStaticBoxSizer14->Add(m_Fields, 0, wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxTOP, 2);
292  m_Fields->SetShowLegalOnly(true);
293 
294  wxBoxSizer* itemBoxSizerRules = new wxBoxSizer(wxVERTICAL);
295  itemStaticBoxSizer14->Add(itemBoxSizerRules, 0, wxALIGN_LEFT | wxALL, 0);
296 
297  wxStaticBox* itemStaticBoxSizer17Static = new wxStaticBox(itemStaticBoxSizer14->GetStaticBox(), wxID_ANY, _("Text Update Rules"));
298  wxStaticBoxSizer* itemStaticBoxSizer17 = new wxStaticBoxSizer(itemStaticBoxSizer17Static, wxVERTICAL);
299  itemBoxSizerRules->Add(itemStaticBoxSizer17, 1, wxEXPAND | wxTOP| wxRIGHT, 2);
300 
301  wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL);
302  itemStaticBoxSizer17->Add(itemBoxSizer20, 0, wxALIGN_LEFT | wxALL, 0);
303 
304  m_Replace = new wxRadioButton(itemStaticBoxSizer17->GetStaticBox(), ID_REPLACE_BTN, _("Replace"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
305  m_Replace->SetValue(true);
306  itemBoxSizer20->Add(m_Replace, 0, wxALIGN_LEFT | wxALL, 2);
307 
308  m_Append = new wxRadioButton(itemStaticBoxSizer17->GetStaticBox(), ID_APPEND_BTN, _("Append"), wxDefaultPosition, wxDefaultSize, 0);
309  m_Append->SetValue(false);
310  itemBoxSizer20->Add(m_Append, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
311 
312  m_Prefix = new wxRadioButton(itemStaticBoxSizer17->GetStaticBox(), ID_PREFIX_BTN, _("Prefix"), wxDefaultPosition, wxDefaultSize, 0);
313  m_Prefix->SetValue(false);
314  itemBoxSizer20->Add(m_Prefix, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
315 
316  wxBoxSizer* itemBoxSizer21 = new wxBoxSizer(wxHORIZONTAL);
317  itemStaticBoxSizer17->Add(itemBoxSizer21, 0, wxALIGN_LEFT | wxALL, 0);
318 
319  m_LeaveOld = new wxRadioButton(itemStaticBoxSizer17->GetStaticBox(), ID_IGNORE_BTN, _("Ignore new text"), wxDefaultPosition, wxDefaultSize, 0);
320  m_LeaveOld->SetValue(false);
321  itemBoxSizer21->Add(m_LeaveOld, 0, wxALIGN_LEFT | wxLEFT | wxALL, 2);
322 
323  m_AddQual = new wxRadioButton(itemStaticBoxSizer17->GetStaticBox(), ID_ADD_QUAL_BTN, _("Add new qual"), wxDefaultPosition, wxDefaultSize, 0);
324  m_AddQual->SetValue(false);
325  itemBoxSizer21->Add(m_AddQual, 0, wxALIGN_LEFT | wxLEFT | wxALL, 2);
326 
327  wxStaticBox* itemStaticBoxSizer18Static = new wxStaticBox(itemStaticBoxSizer14->GetStaticBox(), wxID_ANY, _("Separate New and Old Text with"));
328  wxStaticBoxSizer* itemStaticBoxSizer18 = new wxStaticBoxSizer(itemStaticBoxSizer18Static, wxVERTICAL);
329  itemBoxSizerRules->Add(itemStaticBoxSizer18, 1, wxEXPAND | wxTOP | wxRIGHT, 2);
330 
331  wxBoxSizer* itemBoxSizer27 = new wxBoxSizer(wxHORIZONTAL);
332  itemStaticBoxSizer18->Add(itemBoxSizer27, 0, wxALIGN_LEFT|wxALL, 0);
333 
334  m_Semicolon = new wxRadioButton( itemStaticBoxSizer18->GetStaticBox(), ID_SEMICOLON_BTN, _("Semicolon"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
335  m_Semicolon->SetValue(true);
336  itemBoxSizer27->Add(m_Semicolon, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
337 
338  m_Space = new wxRadioButton( itemStaticBoxSizer18->GetStaticBox(), ID_SPACE_BTN, _("Space"), wxDefaultPosition, wxDefaultSize, 0 );
339  m_Space->SetValue(false);
340  itemBoxSizer27->Add(m_Space, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
341 
342  m_Colon = new wxRadioButton( itemStaticBoxSizer18->GetStaticBox(), ID_COLON_BTN, _("Colon"), wxDefaultPosition, wxDefaultSize, 0 );
343  m_Colon->SetValue(false);
344  itemBoxSizer27->Add(m_Colon, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
345 
346  m_Comma = new wxRadioButton( itemStaticBoxSizer18->GetStaticBox(), ID_COMMA_BTN, _("Comma"), wxDefaultPosition, wxDefaultSize, 0 );
347  m_Comma->SetValue(false);
348  itemBoxSizer27->Add(m_Comma, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
349 
350  m_NoDelimiter = new wxRadioButton( itemStaticBoxSizer18->GetStaticBox(), ID_NODELIMITER_BTN, _("Do not separate"), wxDefaultPosition, wxDefaultSize, 0 );
351  m_NoDelimiter->SetValue(false);
352  itemStaticBoxSizer18->Add(m_NoDelimiter, 0, wxALIGN_LEFT|wxALL, 2);
353 
354  wxStaticBox* itemStaticBoxSizer19Static = new wxStaticBox(itemStaticBoxSizer14->GetStaticBox(), wxID_ANY, _("Treat Blanks in Column"));
355  wxStaticBoxSizer* itemStaticBoxSizer19 = new wxStaticBoxSizer(itemStaticBoxSizer19Static, wxVERTICAL);
356  itemBoxSizerRules->Add(itemStaticBoxSizer19, 1, wxEXPAND | wxTOP | wxRIGHT|wxBOTTOM, 2);
357 
358  m_IgnoreBlanks = new wxRadioButton( itemStaticBoxSizer19->GetStaticBox(), ID_IGNORE_BLANKS_BTN, _("Ignore Blanks"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
359  m_IgnoreBlanks->SetValue(true);
360  itemStaticBoxSizer19->Add(m_IgnoreBlanks, 0, wxALIGN_LEFT|wxALL, 2);
361 
362  m_EraseValue = new wxRadioButton( itemStaticBoxSizer19->GetStaticBox(), ID_ERASE_EXISTING_VALUE_BTN, _("Erase Existing Value in Record"), wxDefaultPosition, wxDefaultSize, 0 );
363  m_EraseValue->SetValue(false);
364  itemStaticBoxSizer19->Add(m_EraseValue, 0, wxALIGN_LEFT|wxALL, 2);
365 
366  wxStaticBox* itemStaticBoxSizer38Static = new wxStaticBox(itemPanel1, wxID_ANY, _("Click on Table Columns to Set Properties"));
367  wxStaticBoxSizer* itemStaticBoxSizer38 = new wxStaticBoxSizer(itemStaticBoxSizer38Static, wxHORIZONTAL);
368  itemBoxSizer2->Add(itemStaticBoxSizer38, 1, wxGROW|wxLEFT|wxRIGHT, 5);
369 
370  m_ColumnIdList = new CTableImportListCtrl(itemStaticBoxSizer38->GetStaticBox(), ID_CTABLEIMPORTLISTCTRL3, wxDefaultPosition, wxSize(-1, 300), wxLC_REPORT|wxLC_VIRTUAL|wxLC_ALIGN_LEFT|wxLC_HRULES|wxLC_VRULES );
371  itemStaticBoxSizer38->Add(m_ColumnIdList, 1, wxGROW|wxALL, 5);
372 
373  bool load_macro_fields = true;
374  m_Constraint = new CConstraintPanel( itemPanel1, m_TopSeqEntry, nullptr, load_macro_fields);
375  itemBoxSizer2->Add(m_Constraint, 0, wxEXPAND|wxALL, 5);
376 
377  wxBoxSizer* itemBoxSizer42 = new wxBoxSizer(wxHORIZONTAL);
378  itemBoxSizer2->Add(itemBoxSizer42, 0, wxALIGN_LEFT|wxALL, 0);
379 
380  wxButton* itemButton43 = new wxButton( itemPanel1, ID_SPLIT_FIRST_COL, _("Split First Col."), wxDefaultPosition, wxDefaultSize, 0 );
381  itemBoxSizer42->Add(itemButton43, 0, wxALIGN_LEFT| wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT|wxTOP, 5);
382 
383  wxButton* itemButton44 = new wxButton( itemPanel1, ID_MULTISPACE_TO_TAB_BTN, _("Multispaces to Tabs"), wxDefaultPosition, wxDefaultSize, 0 );
384  itemBoxSizer42->Add(itemButton44, 0, wxALIGN_CENTER|wxLEFT |wxRIGHT| wxTOP, 5);
385 
386  m_MergeIDCols = new wxButton( itemPanel1, ID_MERGEIDCOLS, _("Merge Cols For ID"), wxDefaultPosition, wxDefaultSize, 0 );
387  itemBoxSizer42->Add(m_MergeIDCols, 0, wxALIGN_CENTER| wxLEFT | wxRIGHT | wxTOP, 5);
388 
389  m_MakeMailReport = new wxCheckBox( itemPanel1, ID_MAIL_REPORT_CHECKBOX, _("Make Mail Report"), wxDefaultPosition, wxDefaultSize, 0 );
390  m_MakeMailReport->SetValue(false);
391  itemBoxSizer42->Add(m_MakeMailReport, 0, wxALIGN_CENTER| wxLEFT | wxRIGHT | wxTOP, 5);
392 
393  wxButton* itemButton47 = new wxButton( itemPanel1, ID_APPLY_NO_CLOSE, _("Apply (No Close)"), wxDefaultPosition, wxDefaultSize, 0 );
394  itemBoxSizer42->Add(itemButton47, 0, wxALIGN_CENTER| wxLEFT | wxRIGHT | wxTOP, 5);
395 
396 ////@end CAttribTableColumnIdPanel content construction
397 }
398 
400 {
401  wxBusyCursor wait;
402  m_TopSeqEntry = seq_entry;
403  if (m_Constraint)
405  m_id_guesser = make_shared<edit::CSeqIdGuesser>(m_TopSeqEntry);
406 }
407 
409 {
410  if (show) {
412 
413  // Get initial size of fields and when it changes, update
414  // the dialog size accordingly
415  m_FieldsSize = m_Fields->GetSize();
417  }
418 
419  return wxPanel::Show(show);
420 }
421 
423 {
424  if (!m_ImportedTableData.IsNull()) {
427 
428 
429  // Set the initial column to the first one that does not have
430  // qualifier automatched or selected yet. If all are matched,
431  // set initial focus column to the first one
432  int focus_col_idx = -1;
433 
434  // Iterate over columns and guess types/qualifiers
435  for (size_t col=1; col<m_ImportedTableData->GetColumns().size(); ++col) {
436  auto& this_column = m_ImportedTableData->GetColumn(col);
437 
438  this_column.SetIsCurrent(false);
439 
440  // Set default type for columns in qualifier table - all text except for the first one
441  // which should be an ID (but user can change)
442  if (col == 1) {
443  // If not already set:
444  bool has_match = false;
445  for (size_t mcol=1; mcol < m_ImportedTableData->GetColumns().size(); ++mcol) {
447  has_match = true;
448  break;
449  }
450  }
451 
452  if (this_column.GetQualifier().empty() && !has_match) {
453  m_PrevColName = this_column.GetName();
454 
455  this_column.SetType(CTableImportColumn::eTextColumn);
456  this_column.SetQualifierType(kFieldTypeSeqId); // this is set even when the column is not 'Seq-ID'
457  this_column.SetQualifier(kFieldTypeSeqId);
458  this_column.SetMatchColumn(true);
459  this_column.SetName("match " + kSequenceIdAbbrevColLabel);
460  this_column.SetWidth((int)this_column.GetName().length());
461 
462  if (m_PrevQual.empty()) m_PrevQual = kFieldTypeSeqId;
464  }
465  else {
466  focus_col_idx = 1;
467  }
468  }
469  else {
470  // If this is not the first time we visited the panel, column may already be skipped
471  // If so, leave it as such.
472  if (!this_column.GetSkipped()) {
473  this_column.SetType(CTableImportColumn::eTextColumn);
474  }
475 
476  // If a qualifier has not yet been selected for this column, try automatch to find
477  // one (this may not be the first time init is called, so some may already be set).
478  // If the user did not specify a header row, (no column names) we will not get any.
479  if (this_column.GetQualifier().empty()) {
480  bool matched = false;
481  string col_name = m_ImportedTableData->GetColumnName(col);
482  if (col_name != "") {
483 
484  string qual = m_Fields->AutoMatch(col_name);
485  if (!qual.empty()) {
487 
489  string ft_str = CFieldNamePanel::GetFieldTypeName(ft);
490  string qual_name = qual.substr(ft_str.length(), qual.length()-ft_str.length());
491  NStr::TruncateSpacesInPlace(qual_name);
492 
493  _ASSERT(!qual_name.empty());
494  this_column.SetQualifierType(ft_str);
495  this_column.SetQualifier(qual_name);
496  this_column.SetName(qual_name);
497  this_column.SetWidth((int)this_column.GetName().length());
498  matched = true;
499  }
500  }
501  }
502  if (this_column.GetQualifier().empty()) {
503  this_column.SetType(CTableImportColumn::eSkippedColumn);
504  }
505 
506  if (!matched && focus_col_idx==-1)
507  focus_col_idx = static_cast<int>(col);
508  }
509  }
510  }
511 
513 
514  // Should only be one selection, but loop anyway and unselect
515  // any selected row
516  long item = -1;
517  for ( ;; )
518  {
519  item = m_ColumnIdList->GetNextItem(item,
520  wxLIST_NEXT_ALL,
521  wxLIST_STATE_SELECTED);
522  if ( item == -1 )
523  break;
524 
525  // deselect
526  m_ColumnIdList->SetItemState(item, 0, wxLIST_STATE_SELECTED);
527  }
528 
529 
530  // Is there a currently selected column? If so make sure the fields
531  // for editing column info are up-to-date. (This only happens if the
532  // users was previously on this page and is returning)
533  if (m_CurrentColumnIdx >= 0 &&
535 
536  wxListEvent dummy_event;
537  dummy_event.m_col = m_CurrentColumnIdx;
538 
540  }
541  // Set the column being edited to the first one that has not been matched
542  // since that is (probably) the first one the user needs to work on
543  else {
544  wxListEvent dummy_event;
545 
546  if (focus_col_idx==-1)
547  dummy_event.m_col = 1;
548  else
549  dummy_event.m_col = focus_col_idx;
550 
552  }
553  }
554 }
555 
557 {
558  if (!m_Fields || ! m_ImportedTableData)
559  return;
560 
561  string field_name = m_Fields->GetFieldName();
562  auto& current_col = m_ImportedTableData->GetColumn(m_CurrentColumnIdx);
563  string prev_qual_name = current_col.GetQualifier();
564 
565  if (!field_name.empty() &&
566  (prev_qual_name != kSequenceIdAbbrevColLabel && prev_qual_name != kFieldTypeTaxname)) {
567 
568  string qual_type_str = m_Fields->GetFieldTypeName(m_Fields->GetFieldType());
569  _ASSERT(!field_name.empty());
570  _ASSERT(!qual_type_str.empty());
571  current_col.SetQualifier(field_name);
572  current_col.SetQualifierType(qual_type_str);
573 
574  if (!field_name.empty()) {
575  m_SkipFormatBtn->SetValue(false);
576  current_col.SetType(CTableImportColumn::eTextColumn);
577  }
578 
579  if (current_col.GetMatchColumn()) {
580  if (!field_name.empty()) {
581  field_name = "match " + field_name;
582  }
583  else {
584  field_name = "match " + current_col.GetName();
585  }
586  }
587  current_col.SetName(field_name);
588  current_col.SetWidth(static_cast<int>(field_name.length()));
589  }
590 }
591 
592 
594 {
595  // When we leave the page, check if we need to update field value of
596  // current column (we otherwise update these not when field choice updates
597  // but rather when user clicks on a new column)
598  // If its the match column we do not update it since it has already been set
599  // (and we have to keep the 'match' string in the title)
600  if (m_CurrentColumnIdx != -1 && (size_t)m_CurrentColumnIdx < m_ImportedTableData->GetColumns().size()) {
601  UpdateCol();
602  }
603 
604  size_t col;
605  for (col=1; col<m_ImportedTableData->GetColumns().size(); ++col) {
608  break;
609  }
610  }
611 
612 
613  // first column is a row number field and is not in the data
614  --col;
615 
616  if (col != m_ImportedTableData->GetColumns().size()-1 && !m_ImportedTableData->GetColumn(col + 1).GetSkipped()) {
617 
618  string msg;
619  map<string, set<CSeq_entry_Handle> > value_to_sehs;
621 
622  for (size_t row=m_ImportedTableData->GetFirstImportRow();
623  row < m_ImportedTableData->GetNumRows(); ++row) {
624 
625  // Get field from table (if this row is messed up and it doesn't have
626  // enough fields blank will be returned
627  string id_val = m_ImportedTableData->GetField(row, col);
629  string seqid_str;
630 
631  CRef<CSeq_id> guess = m_id_guesser->Guess(id_val);
632 
633  if (!guess.IsNull()) {
634  guess->GetLabel(&seqid_str, CSeq_id::eBoth);
635  }
636  else if (value_to_sehs.find(id_val) != value_to_sehs.end()) {
637  seqid_str = id_val;
638  }
639 
640 
641  if (seqid_str.empty()) {
642  // temporary fix, TODO: modify CSeqIdGuesser
643  if (NStr::StartsWith(id_val, "SUB") && id_val.find("/") != NPOS) {
644  continue;
645  }
646  else {
647  if (!msg.empty())
648  msg += "\n";
649 
650  msg += "\"" + id_val + "\" does not appear to be a valid ID";
651  continue;
652  }
653  }
654 
655 
656  // Don't try to set a field that's not there (if this row is incomplete
657  // i.e. did not have a seq-id column because of too few delims)
658  if (col < m_ImportedTableData->GetRow(row).GetNumFields()) {
659  // replace the substring in the row that currently represents the ID
660  // with the updated ID.
661  string row_text = m_ImportedTableData->GetRow(row).GetValue();
662  pair<size_t,size_t> field_pos = m_ImportedTableData->GetRow(row).GetFields()[col];
663 
664  string updated_row = row_text.substr(0, field_pos.first);
665  updated_row += seqid_str;
666  updated_row += row_text.substr(field_pos.first + field_pos.second,
667  row_text.length()-(field_pos.first + field_pos.second));
668 
669  m_ImportedTableData->GetRow(row).GetValue() = updated_row;
671  }
672  }
673 
674  if (msg != "") {
675  CLongMessageDialog dlg(this, wxString(msg + "\nDo you want to continue?"));
676  if (dlg.ShowModal() != wxYES)
677  return false;
678  }
679  }
680  else {
681  /// error not to have a match column
682  size_t match_col = -1;
683  for (match_col=1; match_col<m_ImportedTableData->GetColumns().size(); ++match_col) {
684  if (m_ImportedTableData->GetColumn(match_col).GetMatchColumn()) {
685  break;
686  }
687  }
688 
689  if (match_col == m_ImportedTableData->GetColumns().size()) {
690  NcbiMessageBox("Table must have an ID column");
691  return false;
692  }
693  else if (m_ImportedTableData->GetColumn(match_col).GetSkipped()) {
694  NcbiMessageBox("The ID column is skipped");
695  return false;
696  }
697  }
698 
699  set<string> unique_names;
700  for (col=1; col<m_ImportedTableData->GetColumns().size(); ++col) {
701  string name = m_ImportedTableData->GetColumn(col).GetQualifier();
702 
703  if (!NStr::IsBlank(name)) {
705  {
706  auto inserted_it = unique_names.insert(name);
707  if (!m_ImportedTableData->GetColumn(col).HasProperty("text_separator"))
708  m_ImportedTableData->GetColumn(col).SetProperty("text_separator", ";");
709 
710  if (!m_ImportedTableData->GetColumn(col).HasProperty("update_rule")) {
711  if (inserted_it.second) {
712  m_ImportedTableData->GetColumn(col).SetProperty("update_rule", "replace");
713  }
714  else {
715  m_ImportedTableData->GetColumn(col).SetProperty("update_rule", "add_new_qual");
716  }
717  }
718  }
719 
720  if (!m_ImportedTableData->GetColumn(col).HasProperty("blanks"))
721  m_ImportedTableData->GetColumn(col).SetProperty("blanks", "ignore");
722 
723  CMiscSeqTableColumn seq_table_col(name);
724 
725  vector<string> col_values;
726 
727  for (size_t row=m_ImportedTableData->GetFirstImportRow();
728  row < m_ImportedTableData->GetNumRows(); ++row) {
729 
730  // Get field from table (if this row is messed up and it doesn't have
731  // enough fields blank will be returned). Subtract one here
732  // since the data columns are 1 less than the GetColumns() array (because
733  // line number not in data)
734  string field_val = m_ImportedTableData->GetField(row, col-1);
735  col_values.push_back(field_val);
736  }
737 
738  vector<string> results = seq_table_col.IsValid(col_values);
739 
740  if (results.size() > 0) {
741  string msg;
742  for (size_t i=0; i<results.size(); ++i) {
743  if (results[i].length() > 0) {
744  if (msg != "")
745  msg += "\n";
746 
747  msg += results[i];
748  }
749  }
750 
751  auto res = NcbiMessageBox(msg + "\nDo you want to continue?", eDialog_YesNo, eIcon_Question, "Validation Errors");
752  if (res != eYes)
753  return false;
754  }
755  }
756  }
757 
758  return true;
759 }
760 
761 
763 {
764  m_RegPath = path;
765 }
766 
768 {
769  if ( !m_RegPath.empty() ) {
770  }
771 }
772 
773 
775 {
776  if ( !m_RegPath.empty() ) {
778  CRegistryWriteView view = gui_reg.GetWriteView(m_RegPath);
779  }
780 }
781 
783 {
784  m_SkipFormatBtn->Enable(b);
785  if (m_MatchColumn) m_MatchColumn->Enable(b);
786 
788 }
789 
791 {
792  m_ColumnNameTxtCtrl->Enable(b);
793  m_ColumnPropertiesSizer->Enable(b);
794  m_ColumnNameStaticTxt->Enable(b);
795  m_Fields->Enable(b);
796 }
797 
799 {
800  m_MatchType->Enable(match_column);
801  if (!match_column) {
802  m_Fields->Enable();
803  }
804 
805  bool allow_options = !match_column;
806 
807  m_Semicolon->Enable(allow_options);
808  m_Space->Enable(allow_options);
809  m_Comma->Enable(allow_options);
810  m_Colon->Enable(allow_options);
811  m_NoDelimiter->Enable(allow_options);
812 
813  m_IgnoreBlanks->Enable(allow_options);
814  m_EraseValue->Enable(allow_options);
815 
816  m_Replace->Enable(allow_options);
817  m_Append->Enable(allow_options);
818  m_Prefix->Enable(allow_options);
819  m_LeaveOld->Enable(allow_options);
820  m_AddQual->Enable(allow_options);
821 }
822 
824 {
825  set<string> fields;
827  UpdateStructuredCommentFields(this, fields);
828 }
829 
831 {
832  wxWindowList &slist = win->GetChildren();
833  for (wxWindowList::iterator iter = slist.begin(); iter != slist.end(); ++iter)
834  {
835  wxWindow* child = *iter;
836  CStructFieldValuePanel* fieldvalue_panel = dynamic_cast<CStructFieldValuePanel*>(child);
837  CStructCommentFieldPanel* strcomm_fields_panel = dynamic_cast<CStructCommentFieldPanel*>(child);
838  if (fieldvalue_panel || strcomm_fields_panel)
839  {
840  if (fieldvalue_panel)
841  {
842  fieldvalue_panel->ListStructCommentFields(fields);
843  }
844  else if (strcomm_fields_panel)
845  {
846  strcomm_fields_panel->CompleteStructCommentFields(fields);
847  }
848  }
849  UpdateStructuredCommentFields(child, fields);
850  }
851 }
852 
854 {
855  wxWindowList &slist = win->GetChildren();
856  for (wxWindowList::iterator iter = slist.begin(); iter != slist.end(); ++iter)
857  {
858  wxWindow* child = *iter;
859  CFeatureTypePanel* panel = dynamic_cast<CFeatureTypePanel*>(child);
860  if (panel)
861  {
863  }
864  else
865  {
867  }
868  }
869 }
870 
871 /*!
872  * Should we show tooltips?
873  */
874 
876 {
877  return true;
878 }
879 
880 /*!
881  * Get bitmap resources
882  */
883 
884 wxBitmap CAttribTableColumnIdPanel::GetBitmapResource( const wxString& name )
885 {
886  // Bitmap retrieval
887 ////@begin CAttribTableColumnIdPanel bitmap retrieval
888  wxUnusedVar(name);
889  return wxNullBitmap;
890 ////@end CAttribTableColumnIdPanel bitmap retrieval
891 }
892 
893 /*!
894  * Get icon resources
895  */
896 
897 wxIcon CAttribTableColumnIdPanel::GetIconResource( const wxString& name )
898 {
899  // Icon retrieval
900 ////@begin CAttribTableColumnIdPanel icon retrieval
901  wxUnusedVar(name);
902  return wxNullIcon;
903 ////@end CAttribTableColumnIdPanel icon retrieval
904 }
905 
906 
908 {
909  if (!m_ImportedTableData.IsNull()) {
910  int col = event.GetColumn();
911 
912  // First column is the row number column and has no attributes.
913  if (col == 0) {
914  event.Veto();
915  return;
916  }
917 
918  if ((size_t)col < m_ImportedTableData->GetColumns().size()) {
919 
920  /// if there is another current column, remove the checkmark from it:
921  if (m_CurrentColumnIdx != -1 &&
922  m_CurrentColumnIdx != col &&
923  (size_t)m_CurrentColumnIdx < m_ImportedTableData->GetColumns().size()) {
924  UpdateCol();
925 
927  }
928 
929  m_CurrentColumnIdx = col;
930 
931  m_SkipFormatBtn->SetValue(false);
932 
935 
937  m_SkipFormatBtn->SetValue(true);
938  }
939 
940  // Controls initially default to not being enabled, since no column is
941  // selected. Enable all controls for identifying column info here.
943 
944  // If blank, this just sets type to unknown
946 
949  kFieldTypeSeqId) {
950  m_MatchType->SetSelection(0);
951 
953  m_Fields->Disable();
954  }
957  m_MatchType->SetSelection(1);
958 
960  m_Fields->Disable();
961  }
962  else {
963  // m_SeqidCol->SetValue(false);
964  m_MatchType->SetSelection(2); // other, although if not the match column, this is irrelevant
965  m_Fields->Enable();
966 
967  // There is also SetFieldType, but SetFieldName only works for features if the
968  // type is also appended.
970  if (fieldname != "") {
971  m_Fields->SetFieldName(fieldtype + " " + fieldname);
972  }
973  else {
974  // Default to a source field
976  }
977  }
978  if (m_MatchColumn) {
979  m_MatchColumn->SetValue(true);
980  }
982  }
983  else {
984  if (m_MatchColumn) {
985  m_MatchColumn->SetValue(false);
986  }
988 
989  // There is also SetFieldType, but SetFieldName only works for features if the
990  // type is also appended.
992  if (fieldname != "") {
993  m_Fields->SetFieldName(fieldtype + " " + fieldname);
994  }
995  else {
996  // Default to a source field
998  }
999  }
1000 
1001  /// Update controls to represent current column choice:
1002  m_ColumnNameTxtCtrl->SetValue(
1004 
1005  // Set radio buttons for text handling:
1006  string prop = m_ImportedTableData->GetColumn(m_CurrentColumnIdx).GetProperty("text_separator");
1007  if (prop == ";")
1008  m_Semicolon->SetValue(true);
1009  else if (prop == " ")
1010  m_Space->SetValue(true);
1011  else if (prop == ",")
1012  m_Comma->SetValue(true);
1013  else if (prop == ":")
1014  m_Colon->SetValue(true);
1015  // special case - a blank value is returned if that's the value OR there is no such property
1016  else if (prop=="" && m_ImportedTableData->GetColumn(m_CurrentColumnIdx).HasProperty("text_separator"))
1017  m_NoDelimiter->SetValue(true);
1018  else
1019  m_Semicolon->SetValue(true);
1020 
1022  if (prop == "ignore")
1023  m_IgnoreBlanks->SetValue(true);
1024  else if (prop == "erase")
1025  m_EraseValue->SetValue(true);
1026  else
1027  m_IgnoreBlanks->SetValue(true);
1028 
1030  if (prop == "replace")
1031  m_Replace->SetValue(true);
1032  if (prop == "append")
1033  m_Append->SetValue(true);
1034  else if (prop == "prefix")
1035  m_Prefix->SetValue(true);
1036  else if (prop == "ignore")
1037  m_LeaveOld->SetValue(true);
1038  else if (prop=="add_new_qual")
1039  m_AddQual->SetValue(true);
1040  else
1041  m_Replace->SetValue(true);
1042 
1043  m_Fields->Refresh();
1044 
1045  /// Set column to be 'current'
1047  }
1048  }
1049 
1050 
1052  Refresh();
1053 
1054 }
1055 
1057 {
1058  wxString colname = m_ColumnNameTxtCtrl->GetValue();
1059 
1060  event.Skip();
1061 }
1062 
1063 
1065 {
1066  if (m_CurrentColumnIdx != -1 &&
1068  (size_t)m_CurrentColumnIdx < m_ImportedTableData->GetColumns().size()) {
1069 
1070  /// Set column type based on user selection
1071  if (event.IsChecked()) {
1074 
1075  // Disable column controls other than format (which allows skipped/not skipped
1076  // to be set)
1077  //x_EnableNonFormatEditControls(false);
1079  m_Fields->SetFieldName("");
1080  UpdateCol();
1081  }
1082  else {
1085 
1086  // Disable column controls other than format (which allows skipped/not skipped
1087  // to be set)
1088  //x_EnableNonFormatEditControls(true);
1089  }
1090 
1092 
1093  // Update first row which holds type information
1094  //m_ColumnIdList->RefreshItem(0);
1095  m_ColumnIdList->Refresh();
1096  }
1097 }
1098 
1100 {
1101  // Update the whole control when dragging. This is needed because there
1102  // may be header rows where distrubtion across columns is based on width
1103  // of each column (basically they are left-justified into row irrespective
1104  // of column boundaries)
1105  m_ColumnIdList->Refresh();
1106  event.Skip();
1107 }
1108 
1110 {
1112 }
1113 
1115 {
1116  UpdateCol();
1118  m_ColumnIdList->Refresh();
1120 }
1121 
1123 {
1124  wxDialog* parent = nullptr;
1125  wxWindow* w = this->GetParent();
1126 
1127  while (w != NULL) {
1128  parent = dynamic_cast<wxDialog*>(w);
1129  if (parent) {
1130  break;
1131  }
1132  else {
1133  w = w->GetParent();
1134  }
1135  }
1136  if (!parent)
1137  return;
1138 
1139  parent->Freeze();
1140  parent->Layout();
1141  parent->Refresh();
1142  parent->Thaw();
1143 }
1144 
1146 {
1147  string field_name = m_Fields->GetFieldName();
1148  event.Skip();
1149 
1150  auto& current_col = m_ImportedTableData->GetColumn(m_CurrentColumnIdx);
1151 
1152  if (event.IsChecked()) {
1154 
1155  // If any other column is marked as the match column, unset it
1156  for (size_t col = 1; col < m_ImportedTableData->GetColumns().size(); ++col) {
1158  col != (size_t)m_CurrentColumnIdx) {
1159 
1160  auto& this_column = m_ImportedTableData->GetColumn(col);
1161  this_column.SetMatchColumn(false);
1162  string name = this_column.GetName();
1163 
1164  if (this_column.GetQualifierType() == kFieldTypeSeqId ||
1165  this_column.GetQualifierType() == kFieldTypeTaxname) {
1166  // setting to seqid loses previous values. Since this unsets seqid, set them back
1167  this_column.SetName(m_PrevColName);
1168  this_column.SetWidth(static_cast<int>(m_PrevColName.length()));
1169  this_column.SetQualifierType(m_PrevQualType);
1170  this_column.SetQualifier(m_PrevQual);
1171  }
1172  else if (!NStr::Compare(name, 0, 6, "match ")) {
1173  name = name.substr(6, name.length()-6);
1174  this_column.SetName(name);
1175  this_column.SetWidth(static_cast<int>(name.length()));
1176  }
1177 
1178  // If this is not the first time we visited the panel, column may already be skipped
1179  // If so, leave it as such.
1180  if (!this_column.GetSkipped()) {
1181  this_column.SetType(CTableImportColumn::eTextColumn);
1182  }
1183 
1184  // If a qualifier has not yet been selected for this column, try automatch to find
1185  // one (this may not be the first time init is called, so some may already be set).
1186  // If the user did not specify a header row, (no column names) we will not get any.
1187  if (this_column.GetQualifier().empty()) {
1188  string col_name = m_ImportedTableData->GetColumnName(col);
1189  if (!col_name.empty()) {
1190  string qual = m_Fields->AutoMatch(col_name);
1191  if (!qual.empty()) {
1193 
1195  string ft_str = CFieldNamePanel::GetFieldTypeName(ft);
1196  string qual_name = qual.substr(ft_str.length(), qual.length()-ft_str.length());
1197  NStr::TruncateSpacesInPlace(qual_name);
1198  _ASSERT(!qual_name.empty());
1199  this_column.SetQualifierType(ft_str);
1200  this_column.SetQualifier(qual_name);
1201  this_column.SetName(qual_name);
1202  this_column.SetWidth((int)this_column.GetName().length());
1203  }
1204  }
1205  }
1206  if (this_column.GetQualifier().empty()) {
1207  this_column.SetType(CTableImportColumn::eSkippedColumn);
1208  }
1209 
1210  }
1211  }
1212  }
1213 
1214  // Get the current qualifier name and type and update the table, if needed
1215  string prev_qual_name = current_col.GetQualifier();
1216 
1217  m_PrevColName = current_col.GetName();
1218  m_PrevQual = current_col.GetQualifier();
1219  m_PrevQualType = current_col.GetQualifierType();
1220 
1221  if (field_name == "taxname") {
1222  m_Fields->Disable();
1223  m_MatchType->SetSelection(1);
1224  }
1225  else if (prev_qual_name == kFieldTypeSeqId) {
1226  m_Fields->Disable();
1227  m_MatchType->SetSelection(0);
1228  }
1229  else {
1230  m_Fields->Enable();
1231  m_MatchType->SetSelection(2);
1234  if (!m_PrevQual.empty()) {
1236  }
1237  else {
1239  }
1240  }
1241  else {
1244  }
1245  }
1246 
1247  string qual_type_str = m_Fields->GetFieldTypeName(m_Fields->GetFieldType());
1248  if (!field_name.empty() && !qual_type_str.empty()) {
1249  _ASSERT(!field_name.empty());
1250  current_col.SetQualifierType(qual_type_str);
1251  current_col.SetQualifier(field_name);
1252  }
1253 
1254  if (!field_name.empty()) {
1255  current_col.SetName("match " + field_name);
1256  } else {
1257  current_col.SetName("match " + current_col.GetName());
1258  }
1259  current_col.SetWidth(static_cast<int>(current_col.GetName().length()));
1260  current_col.SetType(CTableImportColumn::eTextColumn);
1261  current_col.SetMatchColumn(true);
1262  m_SkipFormatBtn->SetValue(false);
1263  }
1264  else {
1265  current_col.SetMatchColumn(false);
1266 
1267  // if type of match was not other (so it was taxname or seqid)
1268  if (m_MatchType->GetSelection() != 2) {
1269  // setting to seqid or taxname loses previous values. Since this unsets seqid, set them back
1270  current_col.SetName(m_PrevColName);
1271  current_col.SetWidth(static_cast<int>(m_PrevColName.length()));
1272  _ASSERT(!m_PrevQual.empty());
1273  current_col.SetQualifierType(m_PrevQualType);
1274  current_col.SetQualifier(m_PrevQual);
1275  m_MatchType->SetSelection(2); // set selection to 'other'
1276  }
1277  else {
1278  current_col.SetName(field_name);
1279  current_col.SetWidth(static_cast<int>(field_name.length()));
1280  }
1281 
1282  x_EnableMachColumnFields(false);
1283  }
1284 
1287  Refresh();
1288 }
1289 
1291 {
1292  event.Skip();
1293 }
1294 
1296 {
1297  // Merge first and second columns, and put a colon in between. Does not
1298  // make sense to do this more than once, so disable after
1299  vector<size_t> merge_cols;
1300  merge_cols.push_back(1);
1301  merge_cols.push_back(2);
1302 
1303  vector<CTableImportColumn> cols = m_ImportedTableData->GetColumns();
1304 
1305  // Merge the first two data columns
1306  m_ImportedTableData->MergeColumns(merge_cols, '/');
1307 
1308  auto& first_column = m_ImportedTableData->GetColumn(1);
1309  first_column.SetMatchColumn(true);
1310  first_column.SetType(CTableImportColumn::eTextColumn);
1311  first_column.SetQualifierType(kFieldTypeSeqId);
1312  first_column.SetQualifier(kFieldTypeSeqId);
1313  first_column.SetName("match " + kSequenceIdAbbrevColLabel);
1314  first_column.SetWidth(static_cast<int>(first_column.GetName().length()));
1315 
1316 
1317  // After merging columns, table will re-create columns based on headers, but we prefer to
1318  // use the previous column meta-info which could included qualifiers from both auto-match
1319  // and user-interaction.
1320  for (size_t i=3; i<cols.size() && i<m_ImportedTableData->GetColumns().size()+1; ++i) {
1321  m_ImportedTableData->GetColumn(i-1) = cols[i];
1322  }
1323 
1324  m_RequestMergeFirst = true;
1325 
1326  // This recomputes (and resizes) columns
1328 
1329  m_MergeIDCols->Disable();
1331 
1332  // Set the column being edited to the first one following the merged
1333  // id column (or the id column if there are no other columns)
1334  wxListEvent dummy_event;
1335 
1336  dummy_event.m_col = std::min(2, (int)(m_ImportedTableData->GetColumns().size()-1));
1338 
1339  Refresh();
1340 }
1341 
1343 {
1344  CFieldNamePanel* constraint_field_panel = m_Constraint->GetFieldNamePanel();
1345  string constraint_field;
1346  string constraint_field_type = m_Constraint->GetFieldType();
1347  if (constraint_field_panel)
1348  constraint_field = constraint_field_panel->GetFieldName();
1349 
1350  if (NStr::IsBlank(constraint_field)) {
1351  constraint_field = constraint_field_type;
1352  } else {
1353  if (NStr::StartsWith(constraint_field_type, "RNA") && NStr::Find(constraint_field, "RNA") == NPOS ) {
1354  constraint_field = "RNA " + constraint_field;
1355  }
1356  }
1357 
1358  return constraint_field;
1359 }
1360 
1361 
1362 void CAttribTableColumnIdPanel::x_TableReaderCommon(CIRef<IObjectLoader> object_loader, const wxString& msg, bool modal)
1363 {
1364  NEditingStats::ReportUsage(wxT("Table reader"));
1365  if (!object_loader) {
1366  NcbiErrorBox("Failed to get object loader", "Error");
1367  return;
1368  }
1369  else {
1370  IExecuteUnit* execute_unit = dynamic_cast<IExecuteUnit*>(object_loader.GetPointer());
1371  if (execute_unit) {
1372  if (!execute_unit->PreExecute())
1373  return;
1374 
1375  if (!GUI_AsyncExecUnit(*execute_unit, msg))
1376  return; // Canceled
1377 
1378  if (!execute_unit->PostExecute())
1379  return;
1380  }
1381  }
1382  bool make_mail_report = m_MakeMailReport->GetValue();
1383  const IObjectLoader::TObjects& objects = object_loader->GetObjects();
1385  const CObject& ptr = obj_it->GetObject();
1386  const objects::CSeq_annot* annot = dynamic_cast<const objects::CSeq_annot*>(&ptr);
1387  if (annot && annot->IsSeq_table()) {
1388  try {
1389  CRef<objects::CSeq_table> input_table (new objects::CSeq_table());
1390  input_table->Assign(annot->GetData().GetSeq_table());
1391  CRef<objects::CUser_object> column_properties(new objects::CUser_object);
1392 
1393  // Get user data from seqannot
1394  const CUser_object* ud = NULL;
1395  if (annot->CanGetDesc()) {
1396  const CSeq_annot::TDesc& annot_desc = annot->GetDesc();
1397  if (annot_desc.CanGet()) {
1398  const CAnnot_descr_Base::Tdata& desc_list_data = annot_desc.Get();
1399  CAnnot_descr_Base::Tdata::const_iterator tditer = desc_list_data.begin();
1400 
1401  for (; tditer!=desc_list_data.end(); ++tditer) {
1402  if ( (*tditer)->IsUser() )
1403  break;
1404  }
1405 
1406  if (tditer != desc_list_data.end()) {
1407  // Get User data from Annot Descriptor this is the Properties data
1408  // structure, where each entry is a combination of column number
1409  // and field properties, e.g.
1410  // Column.1 &xtype=StartPosition &one_based=true
1411  ud = &(*tditer)->GetUser();
1412  }
1413  }
1414  }
1415 
1416  if (ud != NULL)
1417  column_properties->Assign(*ud);
1418 
1419  CRef<CSeq_table> mail_report(NULL);
1420  if (make_mail_report) {
1422  }
1423 
1424  string constraint_field = x_GetConstraintField();
1426 
1427  CMiscSeqTable table_applier(input_table, m_TopSeqEntry, *m_id_guesser, column_properties, constraint_field, string_constraint, m_CmdProccessor);
1428  table_applier.ApplyTableToEntry();
1429 
1430  if (mail_report) {
1432  if (modal)
1433  {
1435  report->SetTitle(wxT("Organism Change Report"));
1437  report->ShowModal();
1438  }
1439  else
1440  {
1441  CGenericReportDlg* report = new CGenericReportDlg(NULL);
1442  report->SetTitle(wxT("Organism Change Report"));
1444  report->Show(true);
1445  }
1446  }
1447  }
1448  catch (CException& e) {
1449  NcbiErrorBox(e.GetMsg(), "Error");
1450  }
1451  }
1452  }
1453 }
1454 
1456 {
1457  try {
1458  CRef<CUser_object> column_meta_info(new CUser_object());
1459  CRef<CObject_id> meta_info_id(new CObject_id());
1460  meta_info_id->SetStr("Column Meta Info");
1461  column_meta_info->SetType(*meta_info_id);
1462 
1463  string label, properties;
1464  // Skip first column since it's just a row number
1465  for (size_t i = 1; i < m_ImportedTableData->GetColumns().size(); ++i) {
1466  label = "Column." + NStr::NumericToString(i);
1467 
1468  auto& col = m_ImportedTableData->GetColumn(i);
1469 
1470  string qualifier = col.GetQualifier();
1471  if (qualifier.empty() && col.GetType() != CTableImportColumn::eSkippedColumn) {
1472  qualifier = col.GetName();
1473  if (qualifier.empty()) {
1474  LOG_POST(Info << "Empty column name and qualifier in table reader");
1475  }
1476  while (NStr::StartsWith(qualifier, "match ")) {
1477  qualifier = qualifier.substr(CTempString("match ").length(), NPOS);
1478  LOG_POST(Info << "Generated new qualifier: " << qualifier);
1479  }
1480  }
1481 
1482  if (col.GetType() == CTableImportColumn::eSkippedColumn) {
1483  properties = "&skipped=true";
1484  }
1485  else {
1486  if (qualifier == kFieldTypeSeqId &&
1487  col.GetQualifierType() == kFieldTypeSeqId &&
1488  !NStr::StartsWith(col.GetName(), "match ")) {
1489  properties = "&skipped=true";
1490  }
1491  else {
1492  properties = "&skipped=false";
1493  }
1494  }
1495 
1496  properties += "&match=" + NStr::BoolToString(col.GetMatchColumn());
1497  properties += "&name=" + col.GetName();
1498  properties += "&qualifier=" + qualifier;
1499  properties += "&qual_type=" + col.GetQualifierType();
1500 
1501  // Add any other properties set by the caller
1502  const auto& pmap = col.GetPropertyValues();
1503  for (auto&& it : pmap) {
1504  properties += "&" + it.first + "=" + it.second;
1505  }
1506 
1507  column_meta_info->AddField(label, properties);
1508  }
1509 
1510  CRef<CSeq_table> mail_report(nullptr);
1511  if (m_MakeMailReport->IsChecked()) {
1513  }
1514 
1515  auto dels = m_ImportedTableData->GetDelimiters();
1516  if (dels.size() > 1) {
1517  LOG_POST(Info << "Table reader: table has more than one delimiter.");
1518  for (auto&& del_it : dels) {
1519  LOG_POST(Info << del_it);
1520  }
1521  }
1522 
1523  CTableReaderMacro tbl_macro;
1524  CTableReaderMacro::SColumnDelimiters del_options(string(1, dels.front()),
1528 
1529  auto macros = tbl_macro.CreateMacros(m_ImportedTableData->GetFileName(), column_meta_info,
1530  del_options, m_Constraint);
1531  bool status = tbl_macro.RunMacro(macros, m_TopSeqEntry, m_CmdProccessor);
1532 
1533  if (!status) {
1534  NcbiErrorBox("Unable to apply table", "Error");
1535  }
1536 
1537  if (mail_report) {
1539  if (modal)
1540  {
1542  report->SetTitle(wxT("Organism Change Report"));
1544  report->ShowModal();
1545  }
1546  else
1547  {
1548  CGenericReportDlg* report = new CGenericReportDlg(NULL);
1549  report->SetTitle(wxT("Organism Change Report"));
1551  report->Show(true);
1552  }
1553  }
1554  }
1555  catch (const CException& e) {
1556  NcbiErrorBox(e.GetMsg(), "Error");
1557  }
1558 }
1559 
1561 {
1562  bool valid = IsInputValid();
1563  if (!valid)
1564  return;
1565 
1566  CRef<CTableAnnotDataSource> annot_table_data;
1567  annot_table_data.Reset(new CTableAnnotDataSource());
1568 
1569  m_ImportedTableData->ConvertToSeqAnnot(annot_table_data->GetContainer());
1570  CIRef<IObjectLoader> object_loader(new CTableObjectLoader(*annot_table_data, m_FileNames));
1571 
1572  wxString msg;
1573  x_TableReaderMacro(true);
1574 }
1575 
1577 {
1578  auto& current_col = m_ImportedTableData->GetColumn(m_CurrentColumnIdx);
1579 
1580  // No need to do this is the column has already been unset as the match column
1581  if (!current_col.GetMatchColumn())
1582  return;
1583 
1584  // Must already be the match column (otherwise radio-box would be disabled)
1585 
1586  // If match type is seq-id:
1587  if (m_MatchType->GetSelection() == 0) {
1588  m_PrevColName = current_col.GetName();
1589  if (m_PrevColName.length() >= 6 && m_PrevColName.substr(0,6)== "match ") {
1590  if (m_PrevColName.length() == 6)
1591  m_PrevColName = "";
1592  else
1593  m_PrevColName = m_PrevColName.substr(6, m_PrevColName.length()-6);
1594  }
1595 
1596  m_PrevQualType = current_col.GetQualifierType();
1597  m_PrevQual = current_col.GetQualifier();
1598 
1599  current_col.SetQualifierType(kFieldTypeSeqId);
1600  current_col.SetQualifier(kFieldTypeSeqId);
1601  current_col.SetName("match " + kSequenceIdAbbrevColLabel);
1602  m_Fields->Disable();
1603  }
1604  // If match type is taxname:
1605  else if (m_MatchType->GetSelection() == 1) {
1606  m_PrevColName = current_col.GetName();
1607  if (m_PrevColName.length() >= 6 && m_PrevColName.substr(0,6)== "match ") {
1608  if (m_PrevColName.length() == 6)
1609  m_PrevColName = "";
1610  else
1611  m_PrevColName = m_PrevColName.substr(6, m_PrevColName.length()-6);
1612  }
1613 
1614  m_PrevQualType = current_col.GetQualifierType();
1615  m_PrevQual = current_col.GetQualifier();
1616 
1617  current_col.SetQualifierType(kFieldTypeTaxname);
1618  current_col.SetQualifier(kFieldTypeTaxname);
1619  current_col.SetName("match " + CTempString(kFieldTypeTaxname));
1620  m_Fields->Disable();
1621  }
1622  // match type is other (string):
1623  else {
1624  _ASSERT(!m_PrevQual.empty());
1625  _ASSERT(!m_PrevQualType.empty());
1626  current_col.SetQualifierType(m_PrevQualType);
1627  current_col.SetQualifier(m_PrevQual);
1628 
1629  if (!m_PrevQual.empty())
1630  current_col.SetName("match " + m_PrevQual);
1631  else
1632  current_col.SetName("match " + m_PrevColName);
1633 
1634  auto fieldname = m_Fields->GetFieldName();
1635  if (!fieldname.empty()) {
1636  current_col.SetQualifierType(m_Fields->GetFieldTypeName(m_Fields->GetFieldType()));
1637  current_col.SetQualifier(fieldname);
1638  }
1639  m_Fields->Enable();
1641  }
1642 
1643 
1644  current_col.SetWidth(static_cast<int>(current_col.GetName().length()));
1645  current_col.SetType(CTableImportColumn::eTextColumn);
1646 
1647  m_SkipFormatBtn->SetValue(false);
1650  Refresh();
1651 }
1652 
1653 
1655 {
1656  // Split first column on first blank in that column. Make the (new) first
1657  // field the seq-id match column.
1658  vector<CTableImportColumn> cols = m_ImportedTableData->GetColumns();
1659 
1660  // Merge the first two data columns
1661  m_ImportedTableData->SplitColumn(1, ' ', false);
1667  m_ImportedTableData->GetColumn(1).SetWidth(static_cast<int>(m_ImportedTableData->GetColumn(1).GetName().length()));
1668 
1669  // After merging columns, table will re-create columns based on headers, but we prefer to
1670  // use the previous column meta-info which could included qualifiers from both auto-match
1671  // and user-interaction.
1672  for (size_t i=3; i<cols.size() && i<m_ImportedTableData->GetColumns().size()-1; ++i) {
1673  m_ImportedTableData->GetColumn(i+1) = cols[i];
1674  }
1675 
1676  m_SplitFirstCol = true;
1677  // This recomputes (and resizes) columns
1679 
1681  Refresh();
1682 }
1683 
1685 {
1688  m_Multispacetotab = true;
1689 }
1690 
1691 ///
1692 /// Append field text delimiter options
1693 ///
1695 {
1696  if (event.IsChecked())
1698 }
1699 
1701 {
1702  if (event.IsChecked())
1704 }
1705 
1707 {
1708  if (event.IsChecked())
1710 }
1711 
1713 {
1714  if (event.IsChecked())
1716 }
1717 
1719 {
1720  if (event.IsChecked())
1722 }
1723 
1724 
1725 ///
1726 /// Options for handling blank fields
1727 ///
1729 {
1730  if (event.IsChecked())
1732 }
1733 
1735 {
1736  if (event.IsChecked())
1738 }
1739 
1740 
1741 
1742 ///
1743 /// Text Update rules (append, prefix, add or ignore)
1744 ///
1746 {
1747  if (event.IsChecked())
1748  m_ImportedTableData->GetColumn(m_CurrentColumnIdx).SetProperty("update_rule", "replace");
1749 }
1751 {
1752  if (event.IsChecked())
1753  m_ImportedTableData->GetColumn(m_CurrentColumnIdx).SetProperty("update_rule", "append");
1754 }
1755 
1757 {
1758  if (event.IsChecked())
1759  m_ImportedTableData->GetColumn(m_CurrentColumnIdx).SetProperty("update_rule", "prefix");
1760 }
1761 
1763 {
1764  if (event.IsChecked())
1765  m_ImportedTableData->GetColumn(m_CurrentColumnIdx).SetProperty("update_rule", "ignore");
1766 }
1767 
1769 {
1770  if (event.IsChecked())
1771  m_ImportedTableData->GetColumn(m_CurrentColumnIdx).SetProperty("update_rule", "add_new_qual");
1772 }
1773 
1774 void CAttribTableColumnIdPanel::OnPageChanged(wxBookCtrlEvent& event)
1775 {
1777 }
1778 
1779 
1780 ////////////////////////////////////////////////////////////////////////////
1781 
1782 IMPLEMENT_DYNAMIC_CLASS( CLongMessageDialog, wxDialog )
1783 
1784 
1785 /*!
1786  * CLongMessageDialog event table definition
1787  */
1788 
1789 BEGIN_EVENT_TABLE( CLongMessageDialog, wxDialog )
1790  EVT_BUTTON( wxID_YES, CLongMessageDialog::OnYesClick )
1791  EVT_BUTTON( wxID_NO, CLongMessageDialog::OnNoClick )
1792  EVT_CLOSE( CLongMessageDialog::OnClose )
1794 
1795 
1796 /*!
1797  * CLongMessageDialog constructors
1798  */
1799 
1801 {
1802  Init();
1803 }
1804 
1805 CLongMessageDialog::CLongMessageDialog( wxWindow* parent, wxString msg,
1806  wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
1807  : m_Text(msg)
1808 {
1809  Init();
1810  Create(parent, id, caption, pos, size, style);
1811 }
1812 
1813 
1814 /*!
1815  * CLongMessageDialog creator
1816  */
1817 
1818 bool CLongMessageDialog::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
1819 {
1820 ////@begin CLongMessageDialog creation
1821  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
1822  wxDialog::Create( parent, id, caption, pos, size, style );
1823  CreateControls();
1824  if (GetSizer())
1825  {
1826  GetSizer()->SetSizeHints(this);
1827  }
1828  Centre();
1829 ////@end CLongMessageDialog creation
1830  return true;
1831 }
1832 
1833 
1834 /*!
1835  * CLongMessageDialog destructor
1836  */
1837 
1839 {
1840 }
1841 
1842 
1843 /*!
1844  * Member initialisation
1845  */
1846 
1848 {
1849 }
1850 
1851 
1852 /*!
1853  * Control creation for CLongMessageDialog
1854  */
1855 
1857 {
1858  CLongMessageDialog* itemDialog1 = this;
1859 
1860  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
1861  itemDialog1->SetSizer(itemBoxSizer2);
1862 
1863  wxRichTextCtrl *RTCtrl = new wxRichTextCtrl( itemDialog1, wxID_ANY, m_Text, wxDefaultPosition, wxSize(360, 400), wxRE_MULTILINE | wxRE_READONLY );
1864  //RTCtrl->SetFont(wxFont(10, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Consolas")));
1865  itemBoxSizer2->Add(RTCtrl, 1, wxGROW|wxALL, 5);
1866 
1867  wxSizer* itemBoxSizer4 = itemDialog1->CreateButtonSizer(wxYES | wxNO);
1868  itemBoxSizer2->Add(itemBoxSizer4, 0, wxGROW|wxALL, 5);
1869 }
1870 
1871 /*!
1872  * Should we show tooltips?
1873  */
1874 
1876 {
1877  return true;
1878 }
1879 
1880 /*!
1881  * Get bitmap resources
1882  */
1883 
1884 wxBitmap CLongMessageDialog::GetBitmapResource( const wxString& name )
1885 {
1886  // Bitmap retrieval
1887 ////@begin CLongMessageDialog bitmap retrieval
1888  wxUnusedVar(name);
1889  return wxNullBitmap;
1890 ////@end CLongMessageDialog bitmap retrieval
1891 }
1892 
1893 /*!
1894  * Get icon resources
1895  */
1896 
1897 wxIcon CLongMessageDialog::GetIconResource( const wxString& name )
1898 {
1899  // Icon retrieval
1900 ////@begin CLongMessageDialog icon retrieval
1901  wxUnusedVar(name);
1902  return wxNullIcon;
1903 ////@end CLongMessageDialog icon retrieval
1904 }
1905 
1906 void CLongMessageDialog::OnClose(wxCloseEvent& event)
1907 {
1908  if (IsModal())
1909  {
1910  EndModal(wxNO);
1911  }
1912  else
1913  {
1914  event.Skip();
1915  }
1916 }
1917 
1918 void CLongMessageDialog::OnYesClick( wxCommandEvent& event )
1919 {
1920  if (IsModal())
1921  {
1922  EndModal(wxYES);
1923  }
1924  else
1925  {
1926  Destroy();
1927  }
1928 }
1929 
1930 void CLongMessageDialog::OnNoClick( wxCommandEvent& event )
1931 {
1932  if (IsModal())
1933  {
1934  EndModal(wxNO);
1935  }
1936  else
1937  {
1938  Destroy();
1939  }
1940 }
1941 
1942 
1944 
User-defined methods of the data storage class.
EVT_CHECKBOX(ID_CADJUSTFEATURES_CHECKBOX, CAdjustFeaturesForGaps::OnKnownUnknownSelected) EVT_CHECKBOX(ID_CADJUSTFEATURES_CHECKBOX1
bool GUI_AsyncExecUnit(IExecuteUnit &exec_unit, const wxString &msg)
Definition: async_call.cpp:53
const string kSequenceIdAbbrevColLabel
#define ID_SKIPBTN
#define ID_ERASE_EXISTING_VALUE_BTN
#define ID_APPLY_NO_CLOSE
#define ID_SPLIT_FIRST_COL
#define ID_IGNORE_BLANKS_BTN
#define ID_MULTISPACE_TO_TAB_BTN
#define ID_MAIL_REPORT_CHECKBOX
#define ID_MERGEIDCOLS
#define ID_MATCH_COLUMN
#define ID_MATCHTYPE
#define ID_COLUMNNAMETXT
#define ID_CTABLEIMPORTLISTCTRL3
#define ID_REPLACE_BTN
CAnnot_descr –.
Definition: Annot_descr.hpp:66
void OnReplaceBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_REPLACE_BTN
wxSize m_FieldsSize
Previous size of m_Fields - used to resize dialog as m_Fields layout changes.
void OnPageChanged(wxBookCtrlEvent &event)
Refresh the parent dialog upon changing the field type in the constraint panel.
void x_EnableMachColumnFields(bool match_column)
Enable/ disable fields for match column.
void OnMailReportCheckboxClick(wxCommandEvent &event)
wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_MAIL_REPORT_CHECKBOX
bool Create(wxWindow *parent, wxWindowID id=10230, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void OnMatchColumnClick(wxCommandEvent &event)
wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_MATCH_COLUMN
void OnPrefixBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_PREFIX_BTN
void OnMatchTypeSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_MATCHTYPE
void OnIgnoreBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_IGNORE_BTN
string m_PrevColName
Fields to remember type information for col set to seq-id so that the values can be restored if seq-i...
void OnSpaceBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_SPACE_BTN
void OnAppendBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_APPEND_BTN
void ProcessUpdateFeatEvent(wxCommandEvent &event)
void x_TableReaderCommon(CIRef< IObjectLoader > object_loader, const wxString &msg, bool modal=false)
bool Show(bool show)
Override Show() to allow initialization each time window is displayed.
void x_EnableNonFormatEditControls(bool b)
Enables all controls except the format buttons since they can be used to skip a column (which greys-o...
void OnColonBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_COLON_BTN
void OnEraseExistingValueBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_ERASE_EXISTING_VALUE_BTN
void OnMultispaceToTabBtnClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_MULTISPACE_TO_TAB_BTN
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
void OnSemicolonBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_SEMICOLON_BTN
int m_CurrentColumnIdx
Index within listctrl/datasource of column being edited or -1.
shared_ptr< edit::CSeqIdGuesser > m_id_guesser
void OnMergeIDColsClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_MERGEIDCOLS
void SetTopLevelEntry(CSeq_entry_Handle seq_entry)
void Init()
Initialises member variables.
CSeq_entry_Handle m_TopSeqEntry
Top level seq submit entry.
void OnSplitFirstColClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SPLIT_FIRST_COL
void UpdateChildrenFeaturePanels(wxWindow *win)
Lists the features present in the top seq-entry first in the feature listbox.
void CreateControls()
Creates the controls and sizers.
void SetRegistryPath(const string &path)
CRef< CTableImportDataSource > m_ImportedTableData
Contents of tabular file.
void OnNodelimiterBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_NODELIMITER_BTN
void UpdateStructuredCommentFields(wxWindow *win, const set< string > &fields)
void OnIgnoreBlanksBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_IGNORE_BLANKS_BTN
void OnCtableImportListCtrlColDragging(wxListEvent &event)
wxEVT_COMMAND_LIST_COL_DRAGGING event handler for ID_CTABLEIMPORTLISTCTRL3
void x_GuessQualifiers()
Guess column qualifiers - called on Show() or if table updated significantly.
void OnColumnNameTxtTextUpdated(wxCommandEvent &event)
wxEVT_COMMAND_TEXT_UPDATED event handler for ID_COLUMNNAMETXT
void OnCtableImportListctrlColLeftClick(wxListEvent &event)
wxEVT_COMMAND_LIST_COL_CLICK event handler for ID_CTABLEIMPORTLISTCTRL3
void ProcessUpdateStructCommentEvent(wxCommandEvent &event)
void OnCommaBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_COMMA_BTN
void OnApplyNoCloseClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_APPLY_NO_CLOSE
static bool ShowToolTips()
Should we show tooltips?
void OnAddQualBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_ADD_QUAL_BTN
void OnSkipBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_SKIPBTN
void x_EnableColumnEditControls(bool b)
If a column is currently selected, the controls to edit its type and name should be available,...
string GetFieldType(void) const
CFieldNamePanel * GetFieldNamePanel(void)
void ListPresentFeaturesFirst(objects::CSeq_entry_Handle seh)
CRef< edit::CStringConstraint > GetStringConstraint(void)
void ListPresentFeaturesFirst(const objects::CSeq_entry_Handle &entry, vector< const objects::CFeatListItem * > *featlist=nullptr)
virtual string GetFieldName(const bool subfield=false)
Returns the name of the field as selected in the panel.
bool SetFieldType(CFieldNamePanel::EFieldType field_type, bool is_pair=false)
static string AutoMatch(string field_name)
void SetShowLegalOnly(bool val)
virtual bool SetFieldName(const string &field)
CFieldNamePanel::EFieldType GetFieldType()
virtual string GetFieldName(const bool subfield=false)=0
Returns the name of the field as selected in the panel.
static string GetFieldTypeName(EFieldType field_type)
static EFieldType GetFieldTypeFromName(const string &field_type_name)
void SetText(const wxString &text)
void SetText(const wxString &text)
CRegistryWriteView GetWriteView(const string &section)
get a read-write view at a particular level.
Definition: registry.cpp:462
static CGuiRegistry & GetInstance()
access the application-wide singleton
Definition: registry.cpp:400
static bool ShowToolTips()
Should we show tooltips?
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void CreateControls()
Creates the controls and sizers.
void Init()
Initialises member variables.
void OnClose(wxCloseEvent &event)
void OnNoClick(wxCommandEvent &event)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
void OnYesClick(wxCommandEvent &event)
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &caption=_("ID Errors"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
string IsValid(const string &val)
static void s_GetValueToSehMap(objects::CSeq_entry_Handle seh, map< string, set< CSeq_entry_Handle > > &value_to_sehs, string id_field_name, CFieldNamePanel::EFieldType id_field_type, int id_subtype)
void ApplyTableToEntry()
CObject –.
Definition: ncbiobj.hpp:180
CSeq_entry_Handle –.
void CompleteStructCommentFields(const set< string > &fields)
static void GetStructCommentFields(const objects::CSeq_entry_Handle &seh, set< string > &fields, size_t max=numeric_limits< size_t >::max())
void ListStructCommentFields(const set< string > &field_names)
CRef< CSeq_annot > GetContainer()
eColumnType GetType() const
bool HasProperty(const string &prop_name)
void SetName(const string &n)
void SetQualifierType(const string &q)
void SetType(eColumnType t)
string GetProperty(const string &prop_name)
void SetMatchColumn(bool b)
For attribute table import we need to specify a column as the column to use in matching the table aga...
string GetQualifierType() const
void SetQualifier(const string &q)
void SetProperty(const string &prop_name, const string &prop_value)
Add/update a column property.
const vector< char > & GetDelimiters() const
Return copy of current delimiter(s)
const CTableImportRow & GetRow(size_t row) const
Return a specific row.
void MergeColumns(vector< size_t > col_indices, char ch, bool no_merge_char=false)
Replace all delimiter characters separating cols in the array 'col_indices' with the delimiter char '...
const CTableDelimiterRules & GetDelimiterRules() const
Get set all delimiter rules (for delimited tables)
vector< CTableImportColumn > & GetColumns()
return the array of column data
const CTableImportColumn & GetColumn(size_t col) const
Return the specified column.
string GetField(size_t row, size_t col) const
return a specific field from a specific row, based on current table type and delimiter
void RecomputeRowFields(size_t row_idx)
Do same but only for 1 row.
wxString GetFileName() const
Get name of file last passed to LoadTable.
void ConvertToSeqAnnot(CRef< CSeq_annot > annot_container)
Save data in table into annot_container.
string GetColumnName(size_t col) const
Return name of specified column.
bool ReplaceSpaces()
Replace all instances of multiple spaces with the current delimiter.
bool SplitColumn(size_t col_idx, char ch, bool split_on_whitespace=false)
Split column col_idx into 2 columns using the character 'ch' (if 'ch' does not appear in the column,...
void SetViewType(eDataViewType t)
Set/get view type.
void UpdateColumnImages(bool checkbox_only=false)
Update images on column headers.
void SetDataSource(CRef< CTableImportDataSource > ds)
Set/update data source (used to refresh view to match data source column info)
vector< pair< size_t, size_t > > & GetFields()
Get the array of field start/length pairs.
const string & GetValue() const
Get the entire row.
CTableObjectLoader.
TVecMacroNames CreateMacros(const wxString &filename, CRef< objects::CUser_object > column_properties, const SColumnDelimiters &del_options, CConstraintPanel *panel=nullptr, bool test=false)
bool RunMacro(const TVecMacroNames &macros, objects::CSeq_entry_Handle entry, ICommandProccessor *cmd_processor)
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Definition: tempstr.hpp:65
CUser_object & AddField(const string &label, const string &value, EParseField parse=eParse_String)
add a data field to the user object that holds a given value
virtual bool PreExecute()=0
virtual bool PostExecute()=0
vector< SObject > TObjects
const_iterator end() const
Definition: map.hpp:152
const_iterator find(const key_type &key) const
Definition: map.hpp:153
Definition: map.hpp:338
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
#define _(proto)
Definition: ct_nlmzip_i.h:78
#define ID_PREFIX_BTN
#define ID_COMMA_BTN
#define ID_NODELIMITER_BTN
#define ID_SPACE_BTN
#define ID_ADD_QUAL_BTN
#define ID_COLON_BTN
#define ID_IGNORE_BTN
#define ID_APPEND_BTN
#define ID_SEMICOLON_BTN
#define EVT_UPDATE_FEATURE_LIST(id, fn)
const char * kFieldTypeSeqId
const char * kFieldTypeTaxname
static void Init(void)
Definition: cursor6.c:76
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
#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
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
void Info(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1185
void NcbiErrorBox(const string &message, const string &title="Error")
specialized Message Box function for reporting critical errors
EDialogReturnValue NcbiMessageBox(const string &message, TDialogType type=eDialog_Ok, EDialogIcon icon=eIcon_Exclamation, const string &title="Error", EDialogTextMode text_mode=eRaw)
Definition: message_box.cpp:48
void GetLabel(string *label, ELabelType type=eDefault, TLabelFlags flags=fLabel_Default) const
Append a label for this Seq-id to the supplied string.
Definition: Seq_id.cpp:2040
@ eBoth
Type and content, delimited by a vertical bar.
Definition: Seq_id.hpp:606
CScope & GetScope(void) const
Get scope this handle belongs to.
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
Definition: ncbiobj.hpp:735
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
#define NPOS
Definition: ncbistr.hpp:133
static const string BoolToString(bool value)
Convert bool to string.
Definition: ncbistr.cpp:2815
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
Definition: ncbistr.cpp:3201
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
Definition: ncbistr.cpp:2891
static int Compare(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Compare of a substring with another string.
Definition: ncbistr.hpp:5297
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
Definition: ncbistr.hpp:5412
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
static const char label[]
TStr & SetStr(void)
Select the variant.
Definition: Object_id_.hpp:304
void SetType(TType &value)
Assign a value to Type data member.
const Tdata & Get(void) const
Get the member data.
bool CanGet(void) const
Check if it is safe to call Get method.
list< CRef< CAnnotdesc > > Tdata
@ eIcon_Question
Definition: types.hpp:64
@ eDialog_YesNo
Definition: types.hpp:49
END_EVENT_TABLE()
int i
void MakeMailReportPostReport(CSeq_table &table, CScope &scope)
Definition: mail_report.cpp:90
string GetReportFromMailReportTable(const CSeq_table &table, CScope *scope=nullptr)
CRef< CSeq_table > MakeMailReportPreReport(CSeq_entry_Handle seh)
Definition: mail_report.cpp:55
#define wxT(x)
Definition: muParser.cpp:41
void ReportUsage(const wxString &dialog_name)
Report opening & accepting events in the editing package.
const struct ncbi::grid::netcache::search::fields::SIZE size
static unsigned int ud(time_t one, time_t two)
EIPRangeType t
Definition: ncbi_localip.c:101
T min(T x_, T y_)
static static static wxID_ANY
#define row(bind, expected)
Definition: string_bind.c:73
Definition: type.c:6
#define _ASSERT
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
#define const
Definition: zconf.h:232
Modified on Sat Jun 22 10:42:20 2024 by modify_doxy.py rev. 669887