mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-01 02:03:32 +00:00
Conditions - Finished list support
This commit is contained in:
parent
0537adc27a
commit
693ea29600
@ -84,6 +84,5 @@ namespace Artemis.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,6 +43,16 @@ namespace Artemis.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ListOperator ListOperator { get; set; }
|
public ListOperator ListOperator { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the type of the content of the list this predicate is evaluated on
|
||||||
|
/// </summary>
|
||||||
|
public Type ListType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets whether the list contains primitives
|
||||||
|
/// </summary>
|
||||||
|
public bool IsPrimitiveList { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the currently used instance of the list data model
|
/// Gets the currently used instance of the list data model
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -87,19 +97,21 @@ namespace Artemis.Core
|
|||||||
|
|
||||||
if (dataModel != null)
|
if (dataModel != null)
|
||||||
{
|
{
|
||||||
if (!dataModel.ContainsPath(path))
|
var listType = dataModel.GetListTypeAtPath(path);
|
||||||
throw new ArtemisCoreException($"Data model of type {dataModel.GetType().Name} does not contain a property at path '{path}'");
|
if (listType == null)
|
||||||
if (dataModel.GetListTypeAtPath(path) == null)
|
throw new ArtemisCoreException($"Data model of type {dataModel.GetType().Name} does not contain a list at path '{path}'");
|
||||||
throw new ArtemisCoreException($"The path '{path}' does not contain a list");
|
|
||||||
|
ListType = listType;
|
||||||
|
IsPrimitiveList = listType.IsPrimitive || listType.IsEnum || listType == typeof(string);
|
||||||
|
|
||||||
|
ListDataModel = dataModel;
|
||||||
|
ListPropertyPath = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the old root group that was tied to the old data model
|
// Remove the old root group that was tied to the old data model
|
||||||
while (Children.Any())
|
while (Children.Any())
|
||||||
RemoveChild(Children[0]);
|
RemoveChild(Children[0]);
|
||||||
|
|
||||||
ListDataModel = dataModel;
|
|
||||||
ListPropertyPath = path;
|
|
||||||
|
|
||||||
if (dataModel == null)
|
if (dataModel == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -178,16 +190,25 @@ namespace Artemis.Core
|
|||||||
if (Entity.ListDataModelGuid == null)
|
if (Entity.ListDataModelGuid == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the data model and ensure the path is valid
|
// Get the data model ...
|
||||||
var dataModel = DataModelStore.Get(Entity.ListDataModelGuid.Value)?.DataModel;
|
var dataModel = DataModelStore.Get(Entity.ListDataModelGuid.Value)?.DataModel;
|
||||||
if (dataModel == null || !dataModel.ContainsPath(Entity.ListPropertyPath))
|
if (dataModel == null)
|
||||||
|
return;
|
||||||
|
// ... and ensure the path is valid
|
||||||
|
var listType = dataModel.GetListTypeAtPath(Entity.ListPropertyPath);
|
||||||
|
if (listType == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Populate properties and create the accessor expression
|
ListType = listType;
|
||||||
|
IsPrimitiveList = listType.IsPrimitive || listType.IsEnum || listType == typeof(string);
|
||||||
ListDataModel = dataModel;
|
ListDataModel = dataModel;
|
||||||
ListPropertyPath = Entity.ListPropertyPath;
|
ListPropertyPath = Entity.ListPropertyPath;
|
||||||
|
|
||||||
CreateExpression();
|
CreateExpression();
|
||||||
|
|
||||||
|
if (ListDataModel == null)
|
||||||
|
return;
|
||||||
|
|
||||||
// There should only be one child and it should be a group
|
// There should only be one child and it should be a group
|
||||||
if (Entity.Children.SingleOrDefault() is DataModelConditionGroupEntity rootGroup)
|
if (Entity.Children.SingleOrDefault() is DataModelConditionGroupEntity rootGroup)
|
||||||
AddChild(new DataModelConditionGroup(this, rootGroup));
|
AddChild(new DataModelConditionGroup(this, rootGroup));
|
||||||
|
|||||||
@ -51,24 +51,9 @@ namespace Artemis.Core
|
|||||||
public ConditionOperator Operator { get; private set; }
|
public ConditionOperator Operator { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the type of the content of the list this predicate is evaluated on
|
/// Gets the data model condition list this predicate belongs to
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Type ListType { get; private set; }
|
public DataModelConditionList DataModelConditionList { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets whether the list contains primitives
|
|
||||||
/// </summary>
|
|
||||||
public bool IsPrimitiveList { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the currently used instance of the list data model
|
|
||||||
/// </summary>
|
|
||||||
public DataModel ListDataModel { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the path of the list property in the <see cref="ListDataModel" />
|
|
||||||
/// </summary>
|
|
||||||
public string ListPropertyPath { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the path of the left property in the <see cref="ListType" />
|
/// Gets the path of the left property in the <see cref="ListType" />
|
||||||
@ -108,10 +93,10 @@ namespace Artemis.Core
|
|||||||
/// <param name="path">The path pointing to the left side value inside the list</param>
|
/// <param name="path">The path pointing to the left side value inside the list</param>
|
||||||
public void UpdateLeftSide(string path)
|
public void UpdateLeftSide(string path)
|
||||||
{
|
{
|
||||||
if (IsPrimitiveList)
|
if (DataModelConditionList.IsPrimitiveList)
|
||||||
throw new ArtemisCoreException("Cannot apply a left side to a predicate inside a primitive list");
|
throw new ArtemisCoreException("Cannot apply a left side to a predicate inside a primitive list");
|
||||||
if (!ListContainsInnerPath(path))
|
if (!ListContainsInnerPath(path))
|
||||||
throw new ArtemisCoreException($"List type {ListType.Name} does not contain path {path}");
|
throw new ArtemisCoreException($"List type {DataModelConditionList.ListType.Name} does not contain path {path}");
|
||||||
|
|
||||||
LeftPropertyPath = path;
|
LeftPropertyPath = path;
|
||||||
|
|
||||||
@ -128,9 +113,9 @@ namespace Artemis.Core
|
|||||||
public void UpdateRightSideDynamic(string path)
|
public void UpdateRightSideDynamic(string path)
|
||||||
{
|
{
|
||||||
if (!ListContainsInnerPath(path))
|
if (!ListContainsInnerPath(path))
|
||||||
throw new ArtemisCoreException($"List type {ListType.Name} does not contain path {path}");
|
throw new ArtemisCoreException($"List type {DataModelConditionList.ListType.Name} does not contain path {path}");
|
||||||
|
|
||||||
PredicateType = ListRightSideType.Dynamic;
|
PredicateType = ListRightSideType.DynamicList;
|
||||||
RightPropertyPath = path;
|
RightPropertyPath = path;
|
||||||
|
|
||||||
CreateExpression();
|
CreateExpression();
|
||||||
@ -155,7 +140,7 @@ namespace Artemis.Core
|
|||||||
throw new ArtemisCoreException($"Data model of type {dataModel.GetType().Name} does not contain a property at path '{path}'");
|
throw new ArtemisCoreException($"Data model of type {dataModel.GetType().Name} does not contain a property at path '{path}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
PredicateType = ListRightSideType.DynamicExternal;
|
PredicateType = ListRightSideType.Dynamic;
|
||||||
RightDataModel = dataModel;
|
RightDataModel = dataModel;
|
||||||
RightPropertyPath = path;
|
RightPropertyPath = path;
|
||||||
|
|
||||||
@ -214,11 +199,11 @@ namespace Artemis.Core
|
|||||||
/// <param name="path">The path to evaluate</param>
|
/// <param name="path">The path to evaluate</param>
|
||||||
public bool ListContainsInnerPath(string path)
|
public bool ListContainsInnerPath(string path)
|
||||||
{
|
{
|
||||||
if (ListType == null)
|
if (DataModelConditionList.ListType == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var parts = path.Split('.');
|
var parts = path.Split('.');
|
||||||
var current = ListType;
|
var current = DataModelConditionList.ListType;
|
||||||
foreach (var part in parts)
|
foreach (var part in parts)
|
||||||
{
|
{
|
||||||
var property = current.GetProperty(part);
|
var property = current.GetProperty(part);
|
||||||
@ -236,8 +221,6 @@ namespace Artemis.Core
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
DataModelStore.DataModelAdded -= DataModelStoreOnDataModelAdded;
|
|
||||||
DataModelStore.DataModelRemoved -= DataModelStoreOnDataModelRemoved;
|
|
||||||
ConditionOperatorStore.ConditionOperatorAdded -= ConditionOperatorStoreOnConditionOperatorAdded;
|
ConditionOperatorStore.ConditionOperatorAdded -= ConditionOperatorStoreOnConditionOperatorAdded;
|
||||||
ConditionOperatorStore.ConditionOperatorRemoved -= ConditionOperatorStoreOnConditionOperatorRemoved;
|
ConditionOperatorStore.ConditionOperatorRemoved -= ConditionOperatorStoreOnConditionOperatorRemoved;
|
||||||
|
|
||||||
@ -246,70 +229,13 @@ namespace Artemis.Core
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
internal void ApplyParentList()
|
|
||||||
{
|
|
||||||
var current = Parent;
|
|
||||||
while (current != null)
|
|
||||||
{
|
|
||||||
if (current is DataModelConditionList parentList)
|
|
||||||
{
|
|
||||||
UpdateList(parentList.ListDataModel, parentList.ListPropertyPath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
current = current.Parent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void UpdateList(DataModel dataModel, string path)
|
|
||||||
{
|
|
||||||
if (dataModel != null && path == null)
|
|
||||||
throw new ArtemisCoreException("If a data model is provided, a path is also required");
|
|
||||||
if (dataModel == null && path != null)
|
|
||||||
throw new ArtemisCoreException("If path is provided, a data model is also required");
|
|
||||||
|
|
||||||
if (dataModel != null)
|
|
||||||
{
|
|
||||||
var listType = dataModel.GetListTypeAtPath(path);
|
|
||||||
if (listType == null)
|
|
||||||
throw new ArtemisCoreException($"Data model of type {dataModel.GetType().Name} does not contain a list at path '{path}'");
|
|
||||||
|
|
||||||
ListType = listType;
|
|
||||||
IsPrimitiveList = listType.IsPrimitive || listType.IsEnum || listType == typeof(string);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ListType = null;
|
|
||||||
IsPrimitiveList = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ListDataModel = dataModel;
|
|
||||||
ListPropertyPath = path;
|
|
||||||
|
|
||||||
if (LeftPropertyPath != null && !ListContainsInnerPath(LeftPropertyPath))
|
|
||||||
LeftPropertyPath = null;
|
|
||||||
if (RightPropertyPath != null && !ListContainsInnerPath(RightPropertyPath))
|
|
||||||
RightPropertyPath = null;
|
|
||||||
|
|
||||||
CreateExpression();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Evaluates the condition part on the given target
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="target">
|
|
||||||
/// An instance of the list described in <see cref="ListDataModel" /> and
|
|
||||||
/// <see cref="ListPropertyPath" />
|
|
||||||
/// </param>
|
|
||||||
internal override bool EvaluateObject(object target)
|
internal override bool EvaluateObject(object target)
|
||||||
{
|
{
|
||||||
if (PredicateType == ListRightSideType.Static && CompiledListPredicate != null)
|
if (PredicateType == ListRightSideType.Static && CompiledListPredicate != null)
|
||||||
return CompiledListPredicate(target);
|
return CompiledListPredicate(target);
|
||||||
if (PredicateType == ListRightSideType.Dynamic && CompiledListPredicate != null)
|
if (PredicateType == ListRightSideType.DynamicList && CompiledListPredicate != null)
|
||||||
return CompiledListPredicate(target);
|
return CompiledListPredicate(target);
|
||||||
if (PredicateType == ListRightSideType.DynamicExternal && CompiledExternalListPredicate != null)
|
if (PredicateType == ListRightSideType.Dynamic && CompiledExternalListPredicate != null)
|
||||||
return CompiledExternalListPredicate(target, RightDataModel);
|
return CompiledExternalListPredicate(target, RightDataModel);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -321,7 +247,7 @@ namespace Artemis.Core
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
var parts = path.Split('.');
|
var parts = path.Split('.');
|
||||||
var current = ListType;
|
var current = DataModelConditionList.ListType;
|
||||||
|
|
||||||
Type result = null;
|
Type result = null;
|
||||||
foreach (var part in parts)
|
foreach (var part in parts)
|
||||||
@ -337,12 +263,6 @@ namespace Artemis.Core
|
|||||||
internal override void Save()
|
internal override void Save()
|
||||||
{
|
{
|
||||||
Entity.PredicateType = (int) PredicateType;
|
Entity.PredicateType = (int) PredicateType;
|
||||||
if (ListDataModel != null)
|
|
||||||
{
|
|
||||||
Entity.ListDataModelGuid = ListDataModel.PluginInfo.Guid;
|
|
||||||
Entity.ListPropertyPath = ListPropertyPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
Entity.LeftPropertyPath = LeftPropertyPath;
|
Entity.LeftPropertyPath = LeftPropertyPath;
|
||||||
|
|
||||||
Entity.RightDataModelGuid = RightDataModel?.PluginInfo?.Guid;
|
Entity.RightDataModelGuid = RightDataModel?.PluginInfo?.Guid;
|
||||||
@ -361,10 +281,33 @@ namespace Artemis.Core
|
|||||||
return Entity;
|
return Entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ApplyParentList()
|
||||||
|
{
|
||||||
|
var current = Parent;
|
||||||
|
|
||||||
|
while (current != null)
|
||||||
|
{
|
||||||
|
if (current is DataModelConditionList parentList)
|
||||||
|
{
|
||||||
|
DataModelConditionList = parentList;
|
||||||
|
|
||||||
|
if (LeftPropertyPath != null && !ListContainsInnerPath(LeftPropertyPath))
|
||||||
|
LeftPropertyPath = null;
|
||||||
|
if (RightPropertyPath != null && !ListContainsInnerPath(RightPropertyPath))
|
||||||
|
RightPropertyPath = null;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
current = current.Parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DataModelConditionList == null)
|
||||||
|
throw new ArtemisCoreException("This data model condition list predicate does not belong to a data model condition list");
|
||||||
|
}
|
||||||
|
|
||||||
private void Initialize()
|
private void Initialize()
|
||||||
{
|
{
|
||||||
DataModelStore.DataModelAdded += DataModelStoreOnDataModelAdded;
|
|
||||||
DataModelStore.DataModelRemoved += DataModelStoreOnDataModelRemoved;
|
|
||||||
ConditionOperatorStore.ConditionOperatorAdded += ConditionOperatorStoreOnConditionOperatorAdded;
|
ConditionOperatorStore.ConditionOperatorAdded += ConditionOperatorStoreOnConditionOperatorAdded;
|
||||||
ConditionOperatorStore.ConditionOperatorRemoved += ConditionOperatorStoreOnConditionOperatorRemoved;
|
ConditionOperatorStore.ConditionOperatorRemoved += ConditionOperatorStoreOnConditionOperatorRemoved;
|
||||||
|
|
||||||
@ -381,18 +324,18 @@ namespace Artemis.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Right side dynamic
|
// Right side dynamic
|
||||||
if (PredicateType == ListRightSideType.Dynamic && Entity.RightPropertyPath != null)
|
if (PredicateType == ListRightSideType.Dynamic && Entity.RightDataModelGuid != null && Entity.RightPropertyPath != null)
|
||||||
{
|
|
||||||
if (ListContainsInnerPath(Entity.RightPropertyPath))
|
|
||||||
UpdateRightSideDynamic(Entity.RightPropertyPath);
|
|
||||||
}
|
|
||||||
// Right side dynamic using an external data model
|
|
||||||
else if (PredicateType == ListRightSideType.Dynamic && Entity.RightDataModelGuid != null && Entity.RightPropertyPath != null)
|
|
||||||
{
|
{
|
||||||
var dataModel = DataModelStore.Get(Entity.RightDataModelGuid.Value)?.DataModel;
|
var dataModel = DataModelStore.Get(Entity.RightDataModelGuid.Value)?.DataModel;
|
||||||
if (dataModel != null && dataModel.ContainsPath(Entity.RightPropertyPath))
|
if (dataModel != null && dataModel.ContainsPath(Entity.RightPropertyPath))
|
||||||
UpdateRightSideDynamic(dataModel, Entity.RightPropertyPath);
|
UpdateRightSideDynamic(dataModel, Entity.RightPropertyPath);
|
||||||
}
|
}
|
||||||
|
// Right side dynamic inside the list
|
||||||
|
else if (PredicateType == ListRightSideType.DynamicList && Entity.RightPropertyPath != null)
|
||||||
|
{
|
||||||
|
if (ListContainsInnerPath(Entity.RightPropertyPath))
|
||||||
|
UpdateRightSideDynamic(Entity.RightPropertyPath);
|
||||||
|
}
|
||||||
// Right side static
|
// Right side static
|
||||||
else if (PredicateType == ListRightSideType.Static && Entity.RightStaticValue != null)
|
else if (PredicateType == ListRightSideType.Static && Entity.RightStaticValue != null)
|
||||||
{
|
{
|
||||||
@ -438,10 +381,10 @@ namespace Artemis.Core
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// If the operator does not support a right side, create a static expression because the right side will simply be null
|
// If the operator does not support a right side, create a static expression because the right side will simply be null
|
||||||
if (PredicateType == ListRightSideType.Dynamic && Operator.SupportsRightSide)
|
if (PredicateType == ListRightSideType.DynamicList && Operator.SupportsRightSide)
|
||||||
|
CreateDynamicListExpression();
|
||||||
|
else if (PredicateType == ListRightSideType.Dynamic && Operator.SupportsRightSide)
|
||||||
CreateDynamicExpression();
|
CreateDynamicExpression();
|
||||||
else if (PredicateType == ListRightSideType.DynamicExternal && Operator.SupportsRightSide)
|
|
||||||
CreateDynamicExternalExpression();
|
|
||||||
else
|
else
|
||||||
CreateStaticExpression();
|
CreateStaticExpression();
|
||||||
}
|
}
|
||||||
@ -460,15 +403,6 @@ namespace Artemis.Core
|
|||||||
{
|
{
|
||||||
var leftSideType = GetTypeAtInnerPath(LeftPropertyPath);
|
var leftSideType = GetTypeAtInnerPath(LeftPropertyPath);
|
||||||
if (PredicateType == ListRightSideType.Dynamic)
|
if (PredicateType == ListRightSideType.Dynamic)
|
||||||
{
|
|
||||||
if (RightPropertyPath == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var rightSideType = GetTypeAtInnerPath(RightPropertyPath);
|
|
||||||
if (!leftSideType.IsCastableFrom(rightSideType))
|
|
||||||
UpdateRightSideDynamic(null);
|
|
||||||
}
|
|
||||||
else if (PredicateType == ListRightSideType.DynamicExternal)
|
|
||||||
{
|
{
|
||||||
if (RightDataModel == null)
|
if (RightDataModel == null)
|
||||||
return;
|
return;
|
||||||
@ -477,6 +411,15 @@ namespace Artemis.Core
|
|||||||
if (!leftSideType.IsCastableFrom(rightSideType))
|
if (!leftSideType.IsCastableFrom(rightSideType))
|
||||||
UpdateRightSideDynamic(null, null);
|
UpdateRightSideDynamic(null, null);
|
||||||
}
|
}
|
||||||
|
else if (PredicateType == ListRightSideType.DynamicList)
|
||||||
|
{
|
||||||
|
if (RightPropertyPath == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var rightSideType = GetTypeAtInnerPath(RightPropertyPath);
|
||||||
|
if (!leftSideType.IsCastableFrom(rightSideType))
|
||||||
|
UpdateRightSideDynamic(null);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (RightStaticValue != null && leftSideType.IsCastableFrom(RightStaticValue.GetType()))
|
if (RightStaticValue != null && leftSideType.IsCastableFrom(RightStaticValue.GetType()))
|
||||||
@ -509,7 +452,7 @@ namespace Artemis.Core
|
|||||||
RightStaticValue = null;
|
RightStaticValue = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateDynamicExpression()
|
private void CreateDynamicListExpression()
|
||||||
{
|
{
|
||||||
if (LeftPropertyPath == null || RightPropertyPath == null || Operator == null)
|
if (LeftPropertyPath == null || RightPropertyPath == null || Operator == null)
|
||||||
return;
|
return;
|
||||||
@ -529,7 +472,7 @@ namespace Artemis.Core
|
|||||||
CompiledListPredicate = lambda.Compile();
|
CompiledListPredicate = lambda.Compile();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateDynamicExternalExpression()
|
private void CreateDynamicExpression()
|
||||||
{
|
{
|
||||||
if (LeftPropertyPath == null || RightPropertyPath == null || RightDataModel == null || Operator == null)
|
if (LeftPropertyPath == null || RightPropertyPath == null || RightDataModel == null || Operator == null)
|
||||||
return;
|
return;
|
||||||
@ -551,12 +494,14 @@ namespace Artemis.Core
|
|||||||
|
|
||||||
private void CreateStaticExpression()
|
private void CreateStaticExpression()
|
||||||
{
|
{
|
||||||
if (!IsPrimitiveList && LeftPropertyPath == null || Operator == null)
|
if (!DataModelConditionList.IsPrimitiveList && LeftPropertyPath == null || Operator == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// List accessors share the same parameter because a list always contains one item per entry
|
// List accessors share the same parameter because a list always contains one item per entry
|
||||||
var leftSideParameter = Expression.Parameter(typeof(object), "listItem");
|
var leftSideParameter = Expression.Parameter(typeof(object), "listItem");
|
||||||
var leftSideAccessor = IsPrimitiveList ? Expression.Convert(leftSideParameter, ListType) : CreateListAccessor(LeftPropertyPath, leftSideParameter);
|
var leftSideAccessor = DataModelConditionList.IsPrimitiveList
|
||||||
|
? Expression.Convert(leftSideParameter, DataModelConditionList.ListType)
|
||||||
|
: CreateListAccessor(LeftPropertyPath, leftSideParameter);
|
||||||
|
|
||||||
// If the left side is a value type but the input is empty, this isn't a valid expression
|
// If the left side is a value type but the input is empty, this isn't a valid expression
|
||||||
if (leftSideAccessor.Type.IsValueType && RightStaticValue == null)
|
if (leftSideAccessor.Type.IsValueType && RightStaticValue == null)
|
||||||
@ -575,7 +520,7 @@ namespace Artemis.Core
|
|||||||
private Expression CreateListAccessor(string path, ParameterExpression listParameter)
|
private Expression CreateListAccessor(string path, ParameterExpression listParameter)
|
||||||
{
|
{
|
||||||
return path.Split('.').Aggregate<string, Expression>(
|
return path.Split('.').Aggregate<string, Expression>(
|
||||||
Expression.Convert(listParameter, ListType), // Cast to the appropriate type
|
Expression.Convert(listParameter, DataModelConditionList.ListType), // Cast to the appropriate type
|
||||||
Expression.Property
|
Expression.Property
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -595,31 +540,6 @@ namespace Artemis.Core
|
|||||||
|
|
||||||
#region Event handlers
|
#region Event handlers
|
||||||
|
|
||||||
private void DataModelStoreOnDataModelAdded(object sender, DataModelStoreEvent e)
|
|
||||||
{
|
|
||||||
var dataModel = e.Registration.DataModel;
|
|
||||||
if (dataModel.PluginInfo.Guid == Entity.ListDataModelGuid && dataModel.ContainsPath(Entity.ListPropertyPath))
|
|
||||||
UpdateList(dataModel, Entity.LeftPropertyPath);
|
|
||||||
if (dataModel.PluginInfo.Guid == Entity.RightDataModelGuid && dataModel.ContainsPath(Entity.RightPropertyPath))
|
|
||||||
UpdateRightSideDynamic(dataModel, Entity.RightPropertyPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DataModelStoreOnDataModelRemoved(object sender, DataModelStoreEvent e)
|
|
||||||
{
|
|
||||||
if (ListDataModel == e.Registration.DataModel)
|
|
||||||
{
|
|
||||||
CompiledListPredicate = null;
|
|
||||||
CompiledExternalListPredicate = null;
|
|
||||||
ListDataModel = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RightDataModel == e.Registration.DataModel)
|
|
||||||
{
|
|
||||||
CompiledExternalListPredicate = null;
|
|
||||||
RightDataModel = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ConditionOperatorStoreOnConditionOperatorAdded(object sender, ConditionOperatorStoreEvent e)
|
private void ConditionOperatorStoreOnConditionOperatorAdded(object sender, ConditionOperatorStoreEvent e)
|
||||||
{
|
{
|
||||||
var conditionOperator = e.Registration.ConditionOperator;
|
var conditionOperator = e.Registration.ConditionOperator;
|
||||||
@ -649,13 +569,13 @@ namespace Artemis.Core
|
|||||||
Static,
|
Static,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A dynamic right side value based on a path in the list
|
/// A dynamic right side value based on a path in a data model
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Dynamic,
|
Dynamic,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A dynamic right side value based on a path in a data model
|
/// A dynamic right side value based on a path in the list
|
||||||
/// </summary>
|
/// </summary>
|
||||||
DynamicExternal
|
DynamicList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -29,7 +29,6 @@ namespace Artemis.Core
|
|||||||
_logger.Warning(
|
_logger.Warning(
|
||||||
exception,
|
exception,
|
||||||
"Failed to deserialize display condition list predicate {list} => {left} {operator} {right}",
|
"Failed to deserialize display condition list predicate {list} => {left} {operator} {right}",
|
||||||
dataModelConditionPredicate.Entity.ListPropertyPath,
|
|
||||||
dataModelConditionPredicate.Entity.LeftPropertyPath,
|
dataModelConditionPredicate.Entity.LeftPropertyPath,
|
||||||
dataModelConditionPredicate.Entity.OperatorType,
|
dataModelConditionPredicate.Entity.OperatorType,
|
||||||
dataModelConditionPredicate.Entity.RightPropertyPath
|
dataModelConditionPredicate.Entity.RightPropertyPath
|
||||||
|
|||||||
@ -6,10 +6,7 @@ namespace Artemis.Storage.Entities.Profile.Conditions
|
|||||||
public class DataModelConditionListPredicateEntity : DataModelConditionPartEntity
|
public class DataModelConditionListPredicateEntity : DataModelConditionPartEntity
|
||||||
{
|
{
|
||||||
public int PredicateType { get; set; }
|
public int PredicateType { get; set; }
|
||||||
|
|
||||||
public Guid? ListDataModelGuid { get; set; }
|
|
||||||
public string ListPropertyPath { get; set; }
|
|
||||||
|
|
||||||
public string LeftPropertyPath { get; set; }
|
public string LeftPropertyPath { get; set; }
|
||||||
|
|
||||||
public Guid? RightDataModelGuid { get; set; }
|
public Guid? RightDataModelGuid { get; set; }
|
||||||
|
|||||||
@ -24,6 +24,7 @@ namespace Artemis.UI.Shared.Input
|
|||||||
private bool _isEnabled = true;
|
private bool _isEnabled = true;
|
||||||
private string _placeholder = "Select a property";
|
private string _placeholder = "Select a property";
|
||||||
private DataModelVisualizationViewModel _selectedPropertyViewModel;
|
private DataModelVisualizationViewModel _selectedPropertyViewModel;
|
||||||
|
private Type[] _filterTypes;
|
||||||
|
|
||||||
internal DataModelDynamicViewModel(Module module, ISettingsService settingsService, IDataModelUIService dataModelUIService)
|
internal DataModelDynamicViewModel(Module module, ISettingsService settingsService, IDataModelUIService dataModelUIService)
|
||||||
{
|
{
|
||||||
@ -43,7 +44,6 @@ namespace Artemis.UI.Shared.Input
|
|||||||
set => SetAndNotify(ref _buttonBrush, value);
|
set => SetAndNotify(ref _buttonBrush, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public string Placeholder
|
public string Placeholder
|
||||||
{
|
{
|
||||||
get => _placeholder;
|
get => _placeholder;
|
||||||
@ -56,7 +56,16 @@ namespace Artemis.UI.Shared.Input
|
|||||||
set => SetAndNotify(ref _isEnabled, value);
|
set => SetAndNotify(ref _isEnabled, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type[] FilterTypes { get; set; }
|
public Type[] FilterTypes
|
||||||
|
{
|
||||||
|
get => _filterTypes;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (!SetAndNotify(ref _filterTypes, value)) return;
|
||||||
|
DataModelViewModel?.ApplyTypeFilter(true, FilterTypes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public DelegateCommand SelectPropertyCommand { get; }
|
public DelegateCommand SelectPropertyCommand { get; }
|
||||||
public PluginSetting<bool> ShowDataModelValues { get; }
|
public PluginSetting<bool> ShowDataModelValues { get; }
|
||||||
|
|
||||||
|
|||||||
@ -24,10 +24,10 @@ namespace Artemis.UI.Screens.Modules
|
|||||||
|
|
||||||
public Module Module { get; }
|
public Module Module { get; }
|
||||||
|
|
||||||
protected override void OnActivate()
|
protected override void OnInitialActivate()
|
||||||
{
|
{
|
||||||
AddTabs();
|
AddTabs();
|
||||||
base.OnActivate();
|
base.OnInitialActivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddTabs()
|
private void AddTabs()
|
||||||
|
|||||||
@ -45,7 +45,7 @@
|
|||||||
</Button>
|
</Button>
|
||||||
<Button Grid.Row="0"
|
<Button Grid.Row="0"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
ToolTip="Change the operator of the group"
|
ToolTip="Change the operator of the group, determining which conditions should match"
|
||||||
Style="{StaticResource DataModelConditionButtonLeftClickMenu}"
|
Style="{StaticResource DataModelConditionButtonLeftClickMenu}"
|
||||||
Background="#E74C4C"
|
Background="#E74C4C"
|
||||||
BorderBrush="#E74C4C"
|
BorderBrush="#E74C4C"
|
||||||
@ -54,10 +54,22 @@
|
|||||||
Visibility="{Binding DisplayBooleanOperator, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
Visibility="{Binding DisplayBooleanOperator, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||||
<Button.ContextMenu>
|
<Button.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem Header="And" Command="{s:Action SelectBooleanOperator}" CommandParameter="And" />
|
<MenuItem Header="And"
|
||||||
<MenuItem Header="Or" Command="{s:Action SelectBooleanOperator}" CommandParameter="Or" />
|
Command="{s:Action SelectBooleanOperator}"
|
||||||
<MenuItem Header="And not" Command="{s:Action SelectBooleanOperator}" CommandParameter="AndNot" />
|
CommandParameter="And"
|
||||||
<MenuItem Header="Or not" Command="{s:Action SelectBooleanOperator}" CommandParameter="OrNot" />
|
ToolTip="All the conditions in the group should evaluate to true" />
|
||||||
|
<MenuItem Header="Or"
|
||||||
|
Command="{s:Action SelectBooleanOperator}"
|
||||||
|
CommandParameter="Or"
|
||||||
|
ToolTip="Any of the conditions in the group should evaluate to true"/>
|
||||||
|
<MenuItem Header="And not"
|
||||||
|
Command="{s:Action SelectBooleanOperator}"
|
||||||
|
CommandParameter="AndNot"
|
||||||
|
ToolTip="All the conditions in the group should evaluate to false"/>
|
||||||
|
<MenuItem Header="Or not"
|
||||||
|
Command="{s:Action SelectBooleanOperator}"
|
||||||
|
CommandParameter="OrNot"
|
||||||
|
ToolTip="Any of the conditions in the group should evaluate to false"/>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</Button.ContextMenu>
|
</Button.ContextMenu>
|
||||||
</Button>
|
</Button>
|
||||||
@ -90,7 +102,7 @@
|
|||||||
<Converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
|
<Converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
|
||||||
</ContextMenu.Resources>
|
</ContextMenu.Resources>
|
||||||
<MenuItem Header="Add static condition"
|
<MenuItem Header="Add static condition"
|
||||||
ToolTip="A condition that compares a data model property to a static input"
|
ToolTip="A condition that compares with a static input"
|
||||||
Command="{s:Action AddCondition}"
|
Command="{s:Action AddCondition}"
|
||||||
CommandParameter="Static">
|
CommandParameter="Static">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
@ -98,18 +110,28 @@
|
|||||||
</MenuItem.Icon>
|
</MenuItem.Icon>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem Header="Add dynamic condition"
|
<MenuItem Header="Add dynamic condition"
|
||||||
ToolTip="A condition that compares two data model properties"
|
ToolTip="A condition that compares with a data model property"
|
||||||
Command="{s:Action AddCondition}"
|
Command="{s:Action AddCondition}"
|
||||||
CommandParameter="Dynamic">
|
CommandParameter="Dynamic">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<materialDesign:PackIcon Kind="InsertLink" />
|
<materialDesign:PackIcon Kind="Link" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="Add self condition"
|
||||||
|
ToolTip="A condition that compares with a property contained in the list"
|
||||||
|
Command="{s:Action AddCondition}"
|
||||||
|
CommandParameter="DynamicList"
|
||||||
|
IsEnabled="{Binding Data.DynamicListConditionSupported, Source={StaticResource DataContextProxy}}"
|
||||||
|
Visibility="{Binding Data.IsListGroup, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Source={StaticResource DataContextProxy}}">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<materialDesign:PackIcon Kind="UndoVariant" />
|
||||||
</MenuItem.Icon>
|
</MenuItem.Icon>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem Header="Add list condition"
|
<MenuItem Header="Add list condition"
|
||||||
ToolTip="A condition that evaluates on items in a list"
|
ToolTip="A condition that evaluates on items in a list"
|
||||||
Command="{s:Action AddCondition}"
|
Command="{s:Action AddCondition}"
|
||||||
CommandParameter="List"
|
CommandParameter="List"
|
||||||
IsEnabled="{Binding Data.IsListGroup, Converter={StaticResource InverseBooleanConverter}, Source={StaticResource DataContextProxy}}">
|
Visibility="{Binding Data.IsListGroup, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Source={StaticResource DataContextProxy}}">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<materialDesign:PackIcon Kind="FormatListBulleted" />
|
<materialDesign:PackIcon Kind="FormatListBulleted" />
|
||||||
</MenuItem.Icon>
|
</MenuItem.Icon>
|
||||||
|
|||||||
@ -25,6 +25,11 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
: base(dataModelConditionGroup)
|
: base(dataModelConditionGroup)
|
||||||
{
|
{
|
||||||
IsListGroup = isListGroup;
|
IsListGroup = isListGroup;
|
||||||
|
if (IsListGroup)
|
||||||
|
DynamicListConditionSupported = !((DataModelConditionList) dataModelConditionGroup.Parent).IsPrimitiveList;
|
||||||
|
else
|
||||||
|
DynamicListConditionSupported = false;
|
||||||
|
|
||||||
_profileEditorService = profileEditorService;
|
_profileEditorService = profileEditorService;
|
||||||
_dataModelConditionsVmFactory = dataModelConditionsVmFactory;
|
_dataModelConditionsVmFactory = dataModelConditionsVmFactory;
|
||||||
|
|
||||||
@ -38,7 +43,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool IsListGroup { get; }
|
public bool IsListGroup { get; }
|
||||||
|
public bool DynamicListConditionSupported { get; }
|
||||||
public DataModelConditionGroup DataModelConditionGroup => (DataModelConditionGroup) Model;
|
public DataModelConditionGroup DataModelConditionGroup => (DataModelConditionGroup) Model;
|
||||||
|
|
||||||
public bool IsRootGroup
|
public bool IsRootGroup
|
||||||
@ -81,8 +86,8 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
else
|
else
|
||||||
DataModelConditionGroup.AddChild(new DataModelConditionListPredicate(DataModelConditionGroup, ListRightSideType.Dynamic));
|
DataModelConditionGroup.AddChild(new DataModelConditionListPredicate(DataModelConditionGroup, ListRightSideType.Dynamic));
|
||||||
}
|
}
|
||||||
else if (type == "DynamicExternal" && IsListGroup)
|
else if (type == "DynamicList" && IsListGroup)
|
||||||
DataModelConditionGroup.AddChild(new DataModelConditionListPredicate(DataModelConditionGroup, ListRightSideType.DynamicExternal));
|
DataModelConditionGroup.AddChild(new DataModelConditionListPredicate(DataModelConditionGroup, ListRightSideType.DynamicList));
|
||||||
else if (type == "List" && !IsListGroup)
|
else if (type == "List" && !IsListGroup)
|
||||||
DataModelConditionGroup.AddChild(new DataModelConditionList(DataModelConditionGroup));
|
DataModelConditionGroup.AddChild(new DataModelConditionList(DataModelConditionGroup));
|
||||||
|
|
||||||
|
|||||||
@ -126,7 +126,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
var listDataModelGuid = DataModelConditionListPredicate.ListDataModel.PluginInfo.Guid;
|
var listDataModelGuid = DataModelConditionListPredicate.DataModelConditionList.ListDataModel.PluginInfo.Guid;
|
||||||
if (!_isPrimitiveList)
|
if (!_isPrimitiveList)
|
||||||
{
|
{
|
||||||
LeftSideSelectionViewModel.FilterTypes = _supportedInputTypes.ToArray();
|
LeftSideSelectionViewModel.FilterTypes = _supportedInputTypes.ToArray();
|
||||||
@ -137,7 +137,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
}
|
}
|
||||||
|
|
||||||
var leftSideType = _isPrimitiveList
|
var leftSideType = _isPrimitiveList
|
||||||
? DataModelConditionListPredicate.ListType
|
? DataModelConditionListPredicate.DataModelConditionList.ListType
|
||||||
: LeftSideSelectionViewModel.SelectedPropertyViewModel?.PropertyInfo?.PropertyType;
|
: LeftSideSelectionViewModel.SelectedPropertyViewModel?.PropertyInfo?.PropertyType;
|
||||||
|
|
||||||
// Get the supported operators
|
// Get the supported operators
|
||||||
@ -148,7 +148,8 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
SelectedOperator = DataModelConditionListPredicate.Operator;
|
SelectedOperator = DataModelConditionListPredicate.Operator;
|
||||||
|
|
||||||
// Ensure the right side has the proper VM
|
// Ensure the right side has the proper VM
|
||||||
if (DataModelConditionListPredicate.PredicateType == ListRightSideType.Dynamic || DataModelConditionListPredicate.PredicateType == ListRightSideType.DynamicExternal)
|
if (DataModelConditionListPredicate.PredicateType == ListRightSideType.Dynamic ||
|
||||||
|
DataModelConditionListPredicate.PredicateType == ListRightSideType.DynamicList)
|
||||||
{
|
{
|
||||||
DisposeRightSideStatic();
|
DisposeRightSideStatic();
|
||||||
if (RightSideSelectionViewModel == null)
|
if (RightSideSelectionViewModel == null)
|
||||||
@ -156,17 +157,25 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
RightSideSelectionViewModel = _dataModelUIService.GetDynamicSelectionViewModel(_profileEditorService.GetCurrentModule());
|
RightSideSelectionViewModel = _dataModelUIService.GetDynamicSelectionViewModel(_profileEditorService.GetCurrentModule());
|
||||||
RightSideSelectionViewModel.ButtonBrush = (Brush) Application.Current.FindResource("PrimaryHueMidBrush");
|
RightSideSelectionViewModel.ButtonBrush = (Brush) Application.Current.FindResource("PrimaryHueMidBrush");
|
||||||
RightSideSelectionViewModel.PropertySelected += RightSideOnPropertySelected;
|
RightSideSelectionViewModel.PropertySelected += RightSideOnPropertySelected;
|
||||||
|
|
||||||
|
if (DataModelConditionListPredicate.PredicateType == ListRightSideType.DynamicList)
|
||||||
|
RightSideSelectionViewModel.ChangeDataModel((DataModelPropertiesViewModel) GetListDataModel());
|
||||||
}
|
}
|
||||||
|
|
||||||
RightSideSelectionViewModel.FilterTypes = new[] {leftSideType};
|
RightSideSelectionViewModel.FilterTypes = new[] {leftSideType};
|
||||||
if (DataModelConditionListPredicate.PredicateType == ListRightSideType.Dynamic)
|
if (DataModelConditionListPredicate.PredicateType == ListRightSideType.Dynamic)
|
||||||
|
{
|
||||||
|
RightSideSelectionViewModel.PopulateSelectedPropertyViewModel(
|
||||||
|
DataModelConditionListPredicate.RightDataModel,
|
||||||
|
DataModelConditionListPredicate.RightPropertyPath
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
RightSideSelectionViewModel.SelectedPropertyViewModel = RightSideSelectionViewModel.DataModelViewModel.GetChildByPath(
|
RightSideSelectionViewModel.SelectedPropertyViewModel = RightSideSelectionViewModel.DataModelViewModel.GetChildByPath(
|
||||||
listDataModelGuid, DataModelConditionListPredicate.RightPropertyPath
|
listDataModelGuid, DataModelConditionListPredicate.RightPropertyPath
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
RightSideSelectionViewModel.PopulateSelectedPropertyViewModel(DataModelConditionListPredicate.RightDataModel, DataModelConditionListPredicate.RightPropertyPath);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -195,16 +204,19 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
|
|
||||||
public void ApplyRightSideDynamic()
|
public void ApplyRightSideDynamic()
|
||||||
{
|
{
|
||||||
if (DataModelConditionListPredicate.ListContainsInnerPath(RightSideSelectionViewModel.SelectedPropertyViewModel.PropertyPath))
|
if (DataModelConditionListPredicate.PredicateType == ListRightSideType.Dynamic)
|
||||||
DataModelConditionListPredicate.UpdateRightSideDynamic(RightSideSelectionViewModel.SelectedPropertyViewModel.PropertyPath);
|
{
|
||||||
else
|
|
||||||
DataModelConditionListPredicate.UpdateRightSideDynamic(
|
DataModelConditionListPredicate.UpdateRightSideDynamic(
|
||||||
RightSideSelectionViewModel.SelectedPropertyViewModel.DataModel,
|
RightSideSelectionViewModel.SelectedPropertyViewModel.DataModel,
|
||||||
RightSideSelectionViewModel.SelectedPropertyViewModel.PropertyPath
|
RightSideSelectionViewModel.SelectedPropertyViewModel.PropertyPath
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
else if (DataModelConditionListPredicate.PredicateType == ListRightSideType.DynamicList)
|
||||||
|
{
|
||||||
|
DataModelConditionListPredicate.UpdateRightSideDynamic(RightSideSelectionViewModel.SelectedPropertyViewModel.PropertyPath);
|
||||||
|
}
|
||||||
|
|
||||||
_profileEditorService.UpdateSelectedProfileElement();
|
_profileEditorService.UpdateSelectedProfileElement();
|
||||||
|
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,13 +238,10 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
|
|||||||
|
|
||||||
private DataModelVisualizationViewModel GetListDataModel()
|
private DataModelVisualizationViewModel GetListDataModel()
|
||||||
{
|
{
|
||||||
if (DataModelConditionListPredicate.ListDataModel == null || DataModelConditionListPredicate.ListPropertyPath == null)
|
|
||||||
throw new ArtemisUIException("Cannot create a list predicate without first selecting a target list");
|
|
||||||
|
|
||||||
var dataModel = _dataModelUIService.GetPluginDataModelVisualization(_profileEditorService.GetCurrentModule(), true);
|
var dataModel = _dataModelUIService.GetPluginDataModelVisualization(_profileEditorService.GetCurrentModule(), true);
|
||||||
var listDataModel = (DataModelListViewModel) dataModel.GetChildByPath(
|
var listDataModel = (DataModelListViewModel) dataModel.GetChildByPath(
|
||||||
DataModelConditionListPredicate.ListDataModel.PluginInfo.Guid,
|
DataModelConditionListPredicate.DataModelConditionList.ListDataModel.PluginInfo.Guid,
|
||||||
DataModelConditionListPredicate.ListPropertyPath
|
DataModelConditionListPredicate.DataModelConditionList.ListPropertyPath
|
||||||
);
|
);
|
||||||
|
|
||||||
return listDataModel.GetListTypeViewModel(_dataModelUIService);
|
return listDataModel.GetListTypeViewModel(_dataModelUIService);
|
||||||
|
|||||||
@ -54,13 +54,27 @@
|
|||||||
BorderBrush="#7B7B7B"
|
BorderBrush="#7B7B7B"
|
||||||
Content="{Binding SelectedListOperator}"
|
Content="{Binding SelectedListOperator}"
|
||||||
Click="PropertyButton_OnClick"
|
Click="PropertyButton_OnClick"
|
||||||
HorizontalAlignment="Left">
|
HorizontalAlignment="Left"
|
||||||
|
ToolTip="Change the list operator, determining how the list contents should match">
|
||||||
<Button.ContextMenu>
|
<Button.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem Header="Any" Command="{s:Action SelectListOperator}" CommandParameter="Any" />
|
<MenuItem Header="Any"
|
||||||
<MenuItem Header="All" Command="{s:Action SelectListOperator}" CommandParameter="All" />
|
Command="{s:Action SelectListOperator}"
|
||||||
<MenuItem Header="None" Command="{s:Action SelectListOperator}" CommandParameter="None" />
|
CommandParameter="Any"
|
||||||
<MenuItem Header="Count (NYI)" Command="{s:Action SelectListOperator}" CommandParameter="Count" IsEnabled="False" />
|
ToolTip="Any of the list items should evaluate to true"/>
|
||||||
|
<MenuItem Header="All"
|
||||||
|
Command="{s:Action SelectListOperator}"
|
||||||
|
CommandParameter="All"
|
||||||
|
ToolTip="All of the list items should evaluate to true"/>
|
||||||
|
<MenuItem Header="None"
|
||||||
|
Command="{s:Action SelectListOperator}"
|
||||||
|
CommandParameter="None"
|
||||||
|
ToolTip="None of the list items should evaluate to true"/>
|
||||||
|
<MenuItem Header="Count (NYI)"
|
||||||
|
Command="{s:Action SelectListOperator}"
|
||||||
|
CommandParameter="Count"
|
||||||
|
IsEnabled="False"
|
||||||
|
ToolTip="A specific amount of the list items should evaluate to true"/>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</Button.ContextMenu>
|
</Button.ContextMenu>
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user