| 623 | } |
| 624 | |
| 625 | void ReadableEditorDialog::updateGuiView(wxWindow* parent, |
| 626 | const std::string& guiPath, |
| 627 | const std::string& xDataName, |
| 628 | const std::string& xDataPath) |
| 629 | { |
| 630 | // If the name of an xData object is passed it will be rendered instead of the current |
| 631 | // xData object, to enable previewing of XData definitions induced by the XDataSelector. |
| 632 | if (!xDataName.empty()) |
| 633 | { |
| 634 | XData::XDataPtr xd; |
| 635 | XData::XDataMap xdMap; |
| 636 | |
| 637 | if (_xdLoader->importDef(xDataName, xdMap, xDataPath)) |
| 638 | { |
| 639 | xd = xdMap.begin()->second; |
| 640 | _guiView->setGui(GlobalGuiManager().getGui(xd->getGuiPage(0))); |
| 641 | } |
| 642 | else |
| 643 | { |
| 644 | std::string msg = fmt::format(_("Failed to import {0}."), xDataName); |
| 645 | msg += "\n\n"; |
| 646 | msg += _("Do you want to open the import summary?"); |
| 647 | |
| 648 | wxutil::Messagebox dialog(_("Import failed"), |
| 649 | msg, ui::IDialog::MESSAGE_ASK, parent ? parent : this |
| 650 | ); |
| 651 | |
| 652 | if (dialog.run() == ui::IDialog::RESULT_YES) |
| 653 | { |
| 654 | showXdImportSummary(); |
| 655 | } |
| 656 | return; |
| 657 | } |
| 658 | |
| 659 | const gui::IGuiPtr& gui = _guiView->getGui(); |
| 660 | |
| 661 | if (gui == NULL) |
| 662 | { |
| 663 | std::string msg = fmt::format(_("Failed to load gui definition {0}."), xd->getGuiPage(0)); |
| 664 | msg += "\n\n"; |
| 665 | msg += _("Do you want to open the import summary?"); |
| 666 | |
| 667 | wxutil::Messagebox dialog(_("Import failed"), |
| 668 | msg, ui::IDialog::MESSAGE_ASK, parent ? parent : this |
| 669 | ); |
| 670 | |
| 671 | if (dialog.run() == ui::IDialog::RESULT_YES) |
| 672 | { |
| 673 | showGuiImportSummary(); |
| 674 | } |
| 675 | return; |
| 676 | } |
| 677 | |
| 678 | // Load data from xdata into the GUI's state variables |
| 679 | if (xd->getPageLayout() == XData::OneSided) |
| 680 | { |
| 681 | // One-sided has title and body |
| 682 | gui->setStateString("title", xd->getPageContent(XData::Title, 0, XData::Left)); |
no test coverage detected