Index: Core/Common/src/Core.Common.Controls.TreeView/TreeNodeInfo.cs =================================================================== diff -u -rc07c8243b6c74fa79a77f2edbc1799375064b057 -r99b31025be8be46190cf15e58aec262a4bb18858 --- Core/Common/src/Core.Common.Controls.TreeView/TreeNodeInfo.cs (.../TreeNodeInfo.cs) (revision c07c8243b6c74fa79a77f2edbc1799375064b057) +++ Core/Common/src/Core.Common.Controls.TreeView/TreeNodeInfo.cs (.../TreeNodeInfo.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858) @@ -77,9 +77,10 @@ /// /// Gets or sets a function for checking whether or not the tree node can be renamed. - /// The parameter represents the tree node. + /// The first parameter represents the data of the tree node. + /// The second parameter represents the data of the parent tree node. /// - public Func CanRename { get; set; } + public Func CanRename { get; set; } /// /// Gets or sets an action for obtaining the logic to perform after renaming the tree node. @@ -214,9 +215,10 @@ /// /// Gets or sets a function for checking whether or not the tree node can be renamed. - /// The parameter represents the tree node. + /// The parameter represents the data of the tree node. + /// The parameter represents the data of the parent tree node. /// - public Func CanRename { get; set; } + public Func CanRename { get; set; } /// /// Gets or sets an action for obtaining the logic to perform after renaming the tree node. @@ -317,8 +319,8 @@ ? tag => treeNodeInfo.ChildNodeObjects((TData) tag) : (Func) null, CanRename = treeNodeInfo.CanRename != null - ? sourceNode => treeNodeInfo.CanRename(sourceNode) - : (Func) null, + ? (tag, parentTag) => treeNodeInfo.CanRename((TData) tag, parentTag) + : (Func) null, OnNodeRenamed = treeNodeInfo.OnNodeRenamed != null ? (tag, name) => treeNodeInfo.OnNodeRenamed((TData) tag, name) : (Action) null, Index: Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs =================================================================== diff -u -rab8698e8e106f9157182649a379aa9f021a365d0 -r99b31025be8be46190cf15e58aec262a4bb18858 --- Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs (.../TreeViewControl.cs) (revision ab8698e8e106f9157182649a379aa9f021a365d0) +++ Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs (.../TreeViewControl.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858) @@ -201,8 +201,9 @@ private bool CanRename(TreeNode treeNode) { var treeNodeInfo = GetTreeNodeInfoForData(treeNode.Tag); + var parentTag = treeNode.Parent != null ? treeNode.Parent.Tag : null; - return treeNodeInfo.CanRename != null && treeNodeInfo.CanRename(treeNode); + return treeNodeInfo.CanRename != null && treeNodeInfo.CanRename(treeNode.Tag, parentTag); } private bool CanRemove(TreeNode treeNode) Index: Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs =================================================================== diff -u -rb8e09b3d2c44242360c4426659bcf30a0d674df3 -r99b31025be8be46190cf15e58aec262a4bb18858 --- Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs (.../ContextMenuBuilderTest.cs) (revision b8e09b3d2c44242360c4426659bcf30a0d674df3) +++ Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs (.../ContextMenuBuilderTest.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858) @@ -168,7 +168,7 @@ var viewCommandsMock = mocks.StrictMock(); var treeNodeInfoMock = mocks.StrictMock>(); - treeNodeInfoMock.CanRename = treeNode => treeNode.Tag == dataObject; + treeNodeInfoMock.CanRename = (data, parentData) => data == dataObject; treeViewControl.RegisterTreeNodeInfo(treeNodeInfoMock); Index: Core/Common/test/Core.Common.Gui.Test/ContextMenu/TreeViewContextMenuItemFactoryTest.cs =================================================================== diff -u -rb8e09b3d2c44242360c4426659bcf30a0d674df3 -r99b31025be8be46190cf15e58aec262a4bb18858 --- Core/Common/test/Core.Common.Gui.Test/ContextMenu/TreeViewContextMenuItemFactoryTest.cs (.../TreeViewContextMenuItemFactoryTest.cs) (revision b8e09b3d2c44242360c4426659bcf30a0d674df3) +++ Core/Common/test/Core.Common.Gui.Test/ContextMenu/TreeViewContextMenuItemFactoryTest.cs (.../TreeViewContextMenuItemFactoryTest.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858) @@ -137,9 +137,9 @@ treeNodeMock.Expect(tn => tn.Tag).Return(dataObject); - treeNodeInfoMock.CanRename = tn => + treeNodeInfoMock.CanRename = (data, parentData) => { - if (tn == treeNodeMock) + if (data == dataObject) { return canRename; } Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs =================================================================== diff -u -rc07c8243b6c74fa79a77f2edbc1799375064b057 -r99b31025be8be46190cf15e58aec262a4bb18858 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision c07c8243b6c74fa79a77f2edbc1799375064b057) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858) @@ -93,7 +93,7 @@ Image = assessmentSectionBase => RingtoetsFormsResources.AssessmentSectionFolderIcon, ChildNodeObjects = AssessmentSectionBaseChildNodeObjects, ContextMenuStrip = AssessmentSectionBaseContextMenuStrip, - CanRename = assessmentSectionBase => true, + CanRename = (assessmentSectionBase, parentData) => true, OnNodeRenamed = AssessmentSectionBaseOnNodeRenamed, CanRemove = (assessmentSectionBase, parentNodeData) => true, OnNodeRemoved = AssessmentSectionBaseOnNodeRemoved Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionBaseTreeNodeInfoTest.cs =================================================================== diff -u -rc07c8243b6c74fa79a77f2edbc1799375064b057 -r99b31025be8be46190cf15e58aec262a4bb18858 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionBaseTreeNodeInfoTest.cs (.../AssessmentSectionBaseTreeNodeInfoTest.cs) (revision c07c8243b6c74fa79a77f2edbc1799375064b057) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionBaseTreeNodeInfoTest.cs (.../AssessmentSectionBaseTreeNodeInfoTest.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858) @@ -150,7 +150,7 @@ public void CanRename_Always_ReturnsTrue() { // Call - var canRename = info.CanRename(null); + var canRename = info.CanRename(null, null); // Assert Assert.IsTrue(canRename); Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs =================================================================== diff -u -rc07c8243b6c74fa79a77f2edbc1799375064b057 -r99b31025be8be46190cf15e58aec262a4bb18858 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision c07c8243b6c74fa79a77f2edbc1799375064b057) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858) @@ -80,7 +80,7 @@ Image = pipingCalculationContext => PipingFormsResources.PipingIcon, ContextMenuStrip = PipingCalculationContextContextMenuStrip, ChildNodeObjects = PipingCalculationContextChildNodeObjects, - CanRename = pipingCalculationContext => true, + CanRename = (pipingCalculationContext, parentData) => true, OnNodeRenamed = PipingCalculationContextOnNodeRenamed, CanRemove = PipingCalculationContextCanRemove, OnNodeRemoved = PipingCalculationContextOnNodeRemoved, @@ -607,7 +607,7 @@ .AddCustomItem(clearAllItem) .AddSeparator(); - var isRenamable = PipingCalculationGroupContextCanRenameNode(node); + var isRenamable = PipingCalculationGroupContextCanRenameNode(nodeData, node.Parent.Tag); var isRemovable = PipingCalculationGroupContextCanRemove(nodeData, node.Parent.Tag); if (isRenamable) @@ -684,10 +684,9 @@ } } - private bool PipingCalculationGroupContextCanRenameNode(TreeNode node) + private bool PipingCalculationGroupContextCanRenameNode(PipingCalculationGroupContext pipingCalculationGroupContext, object parentData) { - var parentNode = node.Parent; - return parentNode == null || !(parentNode.Tag is PipingFailureMechanism); + return !(parentData is PipingFailureMechanism); } private void PipingCalculationGroupContextOnNodeRenamed(PipingCalculationGroupContext nodeData, string newName) Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rc07c8243b6c74fa79a77f2edbc1799375064b057 -r99b31025be8be46190cf15e58aec262a4bb18858 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationContextTreeNodeInfoTest.cs (.../PipingCalculationContextTreeNodeInfoTest.cs) (revision c07c8243b6c74fa79a77f2edbc1799375064b057) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationContextTreeNodeInfoTest.cs (.../PipingCalculationContextTreeNodeInfoTest.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858) @@ -147,7 +147,7 @@ public void CanRenameNode_Always_ReturnTrue() { // Call - var renameAllowed = info.CanRename(null); + var renameAllowed = info.CanRename(null, null); // Assert Assert.IsTrue(renameAllowed); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rb8e09b3d2c44242360c4426659bcf30a0d674df3 -r99b31025be8be46190cf15e58aec262a4bb18858 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision b8e09b3d2c44242360c4426659bcf30a0d674df3) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858) @@ -543,16 +543,10 @@ // Setup var failureMechanism = new PipingFailureMechanism(); - var parentNode = mocks.Stub(); - parentNode.Tag = failureMechanism; - - var node = mocks.StrictMock(); - node.Expect(n => n.Parent).Return(parentNode); - mocks.ReplayAll(); // Call - bool isRenamingAllowed = info.CanRename(node); + bool isRenamingAllowed = info.CanRename(null, failureMechanism); // Assert Assert.IsFalse(isRenamingAllowed); @@ -562,17 +556,8 @@ [Test] public void CanRenameNode_EverythingElse_ReturnTrue() { - // Setup - var parentNode = mocks.Stub(); - parentNode.Tag = new object(); - - var node = mocks.StrictMock(); - node.Expect(n => n.Parent).Return(parentNode); - - mocks.ReplayAll(); - // Call - bool isRenamingAllowed = info.CanRename(node); + bool isRenamingAllowed = info.CanRename(null, null); // Assert Assert.IsTrue(isRenamingAllowed);