54 lines
1.8 KiB
C#
54 lines
1.8 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using JD.Asset;
|
|
using JD.Asset.Database;
|
|
using JD.AssetBrowser.ViewModel;
|
|
using Plume.Icons;
|
|
using Plume.Interfaces.WPF.Actions;
|
|
using Plume.Interfaces.WPF.Dialogs;
|
|
|
|
namespace JD.AssetBrowser.Actions.Asset
|
|
{
|
|
public class ShowDependenciesAction : Plume.Interfaces.WPF.Actions.Action<AssetViewModel>
|
|
{
|
|
/// <inheritdoc />
|
|
public ShowDependenciesAction() :
|
|
base("Show dependencies", "Show the dependencies of selected asset", StandardIcon.GraphTopToBottom, null, null)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void Execute(IActionContext context, AssetViewModel asset)
|
|
{
|
|
var task = ShowDependenciesAsync(context, asset);
|
|
}
|
|
|
|
private async Task ShowDependenciesAsync(IActionContext context, AssetViewModel asset)
|
|
{
|
|
var dialogManager = context.DialogManager;
|
|
if (!AssetDatabase.Instance.DependenciesParsed)
|
|
{
|
|
var result = dialogManager.ShowMessageBox("", "Dependencies will be analyzed first.", StandardIcon.Info, StandardButton.Ok, StandardButton.Cancel);
|
|
if (result.StandardButton == StandardButton.Ok)
|
|
{
|
|
await AssetDatabase.Instance.RefreshDependenciesAsync();
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
if (asset.IsFolder && asset.Model.Dependencies.Count == 0 && asset.Model.ReferencedBy.Count == 0)
|
|
{
|
|
asset.Model.FindDependencies();
|
|
}
|
|
AssetBrowserContext.Instance.Selection = asset.Model;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override bool CanExecute(IActionContext context, AssetViewModel parameter)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|