Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/CalculationTreeNodeInfoFactory.cs
===================================================================
diff -u -rd0553e74a8d5ff6534acf03faf4a8801c28bf7c0 -r6b43c39e0f54d1054729aaed5aa6dc19149ef72a
--- Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/CalculationTreeNodeInfoFactory.cs (.../CalculationTreeNodeInfoFactory.cs) (revision d0553e74a8d5ff6534acf03faf4a8801c28bf7c0)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/CalculationTreeNodeInfoFactory.cs (.../CalculationTreeNodeInfoFactory.cs) (revision 6b43c39e0f54d1054729aaed5aa6dc19149ef72a)
@@ -81,12 +81,15 @@
///
/// The icon of the .
/// The function for obtaining the child node objects.
+ /// The function for obtaining the context menu strip.
+ /// The action to perform on removing a node.
/// The type of calculation context to create a object for.
/// A object.
public static TreeNodeInfo CreateCalculationContextTreeNodeInfo(
Bitmap icon,
Func childeNodeObjects,
- Func contextMenuStrip)
+ Func contextMenuStrip,
+ Action onNodeRemoved)
where TCalculationContext : ICalculationContext
{
return new TreeNodeInfo
@@ -95,7 +98,16 @@
Image = context => icon,
EnsureVisibleOnCreate = (context, parent) => true,
ChildNodeObjects = childeNodeObjects,
- ContextMenuStrip = contextMenuStrip
+ ContextMenuStrip = contextMenuStrip,
+ CanRename = (context, parent) => true,
+ OnNodeRenamed = (context, newName) =>
+ {
+ context.WrappedData.Name = newName;
+ context.WrappedData.NotifyObservers();
+ },
+ CanRemove = (context, parentData) => CalculationContextCanRemove(context, parentData),
+ OnNodeRemoved = onNodeRemoved,
+ CanDrag = (context, parentData) => true
};
}
@@ -340,5 +352,15 @@
# endregion
# endregion
+
+ #region Helper methods for CreateCalculationContextTreeNodeInfo
+
+ private static bool CalculationContextCanRemove(ICalculationContext calculationContext, object parentNodeData)
+ {
+ var calculationGroupContext = parentNodeData as ICalculationContext;
+ return calculationGroupContext != null && calculationGroupContext.WrappedData.Children.Contains(calculationContext.WrappedData);
+ }
+
+ #endregion
}
}
\ No newline at end of file