| 442 | } |
| 443 | |
| 444 | void OnCommand( wxCommandEvent &evt ) |
| 445 | { |
| 446 | switch( evt.GetId() ) |
| 447 | { |
| 448 | case ID_SSC_MOD: |
| 449 | LoadSSCTable(); |
| 450 | break; |
| 451 | case wxID_OPEN: |
| 452 | { |
| 453 | wxFileDialog dlg( this, "Read csv file", wxEmptyString, wxEmptyString, "CSV Files (*.csv)|*.csv", wxFD_OPEN ); |
| 454 | if ( dlg.ShowModal() != wxID_OK ) return; |
| 455 | |
| 456 | wxCSVData csv; |
| 457 | if ( !csv.ReadFile( dlg.GetPath() ) ) |
| 458 | { |
| 459 | wxMessageBox("failed to read csv file"); |
| 460 | return; |
| 461 | } |
| 462 | |
| 463 | size_t nr = csv.NumRows(); |
| 464 | size_t nc = csv.NumCols(); |
| 465 | if ( nr == 0 ) nr = 1; |
| 466 | if ( nc != 2 ) nc = 2; |
| 467 | |
| 468 | m_grid->ResizeGrid( nr,2 ); |
| 469 | for( size_t i=0;i<nr;i++) |
| 470 | { |
| 471 | m_grid->SetCellValue( i, 0, csv(i,0) ); |
| 472 | m_grid->SetCellValue( i, 1, csv(i,1) ); |
| 473 | } |
| 474 | |
| 475 | } |
| 476 | break; |
| 477 | case wxID_REFRESH: |
| 478 | LoadVariables(); |
| 479 | break; |
| 480 | case wxID_SAVE: |
| 481 | { |
| 482 | wxFileDialog dlg( this, "Write csv file", wxEmptyString, wxEmptyString, "CSV Files (*.csv)|*.csv", wxFD_SAVE|wxFD_OVERWRITE_PROMPT ); |
| 483 | if ( dlg.ShowModal() != wxID_OK ) return; |
| 484 | |
| 485 | wxCSVData csv; |
| 486 | for( int i=0;i<m_grid->GetNumberRows();i++ ) |
| 487 | { |
| 488 | csv(i,0) = m_grid->GetCellValue( i, 0 ); |
| 489 | csv(i,1) = m_grid->GetCellValue( i, 1 ); |
| 490 | } |
| 491 | |
| 492 | if ( !csv.WriteFile( dlg.GetPath() )) |
| 493 | wxMessageBox("failed to write csv file"); |
| 494 | } |
| 495 | break; |
| 496 | case ID_APPLY_VTL: |
| 497 | for( size_t i=0;i<(size_t)m_grid->GetNumberRows();i++) |
| 498 | { |
| 499 | wxString ssc = m_vtlMap[ m_grid->GetCellValue(i,0) ]; |
| 500 | if ( !ssc.IsEmpty() ) |
| 501 | { |
nothing calls this directly
no test coverage detected