void AWSCoreEditorMenu::InitializeResourceMappingToolAction()

in Gems/AWSCore/Code/Source/Editor/UI/AWSCoreEditorMenu.cpp [77:129]


    void AWSCoreEditorMenu::InitializeResourceMappingToolAction()
    {
#if AWSCORE_EDITOR_RESOURCE_MAPPING_TOOL_ENABLED
        AWSCoreResourceMappingToolAction* resourceMappingTool =
            new AWSCoreResourceMappingToolAction(QObject::tr(AWSResourceMappingTool[NameIndex]), nullptr);

        AzToolsFramework::ActionProperties actionProperties;
        actionProperties.m_name = AWSResourceMappingTool[NameIndex];
        auto outcome = m_actionManagerInterface->RegisterAction(AWSCore::ActionContext, AWSResourceMappingTool[IdentIndex],
            actionProperties,
            [resourceMappingTool, this]()
            {
                AZStd::string launchCommand = resourceMappingTool->GetToolLaunchCommand();
                if (launchCommand.empty())
                {
                    AZStd::string resourceMappingToolReadMePath = resourceMappingTool->GetToolReadMePath();
                    AZStd::string message = AZStd::string::format(AWSResourceMappingToolReadMeWarningText, resourceMappingToolReadMePath.c_str());
                    QMessageBox::warning(QApplication::activeWindow(), "Warning", message.c_str(), QMessageBox::Ok);
                    return;
                }
                if (m_resourceMappingToolWatcher && m_resourceMappingToolWatcher->IsProcessRunning())
                {
                    QMessageBox::information(QApplication::activeWindow(), "Info", AWSResourceMappingToolIsRunningText, QMessageBox::Ok);
                    return;
                }
                if (m_resourceMappingToolWatcher)
                {
                    m_resourceMappingToolWatcher.reset();
                }

                AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
                processLaunchInfo.m_commandlineParameters = launchCommand;
                processLaunchInfo.m_showWindow = false;
                processLaunchInfo.m_tetherLifetime = true;
                m_resourceMappingToolWatcher = AZStd::unique_ptr<AzFramework::ProcessWatcher>(
                    AzFramework::ProcessWatcher::LaunchProcess(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_NONE));

                if (!m_resourceMappingToolWatcher || !m_resourceMappingToolWatcher->IsProcessRunning())
                {
                    AZStd::string resourceMappingToolLogPath = resourceMappingTool->GetToolLogFilePath();
                    AZStd::string message = AZStd::string::format(AWSResourceMappingToolLogWarningText, resourceMappingToolLogPath.c_str());
                    QMessageBox::warning(QApplication::activeWindow(), "Warning", message.c_str(), QMessageBox::Ok);
                }
            }
        );
        AZ_Assert(outcome.IsSuccess(), "Failed to register action %s", AWSResourceMappingTool[IdentIndex]);

        m_menuManagerInterface->AddActionToMenu(AWSMenuIdentifier, AWSResourceMappingTool[IdentIndex], 0);

        m_menuManagerInterface->AddSeparatorToMenu(AWSMenuIdentifier, 0);

#endif
    }