Files
UnrealEngineUWP/Engine/Source/Editor/DetailCustomizations/Private/SourceCodeAccessSettingsDetails.cpp
Thomas Sarkanen 2e3d1f5aae #summary Source code access is now done via plugins
#ttp 330039 	EDITOR: Platform-agnostic editor code depends on Windows-only VSAccessor headers
#detail 	Source code access is now extensible via plugins, so any new editors can be easily added.
#add 	Added SourceCodeAccess module that routes access via plugins.
#change 	Moved much of the old VSAccessor code into a new VisualStudioSourceCodeAccess plugin.
#add 	Added a counterpart XCode plugin & migrated the code from FSourceCodeNavigation (Applescript etc.) into there.
#remove 	Removed applescript for XCode access (it is now done via code).
#remove 	Removed source code access functionality from platform layer.
#add 	Added details customization for source code access settings, so users can choose their own accessor.
#remove 	Removed dependencies on VSAccessor.
#change 	Changed API in SWidget to not require building a string to be parsed, instead this acesses and forwards filenames & line numbers.
#extra 	Tested on Mac by Mark S.
reviewed by 	Andrew.Brown

[CL 2048697 by Thomas Sarkanen in Main branch]
2014-04-23 19:19:51 -04:00

80 lines
3.0 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#include "DetailCustomizationsPrivatePCH.h"
#include "SourceCodeAccessSettingsDetails.h"
#include "ISourceCodeAccessModule.h"
#include "Runtime/Core/Public/Features/IModularFeatures.h"
#define LOCTEXT_NAMESPACE "SourceCodeAccessSettingsDetails"
TSharedRef<IDetailCustomization> FSourceCodeAccessSettingsDetails::MakeInstance()
{
return MakeShareable(new FSourceCodeAccessSettingsDetails());
}
void FSourceCodeAccessSettingsDetails::CustomizeDetails( IDetailLayoutBuilder& DetailLayout )
{
TSharedRef<IPropertyHandle> PreferredProviderPropertyHandle = DetailLayout.GetProperty("PreferredAccessor");
DetailLayout.HideProperty("PreferredAccessor");
// regenerate accessors list
Accessors.Empty();
const int32 FeatureCount = IModularFeatures::Get().GetModularFeatureImplementationCount("SourceCodeAccessor");
for(int32 FeatureIndex = 0; FeatureIndex < FeatureCount; FeatureIndex++)
{
IModularFeature* Feature = IModularFeatures::Get().GetModularFeatureImplementation("SourceCodeAccessor", FeatureIndex);
check(Feature);
ISourceCodeAccessor& Accessor = *static_cast<ISourceCodeAccessor*>(Feature);
if(Accessor.GetFName() != FName("None"))
{
Accessors.Add(MakeShareable(new FAccessorItem(Accessor.GetNameText(), Accessor.GetFName())));
}
}
IDetailCategoryBuilder& AccessorCategory = DetailLayout.EditCategory( "Accessor" );
AccessorCategory.AddCustomRow( LOCTEXT("PreferredAccessor", "Preferred Accessor").ToString() )
.NameContent()
[
PreferredProviderPropertyHandle->CreatePropertyNameWidget()
]
.ValueContent()
.MinDesiredWidth(113)
.MaxDesiredWidth(113)
[
SNew(SComboBox< TSharedPtr<FAccessorItem>>)
.ToolTipText(LOCTEXT("PreferredAccessorToolTip", "Choose the way to access source code."))
.OptionsSource(&Accessors)
.OnSelectionChanged(this, &FSourceCodeAccessSettingsDetails::OnSelectionChanged, PreferredProviderPropertyHandle)
.ContentPadding(2)
.OnGenerateWidget(this, &FSourceCodeAccessSettingsDetails::OnGenerateWidget)
.Content()
[
SNew(STextBlock)
.Text(this, &FSourceCodeAccessSettingsDetails::GetAccessorText)
.Font( IDetailLayoutBuilder::GetDetailFont() )
]
];
}
TSharedRef<SWidget> FSourceCodeAccessSettingsDetails::OnGenerateWidget( TSharedPtr<FAccessorItem> InItem )
{
return SNew(STextBlock)
.Text(InItem->Text);
}
void FSourceCodeAccessSettingsDetails::OnSelectionChanged(TSharedPtr<FAccessorItem> InItem, ESelectInfo::Type InSeletionInfo, TSharedRef<IPropertyHandle> PreferredProviderPropertyHandle)
{
PreferredProviderPropertyHandle->SetValue(InItem->Name.ToString());
ISourceCodeAccessModule& SourceCodeAccessModule = FModuleManager::LoadModuleChecked<ISourceCodeAccessModule>("SourceCodeAccess");
SourceCodeAccessModule.SetAccessor(InItem->Name);
}
FText FSourceCodeAccessSettingsDetails::GetAccessorText() const
{
ISourceCodeAccessModule& SourceCodeAccessModule = FModuleManager::LoadModuleChecked<ISourceCodeAccessModule>("SourceCodeAccess");
return SourceCodeAccessModule.GetAccessor().GetNameText();
}
#undef LOCTEXT_NAMESPACE