Index: Core/Common/src/Core.Common.Controls.TreeView/TreeNodeInfo.cs
===================================================================
diff -u -r5d0ea46dea2c2d063c7fb5c58bed3be219be1c85 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Core/Common/src/Core.Common.Controls.TreeView/TreeNodeInfo.cs (.../TreeNodeInfo.cs) (revision 5d0ea46dea2c2d063c7fb5c58bed3be219be1c85)
+++ Core/Common/src/Core.Common.Controls.TreeView/TreeNodeInfo.cs (.../TreeNodeInfo.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -63,11 +63,11 @@
///
/// Gets or sets a function for obtaining the tree node context menu.
- /// The object parameter represents the wrapped data of the tree node.
- /// The parameter represents the tree node.
+ /// The first object parameter represents the data of the tree node.
+ /// The second object parameter represents the data of the parent tree node.
/// The parameter represents the current tree view control.
///
- public Func ContextMenuStrip { get; set; }
+ public Func ContextMenuStrip { get; set; }
///
/// Gets or sets a function for obtaining child node objects.
@@ -77,8 +77,8 @@
///
/// Gets or sets a function for checking whether or not the tree node can be renamed.
- /// The first parameter represents the data of the tree node.
- /// The second parameter represents the data of the parent tree node.
+ /// The first object parameter represents the data of the tree node.
+ /// The second object parameter represents the data of the parent tree node.
///
public Func CanRename { get; set; }
@@ -117,8 +117,8 @@
///
/// Gets or sets an action for obtaining the logic to perform after checking or unchecking the tree node.
- /// The first parameter represents the data of the tree node.
- /// The second parameter represents the data of the parent tree node.
+ /// The first object parameter represents the data of the tree node.
+ /// The second object parameter represents the data of the parent tree node.
///
public Action OnNodeChecked { get; set; }
@@ -202,11 +202,11 @@
///
/// Gets or sets a function for obtaining the tree node context menu.
- /// The parameter represents the wrapped data of the tree node.
- /// The parameter represents the tree node.
+ /// The parameter represents the data of the tree node.
+ /// The object parameter represents the data of the parent tree node.
/// The parameter represents the current tree view control.
///
- public Func ContextMenuStrip { get; set; }
+ public Func ContextMenuStrip { get; set; }
///
/// Gets or sets a function for obtaining child node objects.
@@ -217,7 +217,7 @@
///
/// Gets or sets a function for checking whether or not the tree node can be renamed.
/// The parameter represents the data of the tree node.
- /// The parameter represents the data of the parent tree node.
+ /// The object parameter represents the data of the parent tree node.
///
public Func CanRename { get; set; }
@@ -257,7 +257,7 @@
///
/// Gets or sets an action for obtaining the logic to perform after checking or unchecking the tree node.
/// The parameter represents the data of the tree node.
- /// The parameter represents the data of the parent tree node.
+ /// The object parameter represents the data of the parent tree node.
///
public Action OnNodeChecked { get; set; }
@@ -315,8 +315,8 @@
? tag => treeNodeInfo.Image((TData) tag)
: (Func) null,
ContextMenuStrip = treeNodeInfo.ContextMenuStrip != null
- ? (tag, sourceNode, treeViewControl) => treeNodeInfo.ContextMenuStrip((TData) tag, sourceNode, treeViewControl)
- : (Func) null,
+ ? (tag, parentTag, treeViewControl) => treeNodeInfo.ContextMenuStrip((TData) tag, parentTag, treeViewControl)
+ : (Func) null,
ChildNodeObjects = treeNodeInfo.ChildNodeObjects != null
? tag => treeNodeInfo.ChildNodeObjects((TData) tag)
: (Func) null,
Index: Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs
===================================================================
diff -u -r5d0ea46dea2c2d063c7fb5c58bed3be219be1c85 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs (.../TreeViewControl.cs) (revision 5d0ea46dea2c2d063c7fb5c58bed3be219be1c85)
+++ Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs (.../TreeViewControl.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -130,6 +130,16 @@
return treeNode != null && CanRename(treeNode);
}
+ public void StartRenameForData(object dataObject)
+ {
+ var treeNode = GetNodeByTag(dataObject);
+
+ if (treeNode != null)
+ {
+ treeNode.BeginEdit();
+ }
+ }
+
public bool CanRemoveNodeForData(object dataObject)
{
var treeNode = GetNodeByTag(dataObject);
@@ -583,7 +593,7 @@
// Update the context menu (relevant in case of keyboard navigation in the tree view)
selectedNode.ContextMenuStrip = treeNodeInfo.ContextMenuStrip != null
- ? treeNodeInfo.ContextMenuStrip(selectedNode.Tag, selectedNode, this)
+ ? treeNodeInfo.ContextMenuStrip(selectedNode.Tag, selectedNode.Parent != null ? selectedNode.Parent.Tag : null, this)
: null;
if (treeView.ContextMenu != null && selectedNode.ContextMenuStrip != null)
@@ -649,7 +659,7 @@
// Update the context menu
clickedNode.ContextMenuStrip = treeNodeInfo.ContextMenuStrip != null
- ? treeNodeInfo.ContextMenuStrip(clickedNode.Tag, clickedNode, this)
+ ? treeNodeInfo.ContextMenuStrip(clickedNode.Tag, clickedNode.Parent != null ? clickedNode.Parent.Tag : null, this)
: null;
return;
Index: Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs
===================================================================
diff -u -rc07c8243b6c74fa79a77f2edbc1799375064b057 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs (.../ContextMenuBuilder.cs) (revision c07c8243b6c74fa79a77f2edbc1799375064b057)
+++ Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs (.../ContextMenuBuilder.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -39,7 +39,7 @@
///
/// Creates a new instance of , which uses the given to
- /// create a for the given .
+ /// create a for the given .
///
/// The from which to obtain information to render and bind actions
/// to the items of the . If null , this builder will not render items which
@@ -51,16 +51,16 @@
/// The from which
/// to obtain information to render and bind actions to the items of the .
/// If null , this builder will not render items which require this type of information.
- /// The for which to create a .
+ /// The data object for which to create a .
/// The to use while executing the actions.
/// Thrown when the required object instances could not be created based on
- /// the or .
- public ContextMenuBuilder(IApplicationFeatureCommands featureCommandHandler, IExportImportCommandHandler importExportHandler, IViewCommands viewsCommandsHandler, TreeNode treeNode, TreeViewControl treeViewControl)
+ /// the or .
+ public ContextMenuBuilder(IApplicationFeatureCommands featureCommandHandler, IExportImportCommandHandler importExportHandler, IViewCommands viewsCommandsHandler, object dataObject, TreeViewControl treeViewControl)
{
try
{
- guiItemsFactory = new GuiContextMenuItemFactory(featureCommandHandler, importExportHandler, viewsCommandsHandler, treeNode);
- treeViewItemsFactory = new TreeViewContextMenuItemFactory(treeNode, treeViewControl);
+ guiItemsFactory = new GuiContextMenuItemFactory(featureCommandHandler, importExportHandler, viewsCommandsHandler, dataObject);
+ treeViewItemsFactory = new TreeViewContextMenuItemFactory(dataObject, treeViewControl);
}
catch (ArgumentNullException e)
{
Index: Core/Common/src/Core.Common.Gui/ContextMenu/GuiContextMenuItemFactory.cs
===================================================================
diff -u -rbc173e2a73c395bf64d1d9b4ad8d81129a1cdd7c -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Core/Common/src/Core.Common.Gui/ContextMenu/GuiContextMenuItemFactory.cs (.../GuiContextMenuItemFactory.cs) (revision bc173e2a73c395bf64d1d9b4ad8d81129a1cdd7c)
+++ Core/Common/src/Core.Common.Gui/ContextMenu/GuiContextMenuItemFactory.cs (.../GuiContextMenuItemFactory.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -37,7 +37,7 @@
private readonly IApplicationFeatureCommands applicationFeatureCommandHandler;
private readonly IExportImportCommandHandler exportImportCommandHandler;
private readonly IViewCommands viewCommands;
- private readonly TreeNode treeNode;
+ private readonly object dataObject;
///
/// Creates a new instance of , which uses the
@@ -49,9 +49,9 @@
/// which contains information for creating the .
/// The which contains
/// information for creating the .
- /// The for which to create .
+ /// The data object for which to create .
/// Thrown when any input argument is null .
- public GuiContextMenuItemFactory(IApplicationFeatureCommands applicationFeatureCommandHandler, IExportImportCommandHandler exportImportCommandHandler, IViewCommands viewCommandsHandler, TreeNode treeNode)
+ public GuiContextMenuItemFactory(IApplicationFeatureCommands applicationFeatureCommandHandler, IExportImportCommandHandler exportImportCommandHandler, IViewCommands viewCommandsHandler, object dataObject)
{
if (applicationFeatureCommandHandler == null)
{
@@ -65,14 +65,14 @@
{
throw new ArgumentNullException("viewCommandsHandler", Resources.GuiContextMenuItemFactory_Can_not_create_gui_context_menu_items_without_view_commands);
}
- if (treeNode == null)
+ if (dataObject == null)
{
- throw new ArgumentNullException("treeNode", Resources.ContextMenuItemFactory_Can_not_create_context_menu_items_without_tree_node);
+ throw new ArgumentNullException("dataObject", Resources.ContextMenuItemFactory_Can_not_create_context_menu_items_without_data);
}
this.applicationFeatureCommandHandler = applicationFeatureCommandHandler;
this.exportImportCommandHandler = exportImportCommandHandler;
viewCommands = viewCommandsHandler;
- this.treeNode = treeNode;
+ this.dataObject = dataObject;
}
///
@@ -82,7 +82,6 @@
/// The created .
public ToolStripItem CreateOpenItem()
{
- object dataObject = treeNode.Tag;
bool canOpenView = viewCommands.CanOpenViewFor(dataObject);
var newItem = new ToolStripMenuItem(Resources.Open)
{
@@ -102,7 +101,6 @@
/// The created .
public ToolStripItem CreateExportItem()
{
- object dataObject = treeNode.Tag;
bool canExport = exportImportCommandHandler.CanExportFrom(dataObject);
var newItem = new ToolStripMenuItem(Resources.Export)
{
@@ -122,7 +120,6 @@
/// The created .
public ToolStripItem CreateImportItem()
{
- object dataObject = treeNode.Tag;
bool canImport = exportImportCommandHandler.CanImportOn(dataObject);
var newItem = new ToolStripMenuItem(Resources.Import)
{
@@ -142,7 +139,6 @@
/// The created .
public ToolStripItem CreatePropertiesItem()
{
- object dataObject = treeNode.Tag;
bool canShowProperties = applicationFeatureCommandHandler.CanShowPropertiesFor(dataObject);
var newItem = new ToolStripMenuItem(Resources.Properties)
{
Index: Core/Common/src/Core.Common.Gui/ContextMenu/IContextMenuBuilderProvider.cs
===================================================================
diff -u -rc07c8243b6c74fa79a77f2edbc1799375064b057 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Core/Common/src/Core.Common.Gui/ContextMenu/IContextMenuBuilderProvider.cs (.../IContextMenuBuilderProvider.cs) (revision c07c8243b6c74fa79a77f2edbc1799375064b057)
+++ Core/Common/src/Core.Common.Gui/ContextMenu/IContextMenuBuilderProvider.cs (.../IContextMenuBuilderProvider.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -32,16 +32,16 @@
{
///
/// Returns a new for creating a
- /// for the given .
+ /// for the given .
///
- /// The to have the
+ /// The data object to have the
/// create a for.
/// The to use while executing the
/// actions.
/// The which can be used to create a
- /// for .
+ /// for .
/// Thrown when the instance could
/// not be created.
- IContextMenuBuilder Get(TreeNode treeNode, TreeViewControl treeViewControl);
+ IContextMenuBuilder Get(object dataObject, TreeViewControl treeViewControl);
}
}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/ContextMenu/TreeViewContextMenuItemFactory.cs
===================================================================
diff -u -rb8e09b3d2c44242360c4426659bcf30a0d674df3 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Core/Common/src/Core.Common.Gui/ContextMenu/TreeViewContextMenuItemFactory.cs (.../TreeViewContextMenuItemFactory.cs) (revision b8e09b3d2c44242360c4426659bcf30a0d674df3)
+++ Core/Common/src/Core.Common.Gui/ContextMenu/TreeViewContextMenuItemFactory.cs (.../TreeViewContextMenuItemFactory.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -31,28 +31,28 @@
///
internal class TreeViewContextMenuItemFactory
{
- private readonly TreeNode treeNode;
+ private readonly object dataObject;
private readonly TreeViewControl treeViewControl;
///
- /// Creates a new instance of for the given .
+ /// Creates a new instance of for the given .
///
- /// The for which to create the objects.
+ /// The data object for which to create the objects.
/// The to use while executing the actions.
- /// Thrown when is null .
- public TreeViewContextMenuItemFactory(TreeNode treeNode, TreeViewControl treeViewControl)
+ /// Thrown when or is null .
+ public TreeViewContextMenuItemFactory(object dataObject, TreeViewControl treeViewControl)
{
- if (treeNode == null)
+ if (dataObject == null)
{
- throw new ArgumentNullException("treeNode", Resources.ContextMenuItemFactory_Can_not_create_context_menu_items_without_tree_node);
+ throw new ArgumentNullException("dataObject", Resources.ContextMenuItemFactory_Can_not_create_context_menu_items_without_data);
}
if (treeViewControl == null)
{
throw new ArgumentNullException("treeViewControl", Resources.ContextMenuItemFactory_Can_not_create_context_menu_items_without_tree_view_control);
}
- this.treeNode = treeNode;
+ this.dataObject = dataObject;
this.treeViewControl = treeViewControl;
}
@@ -67,9 +67,9 @@
{
ToolTipText = Resources.Rename_ToolTip,
Image = Resources.RenameIcon,
- Enabled = treeViewControl.CanRenameNodeForData(treeNode.Tag)
+ Enabled = treeViewControl.CanRenameNodeForData(dataObject)
};
- toolStripMenuItem.Click += (s, e) => treeNode.BeginEdit();
+ toolStripMenuItem.Click += (s, e) => treeViewControl.StartRenameForData(dataObject);
return toolStripMenuItem;
}
@@ -84,9 +84,9 @@
{
ToolTipText = Resources.Delete_ToolTip,
Image = Resources.DeleteIcon,
- Enabled = treeViewControl.CanRemoveNodeForData(treeNode.Tag)
+ Enabled = treeViewControl.CanRemoveNodeForData(dataObject)
};
- toolStripMenuItem.Click += (s, e) => treeViewControl.RemoveNodeForData(treeNode.Tag);
+ toolStripMenuItem.Click += (s, e) => treeViewControl.RemoveNodeForData(dataObject);
return toolStripMenuItem;
}
@@ -101,9 +101,9 @@
{
ToolTipText = Resources.Expand_all_ToolTip,
Image = Resources.ExpandAllIcon,
- Enabled = treeViewControl.CanExpandOrCollapseAllNodesForData(treeNode.Tag)
+ Enabled = treeViewControl.CanExpandOrCollapseAllNodesForData(dataObject)
};
- toolStripMenuItem.Click += (s, e) => treeViewControl.ExpandAllNodesForData(treeNode.Tag);
+ toolStripMenuItem.Click += (s, e) => treeViewControl.ExpandAllNodesForData(dataObject);
return toolStripMenuItem;
}
@@ -118,9 +118,9 @@
{
ToolTipText = Resources.Collapse_all_ToolTip,
Image = Resources.CollapseAllIcon,
- Enabled = treeViewControl.CanExpandOrCollapseAllNodesForData(treeNode.Tag)
+ Enabled = treeViewControl.CanExpandOrCollapseAllNodesForData(dataObject)
};
- toolStripMenuItem.Click += (s, e) => treeViewControl.CollapseAllNodesForData(treeNode.Tag);
+ toolStripMenuItem.Click += (s, e) => treeViewControl.CollapseAllNodesForData(dataObject);
return toolStripMenuItem;
}
}
Index: Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs
===================================================================
diff -u -r5f53f2f23d0c4145d79823c5443966ff4a5a830f -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 5f53f2f23d0c4145d79823c5443966ff4a5a830f)
+++ Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -567,11 +567,11 @@
}
///
- /// Looks up a localized string similar to Kan geen element in het contextmenu creëren zonder dat de knoop bekend is..
+ /// Looks up a localized string similar to Kan geen element in het contextmenu creëren zonder dat de data bekend is..
///
- public static string ContextMenuItemFactory_Can_not_create_context_menu_items_without_tree_node {
+ public static string ContextMenuItemFactory_Can_not_create_context_menu_items_without_data {
get {
- return ResourceManager.GetString("ContextMenuItemFactory_Can_not_create_context_menu_items_without_tree_node", resourceCulture);
+ return ResourceManager.GetString("ContextMenuItemFactory_Can_not_create_context_menu_items_without_data", resourceCulture);
}
}
Index: Core/Common/src/Core.Common.Gui/Properties/Resources.resx
===================================================================
diff -u -r5f53f2f23d0c4145d79823c5443966ff4a5a830f -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision 5f53f2f23d0c4145d79823c5443966ff4a5a830f)
+++ Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -796,8 +796,8 @@
Kan geen 'ApplicationFeatureCommandHandler'-afhankelijk element in het contextmenu creëren zonder een 'ApplicationFeatureCommandHandler'.
-
- Kan geen element in het contextmenu creëren zonder dat de knoop bekend is.
+
+ Kan geen element in het contextmenu creëren zonder dat de data bekend is.
Kan geen element in het contextmenu creëren zonder dat informatie over de knoop bekend is.
Index: Core/Common/src/Core.Common.Gui/RingtoetsGui.cs
===================================================================
diff -u -r81fe6a7333c95776d8312b396a32ec045ea34bd1 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Core/Common/src/Core.Common.Gui/RingtoetsGui.cs (.../RingtoetsGui.cs) (revision 81fe6a7333c95776d8312b396a32ec045ea34bd1)
+++ Core/Common/src/Core.Common.Gui/RingtoetsGui.cs (.../RingtoetsGui.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -28,8 +28,6 @@
using System.Diagnostics;
using System.Linq;
using System.Reflection;
-using System.Windows.Forms;
-
using Core.Common.Base.Data;
using Core.Common.Base.Plugin;
using Core.Common.Base.Storage;
@@ -744,9 +742,9 @@
#region Implementation: IContextMenuBuilderProvider
- public IContextMenuBuilder Get(TreeNode treeNode, TreeViewControl treeViewControl)
+ public IContextMenuBuilder Get(object dataObject, TreeViewControl treeViewControl)
{
- return new ContextMenuBuilder(applicationFeatureCommands, exportImportCommandHandler, ViewCommands, treeNode, treeViewControl);
+ return new ContextMenuBuilder(applicationFeatureCommands, exportImportCommandHandler, ViewCommands, dataObject, treeViewControl);
}
#endregion
Index: Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs
===================================================================
diff -u -r99b31025be8be46190cf15e58aec262a4bb18858 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs (.../ContextMenuBuilderTest.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858)
+++ Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs (.../ContextMenuBuilderTest.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -24,14 +24,13 @@
public void Constructor_NoApplicationFeatureCommands_ThrowsContextMenuBuilderException()
{
// Setup
- var treeNodeMock = mocks.StrictMock();
var importExportHandlerMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
mocks.ReplayAll();
// Call
- TestDelegate test = () => new ContextMenuBuilder(null, importExportHandlerMock, viewCommandsMock, treeNodeMock, treeViewControlMock);
+ TestDelegate test = () => new ContextMenuBuilder(null, importExportHandlerMock, viewCommandsMock, new object(), treeViewControlMock);
// Assert
var message = Assert.Throws(test).Message;
@@ -44,14 +43,13 @@
public void Constructor_NoExportImportHandler_ThrowsContextMenuBuilderException()
{
// Setup
- var treeNodeMock = mocks.StrictMock();
var applicationFeatureCommandsMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
mocks.ReplayAll();
// Call
- TestDelegate test = () => new ContextMenuBuilder(applicationFeatureCommandsMock, null, viewCommandsMock, treeNodeMock, treeViewControlMock);
+ TestDelegate test = () => new ContextMenuBuilder(applicationFeatureCommandsMock, null, viewCommandsMock, new object(), treeViewControlMock);
// Assert
var message = Assert.Throws(test).Message;
@@ -66,12 +64,11 @@
// Setup
var applicationFeatureCommandsMockMock = mocks.StrictMock();
var exportImportHandlerMock = mocks.StrictMock();
- var treeNodeMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
mocks.ReplayAll();
// Call
- TestDelegate test = () => new ContextMenuBuilder(applicationFeatureCommandsMockMock, exportImportHandlerMock, null, treeNodeMock, treeViewControlMock);
+ TestDelegate test = () => new ContextMenuBuilder(applicationFeatureCommandsMockMock, exportImportHandlerMock, null, new object(), treeViewControlMock);
// Assert
var message = Assert.Throws(test).Message;
@@ -81,7 +78,7 @@
}
[Test]
- public void Constructor_NoTreeNode_ThrowsContextMenuBuilderException()
+ public void Constructor_NoDataObject_ThrowsContextMenuBuilderException()
{
// Setup
var applicationFeatureCommandsMock = mocks.StrictMock();
@@ -102,12 +99,11 @@
{
// Setup
var applicationFeatureCommandsMock = mocks.StrictMock();
- var treeNodeMock = mocks.StrictMock();
var importExportHandlerMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
// Call
- TestDelegate test = () => new ContextMenuBuilder(applicationFeatureCommandsMock, importExportHandlerMock, viewCommandsMock, treeNodeMock, null);
+ TestDelegate test = () => new ContextMenuBuilder(applicationFeatureCommandsMock, importExportHandlerMock, viewCommandsMock, new object(), null);
// Assert
var message = Assert.Throws(test).Message;
@@ -121,12 +117,11 @@
var applicationFeatureCommandsMockMock = mocks.StrictMock();
var exportImportHandlerMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
- var treeNodeMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
mocks.ReplayAll();
// Call
- TestDelegate test = () => new ContextMenuBuilder(applicationFeatureCommandsMockMock, exportImportHandlerMock, viewCommandsMock, treeNodeMock, treeViewControlMock);
+ TestDelegate test = () => new ContextMenuBuilder(applicationFeatureCommandsMockMock, exportImportHandlerMock, viewCommandsMock, new object(), treeViewControlMock);
// Assert
Assert.DoesNotThrow(test);
@@ -141,11 +136,10 @@
var applicationFeatureCommandsMockMock = mocks.StrictMock();
var exportImportHandlerMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
- var treeNodeMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(applicationFeatureCommandsMockMock, exportImportHandlerMock, viewCommandsMock, treeNodeMock, treeViewControlMock);
+ var builder = new ContextMenuBuilder(applicationFeatureCommandsMockMock, exportImportHandlerMock, viewCommandsMock, new object(), treeViewControlMock);
// Call
var result = builder.Build();
@@ -176,7 +170,7 @@
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, new TreeNode { Tag = dataObject }, treeViewControl);
+ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, dataObject, treeViewControl);
// Call
var result = builder.AddRenameItem().Build();
@@ -213,7 +207,7 @@
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, new TreeNode { Tag = nodeData }, treeViewControl);
+ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, nodeData, treeViewControl);
// Call
var result = builder.AddDeleteItem().Build();
@@ -234,7 +228,6 @@
{
// Setup
var dataObject = new object();
- var treeNode = new TreeNode { Tag = dataObject };
var applicationFeatureCommandsMock = mocks.StrictMock();
var exportImportHandlerMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
@@ -244,7 +237,7 @@
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, treeNode, treeViewControlMock);
+ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, dataObject, treeViewControlMock);
// Call
var result = builder.AddExpandAllItem().Build();
@@ -265,7 +258,6 @@
{
// Setup
var dataObject = new object();
- var treeNode = new TreeNode { Tag = dataObject };
var applicationFeatureCommandsMock = mocks.StrictMock();
var exportImportHandlerMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
@@ -275,7 +267,7 @@
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, treeNode, treeViewControlMock);
+ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, dataObject, treeViewControlMock);
// Call
var result = builder.AddCollapseAllItem().Build();
@@ -299,17 +291,14 @@
var exportImportHandlerMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
- var treeNodeMock = mocks.Stub();
var nodeData = new object();
viewCommandsMock.Expect(ch => ch.CanOpenViewFor(nodeData)).Return(hasViewForNodeData);
mocks.ReplayAll();
- treeNodeMock.Tag = nodeData;
+ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, nodeData, treeViewControlMock);
- var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, treeNodeMock, treeViewControlMock);
-
// Call
var result = builder.AddOpenItem().Build();
@@ -333,15 +322,12 @@
var viewCommandsMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
var nodeData = new object();
- var treeNodeMock = mocks.Stub();
exportImportHandlerMock.Expect(ch => ch.CanExportFrom(nodeData)).Return(hasExportersForNodeData);
mocks.ReplayAll();
- treeNodeMock.Tag = nodeData;
+ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, nodeData, treeViewControlMock);
- var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, treeNodeMock, treeViewControlMock);
-
// Call
var result = builder.AddExportItem().Build();
@@ -365,15 +351,12 @@
var viewCommandsMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
var nodeData = new object();
- var treeNodeMock = mocks.Stub();
exportImportHandlerMock.Expect(ch => ch.CanImportOn(nodeData)).Return(hasImportersForNodeData);
mocks.ReplayAll();
- treeNodeMock.Tag = nodeData;
+ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, nodeData, treeViewControlMock);
- var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, treeNodeMock, treeViewControlMock);
-
// Call
var result = builder.AddImportItem().Build();
@@ -397,15 +380,12 @@
var viewCommandsMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
var nodeData = new object();
- var treeNodeMock = mocks.Stub();
applicationFeatureCommandsMock.Expect(ch => ch.CanShowPropertiesFor(nodeData)).Return(hasPropertiesForNodeData);
mocks.ReplayAll();
- treeNodeMock.Tag = nodeData;
-
- var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, treeNodeMock, treeViewControlMock);
+ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, nodeData, treeViewControlMock);
// Call
var result = builder.AddPropertiesItem().Build();
@@ -423,14 +403,13 @@
public void AddCustomItem_WhenBuild_ItemAddedToContextMenu()
{
// Setup
- var treeNodeMock = mocks.StrictMock();
var applicationFeatureCommandsMock = mocks.StrictMock();
var exportImportHandlerMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, treeNodeMock, treeViewControlMock);
+ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, new object(), treeViewControlMock);
var item = new StrictContextMenuItem(null,null,null,null);
// Call
@@ -449,14 +428,13 @@
public void AddSeparator_NoOtherItemsWhenBuild_EmptyContextMenu()
{
// Setup
- var treeNodeMock = mocks.StrictMock();
var applicationFeatureCommandsMock = mocks.StrictMock();
var exportImportHandlerMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, treeNodeMock, treeViewControlMock);
+ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, new object(), treeViewControlMock);
// Call
var result = builder.AddSeparator().Build();
@@ -474,14 +452,13 @@
public void AddSeparator_SeparatorAddedAtStart_SeparatorsNotAdded(int count)
{
// Setup
- var treeNodeMock = mocks.StrictMock();
var applicationFeatureCommandsMock = mocks.StrictMock();
var exportImportHandlerMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, treeNodeMock, treeViewControlMock);
+ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, new object(), treeViewControlMock);
var someItem = new StrictContextMenuItem(null, null, null, null);
@@ -507,14 +484,13 @@
public void AddSeparator_SeperatorsAddedInBetweenItems_OneSeparatorAdded(int count)
{
// Setup
- var treeNodeMock = mocks.StrictMock();
var applicationFeatureCommandsMock = mocks.StrictMock();
var exportImportHandlerMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, treeNodeMock, treeViewControlMock);
+ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, new object(), treeViewControlMock);
var someItem = new StrictContextMenuItem(null, null, null, null);
var someOtherItem = new StrictContextMenuItem(null, null, null, null);
@@ -544,14 +520,13 @@
public void AddSeparator_SeparatorsAddedAtEnd_SeparatorsNotAdded(int count)
{
// Setup
- var treeNodeMock = mocks.StrictMock();
var applicationFeatureCommandsMock = mocks.StrictMock();
var exportImportHandlerMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
mocks.ReplayAll();
- var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, treeNodeMock, treeViewControlMock);
+ var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, exportImportHandlerMock, viewCommandsMock, new object(), treeViewControlMock);
builder.AddCustomItem(new StrictContextMenuItem(null, null, null, null));
Index: Core/Common/test/Core.Common.Gui.Test/ContextMenu/GuiContextMenuItemFactoryTest.cs
===================================================================
diff -u -r0c64d8a6c718c0aa67403a16c94dd0c10f862455 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Core/Common/test/Core.Common.Gui.Test/ContextMenu/GuiContextMenuItemFactoryTest.cs (.../GuiContextMenuItemFactoryTest.cs) (revision 0c64d8a6c718c0aa67403a16c94dd0c10f862455)
+++ Core/Common/test/Core.Common.Gui.Test/ContextMenu/GuiContextMenuItemFactoryTest.cs (.../GuiContextMenuItemFactoryTest.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -1,6 +1,4 @@
using System;
-using System.Windows.Forms;
-
using Core.Common.Gui.Commands;
using Core.Common.Gui.ContextMenu;
using Core.Common.Gui.Properties;
@@ -44,11 +42,11 @@
// Call
TestDelegate test = () => new GuiContextMenuItemFactory(applicationFeatureCommandHandler, exportImportCommandHandler, viewCommandsMock, null);
-
+
// Assert
var message = Assert.Throws(test).Message;
- StringAssert.StartsWith(Resources.ContextMenuItemFactory_Can_not_create_context_menu_items_without_tree_node, message);
- StringAssert.EndsWith("treeNode", message);
+ StringAssert.StartsWith(Resources.ContextMenuItemFactory_Can_not_create_context_menu_items_without_data, message);
+ StringAssert.EndsWith("dataObject", message);
mocks.VerifyAll();
}
@@ -98,11 +96,10 @@
var applicationFeatureCommandHandler = mocks.StrictMock();
var exportImportCommandHandlerMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
- var treeNodeMock = mocks.Stub();
mocks.ReplayAll();
// Call
- TestDelegate test = () => new GuiContextMenuItemFactory(applicationFeatureCommandHandler, exportImportCommandHandlerMock, viewCommandsMock, treeNodeMock);
+ TestDelegate test = () => new GuiContextMenuItemFactory(applicationFeatureCommandHandler, exportImportCommandHandlerMock, viewCommandsMock, new object());
// Assert
Assert.DoesNotThrow(test);
@@ -120,7 +117,6 @@
var exportImportCommandHandlerMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
var nodeData = new object();
- var nodeStub = mocks.Stub();
viewCommandsMock.Expect(ch => ch.CanOpenViewFor(nodeData)).Return(hasViewersForNodeData);
if (hasViewersForNodeData)
{
@@ -129,10 +125,8 @@
mocks.ReplayAll();
- nodeStub.Tag = nodeData;
+ var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, exportImportCommandHandlerMock, viewCommandsMock, nodeData);
- var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, exportImportCommandHandlerMock, viewCommandsMock, nodeStub);
-
// Call
var item = contextMenuFactory.CreateOpenItem();
item.PerformClick();
@@ -156,7 +150,6 @@
var exportImportCommandHandlerMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
var nodeData = new object();
- var nodeStub = mocks.Stub();
exportImportCommandHandlerMock.Expect(ch => ch.CanExportFrom(nodeData)).Return(hasExportersForNodeData);
if (hasExportersForNodeData)
{
@@ -165,10 +158,8 @@
mocks.ReplayAll();
- nodeStub.Tag = nodeData;
+ var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, exportImportCommandHandlerMock, viewCommandsMock, nodeData);
- var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, exportImportCommandHandlerMock, viewCommandsMock, nodeStub);
-
// Call
var item = contextMenuFactory.CreateExportItem();
item.PerformClick();
@@ -192,7 +183,6 @@
var exportImportCommandHandlerMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
var nodeData = new object();
- var nodeStub = mocks.Stub();
exportImportCommandHandlerMock.Expect(ch => ch.CanImportOn(nodeData)).Return(hasImportersForNodeData);
if (hasImportersForNodeData)
{
@@ -201,10 +191,8 @@
mocks.ReplayAll();
- nodeStub.Tag = nodeData;
+ var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, exportImportCommandHandlerMock, viewCommandsMock, nodeData);
- var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, exportImportCommandHandlerMock, viewCommandsMock, nodeStub);
-
// Call
var item = contextMenuFactory.CreateImportItem();
item.PerformClick();
@@ -228,19 +216,16 @@
var exportImportCommandHandlerMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
var nodeData = new object();
- var nodeStub = mocks.Stub();
commandHandlerMock.Expect(ch => ch.CanShowPropertiesFor(nodeData)).Return(hasPropertyInfoForNodeData);
if (hasPropertyInfoForNodeData)
{
commandHandlerMock.Expect(ch => ch.ShowPropertiesFor(nodeData));
}
- var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, exportImportCommandHandlerMock, viewCommandsMock, nodeStub);
+ var contextMenuFactory = new GuiContextMenuItemFactory(commandHandlerMock, exportImportCommandHandlerMock, viewCommandsMock, nodeData);
mocks.ReplayAll();
- nodeStub.Tag = nodeData;
-
// Call
var item = contextMenuFactory.CreatePropertiesItem();
item.PerformClick();
Index: Core/Common/test/Core.Common.Gui.Test/ContextMenu/TreeViewContextMenuItemFactoryTest.cs
===================================================================
diff -u -r99b31025be8be46190cf15e58aec262a4bb18858 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Core/Common/test/Core.Common.Gui.Test/ContextMenu/TreeViewContextMenuItemFactoryTest.cs (.../TreeViewContextMenuItemFactoryTest.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858)
+++ Core/Common/test/Core.Common.Gui.Test/ContextMenu/TreeViewContextMenuItemFactoryTest.cs (.../TreeViewContextMenuItemFactoryTest.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -1,5 +1,4 @@
using System;
-using System.Windows.Forms;
using Core.Common.Controls.TreeView;
using Core.Common.Gui.ContextMenu;
using Core.Common.Gui.Properties;
@@ -32,20 +31,15 @@
// Assert
var message = Assert.Throws(test).Message;
- StringAssert.StartsWith(Resources.ContextMenuItemFactory_Can_not_create_context_menu_items_without_tree_node, message);
- StringAssert.EndsWith("treeNode", message);
+ StringAssert.StartsWith(Resources.ContextMenuItemFactory_Can_not_create_context_menu_items_without_data, message);
+ StringAssert.EndsWith("dataObject", message);
}
[Test]
public void Constructor_WithoutTreeViewControl_ThrowsArgumentNullException()
{
- // Setup
- var treeNodeMock = mocks.StrictMock();
-
- mocks.ReplayAll();
-
// Call
- TestDelegate test = () => new TreeViewContextMenuItemFactory(treeNodeMock, null);
+ TestDelegate test = () => new TreeViewContextMenuItemFactory(new object(), null);
// Assert
var message = Assert.Throws(test).Message;
@@ -54,16 +48,15 @@
}
[Test]
- public void Constructor_WithTreeNode_DoesNotThrow()
+ public void Constructor_WithDataObject_DoesNotThrow()
{
// Setup
- var treeNodeMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
mocks.ReplayAll();
// Call
- TestDelegate test = () => new TreeViewContextMenuItemFactory(treeNodeMock, treeViewControlMock);
+ TestDelegate test = () => new TreeViewContextMenuItemFactory(new object(), treeViewControlMock);
// Assert
Assert.DoesNotThrow(test);
@@ -77,19 +70,12 @@
public void CreateDeleteItem_DependingOnCanRemoveNodeForData_ItemWithDeleteFunctionWillBeEnabled(bool canDelete)
{
// Setup
- var treeNodeMock = mocks.StrictMock();
- var treeParentNodeMock = mocks.StrictMock();
var treeNodeInfoMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
var parentNodeData = new object();
var nodeData = new object();
- treeNodeMock.Stub(tn => tn.Text).Return("");
- treeNodeMock.Stub(tn => tn.Parent).Return(treeParentNodeMock);
- treeNodeMock.Stub(tn => tn.Tag).Return(nodeData);
- treeParentNodeMock.Stub(tn => tn.Tag).Return(parentNodeData);
-
treeNodeInfoMock.CanRemove = (nd, pnd) =>
{
if (nd == nodeData && pnd == parentNodeData)
@@ -109,7 +95,7 @@
mocks.ReplayAll();
- var factory = new TreeViewContextMenuItemFactory(treeNodeMock, treeViewControlMock);
+ var factory = new TreeViewContextMenuItemFactory(nodeData, treeViewControlMock);
// Call
var item = factory.CreateDeleteItem();
@@ -131,12 +117,9 @@
{
// Setup
var dataObject = new object();
- var treeNodeMock = mocks.StrictMock();
var treeNodeInfoMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
- treeNodeMock.Expect(tn => tn.Tag).Return(dataObject);
-
treeNodeInfoMock.CanRename = (data, parentData) =>
{
if (data == dataObject)
@@ -151,12 +134,12 @@
if (canRename)
{
- treeNodeMock.Expect(tv => tv.BeginEdit());
+ treeViewControlMock.Expect(tvc => tvc.StartRenameForData(dataObject));
}
mocks.ReplayAll();
- var factory = new TreeViewContextMenuItemFactory(treeNodeMock, treeViewControlMock);
+ var factory = new TreeViewContextMenuItemFactory(dataObject, treeViewControlMock);
// Call
var item = factory.CreateRenameItem();
@@ -186,14 +169,11 @@
{
treeNodeInfo.ChildNodeObjects = o => new object[]
{
- new TreeNode
- {
- Tag = 10.0
- }
+ 10.0
};
}
- var factory = new TreeViewContextMenuItemFactory(new TreeNode { Tag = dataObject }, treeViewControl);
+ var factory = new TreeViewContextMenuItemFactory(dataObject, treeViewControl);
treeViewControl.RegisterTreeNodeInfo(treeNodeInfo);
treeViewControl.RegisterTreeNodeInfo(childTreeNodeInfo);
@@ -227,14 +207,11 @@
{
treeNodeInfo.ChildNodeObjects = o => new object[]
{
- new TreeNode
- {
- Tag = 10.0
- }
+ 10.0
};
}
- var factory = new TreeViewContextMenuItemFactory(new TreeNode { Tag = dataObject }, treeViewControl);
+ var factory = new TreeViewContextMenuItemFactory(dataObject, treeViewControl);
treeViewControl.RegisterTreeNodeInfo(treeNodeInfo);
treeViewControl.RegisterTreeNodeInfo(childTreeNodeInfo);
Index: Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerGuiPlugin.cs
===================================================================
diff -u -rc07c8243b6c74fa79a77f2edbc1799375064b057 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerGuiPlugin.cs (.../ProjectExplorerGuiPlugin.cs) (revision c07c8243b6c74fa79a77f2edbc1799375064b057)
+++ Core/Plugins/src/Core.Plugins.ProjectExplorer/ProjectExplorerGuiPlugin.cs (.../ProjectExplorerGuiPlugin.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -94,15 +94,15 @@
Text = project => project.Name,
Image = project => ProjectExplorerResources.ProjectIcon,
ChildNodeObjects = project => project.Items.ToArray(),
- ContextMenuStrip = (project, sourceNode, treeViewControl) =>
+ ContextMenuStrip = (project, parentData, treeViewControl) =>
{
var addItem = new StrictContextMenuItem(
ProjectExplorerResources.AddItem,
ProjectExplorerResources.AddItem_ToolTip,
ProjectExplorerResources.PlusIcon,
(s, e) => Gui.ProjectCommands.AddNewItem(project));
- return Gui.Get(sourceNode, treeViewControl)
+ return Gui.Get(project, treeViewControl)
.AddCustomItem(addItem)
.AddSeparator()
.AddImportItem()
Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/TreeNodeInfos/ProjectTreeNodeInfoTest.cs
===================================================================
diff -u -rdaac7f75692224f6ad3b765cb0b3d8117c1165a6 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/TreeNodeInfos/ProjectTreeNodeInfoTest.cs (.../ProjectTreeNodeInfoTest.cs) (revision daac7f75692224f6ad3b765cb0b3d8117c1165a6)
+++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/TreeNodeInfos/ProjectTreeNodeInfoTest.cs (.../ProjectTreeNodeInfoTest.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -1,5 +1,4 @@
using System.Linq;
-using System.Windows.Forms;
using Core.Common.Base.Data;
using Core.Common.Controls.TreeView;
using Core.Common.Gui;
@@ -110,13 +109,12 @@
public void ContextMenuStrip_Always_CallsBuilder()
{
// Setup
- var treeNode = new TreeNode();
var gui = mocks.StrictMultiMock();
var treeViewControlMock = mocks.StrictMock();
var menuBuilderMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
- gui.Expect(g => g.Get(treeNode, treeViewControlMock)).Return(menuBuilderMock);
+ gui.Expect(g => g.Get(null, treeViewControlMock)).Return(menuBuilderMock);
gui.Expect(g => g.ViewCommands).Return(viewCommandsMock);
gui.Expect(g => g.GetTreeNodeInfos()).Return(Enumerable.Empty());
@@ -136,7 +134,7 @@
plugin.Gui = gui;
// Call
- info.ContextMenuStrip(null, treeNode, treeViewControlMock);
+ info.ContextMenuStrip(null, null, treeViewControlMock);
// Assert
mocks.VerifyAll();
@@ -148,14 +146,13 @@
{
// Setup
var project = new Project();
- var treeNode = new TreeNode();
var guiMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
var projectCommandsMock = mocks.StrictMock();
var viewCommandsMock = mocks.StrictMock();
- guiMock.Stub(g => g.Get(treeNode, treeViewControlMock)).Return(menuBuilder);
+ guiMock.Stub(g => g.Get(project, treeViewControlMock)).Return(menuBuilder);
guiMock.Stub(g => g.ProjectCommands).Return(projectCommandsMock);
guiMock.Stub(g => g.ViewCommands).Return(viewCommandsMock);
guiMock.Stub(g => g.GetTreeNodeInfos()).Return(Enumerable.Empty());
@@ -166,7 +163,7 @@
plugin.Gui = guiMock;
// Call
- var result = info.ContextMenuStrip(project, treeNode, treeViewControlMock);
+ var result = info.ContextMenuStrip(project, null, treeViewControlMock);
result.Items[0].PerformClick();
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs
===================================================================
diff -u -r99b31025be8be46190cf15e58aec262a4bb18858 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -128,7 +128,7 @@
{
Text = failureMechanismContribution => RingtoetsDataResources.FailureMechanismContribution_DisplayName,
Image = failureMechanismContribution => RingtoetsFormsResources.GenericInputOutputIcon,
- ContextMenuStrip = (failureMechanismContribution, sourceNode, treeViewControl) => Gui.Get(sourceNode, treeViewControl)
+ ContextMenuStrip = (failureMechanismContribution, parentData, treeViewControl) => Gui.Get(failureMechanismContribution, treeViewControl)
.AddOpenItem()
.AddSeparator()
.AddExportItem()
@@ -166,9 +166,9 @@
parentProject.NotifyObservers();
}
- private ContextMenuStrip AssessmentSectionBaseContextMenuStrip(AssessmentSectionBase nodeData, TreeNode node, TreeViewControl treeViewControl)
+ private ContextMenuStrip AssessmentSectionBaseContextMenuStrip(AssessmentSectionBase nodeData, object parentData, TreeViewControl treeViewControl)
{
- return Gui.Get(node, treeViewControl)
+ return Gui.Get(nodeData, treeViewControl)
.AddRenameItem()
.AddDeleteItem()
.AddSeparator()
@@ -217,7 +217,7 @@
};
}
- private ContextMenuStrip FailureMechanismPlaceholderContextMenuStrip(FailureMechanismPlaceholder nodeData, TreeNode node, TreeViewControl treeViewControl)
+ private ContextMenuStrip FailureMechanismPlaceholderContextMenuStrip(FailureMechanismPlaceholder nodeData, object parentData, TreeViewControl treeViewControl)
{
var calculateItem = new StrictContextMenuItem(
RingtoetsCommonFormsResources.Calculate_all,
@@ -236,7 +236,7 @@
Enabled = false
};
- return Gui.Get(node, treeViewControl)
+ return Gui.Get(nodeData, treeViewControl)
.AddCustomItem(calculateItem)
.AddCustomItem(clearOutputItem)
.AddSeparator()
@@ -263,9 +263,9 @@
return RingtoetsFormsResources.PlaceholderIcon;
}
- private ContextMenuStrip PlaceholderWithReadonlyNameContextMenuStrip(PlaceholderWithReadonlyName nodeData, TreeNode node, TreeViewControl treeViewControl)
+ private ContextMenuStrip PlaceholderWithReadonlyNameContextMenuStrip(PlaceholderWithReadonlyName nodeData, object parentData, TreeViewControl treeViewControl)
{
- IContextMenuBuilder menuBuilder = Gui.Get(node, treeViewControl);
+ IContextMenuBuilder menuBuilder = Gui.Get(nodeData, treeViewControl);
if (nodeData is InputPlaceholder || nodeData is OutputPlaceholder)
{
@@ -316,9 +316,9 @@
}
}
- private ContextMenuStrip CategoryTreeFolderContextMenu(CategoryTreeFolder nodeData, TreeNode node, TreeViewControl treeViewControl)
+ private ContextMenuStrip CategoryTreeFolderContextMenu(CategoryTreeFolder nodeData, object parentData, TreeViewControl treeViewControl)
{
- return Gui.Get(node, treeViewControl)
+ return Gui.Get(nodeData, treeViewControl)
.AddExpandAllItem()
.AddCollapseAllItem()
.Build();
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionBaseTreeNodeInfoTest.cs
===================================================================
diff -u -r99b31025be8be46190cf15e58aec262a4bb18858 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionBaseTreeNodeInfoTest.cs (.../AssessmentSectionBaseTreeNodeInfoTest.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionBaseTreeNodeInfoTest.cs (.../AssessmentSectionBaseTreeNodeInfoTest.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Linq;
-using System.Windows.Forms;
using Core.Common.Base;
using Core.Common.Base.Data;
using Core.Common.Controls.TreeView;
@@ -116,13 +115,11 @@
public void ContextMenuStrip_Always_CallsBuilder()
{
// Setup
- var treeNode = new TreeNode();
-
var gui = mocks.StrictMultiMock();
var treeViewControlMock = mocks.StrictMock();
var menuBuilderMock = mocks.StrictMock();
- gui.Expect(g => g.Get(treeNode, treeViewControlMock)).Return(menuBuilderMock);
-
+ gui.Expect(g => g.Get(null, treeViewControlMock)).Return(menuBuilderMock);
+
menuBuilderMock.Expect(mb => mb.AddRenameItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddDeleteItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
@@ -134,13 +131,13 @@
menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.Build()).Return(null);
-
+
mocks.ReplayAll();
plugin.Gui = gui;
// Call
- info.ContextMenuStrip(null, treeNode, treeViewControlMock);
+ info.ContextMenuStrip(null, null, treeViewControlMock);
// Assert
mocks.VerifyAll();
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContributionTreeNodeInfoTest.cs
===================================================================
diff -u -rc07c8243b6c74fa79a77f2edbc1799375064b057 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContributionTreeNodeInfoTest.cs (.../FailureMechanismContributionTreeNodeInfoTest.cs) (revision c07c8243b6c74fa79a77f2edbc1799375064b057)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismContributionTreeNodeInfoTest.cs (.../FailureMechanismContributionTreeNodeInfoTest.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -1,5 +1,4 @@
using System.Linq;
-using System.Windows.Forms;
using Core.Common.Controls.TreeView;
using Core.Common.Gui;
using Core.Common.Gui.ContextMenu;
@@ -79,21 +78,20 @@
var gui = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
var menuBuilderMock = mocks.StrictMock();
- var nodeMock = mocks.StrictMock();
menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddExportItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.Build()).Return(null);
- gui.Expect(cmp => cmp.Get(nodeMock, treeViewControlMock)).Return(menuBuilderMock);
+ gui.Expect(cmp => cmp.Get(null, treeViewControlMock)).Return(menuBuilderMock);
mocks.ReplayAll();
plugin.Gui = gui;
// Call
- info.ContextMenuStrip(null, nodeMock, treeViewControlMock);
+ info.ContextMenuStrip(null, null, treeViewControlMock);
// Assert
mocks.VerifyAll();
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismPlaceholderTreeNodeInfoTest.cs
===================================================================
diff -u -rc07c8243b6c74fa79a77f2edbc1799375064b057 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismPlaceholderTreeNodeInfoTest.cs (.../FailureMechanismPlaceholderTreeNodeInfoTest.cs) (revision c07c8243b6c74fa79a77f2edbc1799375064b057)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismPlaceholderTreeNodeInfoTest.cs (.../FailureMechanismPlaceholderTreeNodeInfoTest.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -1,6 +1,5 @@
using System.Drawing;
using System.Linq;
-using System.Windows.Forms;
using Core.Common.Controls.TreeView;
using Core.Common.Gui;
using Core.Common.Gui.ContextMenu;
@@ -118,7 +117,6 @@
var gui = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
var menuBuilderMock = mocks.StrictMock();
- var nodeMock = mocks.StrictMock();
menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
@@ -132,14 +130,14 @@
menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.Build()).Return(null);
- gui.Expect(cmp => cmp.Get(nodeMock, treeViewControlMock)).Return(menuBuilderMock);
+ gui.Expect(cmp => cmp.Get(null, treeViewControlMock)).Return(menuBuilderMock);
mocks.ReplayAll();
plugin.Gui = gui;
// Call
- info.ContextMenuStrip(null, nodeMock, treeViewControlMock);
+ info.ContextMenuStrip(null, null, treeViewControlMock);
// Assert
mocks.VerifyAll();
@@ -152,16 +150,15 @@
var gui = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
var menuBuilderMock = new CustomItemsOnlyContextMenuBuilder();
- var nodeMock = mocks.StrictMock();
- gui.Expect(cmp => cmp.Get(nodeMock, treeViewControlMock)).Return(menuBuilderMock);
+ gui.Expect(cmp => cmp.Get(null, treeViewControlMock)).Return(menuBuilderMock);
mocks.ReplayAll();
plugin.Gui = gui;
// Call
- var menu = info.ContextMenuStrip(null, nodeMock, treeViewControlMock);
+ var menu = info.ContextMenuStrip(null, null, treeViewControlMock);
// Assert
mocks.VerifyAll();
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/PlaceholderWithReadonlyNameTreeNodeInfoTest.cs
===================================================================
diff -u -rc07c8243b6c74fa79a77f2edbc1799375064b057 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/PlaceholderWithReadonlyNameTreeNodeInfoTest.cs (.../PlaceholderWithReadonlyNameTreeNodeInfoTest.cs) (revision c07c8243b6c74fa79a77f2edbc1799375064b057)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/PlaceholderWithReadonlyNameTreeNodeInfoTest.cs (.../PlaceholderWithReadonlyNameTreeNodeInfoTest.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -1,6 +1,5 @@
using System.Drawing;
using System.Linq;
-using System.Windows.Forms;
using Core.Common.Controls.TreeView;
using Core.Common.Gui;
using Core.Common.Gui.ContextMenu;
@@ -106,10 +105,10 @@
public void GetContextMenu_OutputPlaceHolder_CallsContextMenuBuilderMethods()
{
// Setup
+ var outputPlaceholder = new OutputPlaceholder(string.Empty);
var gui = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
var menuBuilderMock = mocks.StrictMock();
- var nodeMock = mocks.StrictMock();
menuBuilderMock.Expect(mb => mb.AddOpenItem()).IgnoreArguments().Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
@@ -120,14 +119,14 @@
menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.Build()).Return(null);
- gui.Expect(cmp => cmp.Get(nodeMock, treeViewControlMock)).Return(menuBuilderMock);
+ gui.Expect(cmp => cmp.Get(outputPlaceholder, treeViewControlMock)).Return(menuBuilderMock);
mocks.ReplayAll();
plugin.Gui = gui;
-
+
// Call
- info.ContextMenuStrip(new OutputPlaceholder(string.Empty), nodeMock, treeViewControlMock);
+ info.ContextMenuStrip(outputPlaceholder, null, treeViewControlMock);
// Assert
mocks.VerifyAll();
@@ -137,10 +136,10 @@
public void GetContextMenu_InputPlaceHolder_CallsContextMenuBuilderMethods()
{
// Setup
+ var inputPlaceholder = new InputPlaceholder(string.Empty);
var gui = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
var menuBuilderMock = mocks.StrictMock();
- var nodeMock = mocks.StrictMock();
menuBuilderMock.Expect(mb => mb.AddOpenItem()).IgnoreArguments().Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
@@ -150,14 +149,14 @@
menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.Build()).Return(null);
- gui.Expect(cmp => cmp.Get(nodeMock, treeViewControlMock)).Return(menuBuilderMock);
+ gui.Expect(cmp => cmp.Get(inputPlaceholder, treeViewControlMock)).Return(menuBuilderMock);
mocks.ReplayAll();
plugin.Gui = gui;
// Call
- info.ContextMenuStrip(new InputPlaceholder(string.Empty), nodeMock, treeViewControlMock);
+ info.ContextMenuStrip(inputPlaceholder, null, treeViewControlMock);
// Assert
mocks.VerifyAll();
@@ -170,22 +169,21 @@
var gui = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
var menuBuilderMock = mocks.StrictMock();
- var nodeMock = mocks.StrictMock();
menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddExportItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.Build()).Return(null);
- gui.Expect(cmp => cmp.Get(nodeMock, treeViewControlMock)).Return(menuBuilderMock);
+ gui.Expect(cmp => cmp.Get(null, treeViewControlMock)).Return(menuBuilderMock);
mocks.ReplayAll();
plugin.Gui = gui;
// Call
- info.ContextMenuStrip(null, nodeMock, treeViewControlMock);
+ info.ContextMenuStrip(null, null, treeViewControlMock);
// Assert
mocks.VerifyAll();
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs
===================================================================
diff -u -r99b31025be8be46190cf15e58aec262a4bb18858 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -107,12 +107,12 @@
{
Text = pipingInputContext => PipingFormsResources.PipingInputContext_NodeDisplayName,
Image = pipingInputContext => PipingFormsResources.PipingInputIcon,
- ContextMenuStrip = (nodeData, node, treeViewControl) => Gui.Get(node, treeViewControl)
- .AddImportItem()
- .AddExportItem()
- .AddSeparator()
- .AddPropertiesItem()
- .Build()
+ ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl)
+ .AddImportItem()
+ .AddExportItem()
+ .AddSeparator()
+ .AddPropertiesItem()
+ .Build()
};
yield return new TreeNodeInfo>
@@ -121,22 +121,22 @@
Image = ringtoetsPipingSurfaceLine => PipingFormsResources.FolderIcon,
ForeColor = ringtoetsPipingSurfaceLine => ringtoetsPipingSurfaceLine.Any() ? Color.FromKnownColor(KnownColor.ControlText) : Color.FromKnownColor(KnownColor.GrayText),
ChildNodeObjects = ringtoetsPipingSurfaceLine => ringtoetsPipingSurfaceLine.Cast().ToArray(),
- ContextMenuStrip = (nodeData, node, treeViewControl) => Gui.Get(node, treeViewControl)
- .AddImportItem()
- .AddExportItem()
- .AddSeparator()
- .AddExpandAllItem()
- .AddCollapseAllItem()
- .Build()
+ ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl)
+ .AddImportItem()
+ .AddExportItem()
+ .AddSeparator()
+ .AddExpandAllItem()
+ .AddCollapseAllItem()
+ .Build()
};
yield return new TreeNodeInfo
{
Text = pipingSurfaceLine => pipingSurfaceLine.Name,
Image = pipingSurfaceLine => PipingFormsResources.PipingSurfaceLineIcon,
- ContextMenuStrip = (nodeData, node, treeViewControl) => Gui.Get(node, treeViewControl)
- .AddPropertiesItem()
- .Build()
+ ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl)
+ .AddPropertiesItem()
+ .Build()
};
yield return new TreeNodeInfo>
@@ -145,78 +145,78 @@
Image = pipingSoilProfiles => PipingFormsResources.FolderIcon,
ForeColor = pipingSoilProfiles => pipingSoilProfiles.Any() ? Color.FromKnownColor(KnownColor.ControlText) : Color.FromKnownColor(KnownColor.GrayText),
ChildNodeObjects = pipingSoilProfiles => pipingSoilProfiles.Cast().ToArray(),
- ContextMenuStrip = (nodeData, node, treeViewControl) => Gui.Get(node, treeViewControl)
- .AddImportItem()
- .AddExportItem()
- .AddSeparator()
- .AddExpandAllItem()
- .AddCollapseAllItem()
- .Build()
+ ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl)
+ .AddImportItem()
+ .AddExportItem()
+ .AddSeparator()
+ .AddExpandAllItem()
+ .AddCollapseAllItem()
+ .Build()
};
yield return new TreeNodeInfo
{
Text = pipingSoilProfile => pipingSoilProfile.Name,
Image = pipingSoilProfile => PipingFormsResources.PipingSoilProfileIcon,
- ContextMenuStrip = (nodeData, node, treeViewControl) => Gui.Get(node, treeViewControl)
- .AddPropertiesItem()
- .Build()
+ ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl)
+ .AddPropertiesItem()
+ .Build()
};
yield return new TreeNodeInfo
{
Text = pipingOutput => PipingFormsResources.PipingOutput_DisplayName,
Image = pipingOutput => PipingFormsResources.PipingOutputIcon,
- ContextMenuStrip = (nodeData, node, treeViewControl) => Gui.Get(node, treeViewControl)
- .AddExportItem()
- .AddSeparator()
- .AddPropertiesItem()
- .Build()
+ ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl)
+ .AddExportItem()
+ .AddSeparator()
+ .AddPropertiesItem()
+ .Build()
};
yield return new TreeNodeInfo
{
Text = emptyPipingOutput => PipingFormsResources.PipingOutput_DisplayName,
Image = emptyPipingOutput => PipingFormsResources.PipingOutputIcon,
ForeColor = emptyPipingOutput => Color.FromKnownColor(KnownColor.GrayText),
- ContextMenuStrip = (nodeData, node, treeViewControl) => Gui.Get(node, treeViewControl)
- .AddExportItem()
- .AddSeparator()
- .AddPropertiesItem()
- .Build()
+ ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl)
+ .AddExportItem()
+ .AddSeparator()
+ .AddPropertiesItem()
+ .Build()
};
yield return new TreeNodeInfo
{
Text = emptyPipingCalculationReport => PipingDataResources.CalculationReport_DisplayName,
Image = emptyPipingCalculationReport => PipingFormsResources.PipingCalculationReportIcon,
ForeColor = emptyPipingCalculationReport => Color.FromKnownColor(KnownColor.GrayText),
- ContextMenuStrip = (nodeData, node, treeViewControl) => Gui.Get(node, treeViewControl)
- .AddOpenItem()
- .AddSeparator()
- .AddExportItem()
- .AddSeparator()
- .AddPropertiesItem()
- .Build()
+ ContextMenuStrip = (nodeData, parentData, treeViewControl) => Gui.Get(nodeData, treeViewControl)
+ .AddOpenItem()
+ .AddSeparator()
+ .AddExportItem()
+ .AddSeparator()
+ .AddPropertiesItem()
+ .Build()
};
}
# region PipingFailureMechanism TreeNodeInfo
- private ContextMenuStrip FailureMechanismContextMenuStrip(PipingFailureMechanism failureMechanism, TreeNode node, TreeViewControl treeViewControl)
+ private ContextMenuStrip FailureMechanismContextMenuStrip(PipingFailureMechanism failureMechanism, object parentData, TreeViewControl treeViewControl)
{
var addCalculationGroupItem = new StrictContextMenuItem(
PipingFormsResources.PipingCalculationGroup_Add_PipingCalculationGroup,
PipingFormsResources.PipingFailureMechanism_Add_PipingCalculationGroup_Tooltip,
PipingFormsResources.AddFolderIcon,
- (o, args) => AddCalculationGroup(failureMechanism, node, treeViewControl)
+ (o, args) => AddCalculationGroup(failureMechanism)
);
var addCalculationItem = new StrictContextMenuItem(
PipingFormsResources.PipingCalculationGroup_Add_PipingCalculation,
PipingFormsResources.PipingFailureMechanism_Add_PipingCalculation_Tooltip,
PipingFormsResources.PipingIcon,
- (s, e) => AddCalculation(failureMechanism, node, treeViewControl)
+ (s, e) => AddCalculation(failureMechanism)
);
var validateAllItem = CreateValidateAllItem(failureMechanism);
@@ -236,7 +236,7 @@
clearAllItem.ToolTipText = PipingFormsResources.PipingCalculationGroup_ClearOutput_No_calculation_with_output_to_clear;
}
- return Gui.Get(node, treeViewControl)
+ return Gui.Get(failureMechanism, treeViewControl)
.AddCustomItem(addCalculationGroupItem)
.AddCustomItem(addCalculationItem)
.AddSeparator()
@@ -314,50 +314,26 @@
ActivityProgressDialogRunner.Run(Gui.MainWindow, GetAllPipingCalculationsResursively(failureMechanism).Select(calc => new PipingCalculationActivity(calc)));
}
- private void AddCalculationGroup(PipingFailureMechanism failureMechanism, TreeNode failureMechanismNode, TreeViewControl treeViewControl)
+ private void AddCalculationGroup(PipingFailureMechanism failureMechanism)
{
var calculation = new PipingCalculationGroup
{
Name = NamingHelper.GetUniqueName(failureMechanism.CalculationsGroup.Children, PipingDataResources.PipingCalculationGroup_DefaultName, c => c.Name)
};
failureMechanism.CalculationsGroup.Children.Add(calculation);
failureMechanism.CalculationsGroup.NotifyObservers();
-
- SelectNewlyAddedPipingFailureMechanismItemInTreeView(failureMechanismNode, treeViewControl);
}
- private void AddCalculation(PipingFailureMechanism failureMechanism, TreeNode failureMechanismNode, TreeViewControl treeViewControl)
+ private void AddCalculation(PipingFailureMechanism failureMechanism)
{
var calculation = new PipingCalculation
{
Name = NamingHelper.GetUniqueName(failureMechanism.CalculationsGroup.Children, PipingDataResources.PipingCalculation_DefaultName, c => c.Name)
};
failureMechanism.CalculationsGroup.Children.Add(calculation);
failureMechanism.CalculationsGroup.NotifyObservers();
-
- SelectNewlyAddedPipingFailureMechanismItemInTreeView(failureMechanismNode, treeViewControl);
}
- private void SelectNewlyAddedPipingFailureMechanismItemInTreeView(TreeNode failureMechanismNode, TreeViewControl treeViewControl)
- {
- if (!failureMechanismNode.IsExpanded)
- {
- failureMechanismNode.Expand();
- }
-
- // Childnode at index 1 is the PipingCalculationGroup where the new item has been added:
- TreeNode failureMechanismsCalculationsNode = failureMechanismNode.Nodes[1];
-
- // New childnode is appended at the end of PipingCalculationGroup:
- TreeNode newlyAddedGroupNode = failureMechanismsCalculationsNode.Nodes.OfType().Last();
- if (!failureMechanismsCalculationsNode.IsExpanded)
- {
- failureMechanismsCalculationsNode.Expand();
- }
-
- treeViewControl.SelectNodeForData(newlyAddedGroupNode.Tag);
- }
-
private static IEnumerable GetAllPipingCalculationsResursively(PipingFailureMechanism failureMechanism)
{
return failureMechanism.CalculationsGroup.GetPipingCalculations().ToArray();
@@ -396,7 +372,7 @@
# region PipingCalculationContext TreeNodeInfo
- private ContextMenuStrip PipingCalculationContextContextMenuStrip(PipingCalculationContext nodeData, TreeNode node, TreeViewControl treeViewControl)
+ private ContextMenuStrip PipingCalculationContextContextMenuStrip(PipingCalculationContext nodeData, object parentData, TreeViewControl treeViewControl)
{
PipingCalculation calculation = nodeData.WrappedData;
var validateItem = new StrictContextMenuItem(RingtoetsFormsResources.Validate,
@@ -419,7 +395,7 @@
clearOutputItem.ToolTipText = PipingFormsResources.ClearOutput_No_output_to_clear;
}
- return Gui.Get(node, treeViewControl)
+ return Gui.Get(nodeData, treeViewControl)
.AddCustomItem(validateItem)
.AddCustomItem(calculateItem)
.AddCustomItem(clearOutputItem)
@@ -536,7 +512,7 @@
return childNodeObjects.ToArray();
}
- private ContextMenuStrip PipingCalculationGroupContextContextMenuStrip(PipingCalculationGroupContext nodeData, TreeNode node, TreeViewControl treeViewControl)
+ private ContextMenuStrip PipingCalculationGroupContextContextMenuStrip(PipingCalculationGroupContext nodeData, object parentData, TreeViewControl treeViewControl)
{
var group = nodeData.WrappedData;
var addCalculationGroupItem = new StrictContextMenuItem(
@@ -551,8 +527,6 @@
group.Children.Add(newGroup);
nodeData.NotifyObservers();
-
- SelectNewlyAddedPipingCalculationGroupContextItemInTreeView(node, treeViewControl);
});
var addCalculationItem = new StrictContextMenuItem(
@@ -567,8 +541,6 @@
group.Children.Add(calculation);
nodeData.NotifyObservers();
-
- SelectNewlyAddedPipingCalculationGroupContextItemInTreeView(node, treeViewControl);
});
var validateAllItem = CreateValidateAllItem(group);
@@ -598,7 +570,7 @@
clearAllItem.ToolTipText = PipingFormsResources.PipingCalculationGroup_ClearOutput_No_calculation_with_output_to_clear;
}
- var builder = Gui.Get(node, treeViewControl)
+ var builder = Gui.Get(nodeData, treeViewControl)
.AddCustomItem(addCalculationGroupItem)
.AddCustomItem(addCalculationItem)
.AddSeparator()
@@ -607,8 +579,8 @@
.AddCustomItem(clearAllItem)
.AddSeparator();
- var isRenamable = PipingCalculationGroupContextCanRenameNode(nodeData, node.Parent.Tag);
- var isRemovable = PipingCalculationGroupContextCanRemove(nodeData, node.Parent.Tag);
+ var isRenamable = PipingCalculationGroupContextCanRenameNode(nodeData, parentData);
+ var isRemovable = PipingCalculationGroupContextCanRemove(nodeData, parentData);
if (isRenamable)
{
@@ -805,17 +777,6 @@
return new DroppingPipingCalculationToNewContainer(originalOwnerContext, target);
}
- private void SelectNewlyAddedPipingCalculationGroupContextItemInTreeView(TreeNode node, TreeViewControl treeViewControl)
- {
- // Expand parent of 'newItem' to ensure its selected state is visible.
- if (!node.IsExpanded)
- {
- node.Expand();
- }
- TreeNode newlyAppendedNodeForNewItem = node.Nodes.OfType().Last();
- treeViewControl.SelectNodeForData(newlyAppendedNodeForNewItem.Tag);
- }
-
#region Nested Types: DroppingPipingCalculationInContainerStrategy and implementations
///
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/EmptyPipingCalculationReportTreeNodeInfoTest.cs
===================================================================
diff -u -rc07c8243b6c74fa79a77f2edbc1799375064b057 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/EmptyPipingCalculationReportTreeNodeInfoTest.cs (.../EmptyPipingCalculationReportTreeNodeInfoTest.cs) (revision c07c8243b6c74fa79a77f2edbc1799375064b057)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/EmptyPipingCalculationReportTreeNodeInfoTest.cs (.../EmptyPipingCalculationReportTreeNodeInfoTest.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -1,6 +1,5 @@
using System.Drawing;
using System.Linq;
-using System.Windows.Forms;
using Core.Common.Controls.TreeView;
using Core.Common.Gui;
using Core.Common.Gui.ContextMenu;
@@ -87,7 +86,6 @@
var gui = mocks.StrictMock();
var menuBuilderMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
- var nodeMock = mocks.StrictMock();
menuBuilderMock.Expect(mb => mb.AddOpenItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
@@ -96,14 +94,14 @@
menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.Build()).Return(null);
- gui.Expect(cmp => cmp.Get(nodeMock, treeViewControlMock)).Return(menuBuilderMock);
+ gui.Expect(cmp => cmp.Get(null, treeViewControlMock)).Return(menuBuilderMock);
mocks.ReplayAll();
plugin.Gui = gui;
// Call
- info.ContextMenuStrip(null, nodeMock, treeViewControlMock);
+ info.ContextMenuStrip(null, null, treeViewControlMock);
// Assert
mocks.VerifyAll();
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/EmptyPipingOutputTreeNodeInfoTest.cs
===================================================================
diff -u -rc07c8243b6c74fa79a77f2edbc1799375064b057 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/EmptyPipingOutputTreeNodeInfoTest.cs (.../EmptyPipingOutputTreeNodeInfoTest.cs) (revision c07c8243b6c74fa79a77f2edbc1799375064b057)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/EmptyPipingOutputTreeNodeInfoTest.cs (.../EmptyPipingOutputTreeNodeInfoTest.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -1,6 +1,5 @@
using System.Drawing;
using System.Linq;
-using System.Windows.Forms;
using Core.Common.Controls.TreeView;
using Core.Common.Gui;
using Core.Common.Gui.ContextMenu;
@@ -85,20 +84,19 @@
var gui = mocks.StrictMock();
var menuBuilderMock = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
- var nodeMock = mocks.StrictMock();
menuBuilderMock.Expect(mb => mb.AddExportItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.Build()).Return(null);
- gui.Expect(cmp => cmp.Get(nodeMock, treeViewControlMock)).Return(menuBuilderMock);
+ gui.Expect(cmp => cmp.Get(null, treeViewControlMock)).Return(menuBuilderMock);
mocks.ReplayAll();
plugin.Gui = gui;
// Call
- info.ContextMenuStrip(null, nodeMock, treeViewControlMock);
+ info.ContextMenuStrip(null, null, treeViewControlMock);
// Assert
mocks.VerifyAll();
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationContextTreeNodeInfoTest.cs
===================================================================
diff -u -r99b31025be8be46190cf15e58aec262a4bb18858 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationContextTreeNodeInfoTest.cs (.../PipingCalculationContextTreeNodeInfoTest.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationContextTreeNodeInfoTest.cs (.../PipingCalculationContextTreeNodeInfoTest.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -1,6 +1,5 @@
using System;
using System.Linq;
-using System.Windows.Forms;
using Core.Common.Base;
using Core.Common.Controls.TreeView;
using Core.Common.Gui;
@@ -195,21 +194,19 @@
{
var gui = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
- var nodeMock = mocks.StrictMock();
+ var calculation = new PipingCalculation();
+ var nodeData = new PipingCalculationContext(calculation,
+ Enumerable.Empty(),
+ Enumerable.Empty());
- gui.Expect(cmp => cmp.Get(nodeMock, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
+ gui.Expect(cmp => cmp.Get(nodeData, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
mocks.ReplayAll();
plugin.Gui = gui;
- var calculation = new PipingCalculation();
- var nodeData = new PipingCalculationContext(calculation,
- Enumerable.Empty(),
- Enumerable.Empty());
-
// Call
- var contextMenu = info.ContextMenuStrip(nodeData, nodeMock, treeViewControlMock);
+ var contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControlMock);
// Assert
mocks.VerifyAll(); // Expect no calls on arguments
@@ -224,14 +221,6 @@
{
var gui = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
- var nodeMock = mocks.StrictMock();
-
- gui.Expect(cmp => cmp.Get(nodeMock, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
-
- mocks.ReplayAll();
-
- plugin.Gui = gui;
-
var calculation = new PipingCalculation
{
Output = new TestPipingOutput()
@@ -240,9 +229,14 @@
Enumerable.Empty(),
Enumerable.Empty());
+ gui.Expect(cmp => cmp.Get(nodeData, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
// Call
- var contextMenu = info.ContextMenuStrip(nodeData, nodeMock, treeViewControlMock);
+ var contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControlMock);
// Assert
mocks.VerifyAll(); // Expect no calls on arguments
@@ -259,7 +253,9 @@
var gui = mocks.StrictMock();
var menuBuilderMock = mocks.Stub();
var treeViewControlMock = mocks.StrictMock();
- var nodeMock = mocks.StrictMock();
+ var nodeData = new PipingCalculationContext(new PipingCalculation(),
+ Enumerable.Empty(),
+ Enumerable.Empty());
menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
@@ -277,18 +273,14 @@
menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
menuBuilderMock.Expect(mb => mb.Build()).Return(null);
- gui.Expect(cmp => cmp.Get(nodeMock, treeViewControlMock)).Return(menuBuilderMock);
+ gui.Expect(cmp => cmp.Get(nodeData, treeViewControlMock)).Return(menuBuilderMock);
mocks.ReplayAll();
plugin.Gui = gui;
- var nodeData = new PipingCalculationContext(new PipingCalculation(),
- Enumerable.Empty(),
- Enumerable.Empty());
-
// Call
- info.ContextMenuStrip(nodeData, nodeMock, treeViewControlMock);
+ info.ContextMenuStrip(nodeData, null, treeViewControlMock);
// Assert
mocks.VerifyAll(); // Expect no calls on arguments
@@ -407,11 +399,14 @@
var mainWindow = mocks.DynamicMock();
var observer = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
- var treeNodeMock = mocks.StrictMock();
+ var calculation = new PipingCalculation();
+ var pipingCalculationContext = new PipingCalculationContext(calculation,
+ Enumerable.Empty(),
+ Enumerable.Empty());
observer.Expect(o => o.UpdateObserver());
- gui.Expect(cmp => cmp.Get(treeNodeMock, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
+ gui.Expect(cmp => cmp.Get(pipingCalculationContext, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
gui.Expect(g => g.MainWindow).Return(mainWindow);
var expectedValidationMessageCount = 2; // No surfaceline or soil profile selected for calculation
@@ -425,15 +420,10 @@
plugin.Gui = gui;
- var calculation = new PipingCalculation();
calculation.Attach(observer);
- var pipingCalculationContext = new PipingCalculationContext(calculation,
- Enumerable.Empty(),
- Enumerable.Empty());
+ var contextMenuAdapter = info.ContextMenuStrip(pipingCalculationContext, null, treeViewControlMock);
- var contextMenuAdapter = info.ContextMenuStrip(pipingCalculationContext, treeNodeMock, treeViewControlMock);
-
// When
Action action = () =>
{
@@ -466,9 +456,12 @@
var gui = mocks.DynamicMock();
var observer = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
- var treeNodeMock = mocks.StrictMock();
+ var calculation = new PipingCalculation();
+ var pipingCalculationContext = new PipingCalculationContext(calculation,
+ Enumerable.Empty(),
+ Enumerable.Empty());
- gui.Expect(cmp => cmp.Get(treeNodeMock, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
+ gui.Expect(cmp => cmp.Get(pipingCalculationContext, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
var expectedValidationMessageCount = 2; // No surfaceline or soil profile selected for calculation
var expectedStatusMessageCount = 2;
@@ -481,13 +474,9 @@
plugin.Gui = gui;
- var calculation = new PipingCalculation();
calculation.Attach(observer);
- var pipingCalculationContext = new PipingCalculationContext(calculation,
- Enumerable.Empty(),
- Enumerable.Empty());
- var contextMenuAdapter = info.ContextMenuStrip(pipingCalculationContext, treeNodeMock, treeViewControlMock);
+ var contextMenuAdapter = info.ContextMenuStrip(pipingCalculationContext, null, treeViewControlMock);
// When
Action action = () => contextMenuAdapter.Items[validateContextMenuItemIndex].PerformClick();
@@ -506,9 +495,14 @@
var mainWindow = mocks.DynamicMock();
var observer = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
- var treeNodeMock = mocks.StrictMock();
+ var calculateContextMenuItemIndex = 1;
+ var calculation = new PipingCalculation();
+ var validPipingInput = new TestPipingInput();
+ var pipingCalculationContext = new PipingCalculationContext(calculation,
+ Enumerable.Empty(),
+ Enumerable.Empty());
- gui.Expect(g => g.Get(treeNodeMock, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
+ gui.Expect(g => g.Get(pipingCalculationContext, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
gui.Expect(g => g.MainWindow).Return(mainWindow);
observer.Expect(o => o.UpdateObserver());
@@ -521,9 +515,6 @@
plugin.Gui = gui;
- var calculateContextMenuItemIndex = 1;
- var calculation = new PipingCalculation();
- var validPipingInput = new TestPipingInput();
calculation.InputParameters.AssessmentLevel = validPipingInput.AssessmentLevel;
calculation.InputParameters.BeddingAngle = validPipingInput.BeddingAngle;
calculation.InputParameters.DampingFactorExit.Mean = validPipingInput.DampingFactorExit;
@@ -550,12 +541,8 @@
calculation.Attach(observer);
- var pipingCalculationContext = new PipingCalculationContext(calculation,
- Enumerable.Empty(),
- Enumerable.Empty());
+ var contextMenuAdapter = info.ContextMenuStrip(pipingCalculationContext, null, treeViewControlMock);
- var contextMenuAdapter = info.ContextMenuStrip(pipingCalculationContext, treeNodeMock, treeViewControlMock);
-
// When
Action action = () =>
{
@@ -590,9 +577,12 @@
var gui = mocks.DynamicMock();
var observer = mocks.StrictMock();
var treeViewControlMock = mocks.StrictMock();
- var treeNodeMock = mocks.StrictMock();
+ var calculation = new PipingCalculation();
+ var pipingCalculationContext = new PipingCalculationContext(calculation,
+ Enumerable.Empty(),
+ Enumerable.Empty());
- gui.Expect(cmp => cmp.Get(treeNodeMock, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
+ gui.Expect(cmp => cmp.Get(pipingCalculationContext, treeViewControlMock)).Return(new CustomItemsOnlyContextMenuBuilder());
int clearOutputItemPosition = 2;
if (confirm)
@@ -604,16 +594,11 @@
plugin.Gui = gui;
- var calculation = new PipingCalculation();
calculation.Output = new TestPipingOutput();
calculation.Attach(observer);
- var pipingCalculationContext = new PipingCalculationContext(calculation,
- Enumerable.Empty(),
- Enumerable.Empty());
+ var contextMenuAdapter = info.ContextMenuStrip(pipingCalculationContext, null, treeViewControlMock);
- var contextMenuAdapter = info.ContextMenuStrip(pipingCalculationContext, treeNodeMock, treeViewControlMock);
-
DialogBoxHandler = (name, wnd) =>
{
var messageBox = new MessageBoxTester(wnd);
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs
===================================================================
diff -u -r99b31025be8be46190cf15e58aec262a4bb18858 -r5774b9c9fd8cc22fc2196ec871431631133e6221
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision 99b31025be8be46190cf15e58aec262a4bb18858)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision 5774b9c9fd8cc22fc2196ec871431631133e6221)
@@ -713,24 +713,14 @@
var nodeData = new PipingCalculationGroupContext(group,
Enumerable.Empty(),
Enumerable.Empty());
- var nodeParent = new TreeNode
- {
- Tag = parentData
- };
- var node = new TreeNode
- {
- Tag = nodeData
- };
- nodeParent.Nodes.Add(node);
-
var applicationFeatureCommandHandler = mocks.Stub();
var exportImportHandler = mocks.Stub();
var viewCommandsHandler = mocks.StrictMock();
var treeViewControl = mocks.StrictMock();
- var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, exportImportHandler, viewCommandsHandler, node, treeViewControl);
- gui.Expect(g => g.Get(node, treeViewControl)).Return(menuBuilder);
+ var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, exportImportHandler, viewCommandsHandler, nodeData, treeViewControl);
+ gui.Expect(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
treeViewControl.Expect(tvc => tvc.CanRenameNodeForData(nodeData)).Return(true);
treeViewControl.Expect(tvc => tvc.CanRemoveNodeForData(nodeData)).Return(true);
@@ -741,7 +731,7 @@
plugin.Gui = gui;
// Call
- ContextMenuStrip menu = info.ContextMenuStrip(nodeData, node, treeViewControl);
+ ContextMenuStrip menu = info.ContextMenuStrip(nodeData, parentData, treeViewControl);
// Assert
Assert.AreEqual(17, menu.Items.Count);
@@ -832,24 +822,13 @@
Enumerable.Empty(),
Enumerable.Empty());
- var nodeParent = new TreeNode
- {
- Tag = parentData
- };
-
- var node = new TreeNode
- {
- Tag = nodeData
- };
- nodeParent.Nodes.Add(node);
-
var applicationFeatureCommandHandler = mocks.Stub();
var exportImportHandler = mocks.Stub();
var viewCommandsHandler = mocks.StrictMock();
var treeViewControl = mocks.StrictMock();
- var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, exportImportHandler, viewCommandsHandler, node, treeViewControl);
- gui.Expect(g => g.Get(node, treeViewControl)).Return(menuBuilder);
+ var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, exportImportHandler, viewCommandsHandler, nodeData, treeViewControl);
+ gui.Expect(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
treeViewControl.Expect(tvc => tvc.CanRenameNodeForData(nodeData)).Return(true);
treeViewControl.Expect(tvc => tvc.CanExpandOrCollapseAllNodesForData(nodeData)).Repeat.Twice().Return(false);
@@ -859,7 +838,7 @@
plugin.Gui = gui;
// Call
- ContextMenuStrip menu = info.ContextMenuStrip(nodeData, node, treeViewControl);
+ ContextMenuStrip menu = info.ContextMenuStrip(nodeData, parentData, treeViewControl);
// Assert
Assert.AreEqual(16, menu.Items.Count);
@@ -945,32 +924,21 @@
Enumerable.Empty(),
Enumerable.Empty());
- var nodeParent = new TreeNode
- {
- Tag = parentData
- };
-
- var node = new TreeNode
- {
- Tag = nodeData
- };
- nodeParent.Nodes.Add(node);
-
var applicationFeatureCommandHandler = mocks.Stub();
var exportImportHandler = mocks.Stub();
var viewCommandsHandler = mocks.StrictMock();
var treeViewControl = mocks.StrictMock();
- var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, exportImportHandler, viewCommandsHandler, node, treeViewControl);
- gui.Expect(g => g.Get(node, treeViewControl)).Return(menuBuilder);
+ var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler, exportImportHandler, viewCommandsHandler, nodeData, treeViewControl);
+ gui.Expect(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder);
treeViewControl.Expect(tvc => tvc.CanExpandOrCollapseAllNodesForData(nodeData)).Repeat.Twice().Return(false);
mocks.ReplayAll();
plugin.Gui = gui;
// Call
- ContextMenuStrip menu = info.ContextMenuStrip(nodeData, node, treeViewControl);
+ ContextMenuStrip menu = info.ContextMenuStrip(nodeData, parentData, treeViewControl);
// Assert
Assert.AreEqual(14, menu.Items.Count);
@@ -1047,25 +1015,15 @@
var nodeData = new PipingCalculationGroupContext(group,
Enumerable.Empty(),
Enumerable.Empty());
- var nodeParent = new TreeNode
- {
- Tag = parentData
- };
- var node = new TreeNode
- {
- Tag = nodeData
- };
- nodeParent.Nodes.Add(node);
+ gui.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder);
- gui.Expect(cmp => cmp.Get(node, treeViewControl)).Return(menuBuilder);
-
mocks.ReplayAll();
plugin.Gui = gui;
// Call
- ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, node, treeViewControl);
+ ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentData, treeViewControl);
// Assert
ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndex];
@@ -1097,23 +1055,9 @@
observer.Expect(o => o.UpdateObserver());
var treeViewControl = mocks.StrictMock();
- treeViewControl.Expect(tvc => tvc.SelectNodeForData(tag));
- var newCalculationGroupContextNode = new TreeNode { Tag = tag };
+ gui.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder);
- // Parent node of newly added item, should be expanded from collapsed state to show selected node:
- var parentNode = new TreeNode();
- var node = new TreeNode
- {
- Tag = nodeData
- };
- node.Nodes.Add(newCalculationGroupContextNode);
- node.Collapse();
-
- parentNode.Nodes.Add(node);
-
- gui.Expect(cmp => cmp.Get(node, treeViewControl)).Return(menuBuilder);
-
mocks.ReplayAll();
plugin.Gui = gui;
@@ -1122,7 +1066,7 @@
nodeData.Attach(observer);
- ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, node, treeViewControl);
+ ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl);
// Precondition
Assert.AreEqual(1, group.Children.Count);
@@ -1159,23 +1103,9 @@
observer.Expect(o => o.UpdateObserver());
var treeViewControl = mocks.StrictMock();
- treeViewControl.Expect(tvc => tvc.SelectNodeForData(tag));
- var newCalculationContextNode = new TreeNode { Tag = tag };
+ gui.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder);
- // Parent node of newly added item, should be expanded from collapsed state to show selected node:
- var parentNode = new TreeNode();
- var node = new TreeNode
- {
- Tag = nodeData
- };
- node.Nodes.Add(newCalculationContextNode);
- node.Collapse();
-
- parentNode.Nodes.Add(node);
-
- gui.Expect(cmp => cmp.Get(node, treeViewControl)).Return(menuBuilder);
-
mocks.ReplayAll();
plugin.Gui = gui;
@@ -1184,7 +1114,7 @@
nodeData.Attach(observer);
- var contextMenu = info.ContextMenuStrip(nodeData, node, treeViewControl);
+ var contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl);
// Precondition
Assert.AreEqual(1, group.Children.Count);
@@ -1210,16 +1140,6 @@
var treeViewControl = mocks.StrictMock();
var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
- var parentNode = new TreeNode();
- var node = new TreeNode();
- parentNode.Nodes.Add(node);
-
- gui.Expect(cmp => cmp.Get(node, treeViewControl)).Return(menuBuilder);
-
- mocks.ReplayAll();
-
- plugin.Gui = gui;
-
var validCalculation = PipingCalculationFactory.CreateCalculationWithValidInput();
validCalculation.Name = "A";
var invalidCalculation = PipingCalculationFactory.CreateCalculationWithInvalidData();
@@ -1238,8 +1158,14 @@
Enumerable.Empty(),
Enumerable.Empty