2019-01-14 16:55:55 -05:00
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
# include "DataTableRowUtlis.h"
# include "DetailWidgetRow.h"
# include "Editor.h"
# include "Framework/MultiBox/MultiBoxBuilder.h"
# include "Textures/SlateIcon.h"
# include "Widgets/SWidget.h"
2019-04-09 17:09:42 -04:00
# include "Framework/Commands/GenericCommands.h"
# include "IDataTableEditor.h"
2019-01-14 16:55:55 -05:00
# define LOCTEXT_NAMESPACE "FDataTableRowUtils"
const FText FDataTableRowUtils : : SearchForReferencesActionName = LOCTEXT ( " FDataTableRowUtils_SearchForReferences " , " Find Row References " ) ;
const FText FDataTableRowUtils : : SearchForReferencesActionTooltip = LOCTEXT ( " FDataTableRowUtils_SearchForReferencesTooltip " , " Find assets that reference this Row " ) ;
2019-08-08 15:35:30 -04:00
const FText FDataTableRowUtils : : InsertNewRowActionName = LOCTEXT ( " FDataTableRowUtils_InsertNewRow " , " Insert New Row " ) ;
const FText FDataTableRowUtils : : InsertNewRowActionTooltip = LOCTEXT ( " FDataTableRowUtils_InsertNewRowTooltip " , " Insert a new Row " ) ;
2019-07-25 09:42:23 -04:00
2019-08-08 15:35:30 -04:00
const FText FDataTableRowUtils : : InsertNewRowAboveActionName = LOCTEXT ( " FDataTableRowUtils_InsertNewRowAbove " , " Insert New Row Above " ) ;
const FText FDataTableRowUtils : : InsertNewRowAboveActionTooltip = LOCTEXT ( " FDataTableRowUtils_InsertNewRowAboveTooltip " , " Insert a new Row above the current selection " ) ;
const FText FDataTableRowUtils : : InsertNewRowBelowActionName = LOCTEXT ( " FDataTableRowUtils_InsertNewRowBelow " , " Insert New Row Below " ) ;
const FText FDataTableRowUtils : : InsertNewRowBelowActionTooltip = LOCTEXT ( " FDataTableRowUtils_InsertNewRowBelowTooltip " , " Insert a new Row below the current selection " ) ;
2019-08-19 15:32:05 -04:00
const FText FDataTableRowUtils : : MoveToBottomActionName = LOCTEXT ( " FDataTableRowUtils_MoveToBottom " , " Move Row To Bottom " ) ;
const FText FDataTableRowUtils : : MoveToBottomActionTooltip = LOCTEXT ( " FDataTableRowUtils_MoveToBottomTooltip " , " Move selected Row to the bottom " ) ;
const FText FDataTableRowUtils : : MoveToTopActionName = LOCTEXT ( " FDataTableRowUtils_MoveToTopAction " , " Move Row to Top " ) ;
const FText FDataTableRowUtils : : MoveToTopActionTooltip = LOCTEXT ( " FDataTableRowUtils_MoveToTopActionTooltip " , " Move selected Row to the top " ) ;
2019-08-08 15:35:30 -04:00
TSharedRef < SWidget > FDataTableRowUtils : : MakeRowActionsMenu ( TSharedPtr < IDataTableEditor > Editor , FExecuteAction SearchForReferencesAction , FExecuteAction InsertNewRowAction ,
2019-08-19 15:32:05 -04:00
FExecuteAction InsertNewRowAboveAction , FExecuteAction InsertNewRowBelowAction , FExecuteAction MoveToBottomAction , FExecuteAction MoveToTopAction )
2019-01-14 16:55:55 -05:00
{
2019-08-19 15:32:05 -04:00
if ( SearchForReferencesAction . IsBound ( ) & & InsertNewRowAction . IsBound ( ) & & InsertNewRowAboveAction . IsBound ( )
& & InsertNewRowBelowAction . IsBound ( ) )
2019-01-14 16:55:55 -05:00
{
2019-04-09 17:09:42 -04:00
FMenuBuilder MenuBuilder ( true , Editor - > GetToolkitCommands ( ) ) ;
2019-07-25 09:42:23 -04:00
MenuBuilder . AddMenuEntry ( InsertNewRowActionName , InsertNewRowActionTooltip ,
2019-08-26 14:47:18 -04:00
FSlateIcon ( FEditorStyle : : GetStyleSetName ( ) , " DataTableEditor.Add " ) , FUIAction ( InsertNewRowAction ) ) ;
2019-08-08 15:35:30 -04:00
MenuBuilder . AddMenuEntry ( InsertNewRowAboveActionName , InsertNewRowAboveActionTooltip ,
FSlateIcon ( ) , FUIAction ( InsertNewRowAboveAction ) ) ;
MenuBuilder . AddMenuEntry ( InsertNewRowBelowActionName , InsertNewRowBelowActionTooltip ,
FSlateIcon ( ) , FUIAction ( InsertNewRowBelowAction ) ) ;
2019-04-09 17:09:42 -04:00
MenuBuilder . AddMenuEntry ( FGenericCommands : : Get ( ) . Copy ) ;
MenuBuilder . AddMenuEntry ( FGenericCommands : : Get ( ) . Paste ) ;
MenuBuilder . AddMenuEntry ( FGenericCommands : : Get ( ) . Duplicate ) ;
2019-07-23 09:21:58 -04:00
MenuBuilder . AddMenuEntry ( FGenericCommands : : Get ( ) . Rename ) ;
2019-07-24 13:11:40 -04:00
MenuBuilder . AddMenuEntry ( FGenericCommands : : Get ( ) . Delete ) ;
2019-04-09 17:09:42 -04:00
MenuBuilder . AddMenuSeparator ( ) ;
2019-08-19 15:32:05 -04:00
MenuBuilder . AddMenuEntry ( MoveToTopActionName , MoveToTopActionTooltip ,
FSlateIcon ( FEditorStyle : : GetStyleSetName ( ) , " Symbols.DoubleUpArrow " ) , FUIAction ( MoveToTopAction ) ) ;
MenuBuilder . AddMenuEntry ( MoveToBottomActionName , MoveToBottomActionTooltip ,
FSlateIcon ( FEditorStyle : : GetStyleSetName ( ) , " Symbols.DoubleDownArrow " ) , FUIAction ( MoveToBottomAction ) ) ;
MenuBuilder . AddMenuSeparator ( ) ;
2019-01-14 16:55:55 -05:00
MenuBuilder . AddMenuEntry ( SearchForReferencesActionName , SearchForReferencesActionTooltip ,
FSlateIcon ( ) , FUIAction ( SearchForReferencesAction ) ) ;
return MenuBuilder . MakeWidget ( ) ;
}
return SNullWidget : : NullWidget ;
}
void FDataTableRowUtils : : AddSearchForReferencesContextMenu ( FDetailWidgetRow & RowNameDetailWidget , FExecuteAction SearchForReferencesAction )
{
if ( SearchForReferencesAction . IsBound ( ) & & FEditorDelegates : : OnOpenReferenceViewer . IsBound ( ) )
{
RowNameDetailWidget . AddCustomContextMenuAction ( FUIAction ( SearchForReferencesAction ) , SearchForReferencesActionName ,
SearchForReferencesActionTooltip , FSlateIcon ( ) ) ;
}
}
# undef LOCTEXT_NAMESPACE