Browse Source

Adding child elements, inserting elements before and after the currently selected element are now possible in the XML tree editor.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1929 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 19 years ago
parent
commit
4a197ee962
  1. BIN
      data/resources/StringResources.es-mx.resources
  2. BIN
      data/resources/StringResources.es.resources
  3. BIN
      data/resources/StringResources.nl.resources
  4. 3
      src/AddIns/DisplayBindings/XmlEditor/Project/Resources/AddAttributeDialog.xfrm
  5. 60
      src/AddIns/DisplayBindings/XmlEditor/Project/Resources/AddElementDialog.xfrm
  6. 26
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/AddChildElementCommand.cs
  7. 87
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/AddElementDialog.cs
  8. 32
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/IXmlTreeView.cs
  9. 26
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/InsertElementAfterCommand.cs
  10. 26
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/InsertElementBeforeCommand.cs
  11. 2
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlElementTreeNode.cs
  12. 85
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeEditor.cs
  13. 1
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeView.cs
  14. 91
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewContainerControl.cs
  15. 70
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewControl.cs
  16. 22
      src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.addin
  17. 5
      src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.csproj
  18. 120
      src/AddIns/DisplayBindings/XmlEditor/Test/Tree/AddChildElementTestFixture.cs
  19. 97
      src/AddIns/DisplayBindings/XmlEditor/Test/Tree/AddElementsToTreeControlTestFixture.cs
  20. 105
      src/AddIns/DisplayBindings/XmlEditor/Test/Tree/ExplicitNamespaceTestFixture.cs
  21. 129
      src/AddIns/DisplayBindings/XmlEditor/Test/Tree/InsertElementAfterTestFixture.cs
  22. 129
      src/AddIns/DisplayBindings/XmlEditor/Test/Tree/InsertElementBeforeTestFixture.cs
  23. 10
      src/AddIns/DisplayBindings/XmlEditor/Test/Tree/NoMatchingSchemaTestFixture.cs
  24. 90
      src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockXmlTreeView.cs
  25. 5
      src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj
  26. 6
      src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeNode.cs
  27. BIN
      src/Main/StartUp/Project/Resources/StringResources.resources

BIN
data/resources/StringResources.es-mx.resources

Binary file not shown.

BIN
data/resources/StringResources.es.resources

Binary file not shown.

BIN
data/resources/StringResources.nl.resources

Binary file not shown.

3
src/AddIns/DisplayBindings/XmlEditor/Project/Resources/AddAttributeDialog.xfrm

@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
<Name value="label1" />
<Location value="5, 179" />
<Text value="${res:ICSharpCode.XmlEditor.AddAttributeDialog.CustomAttributeLabel}" />
<Anchor value="Bottom, Left" />
<Size value="82, 23" />
<TabIndex value="1" />
</System.Windows.Forms.Label>
@ -22,7 +23,7 @@ @@ -22,7 +23,7 @@
<TabIndex value="2" />
<Size value="183, 21" />
<Location value="100, 179" />
<Anchor value="Top, Left, Right" />
<Anchor value="Bottom, Left, Right" />
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Button>
<Name value="okButton" />

60
src/AddIns/DisplayBindings/XmlEditor/Project/Resources/AddElementDialog.xfrm

@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
<Components version="1.0">
<System.Windows.Forms.Form>
<Name value="AddElementDialog" />
<MinimizeBox value="False" />
<StartPosition value="CenterParent" />
<MinimumSize value="191, 155" />
<ShowInTaskbar value="False" />
<Text value="${res:ICSharpCode.XmlEditor.AddElementDialog.Title}" />
<MaximizeBox value="False" />
<ClientSize value="{Width=289, Height=244}" />
<ShowIcon value="False" />
<Controls>
<System.Windows.Forms.Label>
<Name value="customElementLabel" />
<Location value="5, 179" />
<Text value="${res:ICSharpCode.XmlEditor.AddElementDialog.CustomElementLabel}" />
<Anchor value="Bottom, Left" />
<Size value="82, 23" />
<TabIndex value="1" />
</System.Windows.Forms.Label>
<System.Windows.Forms.TextBox>
<Name value="elementTextBox" />
<TabIndex value="2" />
<Size value="183, 21" />
<Location value="100, 179" />
<Anchor value="Bottom, Left, Right" />
</System.Windows.Forms.TextBox>
<System.Windows.Forms.Button>
<Name value="okButton" />
<DialogResult value="OK" />
<Location value="121, 209" />
<Text value="${res:Global.OKButtonText}" />
<Anchor value="Bottom, Right" />
<UseVisualStyleBackColor value="True" />
<Size value="75, 23" />
<TabIndex value="3" />
</System.Windows.Forms.Button>
<System.Windows.Forms.Button>
<Name value="cancelButton" />
<DialogResult value="Cancel" />
<Location value="202, 209" />
<Text value="${res:Global.CancelButtonText}" />
<Anchor value="Bottom, Right" />
<UseVisualStyleBackColor value="True" />
<Size value="75, 23" />
<TabIndex value="4" />
</System.Windows.Forms.Button>
<System.Windows.Forms.ListBox>
<Name value="elementsListBox" />
<Size value="289, 173" />
<TabIndex value="0" />
<Sorted value="True" />
<SelectionMode value="MultiExtended" />
<FormattingEnabled value="True" />
<Location value="0, 0" />
<Anchor value="Top, Bottom, Left, Right" />
</System.Windows.Forms.ListBox>
</Controls>
</System.Windows.Forms.Form>
</Components>

26
src/AddIns/DisplayBindings/XmlEditor/Project/Src/AddChildElementCommand.cs

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.Core;
using System;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// Adds a new child element to the XML Tree.
/// </summary>
public class AddChildElementCommand : AbstractMenuCommand
{
public override void Run()
{
XmlTreeViewContainerControl view = Owner as XmlTreeViewContainerControl;
if (view != null) {
view.AddChildElement();
}
}
}
}

87
src/AddIns/DisplayBindings/XmlEditor/Project/Src/AddElementDialog.cs

@ -0,0 +1,87 @@ @@ -0,0 +1,87 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.Gui.XmlForms;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace ICSharpCode.XmlEditor
{
public class AddElementDialog : BaseSharpDevelopForm
{
ListBox elementsListBox;
Button okButton;
TextBox elementTextBox;
public AddElementDialog(string[] elementNames)
{
SetupFromXmlStream(GetType().Assembly.GetManifestResourceStream("ICSharpCode.XmlEditor.Resources.AddElementDialog.xfrm"));
okButton = (Button)ControlDictionary["okButton"];
okButton.Enabled = false;
AcceptButton = okButton;
CancelButton = (Button)ControlDictionary["cancelButton"];
elementTextBox = (TextBox)ControlDictionary["elementTextBox"];
elementTextBox.TextChanged += ElementTextBoxTextChanged;
elementsListBox = (ListBox)ControlDictionary["elementsListBox"];
elementsListBox.SelectedIndexChanged += ElementsListBoxSelectedIndexChanged;
foreach (string name in elementNames) {
elementsListBox.Items.Add(name);
}
}
/// <summary>
/// Gets the element names selected.
/// </summary>
public string[] ElementNames {
get {
List<string> elementNames = new List<string>();
if (IsElementSelected) {
foreach (string elementName in elementsListBox.SelectedItems) {
elementNames.Add(elementName);
}
}
string customElementName = elementTextBox.Text.Trim();
if (customElementName.Length > 0) {
elementNames.Add(customElementName);
}
return elementNames.ToArray();
}
}
void ElementsListBoxSelectedIndexChanged(object source, EventArgs e)
{
okButton.Enabled = IsOkButtonEnabled;
}
void ElementTextBoxTextChanged(object source, EventArgs e)
{
okButton.Enabled = IsOkButtonEnabled;
}
bool IsElementSelected {
get {
return elementsListBox.SelectedIndex >= 0;
}
}
bool IsOkButtonEnabled {
get {
return IsElementSelected || IsElementNameEntered;
}
}
bool IsElementNameEntered {
get {
return elementTextBox.Text.Trim().Length > 0;
}
}
}
}

32
src/AddIns/DisplayBindings/XmlEditor/Project/Src/IXmlTreeView.cs

@ -67,12 +67,42 @@ namespace ICSharpCode.XmlEditor @@ -67,12 +67,42 @@ namespace ICSharpCode.XmlEditor
/// </summary>
/// <param name="attributes">The list of attributes to
/// be displayed to the user.</param>
/// <returns>The attributes selected; otherwise null.</returns>
/// <returns>The attributes selected; otherwise an empty
/// collection.</returns>
string[] SelectNewAttributes(string[] attributes);
/// <summary>
/// Gets the name of the selected attribute.
/// </summary>
string SelectedAttribute {get;}
/// <summary>
/// Shows the add element dialog and allows the user
/// to select a new element to be added to the selected
/// xml element, either added as a child, inserted before
/// or after.
/// </summary>
/// <param name="attributes">The list of elements to
/// be displayed to the user.</param>
/// <returns>The attributes elements; otherwise an empty
/// collection.</returns>
string[] SelectNewElements(string[] elements);
/// <summary>
/// Appends the child element to the currently selected element.
/// </summary>
void AppendChildElement(XmlElement element);
/// <summary>
/// Inserts the specified element before the currently selected
/// element.
/// </summary>
void InsertElementBefore(XmlElement element);
/// <summary>
/// Inserts the specified element after the currently selected
/// element.
/// </summary>
void InsertElementAfter(XmlElement element);
}
}

26
src/AddIns/DisplayBindings/XmlEditor/Project/Src/InsertElementAfterCommand.cs

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.Core;
using System;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// Inserts a child element after the selected element in the XML tree.
/// </summary>
public class InsertElementAfterCommand : AbstractMenuCommand
{
public override void Run()
{
XmlTreeViewContainerControl view = Owner as XmlTreeViewContainerControl;
if (view != null) {
view.InsertElementAfter();
}
}
}
}

26
src/AddIns/DisplayBindings/XmlEditor/Project/Src/InsertElementBeforeCommand.cs

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.Core;
using System;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// Inserts a child element before the selected element in the XML tree.
/// </summary>
public class InsertElementBeforeCommand : AbstractMenuCommand
{
public override void Run()
{
XmlTreeViewContainerControl view = Owner as XmlTreeViewContainerControl;
if (view != null) {
view.InsertElementBefore();
}
}
}
}

2
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlElementTreeNode.cs

@ -38,7 +38,7 @@ namespace ICSharpCode.XmlEditor @@ -38,7 +38,7 @@ namespace ICSharpCode.XmlEditor
get {
return element;
}
}
}
/// <summary>
/// Adds child elements to this tree node.

85
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeEditor.cs

@ -133,6 +133,72 @@ namespace ICSharpCode.XmlEditor @@ -133,6 +133,72 @@ namespace ICSharpCode.XmlEditor
}
}
/// <summary>
/// Adds a new child element to the selected element.
/// </summary>
public void AddChildElement()
{
XmlElement selectedElement = view.SelectedElement;
if (selectedElement != null) {
string[] elementNames = GetChildElements(selectedElement);
string[] selectedElementNames = view.SelectNewElements(elementNames);
if (selectedElementNames.Length > 0) {
view.IsDirty = true;
foreach (string elementName in selectedElementNames) {
XmlElement newElement = document.CreateElement(elementName, selectedElement.NamespaceURI);
selectedElement.AppendChild(newElement);
view.AppendChildElement(newElement);
}
}
}
}
/// <summary>
/// Inserts an element before the currently selected element.
/// </summary>
public void InsertElementBefore()
{
XmlElement selectedElement = view.SelectedElement;
if (selectedElement != null) {
XmlElement parentElement = selectedElement.ParentNode as XmlElement;
if (parentElement != null) {
string[] elementNames = GetChildElements(parentElement);
string[] selectedElementNames = view.SelectNewElements(elementNames);
if (selectedElementNames.Length > 0) {
view.IsDirty = true;
foreach (string elementName in selectedElementNames) {
XmlElement newElement = document.CreateElement(elementName, parentElement.NamespaceURI);
parentElement.InsertBefore(newElement, selectedElement);
view.InsertElementBefore(newElement);
}
}
}
}
}
/// <summary>
/// Inserts an element after the currently selected element.
/// </summary>
public void InsertElementAfter()
{
XmlElement selectedElement = view.SelectedElement;
if (selectedElement != null) {
XmlElement parentElement = selectedElement.ParentNode as XmlElement;
if (parentElement != null) {
string[] elementNames = GetChildElements(parentElement);
string[] selectedElementNames = view.SelectNewElements(elementNames);
if (selectedElementNames.Length > 0) {
view.IsDirty = true;
foreach (string elementName in selectedElementNames) {
XmlElement newElement = document.CreateElement(elementName, parentElement.NamespaceURI);
parentElement.InsertAfter(newElement, selectedElement);
view.InsertElementAfter(newElement);
}
}
}
}
}
/// <summary>
/// Gets the missing attributes for the specified element based
/// on its associated schema.
@ -173,5 +239,24 @@ namespace ICSharpCode.XmlEditor @@ -173,5 +239,24 @@ namespace ICSharpCode.XmlEditor
}
return path;
}
/// <summary>
/// Returns a list of elements that can be children of the
/// specified element.
/// </summary>
string[] GetChildElements(XmlElement element)
{
XmlElementPath elementPath = GetElementPath(element);
List<string> elements = new List<string>();
XmlSchemaCompletionData schemaCompletionData = completionDataProvider.FindSchema(elementPath);
if (schemaCompletionData != null) {
ICompletionData[] completionData = schemaCompletionData.GetChildElementCompletionData(elementPath);
foreach (ICompletionData elementCompletionData in completionData) {
elements.Add(elementCompletionData.Text);
}
}
return elements.ToArray();
}
}
}

1
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeView.cs

@ -28,6 +28,7 @@ namespace ICSharpCode.XmlEditor @@ -28,6 +28,7 @@ namespace ICSharpCode.XmlEditor
this.xmlView = xmlView;
treeViewContainer.DirtyChanged += TreeViewContainerDirtyChanged;
treeViewContainer.AttributesGrid.ContextMenuStrip = MenuService.CreateContextMenu(treeViewContainer, "/AddIns/XmlEditor/XmlTree/AttributesGrid/ContextMenu");
treeViewContainer.TreeView.ContextMenuStrip = MenuService.CreateContextMenu(treeViewContainer, "/AddIns/XmlEditor/XmlTree/ContextMenu");
}
public override Control Control {

91
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewContainerControl.cs

@ -15,8 +15,8 @@ using System.Xml; @@ -15,8 +15,8 @@ using System.Xml;
namespace ICSharpCode.XmlEditor
{
/// <summary>
/// This user control holds both the XmlTreeViewControl and the
/// attributes property grid in a split container. This is separate from
/// This user control holds both the XmlTreeViewControl and the
/// attributes property grid in a split container. This is separate from
/// the XmlTreeView class so we can use the forms designer to design this control.
/// </summary>
public class XmlTreeViewContainerControl : System.Windows.Forms.UserControl, IXmlTreeView, IOwnerState
@ -31,7 +31,8 @@ namespace ICSharpCode.XmlEditor @@ -31,7 +31,8 @@ namespace ICSharpCode.XmlEditor
public enum XmlTreeViewContainerControlState {
Nothing = 0,
ElementSelected = 1,
AttributeSelected = 2
RootElementSelected = 2,
AttributeSelected = 4
}
public event EventHandler DirtyChanged;
@ -47,6 +48,9 @@ namespace ICSharpCode.XmlEditor @@ -47,6 +48,9 @@ namespace ICSharpCode.XmlEditor
XmlTreeViewContainerControlState state = XmlTreeViewContainerControlState.Nothing;
if (SelectedElement != null) {
state |= XmlTreeViewContainerControlState.ElementSelected;
if (SelectedElement == DocumentElement) {
state |= XmlTreeViewContainerControlState.RootElementSelected;
}
}
if (SelectedAttribute != null) {
state |= XmlTreeViewContainerControlState.AttributeSelected;
@ -108,7 +112,7 @@ namespace ICSharpCode.XmlEditor @@ -108,7 +112,7 @@ namespace ICSharpCode.XmlEditor
}
}
}
public XmlTreeViewControl TreeView {
get {
return xmlElementTreeView;
@ -143,7 +147,7 @@ namespace ICSharpCode.XmlEditor @@ -143,7 +147,7 @@ namespace ICSharpCode.XmlEditor
editor = new XmlTreeEditor(this, completionDataProvider);
editor.LoadXml(xml);
// Expand document element node.
// Expand document element node.
if (xmlElementTreeView.Nodes.Count > 0) {
xmlElementTreeView.Nodes[0].Expand();
}
@ -176,7 +180,7 @@ namespace ICSharpCode.XmlEditor @@ -176,7 +180,7 @@ namespace ICSharpCode.XmlEditor
}
/// <summary>
/// Shows the xml element's text content after the user has
/// Shows the xml element's text content after the user has
/// selected the text node.
/// </summary>
public void ShowTextContent(string text)
@ -218,7 +222,7 @@ namespace ICSharpCode.XmlEditor @@ -218,7 +222,7 @@ namespace ICSharpCode.XmlEditor
public string SelectedAttribute {
get {
GridItem gridItem = attributesGrid.SelectedGridItem;
if (IsAttributesGridVisible && gridItem != null) {
if (IsAttributesGridVisible && gridItem != null && gridItem.PropertyDescriptor != null) {
return gridItem.PropertyDescriptor.Name;
}
return null;
@ -258,7 +262,74 @@ namespace ICSharpCode.XmlEditor @@ -258,7 +262,74 @@ namespace ICSharpCode.XmlEditor
{
editor.RemoveAttribute();
}
/// <summary>
/// Shows the add element dialog so the user can choose one or more
/// new elements to be added to the selected element.
/// </summary>
/// <param name="attributes">The list of elements the user
/// can choose from.</param>
/// <returns>The elements selected by the user.</returns>
public string[] SelectNewElements(string[] elements)
{
using (AddElementDialog addElementDialog = new AddElementDialog(elements)) {
if (addElementDialog.ShowDialog() == DialogResult.OK) {
return addElementDialog.ElementNames;
}
return new string[0];
}
}
/// <summary>
/// Appends a new child element to the currently selected element.
/// </summary>
public void AppendChildElement(XmlElement element)
{
xmlElementTreeView.AppendChildElement(element);
}
/// <summary>
/// Adds a new child element to the selected element.
/// </summary>
public void AddChildElement()
{
editor.AddChildElement();
}
/// <summary>
/// Inserts an element before the currently selected element.
/// </summary>
public void InsertElementBefore()
{
editor.InsertElementBefore();
}
/// <summary>
/// Inserts the specified element before the currently selected
/// element.
/// </summary>
public void InsertElementBefore(XmlElement element)
{
xmlElementTreeView.InsertElementBefore(element);
}
/// <summary>
/// Inserts an element after the currently selected element.
/// </summary>
public void InsertElementAfter()
{
editor.InsertElementAfter();
}
/// <summary>
/// Inserts the specified element after the currently selected
/// element.
/// </summary>
public void InsertElementAfter(XmlElement element)
{
xmlElementTreeView.InsertElementAfter(element);
}
/// <summary>
/// Disposes resources used by the control.
/// </summary>
@ -449,7 +520,7 @@ namespace ICSharpCode.XmlEditor @@ -449,7 +520,7 @@ namespace ICSharpCode.XmlEditor
}
/// <summary>
/// Gets or sets whether the attributes grid is visible.
/// Gets or sets whether the attributes grid is visible.
/// </summary>
bool IsAttributesGridVisible {
get {
@ -470,7 +541,7 @@ namespace ICSharpCode.XmlEditor @@ -470,7 +541,7 @@ namespace ICSharpCode.XmlEditor
}
/// <summary>
/// Gets or sets whether the text node text box is visible.
/// Gets or sets whether the text node text box is visible.
/// </summary>
bool IsTextBoxVisible {
get {

70
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlTreeViewControl.cs

@ -25,6 +25,11 @@ namespace ICSharpCode.XmlEditor @@ -25,6 +25,11 @@ namespace ICSharpCode.XmlEditor
const string ViewStatePropertyName = "XmlTreeViewControl.ViewState";
XmlElement documentElement;
enum InsertionMode {
Before = 0,
After = 1
}
public XmlTreeViewControl()
{
@ -50,7 +55,7 @@ namespace ICSharpCode.XmlEditor @@ -50,7 +55,7 @@ namespace ICSharpCode.XmlEditor
public XmlElement SelectedElement {
get {
XmlElementTreeNode xmlElementTreeNode = SelectedNode as XmlElementTreeNode;
XmlElementTreeNode xmlElementTreeNode = SelectedElementNode;
if (xmlElementTreeNode != null) {
return xmlElementTreeNode.XmlElement;
}
@ -96,6 +101,45 @@ namespace ICSharpCode.XmlEditor @@ -96,6 +101,45 @@ namespace ICSharpCode.XmlEditor
{
ExtTreeView.ApplyViewStateString(properties.Get(ViewStatePropertyName, String.Empty), this);
}
/// <summary>
/// Appends a new child element to the currently selected node.
/// </summary>
public void AppendChildElement(XmlElement element)
{
XmlElementTreeNode selectedNode = SelectedElementNode;
if (selectedNode != null) {
XmlElementTreeNode newNode = new XmlElementTreeNode(element);
newNode.AddTo(selectedNode);
selectedNode.Expand();
}
}
/// <summary>
/// Inserts a new element node before the currently selected
/// node.
/// </summary>
public void InsertElementBefore(XmlElement element)
{
InsertElement(element, InsertionMode.Before);
}
/// <summary>
/// Inserts a new element node after the currently selected
/// node.
/// </summary>
public void InsertElementAfter(XmlElement element)
{
InsertElement(element, InsertionMode.After);
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (SelectedNode == null) {
this.OnAfterSelect(new TreeViewEventArgs(null, TreeViewAction.ByMouse));
}
}
void ShowDocumentElement()
{
@ -106,11 +150,27 @@ namespace ICSharpCode.XmlEditor @@ -106,11 +150,27 @@ namespace ICSharpCode.XmlEditor
}
}
protected override void OnMouseDown(MouseEventArgs e)
XmlElementTreeNode SelectedElementNode {
get {
return SelectedNode as XmlElementTreeNode;
}
}
/// <summary>
/// Inserts a new element node either before or after the
/// currently selected element node.
/// </summary>
void InsertElement(XmlElement element, InsertionMode insertionMode)
{
base.OnMouseDown(e);
if (SelectedNode == null) {
this.OnAfterSelect(new TreeViewEventArgs(null, TreeViewAction.ByMouse));
XmlElementTreeNode selectedNode = SelectedElementNode;
if (selectedNode != null) {
XmlElementTreeNode parentNode = (XmlElementTreeNode)selectedNode.Parent;
XmlElementTreeNode newNode = new XmlElementTreeNode(element);
int index = parentNode.Nodes.IndexOf(selectedNode);
if (insertionMode == InsertionMode.After) {
index++;
}
newNode.Insert(index, parentNode);
}
}
}

22
src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.addin

@ -196,4 +196,26 @@ @@ -196,4 +196,26 @@
class = "ICSharpCode.XmlEditor.RemoveAttributeCommand"/>
</Condition>
</Path>
<Path name = "/AddIns/XmlEditor/XmlTree/ContextMenu">
<ComplexCondition action = "Disable">
<And>
<Condition name = "Ownerstate" ownerstate = "ElementSelected"/>
<Not>
<Condition name = "Ownerstate" ownerstate = "RootElementSelected"/>
</Not>
</And>
<MenuItem id = "InsertElementBefore"
label = "${res:ICSharpCode.XmlEditor.XmlTreeView.InsertElementBeforeMenuLabel}"
class = "ICSharpCode.XmlEditor.InsertElementBeforeCommand"/>
<MenuItem id = "InsertElementAfter"
label = "${res:ICSharpCode.XmlEditor.XmlTreeView.InsertElementAfterMenuLabel}"
class = "ICSharpCode.XmlEditor.InsertElementAfterCommand"/>
</ComplexCondition>
<Condition name = "Ownerstate" ownerstate = "ElementSelected" action = "Disable">
<MenuItem id = "AddChildElement"
label = "${res:ICSharpCode.XmlEditor.XmlTreeView.AddChildElementMenuLabel}"
class = "ICSharpCode.XmlEditor.AddChildElementCommand"/>
</Condition>
</Path>
</AddIn>

5
src/AddIns/DisplayBindings/XmlEditor/Project/XmlEditor.csproj

@ -131,6 +131,11 @@ @@ -131,6 +131,11 @@
<Compile Include="Src\AddAttributeDialog.cs" />
<Compile Include="Src\AddAttributeCommand.cs" />
<Compile Include="Src\RemoveAttributeCommand.cs" />
<EmbeddedResource Include="Resources\AddElementDialog.xfrm" />
<Compile Include="Src\AddElementDialog.cs" />
<Compile Include="Src\AddChildElementCommand.cs" />
<Compile Include="Src\InsertElementBeforeCommand.cs" />
<Compile Include="Src\InsertElementAfterCommand.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">

120
src/AddIns/DisplayBindings/XmlEditor/Test/Tree/AddChildElementTestFixture.cs

@ -0,0 +1,120 @@ @@ -0,0 +1,120 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
using System.Xml;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Tree
{
/// <summary>
/// Tests that a child element is added to the XML document by the
/// XmlTreeEditor.
/// </summary>
[TestFixture]
public class AddChildElementTestFixture : XmlTreeViewTestFixtureBase
{
XmlElement bodyElement;
[SetUp]
public void Init()
{
base.InitFixture();
bodyElement = (XmlElement)editor.Document.SelectSingleNode("/html/body");
mockXmlTreeView.SelectedElement = bodyElement;
mockXmlTreeView.SelectedNewElementsToReturn.Add("h1");
mockXmlTreeView.SelectedNewElementsToReturn.Add("p");
editor.AddChildElement();
}
[Test]
public void ViewSelectElementsCalled()
{
Assert.IsTrue(mockXmlTreeView.IsSelectNewElementsCalled);
}
[Test]
public void NoElementSelected()
{
mockXmlTreeView.SelectedElement = null;
mockXmlTreeView.IsSelectNewElementsCalled = false;
editor.AddChildElement();
Assert.IsFalse(mockXmlTreeView.IsSelectNewElementsCalled);
}
[Test]
public void IsDirty()
{
Assert.IsTrue(mockXmlTreeView.IsDirty);
}
[Test]
public void NoElementsToAdd()
{
mockXmlTreeView.SelectedNewElementsToReturn.Clear();
mockXmlTreeView.IsDirty = false;
editor.AddChildElement();
Assert.IsFalse(mockXmlTreeView.IsDirty);
}
[Test]
public void ParagraphElementAdded()
{
Assert.AreEqual(1, bodyElement.GetElementsByTagName("p").Count);
}
[Test]
public void HeadlineElementAdded()
{
Assert.AreEqual(1, bodyElement.GetElementsByTagName("h1").Count);
}
[Test]
public void HeadlineElementNamespace()
{
XmlElement element = (XmlElement)(bodyElement.GetElementsByTagName("h1")[0]);
Assert.AreEqual(String.Empty, element.NamespaceURI);
}
[Test]
public void ElementListContainsForm()
{
Assert.IsTrue(mockXmlTreeView.SelectNewElementsList.Contains("form"));
}
[Test]
public void TwoChildElementsAddedToView()
{
Assert.AreEqual(2, mockXmlTreeView.ChildElementsAdded.Count);
}
/// <summary>
/// Returns the xhtml strict schema as the default schema.
/// </summary>
protected override XmlSchemaCompletionData DefaultSchemaCompletionData {
get {
XmlTextReader reader = ResourceManager.GetXhtmlStrictSchema();
return new XmlSchemaCompletionData(reader);
}
}
protected override string GetXml()
{
return "<html>\r\n" +
"\t<head>\r\n" +
"\t\t<title></title>\r\n" +
"\t</head>\r\n" +
"\t<body>\r\n" +
"\t</body>\r\n" +
"</html>";
}
}
}

97
src/AddIns/DisplayBindings/XmlEditor/Test/Tree/AddElementsToTreeControlTestFixture.cs

@ -0,0 +1,97 @@ @@ -0,0 +1,97 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.Windows.Forms;
using System.Xml;
namespace XmlEditor.Tests.Tree
{
[TestFixture]
public class AddElementsToTreeControlTestFixture
{
XmlDocument doc;
XmlElementTreeNode rootNode;
[SetUp]
public void SetUpFixture()
{
doc = new XmlDocument();
doc.LoadXml("<root/>");
using (XmlTreeViewControl treeView = new XmlTreeViewControl()) {
treeView.DocumentElement = doc.DocumentElement;
rootNode = (XmlElementTreeNode)treeView.Nodes[0];
// No node selected in treeview - adding a child
// node should do nothing.
treeView.SelectedNode = null;
XmlElement testElement = doc.CreateElement("test");
treeView.AppendChildElement(testElement);
treeView.SelectedNode = rootNode;
XmlElement childElement = doc.CreateElement("child");
treeView.AppendChildElement(childElement);
// No node selected in treeview - inserting a node
// node should do nothing.
treeView.SelectedNode = null;
treeView.AppendChildElement(testElement);
XmlElementTreeNode childNode = (XmlElementTreeNode)rootNode.Nodes[0];
treeView.SelectedNode = childNode;
XmlElement beforeElement = doc.CreateElement("before");
treeView.InsertElementBefore(beforeElement);
// No node selected in treeview - inserting a node
// node should do nothing.
treeView.SelectedNode = null;
treeView.AppendChildElement(testElement);
treeView.SelectedNode = childNode;
XmlElement afterElement = doc.CreateElement("after");
treeView.InsertElementAfter(afterElement);
}
}
[Test]
public void ChildNodeAdded()
{
XmlElementTreeNode childNode = (XmlElementTreeNode)rootNode.Nodes[1];
Assert.AreEqual("child", childNode.Text);
}
[Test]
public void NodeInsertedBeforeAdded()
{
XmlElementTreeNode node = (XmlElementTreeNode)rootNode.Nodes[0];
Assert.AreEqual("before", node.Text);
}
[Test]
public void NodeInsertedBeforeParent()
{
XmlElementTreeNode node = (XmlElementTreeNode)rootNode.Nodes[0];
Assert.IsNotNull(node.Parent);
}
[Test]
public void NodeInsertedAfterAdded()
{
XmlElementTreeNode node = (XmlElementTreeNode)rootNode.Nodes[2];
Assert.AreEqual("after", node.Text);
}
[Test]
public void ThreeChildNodesAdded()
{
Assert.AreEqual(3, rootNode.Nodes.Count);
}
}
}

105
src/AddIns/DisplayBindings/XmlEditor/Test/Tree/ExplicitNamespaceTestFixture.cs

@ -0,0 +1,105 @@ @@ -0,0 +1,105 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
using System.Xml;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Tree
{
/// <summary>
/// Tests that a child element is added to the XML document by the
/// XmlTreeEditor with the correct namespace.
/// </summary>
[TestFixture]
public class ExplicitNamespaceTestFixture : XmlTreeViewTestFixtureBase
{
XmlElement bodyElement;
[SetUp]
public void Init()
{
base.InitFixture();
XmlNamespaceManager nsManager = new XmlNamespaceManager(editor.Document.NameTable);
nsManager.AddNamespace("h", "http://www.w3.org/1999/xhtml");
bodyElement = (XmlElement)editor.Document.SelectSingleNode("/h:html/h:body", nsManager);
mockXmlTreeView.SelectedElement = bodyElement;
mockXmlTreeView.SelectedNewElementsToReturn.Add("h1");
editor.AddChildElement();
}
[Test]
public void HeadlineElementNamespace()
{
XmlElement element = (XmlElement)bodyElement.FirstChild;
Assert.AreEqual("http://www.w3.org/1999/xhtml", element.NamespaceURI);
}
[Test]
public void InsertBeforeDifferentNamespaceElementSelected()
{
XmlNamespaceManager nsManager = new XmlNamespaceManager(editor.Document.NameTable);
nsManager.AddNamespace("a", "http://asp.net");
XmlElement buttonElement = (XmlElement)editor.Document.SelectSingleNode("//a:button", nsManager);
XmlElement headElement = (XmlElement)buttonElement.ParentNode;
mockXmlTreeView.SelectedElement = buttonElement;
mockXmlTreeView.SelectedNewElementsToReturn.Clear();
mockXmlTreeView.SelectedNewElementsToReturn.Add("title");
editor.InsertElementBefore();
XmlElement titleElement = (XmlElement)headElement.FirstChild;
Assert.AreEqual(2, headElement.ChildNodes.Count);
Assert.AreEqual("title", titleElement.LocalName);
Assert.AreEqual("http://www.w3.org/1999/xhtml", titleElement.NamespaceURI);
}
[Test]
public void InsertAfterDifferentNamespaceElementSelected()
{
XmlNamespaceManager nsManager = new XmlNamespaceManager(editor.Document.NameTable);
nsManager.AddNamespace("a", "http://asp.net");
XmlElement buttonElement = (XmlElement)editor.Document.SelectSingleNode("//a:button", nsManager);
XmlElement headElement = (XmlElement)buttonElement.ParentNode;
mockXmlTreeView.SelectedElement = buttonElement;
mockXmlTreeView.SelectedNewElementsToReturn.Clear();
mockXmlTreeView.SelectedNewElementsToReturn.Add("title");
editor.InsertElementAfter();
XmlElement titleElement = (XmlElement)headElement.LastChild;
Assert.AreEqual(2, headElement.ChildNodes.Count);
Assert.AreEqual("title", titleElement.LocalName);
Assert.AreEqual("http://www.w3.org/1999/xhtml", titleElement.NamespaceURI);
}
/// <summary>
/// Returns the xhtml strict schema as the default schema.
/// </summary>
protected override XmlSchemaCompletionData DefaultSchemaCompletionData {
get {
XmlTextReader reader = ResourceManager.GetXhtmlStrictSchema();
return new XmlSchemaCompletionData(reader);
}
}
protected override string GetXml()
{
return "<html xmlns='http://www.w3.org/1999/xhtml'>\r\n" +
"\t<head>\r\n" +
"\t\t<asp:button xmlns:asp='http://asp.net'/>\r\n" +
"\t</head>\r\n" +
"\t<body>\r\n" +
"\t</body>\r\n" +
"</html>";
}
}
}

129
src/AddIns/DisplayBindings/XmlEditor/Test/Tree/InsertElementAfterTestFixture.cs

@ -0,0 +1,129 @@ @@ -0,0 +1,129 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
using System.Xml;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Tree
{
/// <summary>
/// Tests that an element is inserted after the selected element by the
/// XmlTreeEditor.
/// </summary>
[TestFixture]
public class InsertElementAfterTestFixture : XmlTreeViewTestFixtureBase
{
XmlElement paragraphElement;
XmlElement bodyElement;
[SetUp]
public void Init()
{
base.InitFixture();
bodyElement = (XmlElement)editor.Document.SelectSingleNode("/html/body");
paragraphElement = (XmlElement)bodyElement.FirstChild;
mockXmlTreeView.SelectedElement = paragraphElement;
mockXmlTreeView.SelectedNewElementsToReturn.Add("h1");
editor.InsertElementAfter();
}
[Test]
public void HeadlineElementAdded()
{
XmlElement headlineElement = (XmlElement)bodyElement.LastChild;
Assert.AreEqual("h1", headlineElement.LocalName);
}
[Test]
public void BodyHasTwoChildElements()
{
Assert.AreEqual(2, bodyElement.ChildNodes.Count);
}
[Test]
public void IsDirty()
{
Assert.IsTrue(mockXmlTreeView.IsDirty);
}
[Test]
public void ViewSelectElementsCalled()
{
Assert.IsTrue(mockXmlTreeView.IsSelectNewElementsCalled);
}
[Test]
public void NoElementsToAdd()
{
mockXmlTreeView.SelectedNewElementsToReturn.Clear();
mockXmlTreeView.IsDirty = false;
editor.InsertElementAfter();
Assert.IsFalse(mockXmlTreeView.IsDirty);
}
[Test]
public void NoElementSelected()
{
mockXmlTreeView.SelectedElement = null;
mockXmlTreeView.IsSelectNewElementsCalled = false;
editor.InsertElementAfter();
Assert.IsFalse(mockXmlTreeView.IsSelectNewElementsCalled);
}
[Test]
public void ElementListContainsForm()
{
Assert.IsTrue(mockXmlTreeView.SelectNewElementsList.Contains("form"));
}
[Test]
public void NewElementAddedToView()
{
Assert.AreEqual(1, mockXmlTreeView.ElementsInsertedAfter.Count);
}
/// <summary>
/// Cannot insert after the root element.
/// </summary>
[Test]
public void RootElementSelected()
{
mockXmlTreeView.SelectedElement = editor.Document.DocumentElement;
mockXmlTreeView.IsDirty = false;
editor.InsertElementAfter();
Assert.IsFalse(mockXmlTreeView.IsDirty);
}
/// <summary>
/// Returns the xhtml strict schema as the default schema.
/// </summary>
protected override XmlSchemaCompletionData DefaultSchemaCompletionData {
get {
XmlTextReader reader = ResourceManager.GetXhtmlStrictSchema();
return new XmlSchemaCompletionData(reader);
}
}
protected override string GetXml()
{
return "<html>\r\n" +
"\t<head>\r\n" +
"\t\t<title></title>\r\n" +
"\t</head>\r\n" +
"\t<body>\r\n" +
"\t\t<p/>\r\n" +
"\t</body>\r\n" +
"</html>";
}
}
}

129
src/AddIns/DisplayBindings/XmlEditor/Test/Tree/InsertElementBeforeTestFixture.cs

@ -0,0 +1,129 @@ @@ -0,0 +1,129 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.XmlEditor;
using NUnit.Framework;
using System;
using System.IO;
using System.Xml;
using XmlEditor.Tests.Utils;
namespace XmlEditor.Tests.Tree
{
/// <summary>
/// Tests that an element is inserted before the selected element by the
/// XmlTreeEditor.
/// </summary>
[TestFixture]
public class InsertElementBeforeTestFixture : XmlTreeViewTestFixtureBase
{
XmlElement paragraphElement;
XmlElement bodyElement;
[SetUp]
public void Init()
{
base.InitFixture();
bodyElement = (XmlElement)editor.Document.SelectSingleNode("/html/body");
paragraphElement = (XmlElement)bodyElement.FirstChild;
mockXmlTreeView.SelectedElement = paragraphElement;
mockXmlTreeView.SelectedNewElementsToReturn.Add("h1");
editor.InsertElementBefore();
}
[Test]
public void HeadlineElementAdded()
{
XmlElement headlineElement = (XmlElement)bodyElement.FirstChild;
Assert.AreEqual("h1", headlineElement.LocalName);
}
[Test]
public void BodyHasTwoChildElements()
{
Assert.AreEqual(2, bodyElement.ChildNodes.Count);
}
[Test]
public void IsDirty()
{
Assert.IsTrue(mockXmlTreeView.IsDirty);
}
[Test]
public void ViewSelectElementsCalled()
{
Assert.IsTrue(mockXmlTreeView.IsSelectNewElementsCalled);
}
[Test]
public void NoElementsToAdd()
{
mockXmlTreeView.SelectedNewElementsToReturn.Clear();
mockXmlTreeView.IsDirty = false;
editor.InsertElementBefore();
Assert.IsFalse(mockXmlTreeView.IsDirty);
}
[Test]
public void NoElementSelected()
{
mockXmlTreeView.SelectedElement = null;
mockXmlTreeView.IsSelectNewElementsCalled = false;
editor.InsertElementBefore();
Assert.IsFalse(mockXmlTreeView.IsSelectNewElementsCalled);
}
[Test]
public void ElementListContainsForm()
{
Assert.IsTrue(mockXmlTreeView.SelectNewElementsList.Contains("form"));
}
[Test]
public void NewElementAddedToView()
{
Assert.AreEqual(1, mockXmlTreeView.ElementsInsertedBefore.Count);
}
/// <summary>
/// Cannot insert before the root element.
/// </summary>
[Test]
public void RootElementSelected()
{
mockXmlTreeView.SelectedElement = editor.Document.DocumentElement;
mockXmlTreeView.IsDirty = false;
editor.InsertElementBefore();
Assert.IsFalse(mockXmlTreeView.IsDirty);
}
/// <summary>
/// Returns the xhtml strict schema as the default schema.
/// </summary>
protected override XmlSchemaCompletionData DefaultSchemaCompletionData {
get {
XmlTextReader reader = ResourceManager.GetXhtmlStrictSchema();
return new XmlSchemaCompletionData(reader);
}
}
protected override string GetXml()
{
return "<html>\r\n" +
"\t<head>\r\n" +
"\t\t<title></title>\r\n" +
"\t</head>\r\n" +
"\t<body>\r\n" +
"\t\t<p/>\r\n" +
"\t</body>\r\n" +
"</html>";
}
}
}

10
src/AddIns/DisplayBindings/XmlEditor/Test/Tree/NoMatchingSchemaTestFixture.cs

@ -31,6 +31,7 @@ namespace XmlEditor.Tests.Tree @@ -31,6 +31,7 @@ namespace XmlEditor.Tests.Tree
mockXmlTreeView.SelectedElement = bodyElement;
editor.AddAttribute();
editor.AddChildElement();
}
/// <summary>
@ -42,6 +43,15 @@ namespace XmlEditor.Tests.Tree @@ -42,6 +43,15 @@ namespace XmlEditor.Tests.Tree
Assert.IsTrue(mockXmlTreeView.IsSelectNewAttributesCalled);
}
/// <summary>
/// Can still add a new element even if there is no associated schema.
/// </summary>
[Test]
public void ViewSelectNewElementsCalled()
{
Assert.IsTrue(mockXmlTreeView.IsSelectNewElementsCalled);
}
protected override string GetXml()
{
return "<html>\r\n" +

90
src/AddIns/DisplayBindings/XmlEditor/Test/Utils/MockXmlTreeView.cs

@ -26,6 +26,12 @@ namespace XmlEditor.Tests.Utils @@ -26,6 +26,12 @@ namespace XmlEditor.Tests.Utils
List<string> selectNewAttributesList = new List<string>();
List<string> selectedNewAttributesToReturn = new List<string>();
string selectedAttribute = null;
bool selectNewElementsCalled = false;
List<string> selectedNewElementsToReturn = new List<string>();
List<string> selectNewElementsList = new List<string>();
List<XmlElement> childElementsAdded = new List<XmlElement>();
List<XmlElement> elementsInsertedBefore = new List<XmlElement>();
List<XmlElement> elementsInsertedAfter = new List<XmlElement>();
public MockXmlTreeView()
{
@ -107,6 +113,28 @@ namespace XmlEditor.Tests.Utils @@ -107,6 +113,28 @@ namespace XmlEditor.Tests.Utils
}
}
public string[] SelectNewElements(string[] elements)
{
selectNewElementsCalled = true;
selectNewElementsList.AddRange(elements);
return selectedNewElementsToReturn.ToArray();
}
public void AppendChildElement(XmlElement element)
{
childElementsAdded.Add(element);
}
public void InsertElementBefore(XmlElement element)
{
elementsInsertedBefore.Add(element);
}
public void InsertElementAfter(XmlElement element)
{
elementsInsertedAfter.Add(element);
}
public string TextContent {
get {
return textContentDisplayed;
@ -171,5 +199,67 @@ namespace XmlEditor.Tests.Utils @@ -171,5 +199,67 @@ namespace XmlEditor.Tests.Utils
return selectNewAttributesList;
}
}
/// <summary>
/// Gets whether the SelectNewElements method was called.
/// </summary>
public bool IsSelectNewElementsCalled {
get {
return selectNewElementsCalled;
}
set {
selectNewElementsCalled = value;
}
}
/// <summary>
/// Gets the set of elements that will be returned from the
/// SelectNewElements method.
/// </summary>
public List<string> SelectedNewElementsToReturn {
get {
return selectedNewElementsToReturn;
}
}
/// <summary>
/// Returns the list of elements passed to the
/// SelectNewElement method.
/// </summary>
public List<string> SelectNewElementsList {
get {
return selectNewElementsList;
}
}
/// <summary>
/// Returns the child elements added via the AppendChildElement
/// method.
/// </summary>
public List<XmlElement> ChildElementsAdded {
get {
return childElementsAdded;
}
}
/// <summary>
/// Returns the elements added via the InsertElementBefore
/// method.
/// </summary>
public List<XmlElement> ElementsInsertedBefore {
get {
return elementsInsertedBefore;
}
}
/// <summary>
/// Returns the elements added via the InsertElementAfter
/// method.
/// </summary>
public List<XmlElement> ElementsInsertedAfter {
get {
return elementsInsertedAfter;
}
}
}
}

5
src/AddIns/DisplayBindings/XmlEditor/Test/XmlEditor.Tests.csproj

@ -138,6 +138,11 @@ @@ -138,6 +138,11 @@
<Compile Include="Tree\AddAttributeTestFixture.cs" />
<Compile Include="Tree\NoMatchingSchemaTestFixture.cs" />
<Compile Include="Tree\RemoveAttributeTestFixture.cs" />
<Compile Include="Tree\AddChildElementTestFixture.cs" />
<Compile Include="Tree\ExplicitNamespaceTestFixture.cs" />
<Compile Include="Tree\InsertElementBeforeTestFixture.cs" />
<Compile Include="Tree\AddElementsToTreeControlTestFixture.cs" />
<Compile Include="Tree\InsertElementAfterTestFixture.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Schema\" />

6
src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeNode.cs

@ -71,6 +71,12 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -71,6 +71,12 @@ namespace ICSharpCode.SharpDevelop.Gui
AddTo(view.Nodes);
}
public void Insert(int index, TreeNode parentNode)
{
internalParent = parentNode;
parentNode.Nodes.Insert(index, this);
}
void AddTo(TreeNodeCollection nodes)
{
nodes.Add(this);

BIN
src/Main/StartUp/Project/Resources/StringResources.resources

Binary file not shown.
Loading…
Cancel
Save