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

Go to the SVN repository for this file.

1 /* $Id: 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  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
34 ////@begin includes
35 ////@end includes
36 
38 
44 
46 
47 #include <wx/sizer.h>
48 #include <wx/stattext.h>
49 #include <wx/statbox.h>
50 #include <wx/icon.h>
51 #include <wx/bitmap.h>
52 #include <wx/msgdlg.h>
53 #include <wx/radiobut.h>
54 #include <wx/listctrl.h>
55 #include "wx/imaglist.h"
56 
58 
59 ////@begin XPM images
60 ////@end XPM images
61 
62 IMPLEMENT_DYNAMIC_CLASS( CTableColumnIdPanel, wxPanel )
63 
64 BEGIN_EVENT_TABLE( CTableColumnIdPanel, wxPanel )
65 
66 ////@begin CTableColumnIdPanel event table entries
68  EVT_RADIOBUTTON( ID_SEQIDFORMATBTN, CTableColumnIdPanel::OnSeqidFormatBtnSelected )
69  EVT_RADIOBUTTON( ID_TEXTFORMATBTN, CTableColumnIdPanel::OnTextFmtBtnSelected )
70  EVT_RADIOBUTTON( ID_NUMBERFORMATBTN, CTableColumnIdPanel::OnNumberFmtBtnSelected )
72  EVT_RADIOBUTTON( ID_REALNUMBERFORMATBTN, CTableColumnIdPanel::OnRealNumberFormatBtnSelected )
74  EVT_LISTBOX( ID_DATATYPECOMBO, CTableColumnIdPanel::OnDataTypePropertySelected )
75 ////@end CTableColumnIdPanel event table entries
76 
77  EVT_LIST_COL_CLICK( ID_CTABLEIMPORTLISTCTRL2, CTableColumnIdPanel::OnCtableImportListctrlColLeftClick )
78  EVT_LIST_COL_DRAGGING( ID_CTABLEIMPORTLISTCTRL2, CTableColumnIdPanel::OnCtableImportListctrlColDragging )
79 
80  EVT_COMMAND( wxID_ANY, wxEVT_ASSEMBLY_CHANGED_EVENT, CTableColumnIdPanel::OnAssemblyChanged )
81 
83 
85 {
86  Init();
87 }
88 
89 CTableColumnIdPanel::CTableColumnIdPanel( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
90 {
91  Init();
92  Create(parent, id, caption, pos, size, style);
93 }
94 
95 bool CTableColumnIdPanel::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
96 {
97 ////@begin CTableColumnIdPanel creation
98  SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY|wxWS_EX_BLOCK_EVENTS);
99  wxPanel::Create( parent, id, pos, size, style );
100 
101  CreateControls();
102  if (GetSizer())
103  {
104  GetSizer()->SetSizeHints(this);
105  }
106  Centre();
107 ////@end CTableColumnIdPanel creation
108  return true;
109 }
110 
112 {
113 ////@begin CTableColumnIdPanel destruction
114 ////@end CTableColumnIdPanel destruction
115 }
116 
118 {
119 ////@begin CTableColumnIdPanel member initialisation
133 ////@end CTableColumnIdPanel member initialisation
134 
135  m_CurrentColumnIdx = -1;
136 }
137 
139 {
140 ////@begin CTableColumnIdPanel content construction
141  // Generated by DialogBlocks, 14/08/2019 15:53:33 (unregistered)
142 
143  CTableColumnIdPanel* itemPanel1 = this;
144 
145  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
146  itemPanel1->SetSizer(itemBoxSizer2);
147 
148  wxStaticText* itemStaticText3 = new wxStaticText( itemPanel1, wxID_STATIC, _("Set or Verify Type Information for each Table Column"), wxDefaultPosition, wxDefaultSize, 0 );
149  itemStaticText3->SetFont(wxFont(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, wxT("Tahoma")));
150  itemBoxSizer2->Add(itemStaticText3, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5);
151 
152  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
153  itemBoxSizer2->Add(itemBoxSizer4, 0, wxGROW|wxLEFT|wxRIGHT, 5);
154 
155  m_ColumnPropertiesSizer = new wxStaticBox(itemPanel1, wxID_ANY, _("Column Properties"));
156  wxStaticBoxSizer* itemStaticBoxSizer5 = new wxStaticBoxSizer(m_ColumnPropertiesSizer, wxHORIZONTAL);
157  itemBoxSizer4->Add(itemStaticBoxSizer5, 1, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5);
158 
159  wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxVERTICAL);
160  itemStaticBoxSizer5->Add(itemBoxSizer6, 0, wxALIGN_TOP|wxLEFT|wxRIGHT, 5);
161 
162  wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxHORIZONTAL);
163  itemBoxSizer6->Add(itemBoxSizer7, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT, 5);
164 
165  m_ColumnNameStaticTxt = new wxStaticText( itemStaticBoxSizer5->GetStaticBox(), wxID_STATIC, _("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
166  m_ColumnNameStaticTxt->Enable(false);
167  itemBoxSizer7->Add(m_ColumnNameStaticTxt, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5);
168 
169  m_ColumnNameTxtCtrl = new wxTextCtrl( itemStaticBoxSizer5->GetStaticBox(), ID_COLUMNNAMETXT, wxEmptyString, wxDefaultPosition, wxSize(110, -1), 0 );
170  m_ColumnNameTxtCtrl->Enable(false);
171  itemBoxSizer7->Add(m_ColumnNameTxtCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
172 
173  wxStaticBox* itemStaticBoxSizer10Static = new wxStaticBox(itemStaticBoxSizer5->GetStaticBox(), wxID_ANY, _("Data Type"));
174  wxStaticBoxSizer* itemStaticBoxSizer10 = new wxStaticBoxSizer(itemStaticBoxSizer10Static, wxVERTICAL);
175  itemBoxSizer6->Add(itemStaticBoxSizer10, 0, wxALIGN_LEFT|wxALL, 5);
176 
177  wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxHORIZONTAL);
178  itemStaticBoxSizer10->Add(itemBoxSizer11, 0, wxALIGN_LEFT|wxALL, 0);
179 
180  wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxVERTICAL);
181  itemBoxSizer11->Add(itemBoxSizer12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
182 
183  m_SeqIdFormatBtn = new wxRadioButton( itemStaticBoxSizer10->GetStaticBox(), ID_SEQIDFORMATBTN, _("Sequence ID"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
184  m_SeqIdFormatBtn->SetValue(false);
185  m_SeqIdFormatBtn->Enable(false);
186  itemBoxSizer12->Add(m_SeqIdFormatBtn, 0, wxALIGN_LEFT|wxALL, 5);
187 
188  m_TextFormatBtn = new wxRadioButton( itemStaticBoxSizer10->GetStaticBox(), ID_TEXTFORMATBTN, _("Text"), wxDefaultPosition, wxDefaultSize, 0 );
189  m_TextFormatBtn->SetValue(false);
190  m_TextFormatBtn->Enable(false);
191  itemBoxSizer12->Add(m_TextFormatBtn, 0, wxALIGN_LEFT|wxALL, 5);
192 
193  wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxHORIZONTAL);
194  itemBoxSizer12->Add(itemBoxSizer15, 0, wxALIGN_LEFT|wxRIGHT, 5);
195 
196  m_NumberFormatBtn = new wxRadioButton( itemStaticBoxSizer10->GetStaticBox(), ID_NUMBERFORMATBTN, _("Integer"), wxDefaultPosition, wxDefaultSize, 0 );
197  m_NumberFormatBtn->SetValue(false);
198  m_NumberFormatBtn->Enable(false);
199  itemBoxSizer15->Add(m_NumberFormatBtn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
200 
201  m_OneBasedIntCheck = new wxCheckBox( itemStaticBoxSizer10->GetStaticBox(), ID_ONEBASEDINTCHECK, _("One-Based"), wxDefaultPosition, wxDefaultSize, 0 );
202  m_OneBasedIntCheck->SetValue(true);
203  itemBoxSizer15->Add(m_OneBasedIntCheck, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
204 
205  m_RealNumberFormatBtn = new wxRadioButton( itemStaticBoxSizer10->GetStaticBox(), ID_REALNUMBERFORMATBTN, _("Real Number"), wxDefaultPosition, wxDefaultSize, 0 );
206  m_RealNumberFormatBtn->SetValue(false);
207  itemBoxSizer12->Add(m_RealNumberFormatBtn, 0, wxALIGN_LEFT|wxALL, 5);
208 
209  m_SkipFormatBtn = new wxRadioButton( itemStaticBoxSizer10->GetStaticBox(), ID_SKIPBTN, _("Skip (Do not import)"), wxDefaultPosition, wxDefaultSize, 0 );
210  m_SkipFormatBtn->SetValue(false);
211  m_SkipFormatBtn->Enable(false);
212  itemBoxSizer12->Add(m_SkipFormatBtn, 0, wxALIGN_LEFT|wxALL, 5);
213 
214  wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxVERTICAL);
215  itemBoxSizer11->Add(itemBoxSizer20, 0, wxGROW, 5);
216 
217  wxStaticText* itemStaticText21 = new wxStaticText( itemStaticBoxSizer10->GetStaticBox(), wxID_STATIC, _("Properties:"), wxDefaultPosition, wxDefaultSize, 0 );
218  itemBoxSizer20->Add(itemStaticText21, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT, 5);
219 
220  wxArrayString m_DataTypeListStrings;
221  m_DataTypeList = new wxListBox( itemStaticBoxSizer10->GetStaticBox(), ID_DATATYPECOMBO, wxDefaultPosition, wxSize(140, -1), m_DataTypeListStrings, wxLB_SINGLE );
222  m_DataTypeList->SetStringSelection(_("Undefined"));
223  m_DataTypeList->Enable(false);
224  itemBoxSizer20->Add(m_DataTypeList, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
225 
226  m_AssemblyPanel = new CAssemblySelPanel( itemStaticBoxSizer5->GetStaticBox(), ID_PANEL5, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL );
227  itemStaticBoxSizer5->Add(m_AssemblyPanel, 1, wxALIGN_TOP | wxLEFT | wxRIGHT, 5);
228 
229  wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxHORIZONTAL);
230  itemBoxSizer4->Add(itemBoxSizer24, 0, wxALIGN_TOP|wxALL, 5);
231 
232  wxStaticBox* itemStaticBoxSizer25Static = new wxStaticBox(itemPanel1, wxID_ANY, _("Click on Table Columns to Set Properties"));
233  wxStaticBoxSizer* itemStaticBoxSizer25 = new wxStaticBoxSizer(itemStaticBoxSizer25Static, wxHORIZONTAL);
234  itemBoxSizer2->Add(itemStaticBoxSizer25, 1, wxGROW|wxLEFT, 5);
235 
236  m_ColumnIdPanel = new wxPanel( itemStaticBoxSizer25->GetStaticBox(), ID_COLUMNIDLISTPANEL, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
237  itemStaticBoxSizer25->Add(m_ColumnIdPanel, 1, wxGROW, 5);
238 
239  wxBoxSizer* itemBoxSizer27 = new wxBoxSizer(wxHORIZONTAL);
240  m_ColumnIdPanel->SetSizer(itemBoxSizer27);
241 
242  m_ColumnIdList = new CTableImportListCtrl( m_ColumnIdPanel, ID_CTABLEIMPORTLISTCTRL2, wxDefaultPosition, wxSize(100, 100), wxLC_REPORT|wxLC_VIRTUAL|wxLC_ALIGN_LEFT|wxLC_HRULES|wxLC_VRULES );
243  itemBoxSizer27->Add(m_ColumnIdList, 1, wxGROW|wxALL, 5);
244 
245 ////@end CTableColumnIdPanel content construction
246 
249 }
250 
252 {
253  if (show) {
255 
256  if (!m_ImportedTableData.IsNull()) {
259 
260  // Set x mark for any skipped columns
261  for (int col=1; col<static_cast<int>(m_ImportedTableData->GetColumns().size()); ++col) {
262  if (m_ImportedTableData->GetColumns()[col].GetSkipped()) {
263  wxListItem item;
264  m_ColumnIdList->GetColumn(col, item);
265  int img_idx = m_ColumnIdList->GetColumnImageID(col);
266 
267  // Set the image to indicate column status (skipped or not)
268  item.SetImage(img_idx);
269  item.SetWidth(24); // wide enough to show the X
270  item.SetText(m_ImportedTableData->GetColumns()[col].GetNameEx());
271  m_ColumnIdList->SetColumn(col, item);
272  }
273  }
274 
275  // Is there a currently selected column? If so make sure the fields
276  // for editing column info are up-to-date. (This only happens if the
277  // users was previously on this page and is returning)
278  if (m_CurrentColumnIdx >= 0 &&
280 
281  wxListEvent dummy_event;
282  dummy_event.m_col = m_CurrentColumnIdx;
283 
285  }
286  // Set the first column to the one being edited even though it hasn't been
287  // clicked on yet.
288  else {
289  wxListEvent dummy_event;
290  dummy_event.m_col = 1;
291 
293  }
294  }
295  }
296 
297  return wxPanel::Show(show);
298 }
299 
300 void CTableColumnIdPanel::SetMainTitle(const wxString& title)
301 {
302 }
303 
305 {
306  return true;
307 }
308 
309 
310 void CTableColumnIdPanel::SetRegistryPath( const string& path )
311 {
312  m_RegPath = path;
313 }
314 
315 static const string kTableAssmSearchPath = "TableAssmSearch";
316 static const string kSearchTermTag = "SearchTerm";
317 static const string kTermHistoryTag = "TermHistory";
318 
320 {
321  string search_term;
322 
323  if ( !m_RegPath.empty() ) {
325  CRegistryReadView view = gui_reg.GetReadView(m_RegPath);
326 
327  search_term = view.GetString(kSearchTermTag, search_term);
329  }
330 }
331 
332 
334 {
335  if ( !m_RegPath.empty() ) {
337  CRegistryWriteView view = gui_reg.GetWriteView(m_RegPath);
339  }
340 }
341 
343 {
344  m_SeqIdFormatBtn->Enable(b);
345  m_TextFormatBtn->Enable(b);
346  m_NumberFormatBtn->Enable(b);
347  m_RealNumberFormatBtn->Enable(b);
348  m_SkipFormatBtn->Enable(b);
349 
351 }
352 
354 {
355  /// Get correct list for list box selection based on column type
356  vector<CTableImportColumn::eDataType> property_list_options;
357 
358  if (m_SeqIdFormatBtn->GetValue() == true) {
359  property_list_options = CTableImportColumn::GetMatchingDataTypes(
361  }
362  else if (m_TextFormatBtn->GetValue() == true) {
363  property_list_options = CTableImportColumn::GetMatchingDataTypes(
365  }
366  else if (m_NumberFormatBtn->GetValue() == true) {
367  property_list_options = CTableImportColumn::GetMatchingDataTypes(
369  }
370  else if (m_RealNumberFormatBtn->GetValue() == true) {
371  property_list_options = CTableImportColumn::GetMatchingDataTypes(
373  }
374  else if (m_SkipFormatBtn->GetValue() == true) {
375  property_list_options = CTableImportColumn::GetMatchingDataTypes(
377  }
378 
379  m_DataTypeList->Clear();
380 
381  for (size_t i=0; i<property_list_options.size(); ++i) {
382  m_DataTypeList->AppendString(ToWxString(
383  CTableImportColumn::GetStringFromDataType(property_list_options[i])));
384  };
385 
386  // Should always have some elements in the list
387  if (property_list_options.size() > 0) {
388  // Set the default item to be the last item in the list.
389  m_DataTypeList->SetSelection(m_DataTypeList->GetCount()-1);
390  }
391 }
392 
394 {
395  m_ColumnNameTxtCtrl->Enable(b);
396  m_ColumnPropertiesSizer->Enable(b);
397  m_ColumnNameStaticTxt->Enable(b);
398  m_ColumnPropertiesSizer->Enable(b);
399 
401  m_DataTypeList->Enable(b);
402 }
403 
405 {
406  return true;
407 }
408 wxBitmap CTableColumnIdPanel::GetBitmapResource( const wxString& name )
409 {
410  // Bitmap retrieval
411 ////@begin CTableColumnIdPanel bitmap retrieval
412  wxUnusedVar(name);
413  return wxNullBitmap;
414 ////@end CTableColumnIdPanel bitmap retrieval
415 }
416 wxIcon CTableColumnIdPanel::GetIconResource( const wxString& name )
417 {
418  // Icon retrieval
419 ////@begin CTableColumnIdPanel icon retrieval
420  wxUnusedVar(name);
421  return wxNullIcon;
422 ////@end CTableColumnIdPanel icon retrieval
423 }
424 
426 {
427  if (!m_ImportedTableData.IsNull()) {
428  int col = event.GetColumn();
429 
430  // First column is the row number column and has no attributes.
431  if (col == 0) {
432  event.Veto();
433  return;
434  }
435 
436  if ((size_t)col < m_ImportedTableData->GetColumns().size()) {
437 
438  /// if there is another current column, remove the checkmark from it:
439  if (m_CurrentColumnIdx != -1 &&
440  m_CurrentColumnIdx != col &&
441  (size_t)m_CurrentColumnIdx < m_ImportedTableData->GetColumns().size()) {
442  wxListItem item;
443  m_ColumnIdList->GetColumn(m_CurrentColumnIdx, item);
444  m_ImportedTableData->GetColumns()[m_CurrentColumnIdx].SetIsCurrent(false);
445 
446  // Reset the image from the (previous selected) column:
448  item.SetImage(img_idx);
449  m_ColumnIdList->SetColumn(m_CurrentColumnIdx, item);
450  }
451 
452  m_CurrentColumnIdx = col;
453 
454  m_SeqIdFormatBtn->SetValue(false);
455  m_TextFormatBtn->SetValue(false);
456  m_NumberFormatBtn->SetValue(false);
457  m_RealNumberFormatBtn->SetValue(false);
458  m_SkipFormatBtn->SetValue(false);
459 
460  // If m_OneBasedIntCheck and then gets disable, a bug occurs when
461  // using current version of wxwidgets (2.9.4):
462  // http://trac.wxwidgets.org/ticket/15065
463  // If the current field is the one-based check-box and you then
464  // switch to a new column, the next radio button (real-number) will
465  // be selected. This is because the disabling forces navigation to
466  // the next control in tab order (which is fine) when the check box
467  // is deselected. But it also then selects that radiobutton (not good)
468  //m_OneBasedIntCheck->SetValue(false);
469  //m_OneBasedIntCheck->Enable(false);
470 
473 
474  switch (t) {
476  m_SeqIdFormatBtn->SetValue(true);
477  if (m_OneBasedIntCheck->HasFocus()) {
478  m_SeqIdFormatBtn->SetFocus();
479  }
480  m_OneBasedIntCheck->SetValue(false);
481  m_OneBasedIntCheck->Enable(false);
482  break;
484  m_TextFormatBtn->SetValue(true);
485  if (m_OneBasedIntCheck->HasFocus()) {
486  m_TextFormatBtn->SetFocus();
487  }
488  m_OneBasedIntCheck->SetValue(false);
489  m_OneBasedIntCheck->Enable(false);
490  break;
492  m_NumberFormatBtn->SetValue(true);
493  m_OneBasedIntCheck->Enable(true);
494  m_OneBasedIntCheck->SetValue(
496  break;
498  m_RealNumberFormatBtn->SetValue(true);
499  if (m_OneBasedIntCheck->HasFocus()) {
500  m_RealNumberFormatBtn->SetFocus();
501  }
502  m_OneBasedIntCheck->SetValue(false);
503  m_OneBasedIntCheck->Enable(false);
504  break;
506  m_SkipFormatBtn->SetValue(true);
507  if (m_OneBasedIntCheck->HasFocus()) {
508  m_SkipFormatBtn->SetFocus();
509  }
510  m_OneBasedIntCheck->SetValue(false);
511  m_OneBasedIntCheck->Enable(false);
512  break;
513  default:
514  break;
515  };
516 
517  // Controls initially default to not being enabled, since no column is
518  // selected. Enable all controls for idnetifying column info here.
520 
521  /// Update controls to represent current column choice:
522  m_ColumnNameTxtCtrl->SetValue(
524 
526 
529 
530  /// Set column to be 'current'
531  m_ImportedTableData->GetColumns()[m_CurrentColumnIdx].SetIsCurrent(true);
532 
533  // Disable column attributes field if column is currently skipped
536 
537  // Put a check mark in selected column (I would highlight the column,
538  // but I can't find a way to do that in wx - Changing colors and fonts
539  // here seems to have no effect).
540  wxListItem colinfo;
541  m_ColumnIdList->GetColumn(col, colinfo);
542  colinfo.SetText(m_ImportedTableData->GetColumns()[m_CurrentColumnIdx].GetNameEx());
543  int img_idx = m_ColumnIdList->GetColumnImageID(col);
544  colinfo.SetImage(img_idx);
545  m_ColumnIdList->SetColumn(col, colinfo);
546  }
547  }
548 }
549 
551 {
552  wxString colname = m_ColumnNameTxtCtrl->GetValue();
553 
554  if (m_CurrentColumnIdx != -1 &&
556  (size_t)m_CurrentColumnIdx < m_ImportedTableData->GetColumns().size()) {
557 
558  wxListItem item;
559  m_ColumnIdList->GetColumn(m_CurrentColumnIdx, item);
560 
561  // Set the updated name in both the listwidget here and the
562  // data source
563  m_ImportedTableData->GetColumns()[m_CurrentColumnIdx].SetName(colname.c_str().AsChar());
564  item.SetText(m_ImportedTableData->GetColumns()[m_CurrentColumnIdx].GetNameEx());
565  m_ColumnIdList->SetColumn(m_CurrentColumnIdx, item);
566  }
567 }
568 
569 
571 {
572  bool skipped = m_ImportedTableData->
573  GetColumns()[m_CurrentColumnIdx].GetSkipped();
574 
575  // Enable all column controls if column is not skipped
577 
578  // Get list of all valid bio (property) types for the current column
579  // based on the columns underlying type (id, int, real, or text)
580  vector<CTableImportColumn::eDataType> drop_down_options;
581  drop_down_options = CTableImportColumn::GetMatchingDataTypes(
583 
584  // Get current DataType (which may not be compatible with underlying type
585  // since that just changed)
588 
589  // Find if current data-type is compatible with new basic type. If it isn't
590  // pick the 'undefined' data-type to go with the new underlying type
591  if (std::find(drop_down_options.begin(), drop_down_options.end(), bio_type) ==
592  drop_down_options.end()) {
594  drop_down_options[drop_down_options.size()-1]);
595  }
596 
597  // Update the combo box with the current data-type.
600 
601  // Set the checked or 'x' (skipped) column image as appropriate
602  wxListItem item;
603  m_ColumnIdList->GetColumn(m_CurrentColumnIdx, item);
605  item.SetImage(img_idx);
606  item.SetText(m_ImportedTableData->GetColumns()[m_CurrentColumnIdx].GetNameEx());
607  m_ColumnIdList->SetColumn(m_CurrentColumnIdx, item);
608 
609  // Update first row which holds type information
610  m_ColumnIdList->RefreshItem(0);
611 
612  // Check if the (newly updated) column(s) require an assembly to look up ids
613  // (e.g. chromosome numbers). If so enable the assmebly selection widgets, otherwise
614  // disable them.
616 }
617 
618 
620 {
621  if (m_CurrentColumnIdx != -1 &&
623  (size_t)m_CurrentColumnIdx < m_ImportedTableData->GetColumns().size()) {
624 
625  /// Set column type based on user selection
628 
630  m_OneBasedIntCheck->SetValue(false);
631  m_OneBasedIntCheck->Enable(false);
632  }
633 }
634 
635 void CTableColumnIdPanel::OnTextFmtBtnSelected( wxCommandEvent& event )
636 {
637  if (m_CurrentColumnIdx != -1 &&
639  (size_t)m_CurrentColumnIdx < m_ImportedTableData->GetColumns().size()) {
640 
641  /// Set column type based on user selection
644 
646  m_OneBasedIntCheck->SetValue(false);
647  m_OneBasedIntCheck->Enable(false);
648  }
649 }
650 
651 void CTableColumnIdPanel::OnNumberFmtBtnSelected( wxCommandEvent& event )
652 {
653  if (m_CurrentColumnIdx != -1 &&
655  (size_t)m_CurrentColumnIdx < m_ImportedTableData->GetColumns().size()) {
656 
657  /// Set column type based on user selection
660 
662  m_OneBasedIntCheck->Enable(true);
663  m_OneBasedIntCheck->SetValue(
665  }
666 }
667 
669 {
670  if (m_CurrentColumnIdx != -1 &&
672  (size_t)m_CurrentColumnIdx < m_ImportedTableData->GetColumns().size()) {
673 
674  /// Set column type based on user selection
677 
679  m_OneBasedIntCheck->SetValue(false);
680  m_OneBasedIntCheck->Enable(false);
681  }
682 }
683 
684 void CTableColumnIdPanel::OnSkipBtnSelected( wxCommandEvent& event )
685 {
686  if (m_CurrentColumnIdx != -1 &&
688  (size_t)m_CurrentColumnIdx < m_ImportedTableData->GetColumns().size()) {
689 
690  /// Set column type based on user selection
693 
694  // Disable column controls other than format (which allows skipped/not skipped
695  // to be set)
697 
698  wxListItem item;
699  m_ColumnIdList->GetColumn(m_CurrentColumnIdx, item);
701 
702  // Set the image to indicate column status (skipped or not)
703  item.SetImage(img_idx);
704  item.SetText(m_ImportedTableData->GetColumns()[m_CurrentColumnIdx].GetNameEx());
705  m_ColumnIdList->SetColumn(m_CurrentColumnIdx, item);
706 
707  // Update first row which holds type information
708  m_ColumnIdList->RefreshItem(0);
709  }
710 
712 
713  m_OneBasedIntCheck->SetValue(false);
714  m_OneBasedIntCheck->Enable(false);
715 }
716 
718 {
719  // Update the whole control when dragging. This is needed because there
720  // may be header rows where distrubtion across columns is based on width
721  // of each column (basically they are left-justified into row irrespective
722  // of column boundaries)
723  m_ColumnIdList->Refresh();
724  event.Skip();
725 }
726 
727 void CTableColumnIdPanel::OnOneBasedIntCheckClick( wxCommandEvent& event )
728 {
729  wxString colname = m_ColumnNameTxtCtrl->GetValue();
730 
731  if (m_CurrentColumnIdx != -1 &&
733  (size_t)m_CurrentColumnIdx < m_ImportedTableData->GetColumns().size()) {
734  // Set the updated property in the data source
736  SetOneBased(m_OneBasedIntCheck->GetValue());
737  }
738 }
739 
741 {
742  // Look at column and see if it needs an assembly in order
743  // to generate proper ids, e.g. if one of the columns is a chromosome
744  // number, we need an assembly to map that to an ID.
745  if (m_CurrentColumnIdx != -1 &&
747  (size_t)m_CurrentColumnIdx < m_ImportedTableData->GetColumns().size()) {
748 
751  return false;
752 
753  /// Currently a chromosome number is the only id type that needs mapping, but rsids
754  /// may also have (optional) assembly mapping to determine from what assembly we
755  /// will query the location information.
759  return true;
760  }
761  }
762 
763  return false;
764 }
765 
767 {
770 
771  if (m_CurrentColumnIdx != -1 &&
773  (size_t)m_CurrentColumnIdx < m_ImportedTableData->GetColumns().size()) {
774 
775  /// Set column type based on user selection
777 
779 
780  // Update first row which holds type information
781  m_ColumnIdList->RefreshItem(0);
782  }
783 }
784 
786 {
787  if (NeedsAssemblyMapping()) {
789  assm_info.SetUseMapping(true);
790  m_AssemblyPanel->SetData(assm_info);
791  m_AssemblyPanel->Enable(true);
792  } else {
793  CMapAssemblyParams assm_info;
794  m_AssemblyPanel->SetData(assm_info);
795  m_AssemblyPanel->Enable(false);
796  }
798 }
799 
800 void CTableColumnIdPanel::OnAssemblyChanged ( wxCommandEvent& evt )
801 {
803 
805 
806  if (m_CurrentColumnIdx != -1 &&
808  (size_t)m_CurrentColumnIdx < m_ImportedTableData->GetColumns().size()) {
810  m_CurrentColumnIdx].SetAssembly(assm_info);
811  }
812 }
813 
EVT_CHECKBOX(ID_CADJUSTFEATURES_CHECKBOX, CAdjustFeaturesForGaps::OnKnownUnknownSelected) EVT_CHECKBOX(ID_CADJUSTFEATURES_CHECKBOX1
#define ID_SKIPBTN
#define ID_COLUMNNAMETXT
CMapAssemblyParams & GetData()
Data access.
void SetData(const CMapAssemblyParams &data)
virtual bool TransferDataFromWindow()
virtual bool TransferDataToWindow()
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
CRegistryReadView GetReadView(const string &section) const
get a read-only view at a particular level.
Definition: registry.cpp:428
void SetUseMapping(bool value)
class CRegistryReadView provides a nested hierarchical view at a particular key.
Definition: reg_view.hpp:58
string GetString(const string &key, const string &default_val=kEmptyStr) const
Definition: reg_view.cpp:246
void GetStringList(const string &key, list< string > &val) const
Definition: reg_view.cpp:268
void Set(const string &key, int val)
access a named key at this level, with no recursion
Definition: reg_view.cpp:533
wxRadioButton * m_NumberFormatBtn
wxStaticBox * m_ColumnPropertiesSizer
void SetMainTitle(const wxString &title)
CTableImportListCtrl * m_ColumnIdList
void OnCtableImportListctrlColLeftClick(wxListEvent &event)
int m_CurrentColumnIdx
Index within listctrl/datasource of column being edited or -1.
void OnDataTypePropertySelected(wxCommandEvent &event)
wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_DATATYPECOMBO
void x_InitializePropertyList()
Set values in drop down list box based on data type.
void OnSkipBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_SKIPBTN
void OnAssemblyChanged(wxCommandEvent &evt)
void OnNumberFmtBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_NUMBERFORMATBTN
void OnSeqidFormatBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_SEQIDFORMATBTN
wxRadioButton * m_SeqIdFormatBtn
void OnRealNumberFormatBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_REALNUMBERFORMATBTN
wxRadioButton * m_RealNumberFormatBtn
void OnOneBasedIntCheckClick(wxCommandEvent &event)
wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_ONEBASEDINTCHECK
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 OnCtableImportListctrlColDragging(wxListEvent &event)
void x_EnableColumnEditControls(bool b)
If a column is currently selected, the controls to edit its type and name should be available,...
wxStaticText * m_ColumnNameStaticTxt
void OnTextFmtBtnSelected(wxCommandEvent &event)
wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_TEXTFORMATBTN
bool Create(wxWindow *parent, wxWindowID id=ID_CTABLECOLUMNIDPANEL, const wxString &caption=_("Set Table Column Format"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
void SetRegistryPath(const string &path)
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
CRef< CTableImportDataSource > m_ImportedTableData
Contents of tabular file.
CAssemblySelPanel * m_AssemblyPanel
void OnColumnNametxtTextUpdated(wxCommandEvent &event)
wxEVT_COMMAND_TEXT_UPDATED event handler for ID_COLUMNNAMETXT
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
static string GetStringFromDataType(eDataType t)
Return a string version of a data-type (e.g. "Length" for eLength)
static vector< eDataType > GetMatchingDataTypes(eColumnType c)
static eDataType GetDataTypeFromString(const string &s)
Return enum data-type from string.
vector< CTableImportColumn > & GetColumns()
return the array of column data
string GetColumnName(size_t col) const
Return name of specified column.
void SetViewType(eDataViewType t)
Set/get view type.
int GetColumnImageID(int col, bool checkbox_only=false) const
Returns image ID for column headers.
void SetFixedWidthUseFields(bool b)
Set to true for lists which display rows divided into fixed length fields but do not allow those fiel...
void SetDataSource(CRef< CTableImportDataSource > ds)
Set/update data source (used to refresh view to match data source column info)
void SetDisplayTypeHeader(bool b)
If true, type information is displayed on first row.
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
#define NULL
Definition: ncbistd.hpp:225
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
END_EVENT_TABLE()
int i
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
EIPRangeType t
Definition: ncbi_localip.c:101
static static static wxID_ANY
static const string kSearchTermTag
static const string kTermHistoryTag
static const string kTableAssmSearchPath
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Wed Nov 29 02:21:18 2023 by modify_doxy.py rev. 669887