text: /*
   * Copyright (c) Contributors to the Open 3D Engine Project.
   * For complete copyright and license terms please see the LICENSE at the root of this distribution.
   *
   * SPDX-License-Identifier: Apache-2.0 OR MIT
   *
   */
  
  #include <Atom/Document/MaterialDocumentRequestBus.h>
  #include <Atom/Document/MaterialDocumentSettings.h>
  #include <AtomToolsFramework/Document/AtomToolsDocumentSystemRequestBus.h>
  #include <AzCore/RTTI/BehaviorContext.h>
  #include <AzCore/Serialization/EditContext.h>
  #include <AzCore/Serialization/SerializeContext.h>
  #include <Document/MaterialDocument.h>
  #include <Document/MaterialDocumentSystemComponent.h>
  
  namespace MaterialEditor
  {
      void MaterialDocumentSystemComponent::Reflect(AZ::ReflectContext* context)
      {
          MaterialDocumentSettings::Reflect(context);
  
          if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
          {
              serialize->Class<MaterialDocumentSystemComponent, AZ::Component>()
                  ->Version(0);
  
              if (AZ::EditContext* ec = serialize->GetEditContext())
              {
                  ec->Class<MaterialDocumentSystemComponent>("MaterialDocumentSystemComponent", "Tool for editing Atom material files")
                      ->ClassElement(AZ::Edit::ClassElements::EditorData, "")
                      ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("System"))
                      ->Attribute(AZ::Edit::Attributes::AutoExpand, true)
                      ;
              }
          }
  
          if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
          {
              behaviorContext->EBus<MaterialDocumentRequestBus>("MaterialDocumentRequestBus")
                  ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
                  ->Attribute(AZ::Script::Attributes::Category, "Editor")
                  ->Attribute(AZ::Script::Attributes::Module, "materialeditor")
                  ;
          }
      }
  
      void MaterialDocumentSystemComponent::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required)
      {
          required.push_back(AZ_CRC_CE("AtomToolsDocumentSystemService"));
          required.push_back(AZ_CRC_CE("AssetProcessorToolsConnection"));
          required.push_back(AZ_CRC_CE("AssetDatabaseService"));
          required.push_back(AZ_CRC_CE("PropertyManagerService"));
          required.push_back(AZ_CRC_CE("RPISystem"));
      }
  
      void MaterialDocumentSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
      {
          provided.push_back(AZ_CRC_CE("MaterialDocumentSystemService"));
      }
  
      void MaterialDocumentSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
      {
          incompatible.push_back(AZ_CRC_CE("MaterialDocumentSystemService"));
      }
  
      void MaterialDocumentSystemComponent::Init()
      {
      }
  
      void MaterialDocumentSystemComponent::Activate()
      {
          AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(
              &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Handler::RegisterDocumentType,
              []()
              {
                  return aznew MaterialDocument();
              });
      }
  
      void MaterialDocumentSystemComponent::Deactivate()
      {
      }
  }
  