Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/XmlEditor@4113 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
68 changed files with 11201 additions and 0 deletions
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
#region Using directives
|
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
#endregion
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("XmlBinding")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("")] |
||||
[assembly: AssemblyProduct("XmlBinding")] |
||||
[assembly: AssemblyCopyright("Copyright 2009")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
|
||||
// This sets the default COM visibility of types in the assembly to invisible.
|
||||
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
|
||||
[assembly: ComVisible(false)] |
||||
|
||||
// The assembly version has following format :
|
||||
//
|
||||
// Major.Minor.Build.Revision
|
||||
//
|
||||
// You can specify all the values or you can use the default the Revision and
|
||||
// Build Numbers by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.*")] |
||||
@ -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: 2932 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/* |
||||
/// <summary>
|
||||
/// Holds the text for namespace, child element or attribute
|
||||
/// autocomplete (intellisense).
|
||||
/// </summary>
|
||||
public class XmlCompletionData : ICompletionData |
||||
{ |
||||
string text; |
||||
DataType dataType = DataType.XmlElement; |
||||
string description = String.Empty; |
||||
|
||||
/// <summary>
|
||||
/// The type of text held in this object.
|
||||
/// </summary>
|
||||
public enum DataType { |
||||
XmlElement = 1, |
||||
XmlAttribute = 2, |
||||
NamespaceUri = 3, |
||||
XmlAttributeValue = 4 |
||||
} |
||||
|
||||
public XmlCompletionData(string text) |
||||
: this(text, String.Empty, DataType.XmlElement) |
||||
{ |
||||
} |
||||
|
||||
public XmlCompletionData(string text, string description) |
||||
: this(text, description, DataType.XmlElement) |
||||
{ |
||||
} |
||||
|
||||
public XmlCompletionData(string text, DataType dataType) |
||||
: this(text, String.Empty, dataType) |
||||
{ |
||||
} |
||||
|
||||
public XmlCompletionData(string text, string description, DataType dataType) |
||||
{ |
||||
this.text = text; |
||||
this.description = description; |
||||
this.dataType = dataType; |
||||
} |
||||
|
||||
public int ImageIndex { |
||||
get { |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
public string Text { |
||||
get { |
||||
return text; |
||||
} |
||||
set { |
||||
text = value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the xml item's documentation as retrieved from
|
||||
/// the xs:annotation/xs:documentation element.
|
||||
/// </summary>
|
||||
public string Description { |
||||
get { |
||||
return description; |
||||
} |
||||
} |
||||
|
||||
public double Priority { |
||||
get { |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
public bool InsertAction(TextArea textArea, char ch) |
||||
{ |
||||
if ((dataType == DataType.XmlElement) || (dataType == DataType.XmlAttributeValue)) { |
||||
textArea.InsertString(text); |
||||
} |
||||
else if (dataType == DataType.NamespaceUri) { |
||||
textArea.InsertString(String.Concat("\"", text, "\"")); |
||||
} else { |
||||
// Insert an attribute.
|
||||
Caret caret = textArea.Caret; |
||||
textArea.InsertString(String.Concat(text, "=\"\"")); |
||||
|
||||
// Move caret into the middle of the attribute quotes.
|
||||
caret.Position = textArea.Document.OffsetToPosition(caret.Offset - 1); |
||||
} |
||||
return false; |
||||
} |
||||
} |
||||
*/ |
||||
} |
||||
@ -0,0 +1,289 @@
@@ -0,0 +1,289 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 1965 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/* |
||||
/// <summary>
|
||||
/// A collection that stores <see cref='XmlCompletionData'/> objects.
|
||||
/// </summary>
|
||||
[Serializable()] |
||||
public class XmlCompletionDataCollection : CollectionBase { |
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref='XmlCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
public XmlCompletionDataCollection() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref='XmlCompletionDataCollection'/> based on another <see cref='XmlCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
/// <param name='val'>
|
||||
/// A <see cref='XmlCompletionDataCollection'/> from which the contents are copied
|
||||
/// </param>
|
||||
public XmlCompletionDataCollection(XmlCompletionDataCollection val) |
||||
{ |
||||
this.AddRange(val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref='XmlCompletionDataCollection'/> containing any array of <see cref='XmlCompletionData'/> objects.
|
||||
/// </summary>
|
||||
/// <param name='val'>
|
||||
/// A array of <see cref='XmlCompletionData'/> objects with which to intialize the collection
|
||||
/// </param>
|
||||
public XmlCompletionDataCollection(XmlCompletionData[] val) |
||||
{ |
||||
this.AddRange(val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Represents the entry at the specified index of the <see cref='XmlCompletionData'/>.
|
||||
/// </summary>
|
||||
/// <param name='index'>The zero-based index of the entry to locate in the collection.</param>
|
||||
/// <value>The entry at the specified index of the collection.</value>
|
||||
/// <exception cref='ArgumentOutOfRangeException'><paramref name='index'/> is outside the valid range of indexes for the collection.</exception>
|
||||
public XmlCompletionData this[int index] { |
||||
get { |
||||
return ((XmlCompletionData)(List[index])); |
||||
} |
||||
set { |
||||
List[index] = value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref='XmlCompletionData'/> with the specified value to the
|
||||
/// <see cref='XmlCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If the completion data already exists in the collection it is not added.
|
||||
/// </remarks>
|
||||
/// <param name='val'>The <see cref='XmlCompletionData'/> to add.</param>
|
||||
/// <returns>The index at which the new element was inserted.</returns>
|
||||
/// <seealso cref='XmlCompletionDataCollection.AddRange'/>
|
||||
public int Add(XmlCompletionData val) |
||||
{ |
||||
int index = -1; |
||||
if (!Contains(val)) { |
||||
index = List.Add(val); |
||||
} |
||||
return index; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Copies the elements of an array to the end of the <see cref='XmlCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
/// <param name='val'>
|
||||
/// An array of type <see cref='XmlCompletionData'/> containing the objects to add to the collection.
|
||||
/// </param>
|
||||
/// <seealso cref='XmlCompletionDataCollection.Add'/>
|
||||
public void AddRange(XmlCompletionData[] val) |
||||
{ |
||||
for (int i = 0; i < val.Length; i++) { |
||||
this.Add(val[i]); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds the contents of another <see cref='XmlCompletionDataCollection'/> to the end of the collection.
|
||||
/// </summary>
|
||||
/// <param name='val'>
|
||||
/// A <see cref='XmlCompletionDataCollection'/> containing the objects to add to the collection.
|
||||
/// </param>
|
||||
/// <seealso cref='XmlCompletionDataCollection.Add'/>
|
||||
public void AddRange(XmlCompletionDataCollection val) |
||||
{ |
||||
for (int i = 0; i < val.Count; i++) |
||||
{ |
||||
this.Add(val[i]); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the
|
||||
/// <see cref='XmlCompletionDataCollection'/> contains the specified <see cref='XmlCompletionData'/>.
|
||||
/// </summary>
|
||||
/// <param name='val'>The <see cref='XmlCompletionData'/> to locate.</param>
|
||||
/// <returns>
|
||||
/// <see langword='true'/> if the <see cref='XmlCompletionData'/> is contained in the collection;
|
||||
/// otherwise, <see langword='false'/>.
|
||||
/// </returns>
|
||||
/// <seealso cref='XmlCompletionDataCollection.IndexOf'/>
|
||||
public bool Contains(XmlCompletionData val) |
||||
{ |
||||
if (val.Text != null) { |
||||
if (val.Text.Length > 0) { |
||||
return Contains(val.Text); |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public bool Contains(string name) |
||||
{ |
||||
bool contains = false; |
||||
|
||||
foreach (XmlCompletionData data in this) { |
||||
if (data.Text != null) { |
||||
if (data.Text.Length > 0) { |
||||
if (data.Text == name) { |
||||
contains = true; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
return contains; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Copies the <see cref='XmlCompletionDataCollection'/> values to a one-dimensional <see cref='Array'/> instance at the
|
||||
/// specified index.
|
||||
/// </summary>
|
||||
/// <param name='array'>The one-dimensional <see cref='Array'/> that is the destination of the values copied from <see cref='XmlCompletionDataCollection'/>.</param>
|
||||
/// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
|
||||
/// <exception cref='ArgumentException'>
|
||||
/// <para><paramref name='array'/> is multidimensional.</para>
|
||||
/// <para>-or-</para>
|
||||
/// <para>The number of elements in the <see cref='XmlCompletionDataCollection'/> is greater than
|
||||
/// the available space between <paramref name='arrayIndex'/> and the end of
|
||||
/// <paramref name='array'/>.</para>
|
||||
/// </exception>
|
||||
/// <exception cref='ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
|
||||
/// <exception cref='ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
|
||||
/// <seealso cref='Array'/>
|
||||
public void CopyTo(XmlCompletionData[] array, int index) |
||||
{ |
||||
List.CopyTo(array, index); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Copies the <see cref='XmlCompletionDataCollection'/> values to a one-dimensional <see cref='Array'/> instance at the
|
||||
/// specified index.
|
||||
/// </summary>
|
||||
public void CopyTo(ICompletionData[] array, int index) |
||||
{ |
||||
List.CopyTo(array, index); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the index of a <see cref='XmlCompletionData'/> in
|
||||
/// the <see cref='XmlCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
/// <param name='val'>The <see cref='XmlCompletionData'/> to locate.</param>
|
||||
/// <returns>
|
||||
/// The index of the <see cref='XmlCompletionData'/> of <paramref name='val'/> in the
|
||||
/// <see cref='XmlCompletionDataCollection'/>, if found; otherwise, -1.
|
||||
/// </returns>
|
||||
/// <seealso cref='XmlCompletionDataCollection.Contains'/>
|
||||
public int IndexOf(XmlCompletionData val) |
||||
{ |
||||
return List.IndexOf(val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Inserts a <see cref='XmlCompletionData'/> into the <see cref='XmlCompletionDataCollection'/> at the specified index.
|
||||
/// </summary>
|
||||
/// <param name='index'>The zero-based index where <paramref name='val'/> should be inserted.</param>
|
||||
/// <param name='val'>The <see cref='XmlCompletionData'/> to insert.</param>
|
||||
/// <seealso cref='XmlCompletionDataCollection.Add'/>
|
||||
public void Insert(int index, XmlCompletionData val) |
||||
{ |
||||
List.Insert(index, val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns an array of <see cref="ICompletionData"/> items.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ICompletionData[] ToArray() |
||||
{ |
||||
ICompletionData[] data = new ICompletionData[Count]; |
||||
CopyTo(data, 0); |
||||
return data; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through the <see cref='XmlCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
/// <seealso cref='IEnumerator'/>
|
||||
public new XmlCompletionDataEnumerator GetEnumerator() |
||||
{ |
||||
return new XmlCompletionDataEnumerator(this); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Removes a specific <see cref='XmlCompletionData'/> from the <see cref='XmlCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
/// <param name='val'>The <see cref='XmlCompletionData'/> to remove from the <see cref='XmlCompletionDataCollection'/>.</param>
|
||||
/// <exception cref='ArgumentException'><paramref name='val'/> is not found in the Collection.</exception>
|
||||
public void Remove(XmlCompletionData val) |
||||
{ |
||||
List.Remove(val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Enumerator that can iterate through a XmlCompletionDataCollection.
|
||||
/// </summary>
|
||||
/// <seealso cref='IEnumerator'/>
|
||||
/// <seealso cref='XmlCompletionDataCollection'/>
|
||||
/// <seealso cref='XmlCompletionData'/>
|
||||
public class XmlCompletionDataEnumerator : IEnumerator |
||||
{ |
||||
IEnumerator baseEnumerator; |
||||
IEnumerable temp; |
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref='XmlCompletionDataEnumerator'/>.
|
||||
/// </summary>
|
||||
public XmlCompletionDataEnumerator(XmlCompletionDataCollection mappings) |
||||
{ |
||||
this.temp = ((IEnumerable)(mappings)); |
||||
this.baseEnumerator = temp.GetEnumerator(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the current <see cref='XmlCompletionData'/> in the <seealso cref='XmlCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
public XmlCompletionData Current { |
||||
get { |
||||
return ((XmlCompletionData)(baseEnumerator.Current)); |
||||
} |
||||
} |
||||
|
||||
object IEnumerator.Current { |
||||
get { |
||||
return baseEnumerator.Current; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Advances the enumerator to the next <see cref='XmlCompletionData'/> of the <see cref='XmlCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
public bool MoveNext() |
||||
{ |
||||
return baseEnumerator.MoveNext(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Sets the enumerator to its initial position, which is before the first element in the <see cref='XmlCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
public void Reset() |
||||
{ |
||||
baseEnumerator.Reset(); |
||||
} |
||||
} |
||||
} |
||||
*/ |
||||
} |
||||
@ -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: 915 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
public class XmlCompletionDataImageList |
||||
{ |
||||
XmlCompletionDataImageList() |
||||
{ |
||||
} |
||||
|
||||
public static ImageList GetImageList() |
||||
{ |
||||
ImageList imageList = new ImageList(); |
||||
|
||||
return imageList; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,183 @@
@@ -0,0 +1,183 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 2760 $</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.XmlBinding.Parser; |
||||
using System; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/* |
||||
/// <summary>
|
||||
/// Provides the autocomplete (intellisense) data for an
|
||||
/// xml document that specifies a known schema.
|
||||
/// </summary>
|
||||
public class XmlCompletionDataProvider : AbstractCompletionDataProvider |
||||
{ |
||||
XmlSchemaCompletionDataCollection schemaCompletionDataItems; |
||||
XmlSchemaCompletionData defaultSchemaCompletionData; |
||||
string defaultNamespacePrefix = String.Empty; |
||||
|
||||
public XmlCompletionDataProvider(XmlSchemaCompletionDataCollection schemaCompletionDataItems, XmlSchemaCompletionData defaultSchemaCompletionData, string defaultNamespacePrefix) |
||||
{ |
||||
this.schemaCompletionDataItems = schemaCompletionDataItems; |
||||
this.defaultSchemaCompletionData = defaultSchemaCompletionData; |
||||
this.defaultNamespacePrefix = defaultNamespacePrefix; |
||||
DefaultIndex = 0; |
||||
} |
||||
|
||||
public override ImageList ImageList { |
||||
get { |
||||
return XmlCompletionDataImageList.GetImageList(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Overrides the default behaviour and allows special xml
|
||||
/// characters such as '.' and ':' to be used as completion data.
|
||||
/// </summary>
|
||||
public override CompletionDataProviderKeyResult ProcessKey(char key) |
||||
{ |
||||
if (key == '\r' || key == '\t') { |
||||
return CompletionDataProviderKeyResult.InsertionKey; |
||||
} |
||||
return CompletionDataProviderKeyResult.NormalKey; |
||||
} |
||||
|
||||
public override ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped) |
||||
{ |
||||
preSelection = null; |
||||
string text = String.Concat(textArea.Document.GetText(0, textArea.Caret.Offset), charTyped); |
||||
|
||||
switch (charTyped) { |
||||
case '=': |
||||
// Namespace intellisense.
|
||||
if (XmlParser.IsNamespaceDeclaration(text, text.Length)) { |
||||
return schemaCompletionDataItems.GetNamespaceCompletionData();; |
||||
} |
||||
break; |
||||
case '<': |
||||
// Child element intellisense.
|
||||
XmlElementPath parentPath = XmlParser.GetParentElementPath(text); |
||||
if (parentPath.Elements.Count > 0) { |
||||
return GetChildElementCompletionData(parentPath); |
||||
} else if (defaultSchemaCompletionData != null) { |
||||
return defaultSchemaCompletionData.GetElementCompletionData(defaultNamespacePrefix); |
||||
} |
||||
break; |
||||
|
||||
case ' ': |
||||
// Attribute intellisense.
|
||||
if (!XmlParser.IsInsideAttributeValue(text, text.Length)) { |
||||
XmlElementPath path = XmlParser.GetActiveElementStartPath(text, text.Length); |
||||
if (path.Elements.Count > 0) { |
||||
return GetAttributeCompletionData(path); |
||||
} |
||||
} |
||||
break; |
||||
|
||||
default: |
||||
|
||||
// Attribute value intellisense.
|
||||
if (XmlParser.IsAttributeValueChar(charTyped)) { |
||||
string attributeName = XmlParser.GetAttributeName(text, text.Length); |
||||
if (attributeName.Length > 0) { |
||||
XmlElementPath elementPath = XmlParser.GetActiveElementStartPath(text, text.Length); |
||||
if (elementPath.Elements.Count > 0) { |
||||
preSelection = charTyped.ToString(); |
||||
return GetAttributeValueCompletionData(elementPath, attributeName); |
||||
} |
||||
} |
||||
} |
||||
break; |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Finds the schema given the xml element path.
|
||||
/// </summary>
|
||||
public XmlSchemaCompletionData FindSchema(XmlElementPath path) |
||||
{ |
||||
if (path.Elements.Count > 0) { |
||||
string namespaceUri = path.Elements[0].Namespace; |
||||
if (namespaceUri.Length > 0) { |
||||
return schemaCompletionDataItems[namespaceUri]; |
||||
} else if (defaultSchemaCompletionData != null) { |
||||
|
||||
// Use the default schema namespace if none
|
||||
// specified in a xml element path, otherwise
|
||||
// we will not find any attribute or element matches
|
||||
// later.
|
||||
foreach (QualifiedName name in path.Elements) { |
||||
if (name.Namespace.Length == 0) { |
||||
name.Namespace = defaultSchemaCompletionData.NamespaceUri; |
||||
} |
||||
} |
||||
return defaultSchemaCompletionData; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Finds the schema given a namespace URI.
|
||||
/// </summary>
|
||||
public XmlSchemaCompletionData FindSchema(string namespaceUri) |
||||
{ |
||||
return schemaCompletionDataItems[namespaceUri]; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the schema completion data that was created from the specified
|
||||
/// schema filename.
|
||||
/// </summary>
|
||||
public XmlSchemaCompletionData FindSchemaFromFileName(string fileName) |
||||
{ |
||||
return schemaCompletionDataItems.GetSchemaFromFileName(fileName); |
||||
} |
||||
|
||||
ICompletionData[] GetChildElementCompletionData(XmlElementPath path) |
||||
{ |
||||
ICompletionData[] completionData = null; |
||||
|
||||
XmlSchemaCompletionData schema = FindSchema(path); |
||||
if (schema != null) { |
||||
completionData = schema.GetChildElementCompletionData(path); |
||||
} |
||||
|
||||
return completionData; |
||||
} |
||||
|
||||
ICompletionData[] GetAttributeCompletionData(XmlElementPath path) |
||||
{ |
||||
ICompletionData[] completionData = null; |
||||
|
||||
XmlSchemaCompletionData schema = FindSchema(path); |
||||
if (schema != null) { |
||||
completionData = schema.GetAttributeCompletionData(path); |
||||
} |
||||
|
||||
return completionData; |
||||
} |
||||
|
||||
ICompletionData[] GetAttributeValueCompletionData(XmlElementPath path, string name) |
||||
{ |
||||
ICompletionData[] completionData = null; |
||||
|
||||
XmlSchemaCompletionData schema = FindSchema(path); |
||||
if (schema != null) { |
||||
completionData = schema.GetAttributeValueCompletionData(path, name); |
||||
} |
||||
|
||||
return completionData; |
||||
} |
||||
} |
||||
*/ |
||||
} |
||||
@ -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: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Adds a new attribute to the XML Tree's attribute property grid.
|
||||
/// </summary>
|
||||
public class AddAttributeCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
XmlTreeViewContainerControl view = Owner as XmlTreeViewContainerControl; |
||||
if (view != null) { |
||||
view.AddAttribute(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Adds a new comment to the selected element.
|
||||
/// </summary>
|
||||
public class AddChildCommentCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
XmlTreeViewContainerControl view = Owner as XmlTreeViewContainerControl; |
||||
if (view != null) { |
||||
view.AppendChildComment(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
@ -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: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
|
||||
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(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -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: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Adds a new text node to selected element.
|
||||
/// </summary>
|
||||
public class AddChildTextNodeCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
XmlTreeViewContainerControl view = Owner as XmlTreeViewContainerControl; |
||||
if (view != null) { |
||||
view.AppendChildTextNode(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Allows the user to browse for an XSLT stylesheet. The selected
|
||||
/// stylesheet will be assigned to the currently open xml file.
|
||||
/// </summary>
|
||||
public class AssignStylesheetCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
// Get active xml document.
|
||||
// XmlView xmlView = XmlView.ActiveXmlView;
|
||||
// if (xmlView != null) {
|
||||
//
|
||||
// // Prompt user for filename.
|
||||
// string stylesheetFileName = BrowseForStylesheetFile();
|
||||
//
|
||||
// // Assign stylesheet.
|
||||
// if (stylesheetFileName != null) {
|
||||
// xmlView.StylesheetFileName = stylesheetFileName;
|
||||
// }
|
||||
// }
|
||||
} |
||||
|
||||
public static string BrowseForStylesheetFile() |
||||
{ |
||||
using (OpenFileDialog dialog = new OpenFileDialog()) { |
||||
dialog.AddExtension = true; |
||||
dialog.Multiselect = false; |
||||
dialog.CheckFileExists = true; |
||||
dialog.Title = ResourceService.GetString("ICSharpCode.XmlEditor.AssignXSLT.Title"); |
||||
|
||||
AddInTreeNode node = AddInTree.GetTreeNode("/SharpDevelop/Workbench/FileFilter"); |
||||
if (node != null) { |
||||
|
||||
string xmlFileFilter = (string)node.BuildChildItem("Xml", null, null); |
||||
string allFilesFilter = (string)node.BuildChildItem("AllFiles", null, null); |
||||
string xslFileFilter = (string)node.BuildChildItem("Xsl", null, null); |
||||
|
||||
dialog.Filter = String.Concat(xslFileFilter, "|", xmlFileFilter, "|", allFilesFilter); |
||||
dialog.FilterIndex = 1; |
||||
} |
||||
|
||||
if (dialog.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainWin32Window) == DialogResult.OK) { |
||||
return dialog.FileName; |
||||
} |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
//using ICSharpCode.TextEditor;
|
||||
//using ICSharpCode.TextEditor.Actions;
|
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
// /// <summary>
|
||||
// /// Command executed when the user hits Ctrl+Space
|
||||
// /// </summary>
|
||||
// public class CodeCompletionPopupCommand : AbstractEditAction
|
||||
// {
|
||||
// public override void Execute(TextArea services)
|
||||
// {
|
||||
// throw new NotImplementedException();
|
||||
//// XmlEditorControl editor = services.MotherTextEditorControl as XmlEditorControl;
|
||||
//// if (editor != null) {
|
||||
//// editor.ShowCompletionWindow();
|
||||
//// }
|
||||
// }
|
||||
// }
|
||||
} |
||||
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Creates a schema based on the xml in the currently active view.
|
||||
/// </summary>
|
||||
public class CreateSchemaCommand : AbstractMenuCommand |
||||
{ |
||||
public CreateSchemaCommand() |
||||
{ |
||||
} |
||||
|
||||
public override void Run() |
||||
{ |
||||
// Find active XmlView.
|
||||
throw new NotImplementedException(); |
||||
// XmlView xmlView = XmlView.ActiveXmlView;
|
||||
// if (xmlView != null) {
|
||||
// // Create a schema based on the xml.
|
||||
// string[] schemas = xmlView.InferSchema();
|
||||
// if (schemas != null) {
|
||||
// // Create a new file for each generated schema.
|
||||
// for (int i = 0; i < schemas.Length; ++i) {
|
||||
// string fileName = GenerateSchemaFileName(xmlView.TextEditorControl.FileName, i + 1);
|
||||
// OpenNewXmlFile(fileName, schemas[i]);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Opens a new unsaved xml file in SharpDevelop.
|
||||
/// </summary>
|
||||
void OpenNewXmlFile(string fileName, string xml) |
||||
{ |
||||
FileService.NewFile(fileName, xml); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Generates an xsd filename based on the name of the original xml file.
|
||||
/// </summary>
|
||||
string GenerateSchemaFileName(string xmlFileName, int count) |
||||
{ |
||||
string baseFileName = Path.GetFileNameWithoutExtension(xmlFileName); |
||||
string schemaFileName = String.Concat(baseFileName, ".xsd"); |
||||
if (count == 1) { |
||||
return schemaFileName; |
||||
} |
||||
return schemaFileName = String.Concat(baseFileName, count.ToString(), ".xsd"); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.Core; |
||||
using System; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Pretty prints the xml.
|
||||
/// </summary>
|
||||
public class FormatXmlCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
// Find active XmlView.
|
||||
throw new NotImplementedException(); |
||||
// XmlView xmlView = XmlView.ActiveXmlView;
|
||||
// if (xmlView != null) {
|
||||
// xmlView.FormatXml();
|
||||
// }
|
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Finds the definition of the Xml element or attribute under the cursor,
|
||||
/// finds the schema definition for it and then opens the schema and puts the cursor
|
||||
/// on the definition.
|
||||
/// </summary>
|
||||
public class GoToSchemaDefinitionCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
// XmlView view = XmlView.ActiveXmlView;
|
||||
// if (view != null) {
|
||||
// view.GoToSchemaDefinition();
|
||||
// }
|
||||
} |
||||
} |
||||
} |
||||
@ -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: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Inserts a new comment node after the selected node.
|
||||
/// </summary>
|
||||
public class InsertCommentAfterCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
XmlTreeViewContainerControl view = Owner as XmlTreeViewContainerControl; |
||||
if (view != null) { |
||||
view.InsertCommentAfter(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Inserts a new comment node before the selected node.
|
||||
/// </summary>
|
||||
public class InsertCommentBeforeCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
XmlTreeViewContainerControl view = Owner as XmlTreeViewContainerControl; |
||||
if (view != null) { |
||||
view.InsertCommentBefore(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
@ -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: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
|
||||
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(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -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: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
|
||||
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(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Inserts a new text node to after the selected node.
|
||||
/// </summary>
|
||||
public class InsertTextNodeAfterCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
XmlTreeViewContainerControl view = Owner as XmlTreeViewContainerControl; |
||||
if (view != null) { |
||||
view.InsertTextNodeAfter(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Inserts a new text node to before the selected node.
|
||||
/// </summary>
|
||||
public class InsertTextNodeBeforeCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
XmlTreeViewContainerControl view = Owner as XmlTreeViewContainerControl; |
||||
if (view != null) { |
||||
view.InsertTextNodeBefore(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Opens the stylesheet associated with the active XML document.
|
||||
/// </summary>
|
||||
public class OpenStylesheetCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
// XmlView xmlView = XmlView.ActiveXmlView;
|
||||
// if (xmlView != null) {
|
||||
// if (xmlView.StylesheetFileName != null) {
|
||||
// try {
|
||||
// FileService.OpenFile(xmlView.StylesheetFileName);
|
||||
// } catch (Exception ex) {
|
||||
// MessageService.ShowError(ex);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 1965 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Removes the selected attribute from the xml document being
|
||||
/// displayed in the XML tree.
|
||||
/// </summary>
|
||||
public class RemoveAttributeCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
XmlTreeViewContainerControl view = Owner as XmlTreeViewContainerControl; |
||||
if (view != null) { |
||||
view.RemoveAttribute(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 1966 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
public class RemoveXPathHighlightingCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
XPathQueryPad pad = XPathQueryPad.Instance; |
||||
if (pad != null) { |
||||
pad.RemoveXPathHighlighting(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,93 @@
@@ -0,0 +1,93 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 2313 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Runs an XSL transform on an xml document.
|
||||
/// </summary>
|
||||
public class RunXslTransformCommand : AbstractCommand |
||||
{ |
||||
/// <summary>
|
||||
/// Runs the transform on the xml file using the assigned stylesheet.
|
||||
/// If no stylesheet is assigned the user is prompted to choose one.
|
||||
/// If the view represents a stylesheet that is currently assigned to an
|
||||
/// opened document then run the transform on that document.
|
||||
/// </summary>
|
||||
public override void Run() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
// XmlView xmlView = XmlView.ActiveXmlView;
|
||||
// if (xmlView != null) {
|
||||
//
|
||||
// if (xmlView is XslOutputView) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // Check to see if this view is actually a referenced stylesheet.
|
||||
// if (!string.IsNullOrEmpty(xmlView.PrimaryFileName)) {
|
||||
//
|
||||
// XmlView associatedXmlView = GetAssociatedXmlView(xmlView.PrimaryFileName);
|
||||
// if (associatedXmlView != null) {
|
||||
// LoggingService.Debug("Using associated xml view.");
|
||||
// xmlView = associatedXmlView;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Assign a stylesheet.
|
||||
// if (xmlView.StylesheetFileName == null) {
|
||||
// xmlView.StylesheetFileName = AssignStylesheetCommand.BrowseForStylesheetFile();
|
||||
// }
|
||||
//
|
||||
// if (xmlView.StylesheetFileName != null) {
|
||||
// try {
|
||||
// xmlView.RunXslTransform(GetStylesheetContent(xmlView.StylesheetFileName));
|
||||
// } catch (Exception ex) {
|
||||
// MessageService.ShowError(ex);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
} |
||||
|
||||
// /// <summary>
|
||||
// /// Gets the xml view that is currently referencing the
|
||||
// /// specified stylesheet view.
|
||||
// /// </summary>
|
||||
// XmlView GetAssociatedXmlView(string stylesheetFileName)
|
||||
// {
|
||||
// foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) {
|
||||
// XmlView view = content as XmlView;
|
||||
// if (view != null && view.StylesheetFileName != null) {
|
||||
// if (FileUtility.IsEqualFileName(view.StylesheetFileName, stylesheetFileName)) {
|
||||
// return view;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
string GetStylesheetContent(string fileName) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
// File already open?
|
||||
// XmlView view = FileService.GetOpenFile(fileName) as XmlView;
|
||||
// if (view != null) {
|
||||
// return view.Text;
|
||||
// }
|
||||
|
||||
// Read in file contents.
|
||||
StreamReader reader = new StreamReader(fileName, true); |
||||
return reader.ReadToEnd(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 1965 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Validates the xml in the xml editor against the known schemas.
|
||||
/// </summary>
|
||||
public class ValidateXmlCommand : AbstractMenuCommand |
||||
{ |
||||
/// <summary>
|
||||
/// Validate the xml.
|
||||
/// </summary>
|
||||
public override void Run() |
||||
{ |
||||
// Find active XmlView.
|
||||
throw new NotImplementedException(); |
||||
// XmlView xmlView = XmlView.ActiveXmlView;
|
||||
// if (xmlView != null) {
|
||||
// // Validate the xml.
|
||||
// xmlView.ValidateXml();
|
||||
// }
|
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,341 @@
@@ -0,0 +1,341 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using System.Xml; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.Core.WinForms; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Base class for the AddElementDialog and AddAttributeDialog. This
|
||||
/// dialog presents a list of names and an extra text box for entering
|
||||
/// a custom name. It is used to add a new node to the XML tree. It
|
||||
/// contains all the core logic for the AddElementDialog and
|
||||
/// AddAttributeDialog classes.
|
||||
/// </summary>
|
||||
public class AddXmlNodeDialog : System.Windows.Forms.Form, IAddXmlNodeDialog |
||||
{ |
||||
public AddXmlNodeDialog() : this(new string[0]) |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Creates the dialog and adds the specified names to the
|
||||
/// list box.
|
||||
/// </summary>
|
||||
public AddXmlNodeDialog(string[] names) |
||||
{ |
||||
InitializeComponent(); |
||||
InitStrings(); |
||||
if (names.Length > 0) { |
||||
AddNames(names); |
||||
} else { |
||||
RemoveNamesListBox(); |
||||
} |
||||
RightToLeftConverter.ConvertRecursive(this); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the selected names in the list box together with the
|
||||
/// custom name entered in the text box.
|
||||
/// </summary>
|
||||
public string[] GetNames() |
||||
{ |
||||
// Add items selected in list box.
|
||||
List<string> names = new List<string>(); |
||||
foreach (string name in namesListBox.SelectedItems) { |
||||
names.Add(name); |
||||
} |
||||
|
||||
// Add the custom name if entered.
|
||||
string customName = customNameTextBox.Text.Trim(); |
||||
if (customName.Length > 0) { |
||||
names.Add(customName); |
||||
} |
||||
return names.ToArray(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the text from the error provider.
|
||||
/// </summary>
|
||||
public string GetError() |
||||
{ |
||||
return errorProvider.GetError(customNameTextBox); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the custom name label's text.
|
||||
/// </summary>
|
||||
public string CustomNameLabelText { |
||||
get { |
||||
return customNameTextBoxLabel.Text; |
||||
} |
||||
set { |
||||
customNameTextBoxLabel.Text = value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Disposes resources used by the form.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) |
||||
{ |
||||
if (disposing) { |
||||
if (components != null) { |
||||
components.Dispose(); |
||||
} |
||||
} |
||||
base.Dispose(disposing); |
||||
} |
||||
|
||||
protected void NamesListBoxSelectedIndexChanged(object sender, EventArgs e) |
||||
{ |
||||
UpdateOkButtonState(); |
||||
} |
||||
|
||||
protected void CustomNameTextBoxTextChanged(object sender, EventArgs e) |
||||
{ |
||||
UpdateOkButtonState(); |
||||
} |
||||
|
||||
#region Windows Forms Designer generated code
|
||||
|
||||
void InitializeComponent() |
||||
{ |
||||
this.components = new System.ComponentModel.Container(); |
||||
this.namesListBox = new System.Windows.Forms.ListBox(); |
||||
this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components); |
||||
this.bottomPanel = new System.Windows.Forms.Panel(); |
||||
this.customNameTextBoxLabel = new System.Windows.Forms.Label(); |
||||
this.customNameTextBox = new System.Windows.Forms.TextBox(); |
||||
this.cancelButton = new System.Windows.Forms.Button(); |
||||
this.okButton = new System.Windows.Forms.Button(); |
||||
((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); |
||||
this.bottomPanel.SuspendLayout(); |
||||
this.SuspendLayout(); |
||||
//
|
||||
// namesListBox
|
||||
//
|
||||
this.namesListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
||||
| System.Windows.Forms.AnchorStyles.Left) |
||||
| System.Windows.Forms.AnchorStyles.Right))); |
||||
this.namesListBox.FormattingEnabled = true; |
||||
this.namesListBox.Location = new System.Drawing.Point(0, 0); |
||||
this.namesListBox.Name = "namesListBox"; |
||||
this.namesListBox.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; |
||||
this.namesListBox.Size = new System.Drawing.Size(289, 173); |
||||
this.namesListBox.Sorted = true; |
||||
this.namesListBox.TabIndex = 1; |
||||
this.namesListBox.SelectedIndexChanged += new System.EventHandler(this.NamesListBoxSelectedIndexChanged); |
||||
//
|
||||
// errorProvider
|
||||
//
|
||||
this.errorProvider.ContainerControl = this; |
||||
//
|
||||
// bottomPanel
|
||||
//
|
||||
this.bottomPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) |
||||
| System.Windows.Forms.AnchorStyles.Right))); |
||||
this.bottomPanel.Controls.Add(this.customNameTextBoxLabel); |
||||
this.bottomPanel.Controls.Add(this.customNameTextBox); |
||||
this.bottomPanel.Controls.Add(this.cancelButton); |
||||
this.bottomPanel.Controls.Add(this.okButton); |
||||
this.bottomPanel.Location = new System.Drawing.Point(0, 173); |
||||
this.bottomPanel.Name = "bottomPanel"; |
||||
this.bottomPanel.Size = new System.Drawing.Size(289, 73); |
||||
this.bottomPanel.TabIndex = 2; |
||||
//
|
||||
// customNameTextBoxLabel
|
||||
//
|
||||
this.customNameTextBoxLabel.Location = new System.Drawing.Point(3, 10); |
||||
this.customNameTextBoxLabel.Name = "customNameTextBoxLabel"; |
||||
this.customNameTextBoxLabel.Size = new System.Drawing.Size(82, 23); |
||||
this.customNameTextBoxLabel.TabIndex = 3; |
||||
this.customNameTextBoxLabel.Text = "Custom:"; |
||||
//
|
||||
// customNameTextBox
|
||||
//
|
||||
this.customNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) |
||||
| System.Windows.Forms.AnchorStyles.Right))); |
||||
this.customNameTextBox.Location = new System.Drawing.Point(107, 10); |
||||
this.customNameTextBox.Name = "customNameTextBox"; |
||||
this.customNameTextBox.Size = new System.Drawing.Size(167, 20); |
||||
this.customNameTextBox.TabIndex = 4; |
||||
this.customNameTextBox.TextChanged += new System.EventHandler(this.CustomNameTextBoxTextChanged); |
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); |
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; |
||||
this.cancelButton.Location = new System.Drawing.Point(199, 40); |
||||
this.cancelButton.Name = "cancelButton"; |
||||
this.cancelButton.Size = new System.Drawing.Size(75, 23); |
||||
this.cancelButton.TabIndex = 6; |
||||
this.cancelButton.Text = "Cancel"; |
||||
this.cancelButton.UseVisualStyleBackColor = true; |
||||
//
|
||||
// okButton
|
||||
//
|
||||
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); |
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; |
||||
this.okButton.Enabled = false; |
||||
this.okButton.Location = new System.Drawing.Point(118, 40); |
||||
this.okButton.Name = "okButton"; |
||||
this.okButton.Size = new System.Drawing.Size(75, 23); |
||||
this.okButton.TabIndex = 5; |
||||
this.okButton.Text = "OK"; |
||||
this.okButton.UseVisualStyleBackColor = true; |
||||
//
|
||||
// AddXmlNodeDialog
|
||||
//
|
||||
this.AcceptButton = this.okButton; |
||||
this.CancelButton = this.cancelButton; |
||||
this.ClientSize = new System.Drawing.Size(289, 244); |
||||
this.Controls.Add(this.bottomPanel); |
||||
this.Controls.Add(this.namesListBox); |
||||
this.MaximizeBox = false; |
||||
this.MinimizeBox = false; |
||||
this.MinimumSize = new System.Drawing.Size(289, 143); |
||||
this.Name = "AddXmlNodeDialog"; |
||||
this.ShowIcon = false; |
||||
this.ShowInTaskbar = false; |
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; |
||||
((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); |
||||
this.bottomPanel.ResumeLayout(false); |
||||
this.bottomPanel.PerformLayout(); |
||||
this.ResumeLayout(false); |
||||
} |
||||
private System.Windows.Forms.Panel bottomPanel; |
||||
private System.ComponentModel.IContainer components; |
||||
private System.Windows.Forms.ErrorProvider errorProvider; |
||||
private System.Windows.Forms.Button cancelButton; |
||||
private System.Windows.Forms.Button okButton; |
||||
private System.Windows.Forms.TextBox customNameTextBox; |
||||
private System.Windows.Forms.Label customNameTextBoxLabel; |
||||
private System.Windows.Forms.ListBox namesListBox; |
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Adds the names to the list box.
|
||||
/// </summary>
|
||||
void AddNames(string[] names) |
||||
{ |
||||
foreach (string name in names) { |
||||
namesListBox.Items.Add(name); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Enables or disables the ok button depending on whether any list
|
||||
/// item is selected or a custom name has been entered.
|
||||
/// </summary>
|
||||
void UpdateOkButtonState() |
||||
{ |
||||
okButton.Enabled = IsOkButtonEnabled; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns whether any items are selected in the list box.
|
||||
/// </summary>
|
||||
bool IsItemSelected { |
||||
get { |
||||
return namesListBox.SelectedIndex >= 0; |
||||
} |
||||
} |
||||
|
||||
bool IsOkButtonEnabled { |
||||
get { |
||||
return IsItemSelected || ValidateCustomName(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns whether there is a valid string in the custom
|
||||
/// name text box. The string must be a name that can be used to
|
||||
/// create an xml element or attribute.
|
||||
/// </summary>
|
||||
bool ValidateCustomName() |
||||
{ |
||||
string name = customNameTextBox.Text.Trim(); |
||||
if (name.Length > 0) { |
||||
try { |
||||
VerifyName(name); |
||||
errorProvider.Clear(); |
||||
return true; |
||||
} catch (XmlException ex) { |
||||
errorProvider.SetError(customNameTextBox, ex.Message); |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Checks that the name would make a valid element name or
|
||||
/// attribute name. Trying to use XmlConvert and its Verify methods
|
||||
/// so the validation is not done ourselves. XmlDocument has a
|
||||
/// CheckName method but this is not public.
|
||||
/// </summary>
|
||||
void VerifyName(string name) |
||||
{ |
||||
// Check the qualification is valid.
|
||||
string[] parts = name.Split(new char[] {':'}, 2); |
||||
if (parts.Length == 1) { |
||||
// No colons.
|
||||
XmlConvert.VerifyName(name); |
||||
return; |
||||
} |
||||
|
||||
string firstPart = parts[0].Trim(); |
||||
string secondPart = parts[1].Trim(); |
||||
if (firstPart.Length > 0 && secondPart.Length > 0) { |
||||
XmlConvert.VerifyNCName(firstPart); |
||||
XmlConvert.VerifyNCName(secondPart); |
||||
} else { |
||||
// Throw an error using VerifyNCName since the
|
||||
// qualified name parts have no strings.
|
||||
XmlConvert.VerifyNCName(name); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Sets the control's text using string resources.
|
||||
/// </summary>
|
||||
void InitStrings() |
||||
{ |
||||
okButton.Text = StringParser.Parse("${res:Global.OKButtonText}"); |
||||
cancelButton.Text = StringParser.Parse("${res:Global.CancelButtonText}"); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Removes the names list box from the dialog, re-positions the
|
||||
/// remaining controls and resizes the dialog to fit.
|
||||
/// </summary>
|
||||
void RemoveNamesListBox() |
||||
{ |
||||
using (namesListBox) { |
||||
Controls.Remove(namesListBox); |
||||
|
||||
// Reset the dialog's minimum size first so setting the
|
||||
// ClientSize to something smaller works as expected.
|
||||
MinimumSize = Size.Empty; |
||||
ClientSize = bottomPanel.Size; |
||||
MinimumSize = Size; |
||||
|
||||
// Make sure bottom panel fills the dialog when it is resized.
|
||||
bottomPanel.Dock = DockStyle.Fill; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
// TODO : Add extendable WPF commands to allow this with AvalonEdit
|
||||
// /// <summary>
|
||||
// /// Finds the schema definition of the Xml element or attribute under the cursor
|
||||
// /// when the user presses Control+Enter
|
||||
// /// </summary>
|
||||
// public class GoToSchemaDefinitionEditAction : AbstractEditAction
|
||||
// {
|
||||
// public override void Execute(TextArea services)
|
||||
// {
|
||||
// GoToSchemaDefinitionCommand goToDefinitionCommand = new GoToSchemaDefinitionCommand();
|
||||
// goToDefinitionCommand.Run();
|
||||
// }
|
||||
// }
|
||||
} |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
|
||||
using System; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Interface for the AddXmlNodeDialog.
|
||||
/// </summary>
|
||||
public interface IAddXmlNodeDialog : IDisposable |
||||
{ |
||||
/// <summary>
|
||||
/// The names that should be added. These are the
|
||||
/// names that the user selected in the dialog when
|
||||
/// it was closed.
|
||||
/// </summary>
|
||||
string[] GetNames(); |
||||
|
||||
/// <summary>
|
||||
/// Shows the dialog.
|
||||
/// </summary>
|
||||
DialogResult ShowDialog(); |
||||
} |
||||
} |
||||
@ -0,0 +1,201 @@
@@ -0,0 +1,201 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
public interface IXmlTreeView |
||||
{ |
||||
/// <summary>
|
||||
/// Displays an error message indicating that the xml tree view
|
||||
/// could not display the xml since the xml is not well formed.
|
||||
/// </summary>
|
||||
/// <param name="ex">The exception that occurred when the xml
|
||||
/// was loaded.</param>
|
||||
void ShowXmlIsNotWellFormedMessage(XmlException ex); |
||||
|
||||
/// <summary>
|
||||
/// Displays an error message.
|
||||
/// </summary>
|
||||
void ShowErrorMessage(string message); |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether this view needs saving.
|
||||
/// </summary>
|
||||
bool IsDirty {get; set;} |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the xml document.
|
||||
/// </summary>
|
||||
XmlDocument Document {get; set;} |
||||
|
||||
/// <summary>
|
||||
/// Gets the selected node in the tree.
|
||||
/// </summary>
|
||||
XmlNode SelectedNode {get;} |
||||
|
||||
/// <summary>
|
||||
/// Gets the xml element selected.
|
||||
/// </summary>
|
||||
XmlElement SelectedElement {get;} |
||||
|
||||
/// <summary>
|
||||
/// Shows the attributes for the selected xml element in the view.
|
||||
/// </summary>
|
||||
void ShowAttributes(XmlAttributeCollection attributes); |
||||
|
||||
/// <summary>
|
||||
/// Removes the attributes from the view.
|
||||
/// </summary>
|
||||
void ClearAttributes(); |
||||
|
||||
/// <summary>
|
||||
/// Shows the xml element text content.
|
||||
/// </summary>
|
||||
void ShowTextContent(string text); |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text content currently on display. The
|
||||
/// text content will not be displayed unless
|
||||
/// ShowTextContent has been called.
|
||||
/// </summary>
|
||||
string TextContent {get; set;} |
||||
|
||||
/// <summary>
|
||||
/// Gets the xml element text node.
|
||||
/// </summary>
|
||||
XmlText SelectedTextNode {get;} |
||||
|
||||
/// <summary>
|
||||
/// Shows the add attribute dialog and allows the user
|
||||
/// to select a new attribute to be added to the selected
|
||||
/// xml element.
|
||||
/// </summary>
|
||||
/// <param name="attributes">The list of attributes to
|
||||
/// be displayed to the user.</param>
|
||||
/// <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); |
||||
|
||||
/// <summary>
|
||||
/// Removes the specified element from the tree.
|
||||
/// </summary>
|
||||
void RemoveElement(XmlElement element); |
||||
|
||||
/// <summary>
|
||||
/// Informs the view that the specified node has been selected
|
||||
/// to be cut from the tree. The view can then update its display
|
||||
/// to inform the user that the node has been cut.
|
||||
/// </summary>
|
||||
void ShowCut(XmlNode node); |
||||
|
||||
/// <summary>
|
||||
/// Informs the view that the visual indication of the cut should
|
||||
/// be cleared.
|
||||
/// </summary>
|
||||
void HideCut(XmlNode node); |
||||
|
||||
/// <summary>
|
||||
/// Appends a new child text node to the currently selected
|
||||
/// element.
|
||||
/// </summary>
|
||||
void AppendChildTextNode(XmlText textNode); |
||||
|
||||
/// <summary>
|
||||
/// Inserts a new child text node before the currently
|
||||
/// selected node.
|
||||
/// </summary>
|
||||
void InsertTextNodeBefore(XmlText textNode); |
||||
|
||||
/// <summary>
|
||||
/// Inserts a new child text node after the currently
|
||||
/// selected node.
|
||||
/// </summary>
|
||||
void InsertTextNodeAfter(XmlText textNode); |
||||
|
||||
/// <summary>
|
||||
/// Removes the currently selected text node.
|
||||
/// </summary>
|
||||
void RemoveTextNode(XmlText textNode); |
||||
|
||||
/// <summary>
|
||||
/// Informs the xml tree view that the text node
|
||||
/// has changed and the corresponding tree node
|
||||
/// needs to be updated.
|
||||
/// </summary>
|
||||
void UpdateTextNode(XmlText textNode); |
||||
|
||||
/// <summary>
|
||||
/// Gets the currently selected comment node.
|
||||
/// </summary>
|
||||
XmlComment SelectedComment {get;} |
||||
|
||||
/// <summary>
|
||||
/// Informs the xml tree view that the comment node
|
||||
/// has changed and the corresponding tree node
|
||||
/// needs to be updated.
|
||||
/// </summary>
|
||||
void UpdateComment(XmlComment comment); |
||||
|
||||
/// <summary>
|
||||
/// Appends a new child comment to the currently selected
|
||||
/// element.
|
||||
/// </summary>
|
||||
void AppendChildComment(XmlComment comment); |
||||
|
||||
/// <summary>
|
||||
/// Removes the specified comment node from the view.
|
||||
/// </summary>
|
||||
void RemoveComment(XmlComment comment); |
||||
|
||||
/// <summary>
|
||||
/// Inserts the comment before the currently selected node.
|
||||
/// </summary>
|
||||
void InsertCommentBefore(XmlComment comment); |
||||
|
||||
/// <summary>
|
||||
/// Inserts the comment after the currently selected node.
|
||||
/// </summary>
|
||||
void InsertCommentAfter(XmlComment comment); |
||||
} |
||||
} |
||||
@ -0,0 +1,90 @@
@@ -0,0 +1,90 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui.XmlForms; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Allows the use to choose a schema from the schemas that SharpDevelop
|
||||
/// knows about.
|
||||
/// </summary>
|
||||
public class SelectXmlSchemaForm : XmlForm |
||||
{ |
||||
ListBox schemaListBox; |
||||
string NoSchemaSelectedText = String.Empty; |
||||
|
||||
public SelectXmlSchemaForm(string[] namespaces) |
||||
{ |
||||
Initialize(); |
||||
PopulateListBox(namespaces); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the selected schema namesace.
|
||||
/// </summary>
|
||||
public string SelectedNamespaceUri { |
||||
get { |
||||
string namespaceUri = schemaListBox.Text; |
||||
if (namespaceUri == NoSchemaSelectedText) { |
||||
namespaceUri = String.Empty; |
||||
} |
||||
return namespaceUri; |
||||
} |
||||
|
||||
set { |
||||
int index = 0; |
||||
if (value.Length > 0) { |
||||
index = schemaListBox.Items.IndexOf(value); |
||||
} |
||||
|
||||
// Select the option representing "no schema" if
|
||||
// the value does not exist in the list box.
|
||||
if (index == -1) { |
||||
index = 0; |
||||
} |
||||
|
||||
schemaListBox.SelectedIndex = index; |
||||
} |
||||
} |
||||
|
||||
protected override void SetupXmlLoader() |
||||
{ |
||||
xmlLoader.StringValueFilter = new SharpDevelopStringValueFilter(); |
||||
xmlLoader.PropertyValueCreator = new SharpDevelopPropertyValueCreator(); |
||||
} |
||||
|
||||
void Initialize() |
||||
{ |
||||
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("ICSharpCode.XmlEditor.Resources.SelectXmlSchema.xfrm")); |
||||
|
||||
NoSchemaSelectedText = StringParser.Parse("${res:Dialog.Options.IDEOptions.TextEditor.Behaviour.IndentStyle.None}"); |
||||
|
||||
schemaListBox = (ListBox)ControlDictionary["schemaListBox"]; |
||||
|
||||
AcceptButton = (Button)ControlDictionary["okButton"]; |
||||
CancelButton = (Button)ControlDictionary["cancelButton"]; |
||||
AcceptButton.DialogResult = DialogResult.OK; |
||||
} |
||||
|
||||
void PopulateListBox(string[] namespaces) |
||||
{ |
||||
foreach (string schemaNamespace in namespaces) { |
||||
schemaListBox.Items.Add(schemaNamespace); |
||||
} |
||||
|
||||
// Add the "None" string at the top of the list.
|
||||
schemaListBox.Sorted = true; |
||||
schemaListBox.Sorted = false; |
||||
|
||||
schemaListBox.Items.Insert(0, NoSchemaSelectedText); |
||||
} |
||||
} |
||||
} |
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,68 @@
@@ -0,0 +1,68 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
public class XPathQueryPad : AbstractPadContent |
||||
{ |
||||
public const string XPathQueryControlProperties = "XPathQueryControl.Options"; |
||||
|
||||
XPathQueryControl xPathQueryControl; |
||||
bool disposed; |
||||
static XPathQueryPad instance; |
||||
|
||||
public XPathQueryPad() |
||||
{ |
||||
xPathQueryControl = new XPathQueryControl(); |
||||
WorkbenchSingleton.Workbench.ActiveViewContentChanged += ActiveViewContentChanged; |
||||
Properties properties = PropertyService.Get(XPathQueryControlProperties, new Properties()); |
||||
xPathQueryControl.SetMemento(properties); |
||||
instance = this; |
||||
} |
||||
|
||||
public static XPathQueryPad Instance { |
||||
get { |
||||
return instance; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The <see cref="System.Windows.Forms.Control"/> representing the pad.
|
||||
/// </summary>
|
||||
public override object Control { |
||||
get { |
||||
return xPathQueryControl; |
||||
} |
||||
} |
||||
|
||||
public override void Dispose() |
||||
{ |
||||
if (!disposed) { |
||||
disposed = true; |
||||
WorkbenchSingleton.Workbench.ActiveViewContentChanged -= ActiveViewContentChanged; |
||||
Properties properties = xPathQueryControl.CreateMemento(); |
||||
PropertyService.Set(XPathQueryControlProperties, properties); |
||||
xPathQueryControl.Dispose(); |
||||
} |
||||
} |
||||
|
||||
public void RemoveXPathHighlighting() |
||||
{ |
||||
xPathQueryControl.RemoveXPathNodeTextMarkers(); |
||||
} |
||||
|
||||
void ActiveViewContentChanged(object source, EventArgs e) |
||||
{ |
||||
xPathQueryControl.ActiveWindowChanged(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,86 @@
@@ -0,0 +1,86 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.XmlEditor; |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.XmlBinding.Gui |
||||
{ |
||||
/// <summary>
|
||||
/// Display binding for the xml editor.
|
||||
/// </summary>
|
||||
public class XmlDisplayBinding : ISecondaryDisplayBinding |
||||
{ |
||||
public bool ReattachWhenParserServiceIsReady { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public bool CanAttachTo(IViewContent content) |
||||
{ |
||||
return content.PrimaryFileName != null && IsFileNameHandled(content.PrimaryFileName); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns whether the view can handle the specified file.
|
||||
/// </summary>
|
||||
public static bool IsFileNameHandled(string fileName) |
||||
{ |
||||
return IsXmlFileExtension(Path.GetExtension(fileName)); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Checks that the file extension refers to an xml file as
|
||||
/// specified in the SyntaxModes.xml file.
|
||||
/// </summary>
|
||||
static bool IsXmlFileExtension(string extension) |
||||
{ |
||||
foreach (string currentExtension in GetXmlFileExtensions()) { |
||||
if (String.Compare(extension, currentExtension, true) == 0) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the known xml file extensions.
|
||||
/// </summary>
|
||||
public static string[] GetXmlFileExtensions() |
||||
{ |
||||
return string[] { ".xml", ".xaml" }; |
||||
|
||||
foreach (ParserDescriptor parser in AddInTree.BuildItems<ParserDescriptor>("/Workspace/Parser", null, false)) { |
||||
if (parser.Codon.Id == "XmlFoldingParser") { |
||||
return parser.Supportedextensions; |
||||
} |
||||
} |
||||
|
||||
// // Did not find the XmlFoldingParser so default to those files defined by the
|
||||
// // HighlightingManager.
|
||||
// IHighlightingStrategy strategy = HighlightingManager.Manager.FindHighlighter("XML");
|
||||
// if (strategy != null) {
|
||||
// return strategy.Extensions;
|
||||
// }
|
||||
|
||||
return new string[0]; |
||||
} |
||||
|
||||
public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent) |
||||
{ |
||||
return (new List<IViewContent>() { |
||||
new XmlTreeView(viewContent) |
||||
}).ToArray(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,137 @@
@@ -0,0 +1,137 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 4018 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.Core.WinForms; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// The secondary view content that displays the XML document as a tree view.
|
||||
/// </summary>
|
||||
public class XmlTreeView : AbstractViewContent, IClipboardHandler |
||||
{ |
||||
XmlTreeViewContainerControl treeViewContainer = new XmlTreeViewContainerControl(); |
||||
IViewContent parent; |
||||
bool disposed; |
||||
bool ignoreDirtyChange; |
||||
|
||||
public XmlTreeView(IViewContent parent) |
||||
{ |
||||
this.parent = parent; |
||||
treeViewContainer.AttributesGrid.ContextMenuStrip = MenuService.CreateContextMenu(treeViewContainer, "/AddIns/XmlEditor/XmlTree/AttributesGrid/ContextMenu"); |
||||
treeViewContainer.TreeView.ContextMenuStrip = MenuService.CreateContextMenu(treeViewContainer, "/AddIns/XmlEditor/XmlTree/ContextMenu"); |
||||
} |
||||
|
||||
#region IClipboardHandler implementation
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the edit menu's cut command should be enabled.
|
||||
/// </summary>
|
||||
public bool EnableCut { |
||||
get { |
||||
return treeViewContainer.EnableCut; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether the edit menu's copy command should be enabled.
|
||||
/// </summary>
|
||||
public bool EnableCopy { |
||||
get { |
||||
return treeViewContainer.EnableCopy; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether the edit menu's paste command should be enabled.
|
||||
/// </summary>
|
||||
public bool EnablePaste { |
||||
get { |
||||
return treeViewContainer.EnablePaste; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets whether the edit menu's delete command should be enabled.
|
||||
/// </summary>
|
||||
public bool EnableDelete { |
||||
get { |
||||
return treeViewContainer.EnableDelete; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Always returns false.
|
||||
/// </summary>
|
||||
public bool EnableSelectAll { |
||||
get { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Cuts the selected tree node.
|
||||
/// </summary>
|
||||
public void Cut() |
||||
{ |
||||
treeViewContainer.Cut(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Copies the selected tree node.
|
||||
/// </summary>
|
||||
public void Copy() |
||||
{ |
||||
treeViewContainer.Copy(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Pastes the copied or cut node as a child of the selected tree node.
|
||||
/// </summary>
|
||||
public void Paste() |
||||
{ |
||||
treeViewContainer.Paste(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Deletes the selected tree node.
|
||||
/// </summary>
|
||||
public void Delete() |
||||
{ |
||||
treeViewContainer.Delete(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Select all is not currently supported.
|
||||
/// </summary>
|
||||
public void SelectAll() |
||||
{ |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
void TreeViewContainerDirtyChanged(object source, EventArgs e) |
||||
{ |
||||
if (!ignoreDirtyChange) { |
||||
this.PrimaryFile.IsDirty = treeViewContainer.IsDirty; |
||||
} |
||||
} |
||||
|
||||
public override object Control { |
||||
get { |
||||
return this.treeViewContainer; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
// TODO : reimplement this
|
||||
// /// <summary>
|
||||
// /// Displays the resulting output from an XSL transform.
|
||||
// /// </summary>
|
||||
// public class XslOutputView : XmlView
|
||||
// {
|
||||
// public XslOutputView()
|
||||
// {
|
||||
// TitleName = StringParser.Parse("${res:ICSharpCode.XmlEditor.XslOutputView.Title}");
|
||||
// TextEditorControl.FileName = String.Empty;
|
||||
// }
|
||||
//
|
||||
// public static XslOutputView Instance {
|
||||
// get {
|
||||
// foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) {
|
||||
// if (content is XslOutputView) {
|
||||
// LoggingService.Debug("XslOutputView instance exists.");
|
||||
// return (XslOutputView)content;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
} |
||||
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.XmlBinding.Gui; |
||||
using System; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.XmlEditor; |
||||
|
||||
namespace ICSharpCode.XmlBinding.Parser |
||||
{ |
||||
/// <summary>
|
||||
/// Parser that does nothing except return empty compilation unit
|
||||
/// classes so the XmlFoldingStrategy is executed.
|
||||
/// </summary>
|
||||
public class Parser : IParser |
||||
{ |
||||
public Parser() |
||||
{ |
||||
} |
||||
|
||||
#region IParser interface
|
||||
public string[] LexerTags { |
||||
get { |
||||
return null; |
||||
} |
||||
set { |
||||
} |
||||
} |
||||
|
||||
public LanguageProperties Language { |
||||
get { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
public IExpressionFinder CreateExpressionFinder(string fileName) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public IResolver CreateResolver() |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public ICompilationUnit Parse(IProjectContent projectContent, string fileName, string fileContent) |
||||
{ |
||||
DefaultCompilationUnit compilationUnit = new DefaultCompilationUnit(projectContent); |
||||
compilationUnit.FileName = fileName; |
||||
return compilationUnit; |
||||
} |
||||
|
||||
public bool CanParse(IProject project) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public bool CanParse(string fileName) |
||||
{ |
||||
return XmlDisplayBinding.IsFileNameHandled(fileName); |
||||
} |
||||
#endregion
|
||||
} |
||||
} |
||||
@ -0,0 +1,127 @@
@@ -0,0 +1,127 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.XmlBinding.Parser |
||||
{ |
||||
/// <summary>
|
||||
/// An <see cref="XmlQualifiedName"/> with the namespace prefix.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The namespace prefix active for a namespace is
|
||||
/// needed when an element is inserted via autocompletion. This
|
||||
/// class just adds this extra information alongside the
|
||||
/// <see cref="XmlQualifiedName"/>.
|
||||
/// </remarks>
|
||||
public class QualifiedName |
||||
{ |
||||
XmlQualifiedName xmlQualifiedName = XmlQualifiedName.Empty; |
||||
string prefix = String.Empty; |
||||
|
||||
public QualifiedName() |
||||
{ |
||||
} |
||||
|
||||
public QualifiedName(string name, string namespaceUri) |
||||
: this(name, namespaceUri, String.Empty) |
||||
{ |
||||
} |
||||
|
||||
public QualifiedName(string name, string namespaceUri, string prefix) |
||||
{ |
||||
xmlQualifiedName = new XmlQualifiedName(name, namespaceUri); |
||||
this.prefix = prefix; |
||||
} |
||||
|
||||
public static bool operator ==(QualifiedName lhs, QualifiedName rhs) |
||||
{ |
||||
bool equals = false; |
||||
|
||||
if (((object)lhs != null) && ((object)rhs != null)) { |
||||
equals = lhs.Equals(rhs); |
||||
} else if (((object)lhs == null) && ((object)rhs == null)) { |
||||
equals = true; |
||||
} |
||||
|
||||
return equals; |
||||
} |
||||
|
||||
public static bool operator !=(QualifiedName lhs, QualifiedName rhs) |
||||
{ |
||||
return !(lhs == rhs); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// A qualified name is considered equal if the namespace and
|
||||
/// name are the same. The prefix is ignored.
|
||||
/// </summary>
|
||||
public override bool Equals(object obj) |
||||
{ |
||||
bool equals = false; |
||||
|
||||
QualifiedName qualifiedName = obj as QualifiedName; |
||||
if (qualifiedName != null) { |
||||
equals = xmlQualifiedName.Equals(qualifiedName.xmlQualifiedName); |
||||
} else { |
||||
XmlQualifiedName name = obj as XmlQualifiedName; |
||||
if (name != null) { |
||||
equals = xmlQualifiedName.Equals(name); |
||||
} |
||||
} |
||||
|
||||
return equals; |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
return xmlQualifiedName.GetHashCode(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the namespace of the qualified name.
|
||||
/// </summary>
|
||||
public string Namespace { |
||||
get { return xmlQualifiedName.Namespace; } |
||||
set { xmlQualifiedName = new XmlQualifiedName(xmlQualifiedName.Name, value); } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the element.
|
||||
/// </summary>
|
||||
public string Name { |
||||
get { return xmlQualifiedName.Name; } |
||||
set { xmlQualifiedName = new XmlQualifiedName(value, xmlQualifiedName.Namespace); } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the namespace prefix used.
|
||||
/// </summary>
|
||||
public string Prefix { |
||||
get { return prefix; } |
||||
set { prefix = value; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns a string that represents the QualifiedName.
|
||||
/// </summary>
|
||||
public override string ToString() |
||||
{ |
||||
if (xmlQualifiedName.Namespace.Length > 0) { |
||||
string prefixToString = String.Empty; |
||||
if (!String.IsNullOrEmpty(prefix)) { |
||||
prefixToString = prefix + ":"; |
||||
} |
||||
return String.Concat(prefixToString, xmlQualifiedName.Name, " [", xmlQualifiedName.Namespace, "]"); |
||||
} else if (!String.IsNullOrEmpty(prefix)) { |
||||
return prefix + ":" + xmlQualifiedName.Name; |
||||
} |
||||
return xmlQualifiedName.Name; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,274 @@
@@ -0,0 +1,274 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using System.Linq; |
||||
|
||||
namespace ICSharpCode.XmlBinding.Parser |
||||
{ |
||||
/// <summary>
|
||||
/// A collection that stores <see cref='QualifiedName'/> objects.
|
||||
/// </summary>
|
||||
[Serializable()] |
||||
public class QualifiedNameCollection : Collection<QualifiedName> { |
||||
List<QualifiedName> list; |
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref='QualifiedNameCollection'/>.
|
||||
/// </summary>
|
||||
public QualifiedNameCollection() |
||||
{ |
||||
this.list = new List<QualifiedName>(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref='QualifiedNameCollection'/> based on another <see cref='QualifiedNameCollection'/>.
|
||||
/// </summary>
|
||||
/// <param name='val'>
|
||||
/// A <see cref='QualifiedNameCollection'/> from which the contents are copied
|
||||
/// </param>
|
||||
public QualifiedNameCollection(QualifiedNameCollection val) |
||||
{ |
||||
this.AddRange(val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref='QualifiedNameCollection'/> containing any array of <see cref='QualifiedName'/> objects.
|
||||
/// </summary>
|
||||
/// <param name='val'>
|
||||
/// A array of <see cref='QualifiedName'/> objects with which to intialize the collection
|
||||
/// </param>
|
||||
public QualifiedNameCollection(QualifiedName[] val) |
||||
{ |
||||
this.AddRange(val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Represents the entry at the specified index of the <see cref='QualifiedName'/>.
|
||||
/// </summary>
|
||||
/// <param name='index'>The zero-based index of the entry to locate in the collection.</param>
|
||||
/// <value>The entry at the specified index of the collection.</value>
|
||||
/// <exception cref='ArgumentOutOfRangeException'><paramref name='index'/> is outside the valid range of indexes for the collection.</exception>
|
||||
public QualifiedName this[int index] { |
||||
get { |
||||
return ((QualifiedName)(this.list[index])); |
||||
} |
||||
set { |
||||
this.list[index] = value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref='QualifiedName'/> with the specified value to the
|
||||
/// <see cref='QualifiedNameCollection'/>.
|
||||
/// </summary>
|
||||
/// <param name='val'>The <see cref='QualifiedName'/> to add.</param>
|
||||
/// <seealso cref='QualifiedNameCollection.AddRange'/>
|
||||
public void Add(QualifiedName val) |
||||
{ |
||||
this.list.Add(val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Copies the elements of an array to the end of the <see cref='QualifiedNameCollection'/>.
|
||||
/// </summary>
|
||||
/// <param name='val'>
|
||||
/// An array of type <see cref='QualifiedName'/> containing the objects to add to the collection.
|
||||
/// </param>
|
||||
/// <seealso cref='QualifiedNameCollection.Add'/>
|
||||
public void AddRange(QualifiedName[] val) |
||||
{ |
||||
for (int i = 0; i < val.Length; i++) { |
||||
this.Add(val[i]); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds the contents of another <see cref='QualifiedNameCollection'/> to the end of the collection.
|
||||
/// </summary>
|
||||
/// <param name='val'>
|
||||
/// A <see cref='QualifiedNameCollection'/> containing the objects to add to the collection.
|
||||
/// </param>
|
||||
/// <seealso cref='QualifiedNameCollection.Add'/>
|
||||
public void AddRange(QualifiedNameCollection val) |
||||
{ |
||||
for (int i = 0; i < val.Count; i++) |
||||
{ |
||||
this.Add(val[i]); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the
|
||||
/// <see cref='QualifiedNameCollection'/> contains the specified <see cref='QualifiedName'/>.
|
||||
/// </summary>
|
||||
/// <param name='val'>The <see cref='QualifiedName'/> to locate.</param>
|
||||
/// <returns>
|
||||
/// <see langword='true'/> if the <see cref='QualifiedName'/> is contained in the collection;
|
||||
/// otherwise, <see langword='false'/>.
|
||||
/// </returns>
|
||||
/// <seealso cref='QualifiedNameCollection.IndexOf'/>
|
||||
public bool Contains(QualifiedName val) |
||||
{ |
||||
return this.list.Contains(val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Copies the <see cref='QualifiedNameCollection'/> values to a one-dimensional <see cref='Array'/> instance at the
|
||||
/// specified index.
|
||||
/// </summary>
|
||||
/// <param name='array'>The one-dimensional <see cref='Array'/> that is the destination of the values copied from <see cref='QualifiedNameCollection'/>.</param>
|
||||
/// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
|
||||
/// <exception cref='ArgumentException'>
|
||||
/// <para><paramref name='array'/> is multidimensional.</para>
|
||||
/// <para>-or-</para>
|
||||
/// <para>The number of elements in the <see cref='QualifiedNameCollection'/> is greater than
|
||||
/// the available space between <paramref name='arrayIndex'/> and the end of
|
||||
/// <paramref name='array'/>.</para>
|
||||
/// </exception>
|
||||
/// <exception cref='ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
|
||||
/// <exception cref='ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
|
||||
/// <seealso cref='Array'/>
|
||||
public void CopyTo(QualifiedName[] array, int index) |
||||
{ |
||||
this.list.CopyTo(array, index); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the index of a <see cref='QualifiedName'/> in
|
||||
/// the <see cref='QualifiedNameCollection'/>.
|
||||
/// </summary>
|
||||
/// <param name='val'>The <see cref='QualifiedName'/> to locate.</param>
|
||||
/// <returns>
|
||||
/// The index of the <see cref='QualifiedName'/> of <paramref name='val'/> in the
|
||||
/// <see cref='QualifiedNameCollection'/>, if found; otherwise, -1.
|
||||
/// </returns>
|
||||
/// <seealso cref='QualifiedNameCollection.Contains'/>
|
||||
public int IndexOf(QualifiedName val) |
||||
{ |
||||
return this.list.IndexOf(val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Inserts a <see cref='QualifiedName'/> into the <see cref='QualifiedNameCollection'/> at the specified index.
|
||||
/// </summary>
|
||||
/// <param name='index'>The zero-based index where <paramref name='val'/> should be inserted.</param>
|
||||
/// <param name='val'>The <see cref='QualifiedName'/> to insert.</param>
|
||||
/// <seealso cref='QualifiedNameCollection.Add'/>
|
||||
public void Insert(int index, QualifiedName val) |
||||
{ |
||||
this.list.Insert(index, val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through the <see cref='QualifiedNameCollection'/>.
|
||||
/// </summary>
|
||||
/// <seealso cref='IEnumerator'/>
|
||||
public new QualifiedNameEnumerator GetEnumerator() |
||||
{ |
||||
return new QualifiedNameEnumerator(this); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Removes a specific <see cref='QualifiedName'/> from the <see cref='QualifiedNameCollection'/>.
|
||||
/// </summary>
|
||||
/// <param name='val'>The <see cref='QualifiedName'/> to remove from the <see cref='QualifiedNameCollection'/>.</param>
|
||||
/// <exception cref='ArgumentException'><paramref name='val'/> is not found in the Collection.</exception>
|
||||
public void Remove(QualifiedName val) |
||||
{ |
||||
this.list.Remove(val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Removes the last item in this collection.
|
||||
/// </summary>
|
||||
public void RemoveLast() |
||||
{ |
||||
if (Count > 0) { |
||||
RemoveAt(Count - 1); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Removes the first item in the collection.
|
||||
/// </summary>
|
||||
public void RemoveFirst() |
||||
{ |
||||
if (Count > 0) { |
||||
RemoveAt(0); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the namespace prefix of the last item.
|
||||
/// </summary>
|
||||
public string LastPrefix { |
||||
get { |
||||
if (Count > 0) { |
||||
QualifiedName name = this[Count - 1]; |
||||
return name.Prefix; |
||||
} |
||||
return String.Empty; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Enumerator that can iterate through a QualifiedNameCollection.
|
||||
/// </summary>
|
||||
/// <seealso cref='IEnumerator'/>
|
||||
/// <seealso cref='QualifiedNameCollection'/>
|
||||
/// <seealso cref='QualifiedName'/>
|
||||
public class QualifiedNameEnumerator : IEnumerator |
||||
{ |
||||
IEnumerator baseEnumerator; |
||||
IEnumerable temp; |
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref='QualifiedNameEnumerator'/>.
|
||||
/// </summary>
|
||||
public QualifiedNameEnumerator(QualifiedNameCollection mappings) |
||||
{ |
||||
this.temp = ((IEnumerable)(mappings)); |
||||
this.baseEnumerator = temp.GetEnumerator(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the current <see cref='QualifiedName'/> in the <seealso cref='QualifiedNameCollection'/>.
|
||||
/// </summary>
|
||||
public QualifiedName Current { |
||||
get { |
||||
return ((QualifiedName)(baseEnumerator.Current)); |
||||
} |
||||
} |
||||
|
||||
object IEnumerator.Current { |
||||
get { |
||||
return baseEnumerator.Current; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Advances the enumerator to the next <see cref='QualifiedName'/> of the <see cref='QualifiedNameCollection'/>.
|
||||
/// </summary>
|
||||
public bool MoveNext() |
||||
{ |
||||
return baseEnumerator.MoveNext(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Sets the enumerator to its initial position, which is before the first element in the <see cref='QualifiedNameCollection'/>.
|
||||
/// </summary>
|
||||
public void Reset() |
||||
{ |
||||
baseEnumerator.Reset(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,148 @@
@@ -0,0 +1,148 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Text; |
||||
|
||||
namespace ICSharpCode.XmlBinding.Parser |
||||
{ |
||||
/// <summary>
|
||||
/// Represents the path to an xml element starting from the root of the
|
||||
/// document.
|
||||
/// </summary>
|
||||
public class XmlElementPath |
||||
{ |
||||
QualifiedNameCollection elements = new QualifiedNameCollection(); |
||||
|
||||
public XmlElementPath() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the elements specifying the path.
|
||||
/// </summary>
|
||||
/// <remarks>The order of the elements determines the path.</remarks>
|
||||
public QualifiedNameCollection Elements { |
||||
get { return elements; } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Compacts the path so it only contains the elements that are from
|
||||
/// the namespace of the last element in the path.
|
||||
/// </summary>
|
||||
/// <remarks>This method is used when we need to know the path for a
|
||||
/// particular namespace and do not care about the complete path.
|
||||
/// </remarks>
|
||||
public void Compact() |
||||
{ |
||||
if (elements.Count > 0) { |
||||
QualifiedName lastName = Elements[Elements.Count - 1]; |
||||
if (lastName != null) { |
||||
int index = FindNonMatchingParentElement(lastName.Namespace); |
||||
if (index != -1) { |
||||
RemoveParentElements(index); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// An xml element path is considered to be equal if
|
||||
/// each path item has the same name and namespace.
|
||||
/// </summary>
|
||||
public override bool Equals(object obj) |
||||
{ |
||||
if (!(obj is XmlElementPath)) return false; |
||||
if (this == obj) return true; |
||||
|
||||
XmlElementPath rhs = (XmlElementPath)obj; |
||||
if (elements.Count == rhs.elements.Count) { |
||||
|
||||
for (int i = 0; i < elements.Count; ++i) { |
||||
if (!elements[i].Equals(rhs.elements[i])) { |
||||
return false; |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
return elements.GetHashCode(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets a string that represents the XmlElementPath.
|
||||
/// </summary>
|
||||
public override string ToString() |
||||
{ |
||||
if (elements.Count > 0) { |
||||
StringBuilder toString = new StringBuilder(); |
||||
int lastIndex = elements.Count - 1; |
||||
for (int i = 0; i < elements.Count; ++i) { |
||||
string elementToString = GetElementToString(elements[i]); |
||||
if (i == lastIndex) { |
||||
toString.Append(elementToString); |
||||
} else { |
||||
toString.Append(elementToString); |
||||
toString.Append(" > "); |
||||
} |
||||
} |
||||
return toString.ToString(); |
||||
} |
||||
return String.Empty; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Removes elements up to and including the specified index.
|
||||
/// </summary>
|
||||
void RemoveParentElements(int index) |
||||
{ |
||||
while (index >= 0) { |
||||
--index; |
||||
elements.RemoveFirst(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Finds the first parent that does belong in the specified
|
||||
/// namespace.
|
||||
/// </summary>
|
||||
int FindNonMatchingParentElement(string namespaceUri) |
||||
{ |
||||
int index = -1; |
||||
|
||||
if (elements.Count > 1) { |
||||
// Start the check from the the last but one item.
|
||||
for (int i = elements.Count - 2; i >= 0; --i) { |
||||
QualifiedName name = elements[i]; |
||||
if (name.Namespace != namespaceUri) { |
||||
index = i; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
return index; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the qualified name as a string. If the name has a
|
||||
/// prefix then it returns "prefix:element" otherwise it returns
|
||||
/// just the element name.
|
||||
/// </summary>
|
||||
static string GetElementToString(QualifiedName name) |
||||
{ |
||||
if (name.Prefix.Length > 0) { |
||||
return name.Prefix + ":" + name.Name; |
||||
} |
||||
return name.Name; |
||||
} |
||||
} |
||||
} |
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,167 @@
@@ -0,0 +1,167 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 1662 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Xml; |
||||
using System.Xml.XPath; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Stores an XmlNode and its associated line number and position after an
|
||||
/// XPath query has been evaluated.
|
||||
/// </summary>
|
||||
public class XPathNodeMatch : IXmlLineInfo |
||||
{ |
||||
int? lineNumber; |
||||
int linePosition; |
||||
string value; |
||||
string displayValue; |
||||
XPathNodeType nodeType; |
||||
|
||||
/// <summary>
|
||||
/// Creates an XPathNodeMatch from the navigator which should be position on the
|
||||
/// node.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// We deliberately use the OuterXml when we find a Namespace since the
|
||||
/// navigator location returned starts from the xmlns attribute.
|
||||
/// </remarks>
|
||||
public XPathNodeMatch(XPathNavigator currentNavigator) |
||||
{ |
||||
SetLineNumbers(currentNavigator as IXmlLineInfo); |
||||
nodeType = currentNavigator.NodeType; |
||||
switch (nodeType) { |
||||
case XPathNodeType.Text: |
||||
SetTextValue(currentNavigator); |
||||
break; |
||||
case XPathNodeType.Comment: |
||||
SetCommentValue(currentNavigator); |
||||
break; |
||||
case XPathNodeType.Namespace: |
||||
SetNamespaceValue(currentNavigator); |
||||
break; |
||||
case XPathNodeType.Element: |
||||
SetElementValue(currentNavigator); |
||||
break; |
||||
case XPathNodeType.ProcessingInstruction: |
||||
SetProcessingInstructionValue(currentNavigator); |
||||
break; |
||||
case XPathNodeType.Attribute: |
||||
SetAttributeValue(currentNavigator); |
||||
break; |
||||
default: |
||||
value = currentNavigator.LocalName; |
||||
displayValue = value; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Line numbers are zero based.
|
||||
/// </summary>
|
||||
public int LineNumber { |
||||
get { |
||||
return lineNumber.GetValueOrDefault(0); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Line positions are zero based.
|
||||
/// </summary>
|
||||
public int LinePosition { |
||||
get { |
||||
return linePosition; |
||||
} |
||||
} |
||||
|
||||
public bool HasLineInfo() |
||||
{ |
||||
return lineNumber.HasValue; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the text value of the node.
|
||||
/// </summary>
|
||||
public string Value { |
||||
get { |
||||
return value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the node display value. This includes the angle brackets if it is
|
||||
/// an element, for example.
|
||||
/// </summary>
|
||||
public string DisplayValue { |
||||
get { |
||||
return displayValue; |
||||
} |
||||
} |
||||
|
||||
public XPathNodeType NodeType { |
||||
get { |
||||
return nodeType; |
||||
} |
||||
} |
||||
|
||||
void SetElementValue(XPathNavigator navigator) |
||||
{ |
||||
value = navigator.Name; |
||||
if (navigator.IsEmptyElement) { |
||||
displayValue = String.Concat("<", value, "/>"); |
||||
} else { |
||||
displayValue = String.Concat("<", value, ">"); |
||||
} |
||||
} |
||||
|
||||
void SetTextValue(XPathNavigator navigator) |
||||
{ |
||||
value = navigator.Value; |
||||
displayValue = value; |
||||
} |
||||
|
||||
void SetCommentValue(XPathNavigator navigator) |
||||
{ |
||||
value = navigator.Value; |
||||
displayValue = navigator.OuterXml; |
||||
} |
||||
|
||||
void SetNamespaceValue(XPathNavigator navigator) |
||||
{ |
||||
value = navigator.OuterXml; |
||||
displayValue = value; |
||||
} |
||||
|
||||
void SetProcessingInstructionValue(XPathNavigator navigator) |
||||
{ |
||||
value = navigator.Name; |
||||
displayValue = navigator.OuterXml; |
||||
} |
||||
|
||||
void SetAttributeValue(XPathNavigator navigator) |
||||
{ |
||||
value = navigator.Name; |
||||
displayValue = String.Concat("@", value); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Takes one of the xml line number so the numbers are now zero
|
||||
/// based instead of one based.
|
||||
/// </summary>
|
||||
/// <remarks>A namespace query (e.g. //namespace::*) will return
|
||||
/// a line info of -1, -1 for the xml namespace. Which looks like
|
||||
/// a bug in the XPathDocument class.</remarks>
|
||||
void SetLineNumbers(IXmlLineInfo lineInfo) |
||||
{ |
||||
if (lineInfo.HasLineInfo() && lineInfo.LineNumber > 0) { |
||||
lineNumber = lineInfo.LineNumber - 1; |
||||
linePosition = lineInfo.LinePosition - 1; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 1965 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Drawing; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/* |
||||
/// <summary>
|
||||
/// A text marker for an XPath query match.
|
||||
/// </summary>
|
||||
public class XPathNodeTextMarker : TextMarker |
||||
{ |
||||
public static readonly Color MarkerBackColor = Color.FromArgb(159, 255, 162); |
||||
|
||||
public XPathNodeTextMarker(int offset, XPathNodeMatch node) : base(offset, node.Value.Length, TextMarkerType.SolidBlock, MarkerBackColor) |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds markers for each XPathNodeMatch.
|
||||
/// </summary>
|
||||
public static void AddMarkers(MarkerStrategy markerStrategy, XPathNodeMatch[] nodes) |
||||
{ |
||||
foreach (XPathNodeMatch node in nodes) { |
||||
AddMarker(markerStrategy, node); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds a single marker for the XPathNodeMatch.
|
||||
/// </summary>
|
||||
public static void AddMarker(MarkerStrategy markerStrategy, XPathNodeMatch node) |
||||
{ |
||||
if (node.HasLineInfo() && node.Value.Length > 0) { |
||||
LineSegment lineSegment = markerStrategy.Document.GetLineSegment(node.LineNumber); |
||||
markerStrategy.AddMarker(new XPathNodeTextMarker(lineSegment.Offset + node.LinePosition, node)); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Removes all the XPathNodeMarkers from the marker strategy.
|
||||
/// </summary>
|
||||
public static void RemoveMarkers(MarkerStrategy markerStrategy) |
||||
{ |
||||
markerStrategy.RemoveAll(IsXPathNodeTextMarkerMatch); |
||||
} |
||||
|
||||
static bool IsXPathNodeTextMarkerMatch(TextMarker marker) |
||||
{ |
||||
return marker is XPathNodeTextMarker; |
||||
} |
||||
} |
||||
*/ |
||||
} |
||||
@ -0,0 +1,95 @@
@@ -0,0 +1,95 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 1965 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Property descriptor for an XmlAttribute. This is used when displaying
|
||||
/// an XmlAttribute in the property grid.
|
||||
/// </summary>
|
||||
public class XmlAttributePropertyDescriptor : PropertyDescriptor |
||||
{ |
||||
XmlAttribute xmlAttribute; |
||||
public XmlAttributePropertyDescriptor(XmlAttribute xmlAttribute) |
||||
: base(xmlAttribute.LocalName, new Attribute[0]) |
||||
{ |
||||
this.xmlAttribute = xmlAttribute; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the property descriptors for the specified attributes.
|
||||
/// </summary>
|
||||
public static PropertyDescriptorCollection GetProperties(XmlAttributeCollection xmlAttributes) |
||||
{ |
||||
List<PropertyDescriptor> properties = new List<PropertyDescriptor>(); |
||||
foreach (XmlAttribute xmlAttribute in xmlAttributes) { |
||||
properties.Add(new XmlAttributePropertyDescriptor(xmlAttribute)); |
||||
} |
||||
return new PropertyDescriptorCollection(properties.ToArray()); |
||||
} |
||||
|
||||
public override Type ComponentType { |
||||
get { |
||||
return typeof(String); |
||||
} |
||||
} |
||||
|
||||
public override bool IsReadOnly { |
||||
get { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the property type in this case a string.
|
||||
/// </summary>
|
||||
public override Type PropertyType { |
||||
get { |
||||
return typeof(String); |
||||
} |
||||
} |
||||
|
||||
public override bool CanResetValue(object component) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the xml attribute.
|
||||
/// </summary>
|
||||
public override object GetValue(object component) |
||||
{ |
||||
return xmlAttribute.Value; |
||||
} |
||||
|
||||
public override void ResetValue(object component) |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Sets the xml attribute value.
|
||||
/// </summary>
|
||||
public override void SetValue(object component, object value) |
||||
{ |
||||
xmlAttribute.Value = (String)value; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// If the current value has changed from the default value then this
|
||||
/// method will return true.
|
||||
/// </summary>
|
||||
public override bool ShouldSerializeValue(object component) |
||||
{ |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,94 @@
@@ -0,0 +1,94 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 1965 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Type descriptor that allows us to display properties in the property grid
|
||||
/// for Xml attributes.
|
||||
/// </summary>
|
||||
public class XmlAttributeTypeDescriptor : ICustomTypeDescriptor |
||||
{ |
||||
PropertyDescriptorCollection properties; |
||||
|
||||
public XmlAttributeTypeDescriptor(XmlAttributeCollection xmlAttributes) |
||||
{ |
||||
if (xmlAttributes != null) { |
||||
properties = XmlAttributePropertyDescriptor.GetProperties(xmlAttributes); |
||||
} else { |
||||
properties = new PropertyDescriptorCollection(new XmlAttributePropertyDescriptor[0]); |
||||
} |
||||
} |
||||
|
||||
public AttributeCollection GetAttributes() |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public string GetClassName() |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public string GetComponentName() |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public TypeConverter GetConverter() |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public EventDescriptor GetDefaultEvent() |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public PropertyDescriptor GetDefaultProperty() |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public object GetEditor(Type editorBaseType) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public EventDescriptorCollection GetEvents() |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public EventDescriptorCollection GetEvents(Attribute[] attributes) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public PropertyDescriptorCollection GetProperties() |
||||
{ |
||||
return GetProperties(new Attribute[0]); |
||||
} |
||||
|
||||
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) |
||||
{ |
||||
return properties; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns this class instance.
|
||||
/// </summary>
|
||||
public object GetPropertyOwner(PropertyDescriptor pd) |
||||
{ |
||||
return this; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 2128 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Xml; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Base class for XmlTextTreeNodes and XmlCommentTreeNodes
|
||||
/// </summary>
|
||||
public abstract class XmlCharacterDataTreeNode : ExtTreeNode |
||||
{ |
||||
XmlCharacterData characterData; |
||||
|
||||
public XmlCharacterDataTreeNode(XmlCharacterData characterData) |
||||
{ |
||||
this.characterData = characterData; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Updates the display text based on changes in the
|
||||
/// XmlCharacterData's InnerText associated with this node.
|
||||
/// </summary>
|
||||
public void Update() |
||||
{ |
||||
Text = GetDisplayText(characterData.InnerText); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the text to display for this tree node.
|
||||
/// </summary>
|
||||
/// <remarks>If the text is a single line then it is returned, but
|
||||
/// trimmed. If the text has multiple lines then the first line that
|
||||
/// is not empty is returned. This line may have "..." appended to indicate
|
||||
/// there is more text for this node that is not being displayed. The
|
||||
/// "..." will be appended only if there are multiple lines containing
|
||||
/// text.</remarks>
|
||||
static string GetDisplayText(string s) |
||||
{ |
||||
string[] lines = s.Trim().Split('\n'); |
||||
for (int i = 0; i < lines.Length; ++i) { |
||||
string line = lines[i].Trim(); |
||||
if (line.Length > 0) { |
||||
if (lines.Length == 1) { |
||||
return line; |
||||
} else { |
||||
return String.Concat(line, "..."); |
||||
} |
||||
} |
||||
} |
||||
return String.Empty; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 2164 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Xml; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Represents an xml comment in the tree.
|
||||
/// </summary>
|
||||
public class XmlCommentTreeNode : XmlCharacterDataTreeNode |
||||
{ |
||||
public const string XmlCommentTreeNodeImageKey = "XmlCommentTreeNodeImage"; |
||||
public const string XmlCommentTreeNodeGhostImageKey = "XmlCommentTreeNodeGhostImage"; |
||||
|
||||
XmlComment comment; |
||||
|
||||
public XmlCommentTreeNode(XmlComment comment) |
||||
: base(comment) |
||||
{ |
||||
this.comment = comment; |
||||
ImageKey = XmlCommentTreeNodeImageKey; |
||||
SelectedImageKey = ImageKey; |
||||
Update(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the XmlComment associated with this tree node.
|
||||
/// </summary>
|
||||
public XmlComment XmlComment { |
||||
get { |
||||
return comment; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether to show the ghost image which is
|
||||
/// displayed when cutting the node.
|
||||
/// </summary>
|
||||
public bool ShowGhostImage { |
||||
get { |
||||
return ImageKey == XmlCommentTreeNodeGhostImageKey; |
||||
} |
||||
set { |
||||
if (value) { |
||||
ImageKey = XmlCommentTreeNodeGhostImageKey; |
||||
} else { |
||||
ImageKey = XmlCommentTreeNodeImageKey; |
||||
} |
||||
SelectedImageKey = ImageKey; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,119 @@
@@ -0,0 +1,119 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 1965 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Diagnostics; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// The Xml Editor add-in options.
|
||||
/// </summary>
|
||||
public static class XmlEditorAddInOptions |
||||
{ |
||||
public static readonly string OptionsProperty = "XmlEditor.AddIn.Options"; |
||||
public static readonly string ShowAttributesWhenFoldedPropertyName = "ShowAttributesWhenFolded"; |
||||
public static readonly string ShowSchemaAnnotationPropertyName = "ShowSchemaAnnotation"; |
||||
|
||||
static Properties properties; |
||||
|
||||
static XmlEditorAddInOptions() |
||||
{ |
||||
properties = PropertyService.Get(OptionsProperty, new Properties()); |
||||
} |
||||
|
||||
static Properties Properties { |
||||
get { |
||||
Debug.Assert(properties != null); |
||||
return properties; |
||||
} |
||||
} |
||||
|
||||
public static event PropertyChangedEventHandler PropertyChanged { |
||||
add { Properties.PropertyChanged += value; } |
||||
remove { Properties.PropertyChanged -= value; } |
||||
} |
||||
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets an association between a schema and a file extension.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>The property will be an xml element when the SharpDevelopProperties.xml
|
||||
/// is read on startup. The property will be a schema association
|
||||
/// if the user changes the schema associated with the file
|
||||
/// extension in tools->options.</para>
|
||||
/// <para>The normal way of doing things is to
|
||||
/// pass the GetProperty method a default value which auto-magically
|
||||
/// turns the xml element into a schema association so we would not
|
||||
/// have to check for both. In this case, however, I do not want
|
||||
/// a default saved to the SharpDevelopProperties.xml file unless the user
|
||||
/// makes a change using Tools->Options.</para>
|
||||
/// <para>If we have a file extension that is currently missing a default
|
||||
/// schema then if we ship the schema at a later date the association will
|
||||
/// be updated by the code if the user has not changed the settings themselves.
|
||||
/// </para>
|
||||
/// <para>For example, the initial release of the xml editor add-in had
|
||||
/// no default schema for .xsl files, by default it was associated with
|
||||
/// no schema and this setting is saved if the user ever viewed the settings
|
||||
/// in the tools->options dialog. Now, after the initial release the
|
||||
/// .xsl schema was created and shipped with SharpDevelop, there is
|
||||
/// no way to associate this schema to .xsl files by default since
|
||||
/// the property exists in the SharpDevelopProperties.xml file.</para>
|
||||
/// <para>An alternative way of doing this might be to have the
|
||||
/// config info in the schema itself, which a special SharpDevelop
|
||||
/// namespace. I believe this is what Visual Studio does. This
|
||||
/// way is not as flexible since it requires the user to locate
|
||||
/// the schema and change the association manually.</para>
|
||||
/// </remarks>
|
||||
public static XmlSchemaAssociation GetSchemaAssociation(string extension) |
||||
{ |
||||
extension = extension.ToLower(); |
||||
string property = Properties.Get("ext" + extension, String.Empty); |
||||
XmlSchemaAssociation association = null; |
||||
|
||||
if (property.Length > 0) { |
||||
association = XmlSchemaAssociation.ConvertFromString(property); |
||||
} |
||||
|
||||
// Use default?
|
||||
if (association == null) { |
||||
association = XmlSchemaAssociation.GetDefaultAssociation(extension); |
||||
} |
||||
|
||||
return association; |
||||
} |
||||
|
||||
public static void SetSchemaAssociation(XmlSchemaAssociation association) |
||||
{ |
||||
Properties.Set("ext" + association.Extension, association.ConvertToString()); |
||||
} |
||||
|
||||
public static bool ShowAttributesWhenFolded { |
||||
get { |
||||
return Properties.Get(ShowAttributesWhenFoldedPropertyName, false); |
||||
} |
||||
|
||||
set { |
||||
Properties.Set(ShowAttributesWhenFoldedPropertyName, value); |
||||
} |
||||
} |
||||
|
||||
public static bool ShowSchemaAnnotation { |
||||
get { |
||||
return Properties.Get(ShowSchemaAnnotationPropertyName, true); |
||||
} |
||||
|
||||
set { |
||||
Properties.Set(ShowSchemaAnnotationPropertyName, value); |
||||
} |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
||||
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 3568 $</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.SharpDevelop.Gui.OptionPanels; |
||||
using System; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Configuration settings for the xml editor.
|
||||
/// </summary>
|
||||
public class XmlEditorOptionsPanel : XmlFormsOptionPanel |
||||
{ |
||||
static readonly string showAttributesWhenFoldedCheckBoxName = "showAttributesWhenFoldedCheckBox"; |
||||
static readonly string showSchemaAnnotationCheckBoxName = "showSchemaAnnotationCheckBox"; |
||||
|
||||
public XmlEditorOptionsPanel() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Initialises the panel.
|
||||
/// </summary>
|
||||
public override void LoadPanelContents() |
||||
{ |
||||
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("ICSharpCode.XmlEditor.Resources.XmlEditorOptionsPanel.xfrm")); |
||||
|
||||
((CheckBox)ControlDictionary[showAttributesWhenFoldedCheckBoxName]).Checked = XmlEditorAddInOptions.ShowAttributesWhenFolded; |
||||
((CheckBox)ControlDictionary[showSchemaAnnotationCheckBoxName]).Checked = XmlEditorAddInOptions.ShowSchemaAnnotation; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Saves any changes.
|
||||
/// </summary>
|
||||
public override bool StorePanelContents() |
||||
{ |
||||
XmlEditorAddInOptions.ShowAttributesWhenFolded = ((CheckBox)ControlDictionary[showAttributesWhenFoldedCheckBoxName]).Checked; |
||||
XmlEditorAddInOptions.ShowSchemaAnnotation = ((CheckBox)ControlDictionary[showSchemaAnnotationCheckBoxName]).Checked; |
||||
|
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,99 @@
@@ -0,0 +1,99 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 2164 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Xml; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Represents an XmlElement in the Xml Tree.
|
||||
/// </summary>
|
||||
public class XmlElementTreeNode : ExtTreeNode |
||||
{ |
||||
public const string XmlElementTreeNodeImageKey = "XmlElementTreeNodeImage"; |
||||
public const string XmlElementTreeNodeGhostImageKey = "XmlElementTreeNodeGhostImage"; |
||||
|
||||
XmlElement element; |
||||
|
||||
public XmlElementTreeNode(XmlElement element) |
||||
{ |
||||
this.element = element; |
||||
Text = GetDisplayText(element); |
||||
Tag = element; |
||||
ImageKey = XmlElementTreeNodeImageKey; |
||||
|
||||
if (element.HasChildNodes) { |
||||
// Add dummy node so that the tree node can be
|
||||
// expanded in the tree view.
|
||||
Nodes.Add(new ExtTreeNode()); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the XmlElement associated with this tree node.
|
||||
/// </summary>
|
||||
public XmlElement XmlElement { |
||||
get { |
||||
return element; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether to show the ghost image which is
|
||||
/// displayed when cutting the node.
|
||||
/// </summary>
|
||||
public bool ShowGhostImage { |
||||
get { |
||||
return ImageKey == XmlElementTreeNodeGhostImageKey; |
||||
} |
||||
set { |
||||
if (value) { |
||||
ImageKey = XmlElementTreeNodeGhostImageKey; |
||||
} else { |
||||
ImageKey = XmlElementTreeNodeImageKey; |
||||
} |
||||
SelectedImageKey = ImageKey; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds child elements to this tree node.
|
||||
/// </summary>
|
||||
protected override void Initialize() |
||||
{ |
||||
Nodes.Clear(); |
||||
foreach (XmlNode childNode in element.ChildNodes) { |
||||
XmlElement childElement = childNode as XmlElement; |
||||
XmlText text = childNode as XmlText; |
||||
XmlComment comment = childNode as XmlComment; |
||||
if (childElement != null) { |
||||
XmlElementTreeNode treeNode = new XmlElementTreeNode(childElement); |
||||
treeNode.AddTo(this); |
||||
} else if (text != null) { |
||||
XmlTextTreeNode treeNode = new XmlTextTreeNode(text); |
||||
treeNode.AddTo(this); |
||||
} else if (comment != null) { |
||||
XmlCommentTreeNode treeNode = new XmlCommentTreeNode(comment); |
||||
treeNode.AddTo(this); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the tree node's text for the element.
|
||||
/// </summary>
|
||||
static string GetDisplayText(XmlElement element) |
||||
{ |
||||
if (element.Prefix.Length > 0) { |
||||
return String.Concat(element.Prefix, ":", element.LocalName); |
||||
} |
||||
return element.LocalName; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,157 @@
@@ -0,0 +1,157 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 1965 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Represents an association between an xml schema and a file extension.
|
||||
/// </summary>
|
||||
public class XmlSchemaAssociation //: IXmlConvertable
|
||||
{ |
||||
string namespaceUri = String.Empty; |
||||
string extension = String.Empty; |
||||
string namespacePrefix = String.Empty; |
||||
|
||||
public XmlSchemaAssociation(string extension) |
||||
: this(extension, String.Empty, String.Empty) |
||||
{ |
||||
} |
||||
|
||||
public XmlSchemaAssociation(string extension, string namespaceUri) |
||||
: this(extension, namespaceUri, String.Empty) |
||||
{ |
||||
} |
||||
|
||||
public XmlSchemaAssociation(string extension, string namespaceUri, string namespacePrefix) |
||||
{ |
||||
this.extension = extension; |
||||
this.namespaceUri = namespaceUri; |
||||
this.namespacePrefix = namespacePrefix; |
||||
} |
||||
|
||||
public string NamespaceUri { |
||||
get { |
||||
return namespaceUri; |
||||
} |
||||
|
||||
set { |
||||
namespaceUri = value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the file extension (e.g. '.xml').
|
||||
/// </summary>
|
||||
public string Extension { |
||||
get { |
||||
return extension; |
||||
} |
||||
|
||||
set { |
||||
extension = value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default namespace prefix that will be added
|
||||
/// to the xml elements.
|
||||
/// </summary>
|
||||
public string NamespacePrefix { |
||||
get { |
||||
return namespacePrefix; |
||||
} |
||||
|
||||
set { |
||||
namespacePrefix = value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the default schema association for the file extension.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// These defaults are hard coded.
|
||||
/// </remarks>
|
||||
public static XmlSchemaAssociation GetDefaultAssociation(string extension) |
||||
{ |
||||
XmlSchemaAssociation association = null; |
||||
|
||||
switch (extension.ToLowerInvariant()) { |
||||
case ".wxs": |
||||
association = new XmlSchemaAssociation(extension, @"http://schemas.microsoft.com/wix/2003/01/wi"); |
||||
break; |
||||
case ".config": |
||||
association = new XmlSchemaAssociation(extension, @"urn:app-config"); |
||||
break; |
||||
case ".build": |
||||
association = new XmlSchemaAssociation(extension, @"http://nant.sf.net/release/0.85/nant.xsd"); |
||||
break; |
||||
case ".addin": |
||||
association = new XmlSchemaAssociation(extension, @"http://www.icsharpcode.net/2005/addin"); |
||||
break; |
||||
case ".xsl": |
||||
case ".xslt": |
||||
association = new XmlSchemaAssociation(extension, @"http://www.w3.org/1999/XSL/Transform", "xsl"); |
||||
break; |
||||
case ".xsd": |
||||
association = new XmlSchemaAssociation(extension, @"http://www.w3.org/2001/XMLSchema", "xs"); |
||||
break; |
||||
case ".manifest": |
||||
association = new XmlSchemaAssociation(extension, @"urn:schemas-microsoft-com:asm.v1"); |
||||
break; |
||||
case ".xaml": |
||||
association = new XmlSchemaAssociation(extension, @"http://schemas.microsoft.com/winfx/avalon/2005"); |
||||
break; |
||||
default: |
||||
association = new XmlSchemaAssociation(extension); |
||||
break; |
||||
} |
||||
return association; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Two schema associations are considered equal if their file extension,
|
||||
/// prefix and namespaceUri are the same.
|
||||
/// </summary>
|
||||
public override bool Equals(object obj) |
||||
{ |
||||
bool equals = false; |
||||
|
||||
XmlSchemaAssociation rhs = obj as XmlSchemaAssociation; |
||||
if (rhs != null) { |
||||
if ((this.namespacePrefix == rhs.namespacePrefix) && |
||||
(this.extension == rhs.extension) && |
||||
(this.namespaceUri == rhs.namespaceUri)) { |
||||
equals = true; |
||||
} |
||||
} |
||||
|
||||
return equals; |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
return (namespaceUri != null ? namespaceUri.GetHashCode() : 0) ^ (extension != null ? extension.GetHashCode() : 0) ^ (namespacePrefix != null ? namespacePrefix.GetHashCode() : 0); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Creates an XmlSchemaAssociation from the saved xml.
|
||||
/// </summary>
|
||||
public static XmlSchemaAssociation ConvertFromString(string text) |
||||
{ |
||||
string[] parts = text.Split(new char[] {'|'}, 3); |
||||
return new XmlSchemaAssociation(parts[0], parts[1], parts[2]); |
||||
} |
||||
|
||||
public string ConvertToString() |
||||
{ |
||||
return extension + "|" + namespaceUri + "|" + namespacePrefix; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,89 @@
@@ -0,0 +1,89 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 1965 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Represents list box item showing the association between an xml schema
|
||||
/// and a file extension.
|
||||
/// </summary>
|
||||
public class XmlSchemaAssociationListBoxItem |
||||
{ |
||||
bool isDirty = false; |
||||
string namespaceUri = String.Empty; |
||||
string extension = String.Empty; |
||||
string namespacePrefix = String.Empty; |
||||
|
||||
public XmlSchemaAssociationListBoxItem(string extension, string namespaceUri, string namespacePrefix) |
||||
{ |
||||
this.extension = extension; |
||||
this.namespaceUri = namespaceUri; |
||||
this.namespacePrefix = namespacePrefix; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether this association has been changed by the user.
|
||||
/// </summary>
|
||||
public bool IsDirty { |
||||
get { |
||||
return isDirty; |
||||
} |
||||
|
||||
set { |
||||
isDirty = value; |
||||
} |
||||
} |
||||
|
||||
public string NamespaceUri { |
||||
get { |
||||
return namespaceUri; |
||||
} |
||||
|
||||
set { |
||||
namespaceUri = value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the file extension (e.g. '.xml').
|
||||
/// </summary>
|
||||
public string Extension { |
||||
get { |
||||
return extension; |
||||
} |
||||
|
||||
set { |
||||
extension = value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default namespace prefix that will be added
|
||||
/// to the xml elements.
|
||||
/// </summary>
|
||||
public string NamespacePrefix { |
||||
get { |
||||
return namespacePrefix; |
||||
} |
||||
|
||||
set { |
||||
namespacePrefix = value; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the file extension so this can be sorted in a list box.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString() |
||||
{ |
||||
return extension; |
||||
} |
||||
} |
||||
} |
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,292 @@
@@ -0,0 +1,292 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 1965 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/* |
||||
/// <summary>
|
||||
/// A collection that stores <see cref='XmlSchemaCompletionData'/> objects.
|
||||
/// </summary>
|
||||
[Serializable()] |
||||
public class XmlSchemaCompletionDataCollection : System.Collections.CollectionBase { |
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref='XmlSchemaCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
public XmlSchemaCompletionDataCollection() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref='XmlSchemaCompletionDataCollection'/> based on another <see cref='XmlSchemaCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
/// <param name='val'>
|
||||
/// A <see cref='XmlSchemaCompletionDataCollection'/> from which the contents are copied
|
||||
/// </param>
|
||||
public XmlSchemaCompletionDataCollection(XmlSchemaCompletionDataCollection val) |
||||
{ |
||||
this.AddRange(val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref='XmlSchemaCompletionDataCollection'/> containing any array of <see cref='XmlSchemaCompletionData'/> objects.
|
||||
/// </summary>
|
||||
/// <param name='val'>
|
||||
/// A array of <see cref='XmlSchemaCompletionData'/> objects with which to intialize the collection
|
||||
/// </param>
|
||||
public XmlSchemaCompletionDataCollection(XmlSchemaCompletionData[] val) |
||||
{ |
||||
this.AddRange(val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Represents the entry at the specified index of the <see cref='XmlSchemaCompletionData'/>.
|
||||
/// </summary>
|
||||
/// <param name='index'>The zero-based index of the entry to locate in the collection.</param>
|
||||
/// <value>The entry at the specified index of the collection.</value>
|
||||
/// <exception cref='ArgumentOutOfRangeException'><paramref name='index'/> is outside the valid range of indexes for the collection.</exception>
|
||||
public XmlSchemaCompletionData this[int index] { |
||||
get { |
||||
return ((XmlSchemaCompletionData)(List[index])); |
||||
} |
||||
set { |
||||
List[index] = value; |
||||
} |
||||
} |
||||
|
||||
public ICompletionData[] GetNamespaceCompletionData() |
||||
{ |
||||
List<ICompletionData> completionItems = new List<ICompletionData>(); |
||||
|
||||
foreach (XmlSchemaCompletionData schema in this) { |
||||
XmlCompletionData completionData = new XmlCompletionData(schema.NamespaceUri, XmlCompletionData.DataType.NamespaceUri); |
||||
completionItems.Add(completionData); |
||||
} |
||||
|
||||
return completionItems.ToArray(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Represents the <see cref='XmlSchemaCompletionData'/> entry with the specified namespace URI.
|
||||
/// </summary>
|
||||
/// <param name='namespaceUri'>The schema's namespace URI.</param>
|
||||
/// <value>The entry with the specified namespace URI.</value>
|
||||
public XmlSchemaCompletionData this[string namespaceUri] { |
||||
get { |
||||
return GetItem(namespaceUri); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds a <see cref='XmlSchemaCompletionData'/> with the specified value to the
|
||||
/// <see cref='XmlSchemaCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
/// <param name='val'>The <see cref='XmlSchemaCompletionData'/> to add.</param>
|
||||
/// <returns>The index at which the new element was inserted.</returns>
|
||||
/// <seealso cref='XmlSchemaCompletionDataCollection.AddRange'/>
|
||||
public int Add(XmlSchemaCompletionData val) |
||||
{ |
||||
return List.Add(val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Copies the elements of an array to the end of the <see cref='XmlSchemaCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
/// <param name='val'>
|
||||
/// An array of type <see cref='XmlSchemaCompletionData'/> containing the objects to add to the collection.
|
||||
/// </param>
|
||||
/// <seealso cref='XmlSchemaCompletionDataCollection.Add'/>
|
||||
public void AddRange(XmlSchemaCompletionData[] val) |
||||
{ |
||||
for (int i = 0; i < val.Length; i++) { |
||||
this.Add(val[i]); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds the contents of another <see cref='XmlSchemaCompletionDataCollection'/> to the end of the collection.
|
||||
/// </summary>
|
||||
/// <param name='val'>
|
||||
/// A <see cref='XmlSchemaCompletionDataCollection'/> containing the objects to add to the collection.
|
||||
/// </param>
|
||||
/// <seealso cref='XmlSchemaCompletionDataCollection.Add'/>
|
||||
public void AddRange(XmlSchemaCompletionDataCollection val) |
||||
{ |
||||
for (int i = 0; i < val.Count; i++) |
||||
{ |
||||
this.Add(val[i]); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the
|
||||
/// <see cref='XmlSchemaCompletionDataCollection'/> contains the specified <see cref='XmlSchemaCompletionData'/>.
|
||||
/// </summary>
|
||||
/// <param name='val'>The <see cref='XmlSchemaCompletionData'/> to locate.</param>
|
||||
/// <returns>
|
||||
/// <see langword='true'/> if the <see cref='XmlSchemaCompletionData'/> is contained in the collection;
|
||||
/// otherwise, <see langword='false'/>.
|
||||
/// </returns>
|
||||
/// <seealso cref='XmlSchemaCompletionDataCollection.IndexOf'/>
|
||||
public bool Contains(XmlSchemaCompletionData val) |
||||
{ |
||||
return List.Contains(val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Copies the <see cref='XmlSchemaCompletionDataCollection'/> values to a one-dimensional <see cref='Array'/> instance at the
|
||||
/// specified index.
|
||||
/// </summary>
|
||||
/// <param name='array'>The one-dimensional <see cref='Array'/> that is the destination of the values copied from <see cref='XmlSchemaCompletionDataCollection'/>.</param>
|
||||
/// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
|
||||
/// <exception cref='ArgumentException'>
|
||||
/// <para><paramref name='array'/> is multidimensional.</para>
|
||||
/// <para>-or-</para>
|
||||
/// <para>The number of elements in the <see cref='XmlSchemaCompletionDataCollection'/> is greater than
|
||||
/// the available space between <paramref name='arrayIndex'/> and the end of
|
||||
/// <paramref name='array'/>.</para>
|
||||
/// </exception>
|
||||
/// <exception cref='ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
|
||||
/// <exception cref='ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
|
||||
/// <seealso cref='Array'/>
|
||||
public void CopyTo(XmlSchemaCompletionData[] array, int index) |
||||
{ |
||||
List.CopyTo(array, index); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the index of a <see cref='XmlSchemaCompletionData'/> in
|
||||
/// the <see cref='XmlSchemaCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
/// <param name='val'>The <see cref='XmlSchemaCompletionData'/> to locate.</param>
|
||||
/// <returns>
|
||||
/// The index of the <see cref='XmlSchemaCompletionData'/> of <paramref name='val'/> in the
|
||||
/// <see cref='XmlSchemaCompletionDataCollection'/>, if found; otherwise, -1.
|
||||
/// </returns>
|
||||
/// <seealso cref='XmlSchemaCompletionDataCollection.Contains'/>
|
||||
public int IndexOf(XmlSchemaCompletionData val) |
||||
{ |
||||
return List.IndexOf(val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Inserts a <see cref='XmlSchemaCompletionData'/> into the <see cref='XmlSchemaCompletionDataCollection'/> at the specified index.
|
||||
/// </summary>
|
||||
/// <param name='index'>The zero-based index where <paramref name='val'/> should be inserted.</param>
|
||||
/// <param name='val'>The <see cref='XmlSchemaCompletionData'/> to insert.</param>
|
||||
/// <seealso cref='XmlSchemaCompletionDataCollection.Add'/>
|
||||
public void Insert(int index, XmlSchemaCompletionData val) |
||||
{ |
||||
List.Insert(index, val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerator that can iterate through the <see cref='XmlSchemaCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
/// <seealso cref='IEnumerator'/>
|
||||
public new XmlSchemaCompletionDataEnumerator GetEnumerator() |
||||
{ |
||||
return new XmlSchemaCompletionDataEnumerator(this); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Removes a specific <see cref='XmlSchemaCompletionData'/> from the <see cref='XmlSchemaCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
/// <param name='val'>The <see cref='XmlSchemaCompletionData'/> to remove from the <see cref='XmlSchemaCompletionDataCollection'/>.</param>
|
||||
/// <exception cref='ArgumentException'><paramref name='val'/> is not found in the Collection.</exception>
|
||||
public void Remove(XmlSchemaCompletionData val) |
||||
{ |
||||
List.Remove(val); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the schema completion data with the same filename.
|
||||
/// </summary>
|
||||
/// <returns><see langword="null"/> if no matching schema found.</returns>
|
||||
public XmlSchemaCompletionData GetSchemaFromFileName(string fileName) |
||||
{ |
||||
foreach (XmlSchemaCompletionData schema in this) { |
||||
if (FileUtility.IsEqualFileName(schema.FileName, fileName)) { |
||||
return schema; |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Enumerator that can iterate through a XmlSchemaCompletionDataCollection.
|
||||
/// </summary>
|
||||
/// <seealso cref='IEnumerator'/>
|
||||
/// <seealso cref='XmlSchemaCompletionDataCollection'/>
|
||||
/// <seealso cref='XmlSchemaCompletionData'/>
|
||||
public class XmlSchemaCompletionDataEnumerator : System.Collections.IEnumerator |
||||
{ |
||||
System.Collections.IEnumerator baseEnumerator; |
||||
System.Collections.IEnumerable temp; |
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref='XmlSchemaCompletionDataEnumerator'/>.
|
||||
/// </summary>
|
||||
public XmlSchemaCompletionDataEnumerator(XmlSchemaCompletionDataCollection mappings) |
||||
{ |
||||
this.temp = ((System.Collections.IEnumerable)(mappings)); |
||||
this.baseEnumerator = temp.GetEnumerator(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the current <see cref='XmlSchemaCompletionData'/> in the <seealso cref='XmlSchemaCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
public XmlSchemaCompletionData Current { |
||||
get { |
||||
return ((XmlSchemaCompletionData)(baseEnumerator.Current)); |
||||
} |
||||
} |
||||
|
||||
object System.Collections.IEnumerator.Current { |
||||
get { |
||||
return baseEnumerator.Current; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Advances the enumerator to the next <see cref='XmlSchemaCompletionData'/> of the <see cref='XmlSchemaCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
public bool MoveNext() |
||||
{ |
||||
return baseEnumerator.MoveNext(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Sets the enumerator to its initial position, which is before the first element in the <see cref='XmlSchemaCompletionDataCollection'/>.
|
||||
/// </summary>
|
||||
public void Reset() |
||||
{ |
||||
baseEnumerator.Reset(); |
||||
} |
||||
} |
||||
|
||||
XmlSchemaCompletionData GetItem(string namespaceUri) |
||||
{ |
||||
XmlSchemaCompletionData matchedItem = null; |
||||
|
||||
foreach(XmlSchemaCompletionData item in this) |
||||
{ |
||||
if (item.NamespaceUri == namespaceUri) { |
||||
matchedItem = item; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
return matchedItem; |
||||
} |
||||
} |
||||
*/ |
||||
} |
||||
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 915 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// A schema item shown in the tools options dialog.
|
||||
/// </summary>
|
||||
public class XmlSchemaListBoxItem |
||||
{ |
||||
string namespaceUri = String.Empty; |
||||
bool readOnly = false; |
||||
|
||||
/// <summary>
|
||||
/// Creates a new list box item.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A readonly list box item is used for system schemas, those that
|
||||
/// are installed with SharpDevelop.
|
||||
/// </remarks>
|
||||
public XmlSchemaListBoxItem(string namespaceUri, bool readOnly) |
||||
{ |
||||
this.namespaceUri = namespaceUri; |
||||
this.readOnly = readOnly; |
||||
} |
||||
|
||||
public XmlSchemaListBoxItem(string namespaceUri) |
||||
: this(namespaceUri, false) |
||||
{ |
||||
} |
||||
|
||||
public string NamespaceUri { |
||||
get { |
||||
return namespaceUri; |
||||
} |
||||
} |
||||
|
||||
public bool ReadOnly { |
||||
get { |
||||
return readOnly; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the namespace Uri so the list box item is sorted correctly.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString() |
||||
{ |
||||
return namespaceUri; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,223 @@
@@ -0,0 +1,223 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 1965 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/* |
||||
/// <summary>
|
||||
/// Keeps track of all the schemas that the Xml Editor is aware
|
||||
/// of.
|
||||
/// </summary>
|
||||
public class XmlSchemaManager |
||||
{ |
||||
public const string XmlSchemaNamespace = "http://www.w3.org/2001/XMLSchema"; |
||||
|
||||
static XmlSchemaCompletionDataCollection schemas = null; |
||||
static XmlSchemaManager manager = null; |
||||
|
||||
public static event EventHandler UserSchemaAdded; |
||||
|
||||
public static event EventHandler UserSchemaRemoved; |
||||
|
||||
XmlSchemaManager() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified namespace is actually the W3C namespace for
|
||||
/// XSD files.
|
||||
/// </summary>
|
||||
public static bool IsXmlSchemaNamespace(string schemaNamespace) |
||||
{ |
||||
return schemaNamespace == XmlSchemaNamespace; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the schemas that SharpDevelop knows about.
|
||||
/// </summary>
|
||||
public static XmlSchemaCompletionDataCollection SchemaCompletionDataItems { |
||||
get { |
||||
if (schemas == null) { |
||||
schemas = new XmlSchemaCompletionDataCollection(); |
||||
manager = new XmlSchemaManager(); |
||||
manager.ReadSchemas(); |
||||
} |
||||
|
||||
return schemas; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the schema completion data that is associated with the
|
||||
/// specified file extension.
|
||||
/// </summary>
|
||||
public static XmlSchemaCompletionData GetSchemaCompletionData(string extension) |
||||
{ |
||||
XmlSchemaCompletionData data = null; |
||||
|
||||
XmlSchemaAssociation association = XmlEditorAddInOptions.GetSchemaAssociation(extension); |
||||
if (association != null) { |
||||
if (association.NamespaceUri.Length > 0) { |
||||
data = SchemaCompletionDataItems[association.NamespaceUri]; |
||||
} |
||||
} |
||||
return data; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the namespace prefix that is associated with the
|
||||
/// specified file extension.
|
||||
/// </summary>
|
||||
public static string GetNamespacePrefix(string extension) |
||||
{ |
||||
string prefix = String.Empty; |
||||
|
||||
XmlSchemaAssociation association = XmlEditorAddInOptions.GetSchemaAssociation(extension); |
||||
if (association != null) { |
||||
prefix = association.NamespacePrefix; |
||||
} |
||||
|
||||
return prefix; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Removes the schema with the specified namespace from the
|
||||
/// user schemas folder and removes the completion data.
|
||||
/// </summary>
|
||||
public static void RemoveUserSchema(string namespaceUri) |
||||
{ |
||||
XmlSchemaCompletionData schemaData = SchemaCompletionDataItems[namespaceUri]; |
||||
if (schemaData != null) { |
||||
if (File.Exists(schemaData.FileName)) { |
||||
File.Delete(schemaData.FileName); |
||||
} |
||||
SchemaCompletionDataItems.Remove(schemaData); |
||||
OnUserSchemaRemoved(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds the schema to the user schemas folder and makes the
|
||||
/// schema available to the xml editor.
|
||||
/// </summary>
|
||||
public static void AddUserSchema(XmlSchemaCompletionData schemaData) |
||||
{ |
||||
if (SchemaCompletionDataItems[schemaData.NamespaceUri] == null) { |
||||
|
||||
if (!Directory.Exists(UserSchemaFolder)) { |
||||
Directory.CreateDirectory(UserSchemaFolder); |
||||
} |
||||
|
||||
string fileName = Path.GetFileName(schemaData.FileName); |
||||
string destinationFileName = Path.Combine(UserSchemaFolder, fileName); |
||||
File.Copy(schemaData.FileName, destinationFileName); |
||||
schemaData.FileName = destinationFileName; |
||||
SchemaCompletionDataItems.Add(schemaData); |
||||
OnUserSchemaAdded(); |
||||
} else { |
||||
LoggingService.Warn("Trying to add a schema that already exists. Namespace=" + schemaData.NamespaceUri); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Reads the system and user added schemas.
|
||||
/// </summary>
|
||||
void ReadSchemas() |
||||
{ |
||||
// MSBuild schemas are in framework directory:
|
||||
ReadSchemas(RuntimeEnvironment.GetRuntimeDirectory(), true); |
||||
ReadSchemas(SchemaFolder, true); |
||||
ReadSchemas(UserSchemaFolder, false); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Reads all .xsd files in the specified folder.
|
||||
/// </summary>
|
||||
void ReadSchemas(string folder, bool readOnly) |
||||
{ |
||||
if (Directory.Exists(folder)) { |
||||
foreach (string fileName in Directory.GetFiles(folder, "*.xsd")) { |
||||
ReadSchema(fileName, readOnly); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Reads an individual schema and adds it to the collection.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If the schema namespace exists in the collection it is not added.
|
||||
/// </remarks>
|
||||
void ReadSchema(string fileName, bool readOnly) |
||||
{ |
||||
try { |
||||
string baseUri = XmlSchemaCompletionData.GetUri(fileName); |
||||
XmlSchemaCompletionData data = new XmlSchemaCompletionData(baseUri, fileName); |
||||
if (data.NamespaceUri != null) { |
||||
if (schemas[data.NamespaceUri] == null) { |
||||
data.ReadOnly = readOnly; |
||||
schemas.Add(data); |
||||
} else { |
||||
// Namespace already exists.
|
||||
LoggingService.Warn("Ignoring duplicate schema namespace " + data.NamespaceUri); |
||||
} |
||||
} else { |
||||
// Namespace is null.
|
||||
LoggingService.Warn("Ignoring schema with no namespace " + data.FileName); |
||||
} |
||||
} catch (Exception ex) { |
||||
LoggingService.Warn("Unable to read schema '" + fileName + "'. ", ex); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the folder where the schemas for all users on the
|
||||
/// local machine are stored.
|
||||
/// </summary>
|
||||
static string SchemaFolder { |
||||
get { |
||||
return Path.Combine(PropertyService.DataDirectory, "schemas"); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the folder where schemas are stored for an individual user.
|
||||
/// </summary>
|
||||
static string UserSchemaFolder { |
||||
get { |
||||
return Path.Combine(PropertyService.ConfigDirectory, "schemas"); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Should really pass schema info with the event.
|
||||
/// </summary>
|
||||
static void OnUserSchemaAdded() |
||||
{ |
||||
if (UserSchemaAdded != null) { |
||||
UserSchemaAdded(manager, new EventArgs()); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Should really pass schema info with the event.
|
||||
/// </summary>
|
||||
static void OnUserSchemaRemoved() |
||||
{ |
||||
if (UserSchemaRemoved != null) { |
||||
UserSchemaRemoved(manager, new EventArgs()); |
||||
} |
||||
} |
||||
} |
||||
*/ |
||||
} |
||||
@ -0,0 +1,412 @@
@@ -0,0 +1,412 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 3568 $</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.XmlBinding.Gui; |
||||
using System; |
||||
using System.Collections.Specialized; |
||||
using System.Drawing; |
||||
using System.IO; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Gui.OptionPanels; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/* |
||||
/// <summary>
|
||||
/// Shows the xml schemas that SharpDevelop knows about.
|
||||
/// </summary>
|
||||
public class XmlSchemasPanel : XmlFormsOptionPanel |
||||
{ |
||||
ListBox schemaListBox; |
||||
Button removeButton; |
||||
ComboBox fileExtensionComboBox; |
||||
TextBox schemaTextBox; |
||||
TextBox namespacePrefixTextBox; |
||||
|
||||
bool ignoreNamespacePrefixTextChanges; |
||||
|
||||
bool changed; |
||||
XmlSchemaCompletionDataCollection addedSchemas = new XmlSchemaCompletionDataCollection(); |
||||
StringCollection removedSchemaNamespaces = new StringCollection(); |
||||
|
||||
SolidBrush readonlyTextBrush = new SolidBrush(SystemColors.GrayText); |
||||
SolidBrush selectedTextBrush = new SolidBrush(SystemColors.HighlightText); |
||||
SolidBrush normalTextBrush = new SolidBrush(SystemColors.WindowText); |
||||
|
||||
/// <summary>
|
||||
/// Initialises the panel.
|
||||
/// </summary>
|
||||
public override void LoadPanelContents() |
||||
{ |
||||
SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("ICSharpCode.XmlEditor.Resources.XmlSchemasPanel.xfrm")); |
||||
|
||||
schemaListBox = (ListBox)ControlDictionary["schemaListBox"]; |
||||
schemaListBox.DrawMode = DrawMode.OwnerDrawFixed; |
||||
schemaListBox.DrawItem += new DrawItemEventHandler(SchemaListBoxDrawItem); |
||||
schemaListBox.Sorted = true; |
||||
PopulateSchemaListBox(); |
||||
schemaListBox.SelectedIndexChanged += new EventHandler(SchemaListBoxSelectedIndexChanged); |
||||
|
||||
namespacePrefixTextBox = (TextBox)ControlDictionary["namespacePrefixTextBox"]; |
||||
namespacePrefixTextBox.TextChanged += new EventHandler(NamespacePrefixTextBoxTextChanged); |
||||
|
||||
ControlDictionary["addButton"].Click += new EventHandler(AddButtonClick); |
||||
removeButton = (Button)ControlDictionary["removeButton"]; |
||||
removeButton.Click += new EventHandler(RemoveButtonClick); |
||||
removeButton.Enabled = false; |
||||
|
||||
ControlDictionary["changeSchemaButton"].Click += new EventHandler(ChangeSchemaButtonClick); |
||||
|
||||
schemaTextBox = (TextBox)ControlDictionary["schemaTextBox"]; |
||||
fileExtensionComboBox = (ComboBox)ControlDictionary["fileExtensionComboBox"]; |
||||
fileExtensionComboBox.Sorted = true; |
||||
PopulateFileExtensionComboBox(); |
||||
fileExtensionComboBox.SelectedIndexChanged += new EventHandler(FileExtensionComboBoxSelectedIndexChanged); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Saves any changes to the configured schemas.
|
||||
/// </summary>
|
||||
public override bool StorePanelContents() |
||||
{ |
||||
if (changed) { |
||||
try { |
||||
return SaveSchemaChanges(); |
||||
} catch (Exception ex) { |
||||
MessageService.ShowError(ex, "${res:ICSharpCode.XmlEditor.XmlSchemasPanel.UnableToSaveChanges}"); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
// Update schema associations after we have added any new schemas to
|
||||
// the schema manager.
|
||||
UpdateSchemaAssociations(); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
void AddButtonClick(object source, EventArgs e) |
||||
{ |
||||
try { |
||||
// Browse for schema.
|
||||
|
||||
string schemaFileName = BrowseForSchema(); |
||||
|
||||
// Add schema if the namespace does not already exist.
|
||||
|
||||
if (schemaFileName.Length > 0) { |
||||
changed = AddSchema(schemaFileName); |
||||
} |
||||
} catch (Exception ex) { |
||||
MessageService.ShowError("${res:ICSharpCode.XmlEditor.XmlSchemasPanel.UnableToAddSchema}\n\n" + ex.Message); |
||||
} |
||||
} |
||||
|
||||
void RemoveButtonClick(object source, EventArgs e) |
||||
{ |
||||
// Remove selected schema.
|
||||
XmlSchemaListBoxItem item = schemaListBox.SelectedItem as XmlSchemaListBoxItem; |
||||
if (item != null) { |
||||
RemoveSchema(item.NamespaceUri); |
||||
changed = true; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Enables the remove button if a list box item is selected.
|
||||
/// </summary>
|
||||
void SchemaListBoxSelectedIndexChanged(object source, EventArgs e) |
||||
{ |
||||
XmlSchemaListBoxItem item = schemaListBox.SelectedItem as XmlSchemaListBoxItem; |
||||
if (item != null) { |
||||
if (item.ReadOnly) { |
||||
removeButton.Enabled = false; |
||||
} else { |
||||
removeButton.Enabled = true; |
||||
} |
||||
} else { |
||||
removeButton.Enabled = false; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds the schema namespaces to the list.
|
||||
/// </summary>
|
||||
void PopulateSchemaListBox() |
||||
{ |
||||
foreach (XmlSchemaCompletionData schema in XmlSchemaManager.SchemaCompletionDataItems) { |
||||
XmlSchemaListBoxItem item = new XmlSchemaListBoxItem(schema.NamespaceUri, schema.ReadOnly); |
||||
schemaListBox.Items.Add(item); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Saves any changes to the configured schemas.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool SaveSchemaChanges() |
||||
{ |
||||
RemoveUserSchemas(); |
||||
AddUserSchemas(); |
||||
|
||||
return true; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Allows the user to browse the file system for a schema.
|
||||
/// </summary>
|
||||
/// <returns>The schema file name the user selected; otherwise an
|
||||
/// empty string.</returns>
|
||||
string BrowseForSchema() |
||||
{ |
||||
string fileName = String.Empty; |
||||
|
||||
using (OpenFileDialog openFileDialog = new OpenFileDialog()) { |
||||
openFileDialog.CheckFileExists = true; |
||||
openFileDialog.Multiselect = false; |
||||
openFileDialog.Filter = StringParser.Parse("${res:SharpDevelop.FileFilter.XmlSchemaFiles}|*.xsd|${res:SharpDevelop.FileFilter.AllFiles}|*.*"); |
||||
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK) { |
||||
fileName = openFileDialog.FileName; |
||||
} |
||||
} |
||||
|
||||
return fileName; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Loads the specified schema and adds it to an internal collection.
|
||||
/// </summary>
|
||||
/// <remarks>The schema file is not copied to the user's schema folder
|
||||
/// until they click the OK button.</remarks>
|
||||
/// <returns><see langword="true"/> if the schema namespace
|
||||
/// does not already exist; otherwise <see langword="false"/>
|
||||
/// </returns>
|
||||
bool AddSchema(string fileName) |
||||
{ |
||||
// Load the schema.
|
||||
XmlSchemaCompletionData schema = new XmlSchemaCompletionData(fileName); |
||||
|
||||
// Make sure the schema has a target namespace.
|
||||
if (schema.NamespaceUri == null) { |
||||
MessageService.ShowErrorFormatted("${res:ICSharpCode.XmlEditor.XmlSchemasPanel.NoTargetNamespace}", Path.GetFileName(schema.FileName)); |
||||
return false; |
||||
} |
||||
|
||||
// Check that the schema does not exist.
|
||||
if (SchemaNamespaceExists(schema.NamespaceUri)) { |
||||
MessageService.ShowErrorFormatted("${res:ICSharpCode.XmlEditor.XmlSchemasPanel.NamespaceExists}", schema.NamespaceUri); |
||||
return false; |
||||
} |
||||
|
||||
// Store the schema so we can add it later.
|
||||
int index = schemaListBox.Items.Add(new XmlSchemaListBoxItem(schema.NamespaceUri)); |
||||
schemaListBox.SelectedIndex = index; |
||||
addedSchemas.Add(schema); |
||||
if (removedSchemaNamespaces.Contains(schema.NamespaceUri)) { |
||||
removedSchemaNamespaces.Remove(schema.NamespaceUri); |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Checks that the schema namespace does not already exist.
|
||||
/// </summary>
|
||||
bool SchemaNamespaceExists(string namespaceURI) |
||||
{ |
||||
bool exists = true; |
||||
if ((XmlSchemaManager.SchemaCompletionDataItems[namespaceURI] == null) && |
||||
(addedSchemas[namespaceURI] == null)){ |
||||
exists = false; |
||||
} else { |
||||
// Makes sure it has not been flagged for removal.
|
||||
exists = !removedSchemaNamespaces.Contains(namespaceURI); |
||||
} |
||||
return exists; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Schedules the schema for removal.
|
||||
/// </summary>
|
||||
void RemoveSchema(string namespaceUri) |
||||
{ |
||||
RemoveListBoxItem(namespaceUri); |
||||
|
||||
XmlSchemaCompletionData addedSchema = addedSchemas[namespaceUri]; |
||||
if (addedSchema != null) { |
||||
addedSchemas.Remove(addedSchema); |
||||
} else { |
||||
removedSchemaNamespaces.Add(namespaceUri); |
||||
} |
||||
} |
||||
|
||||
void RemoveListBoxItem(string namespaceUri) |
||||
{ |
||||
foreach (XmlSchemaListBoxItem item in schemaListBox.Items) { |
||||
if (item.NamespaceUri == namespaceUri) { |
||||
schemaListBox.Items.Remove(item); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Removes the schemas from the schema manager.
|
||||
/// </summary>
|
||||
void RemoveUserSchemas() |
||||
{ |
||||
while (removedSchemaNamespaces.Count > 0) { |
||||
XmlSchemaManager.RemoveUserSchema(removedSchemaNamespaces[0]); |
||||
removedSchemaNamespaces.RemoveAt(0); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Adds the schemas to the schema manager.
|
||||
/// </summary>
|
||||
void AddUserSchemas() |
||||
{ |
||||
while (addedSchemas.Count > 0) { |
||||
XmlSchemaManager.AddUserSchema(addedSchemas[0]); |
||||
addedSchemas.RemoveAt(0); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Draws the list box items so we can show the read only schemas in
|
||||
/// a different colour.
|
||||
/// </summary>
|
||||
void SchemaListBoxDrawItem(object sender, DrawItemEventArgs e) |
||||
{ |
||||
e.DrawBackground(); |
||||
|
||||
if (e.Index >= 0) { |
||||
XmlSchemaListBoxItem item = (XmlSchemaListBoxItem)schemaListBox.Items[e.Index]; |
||||
|
||||
if (IsListBoxItemSelected(e.State)) { |
||||
e.Graphics.DrawString(item.NamespaceUri, schemaListBox.Font, selectedTextBrush, e.Bounds); |
||||
} else if (item.ReadOnly) { |
||||
e.Graphics.DrawString(item.NamespaceUri, schemaListBox.Font, readonlyTextBrush, e.Bounds); |
||||
} else { |
||||
e.Graphics.DrawString(item.NamespaceUri, schemaListBox.Font, normalTextBrush, e.Bounds); |
||||
} |
||||
} |
||||
|
||||
e.DrawFocusRectangle(); |
||||
} |
||||
|
||||
bool IsListBoxItemSelected(DrawItemState state) |
||||
{ |
||||
return ((state & DrawItemState.Selected) == DrawItemState.Selected); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Shows the namespace associated with the selected xml file extension.
|
||||
/// </summary>
|
||||
void FileExtensionComboBoxSelectedIndexChanged(object source, EventArgs e) |
||||
{ |
||||
schemaTextBox.Text = String.Empty; |
||||
ignoreNamespacePrefixTextChanges = true; |
||||
namespacePrefixTextBox.Text = String.Empty; |
||||
|
||||
try { |
||||
XmlSchemaAssociationListBoxItem association = fileExtensionComboBox.SelectedItem as XmlSchemaAssociationListBoxItem; |
||||
if (association != null) { |
||||
schemaTextBox.Text = association.NamespaceUri; |
||||
namespacePrefixTextBox.Text = association.NamespacePrefix; |
||||
} |
||||
} finally { |
||||
ignoreNamespacePrefixTextChanges = false; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Allows the user to change the schema associated with an xml file
|
||||
/// extension.
|
||||
/// </summary>
|
||||
void ChangeSchemaButtonClick(object source, EventArgs e) |
||||
{ |
||||
string[] namespaces = GetSchemaListBoxNamespaces(); |
||||
using (SelectXmlSchemaForm form = new SelectXmlSchemaForm(namespaces)) { |
||||
form.SelectedNamespaceUri = schemaTextBox.Text; |
||||
if (form.ShowDialog(this) == DialogResult.OK) { |
||||
schemaTextBox.Text = form.SelectedNamespaceUri; |
||||
XmlSchemaAssociationListBoxItem item = (XmlSchemaAssociationListBoxItem)fileExtensionComboBox.SelectedItem; |
||||
item.NamespaceUri = form.SelectedNamespaceUri; |
||||
item.IsDirty = true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Reads the configured xml file extensions and their associated namespaces.
|
||||
/// </summary>
|
||||
void PopulateFileExtensionComboBox() |
||||
{ |
||||
string [] extensions = XmlDisplayBinding.GetXmlFileExtensions(); |
||||
|
||||
foreach (string extension in extensions) { |
||||
XmlSchemaAssociation association = XmlEditorAddInOptions.GetSchemaAssociation(extension); |
||||
XmlSchemaAssociationListBoxItem item = new XmlSchemaAssociationListBoxItem(association.Extension, association.NamespaceUri, association.NamespacePrefix); |
||||
fileExtensionComboBox.Items.Add(item); |
||||
} |
||||
|
||||
if (fileExtensionComboBox.Items.Count > 0) { |
||||
fileExtensionComboBox.SelectedIndex = 0; |
||||
FileExtensionComboBoxSelectedIndexChanged(this, new EventArgs()); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Updates the configured file extension to namespace mappings.
|
||||
/// </summary>
|
||||
void UpdateSchemaAssociations() |
||||
{ |
||||
foreach (XmlSchemaAssociationListBoxItem item in fileExtensionComboBox.Items) { |
||||
if (item.IsDirty) { |
||||
XmlSchemaAssociation association = new XmlSchemaAssociation(item.Extension, item.NamespaceUri, item.NamespacePrefix); |
||||
XmlEditorAddInOptions.SetSchemaAssociation(association); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns an array of schema namespace strings that will be displayed
|
||||
/// when the user chooses to associated a namespace to a file extension
|
||||
/// by default.
|
||||
/// </summary>
|
||||
string[] GetSchemaListBoxNamespaces() |
||||
{ |
||||
string[] namespaces = new string[schemaListBox.Items.Count]; |
||||
|
||||
for (int i = 0; i < schemaListBox.Items.Count; ++i) { |
||||
XmlSchemaListBoxItem item = (XmlSchemaListBoxItem)schemaListBox.Items[i]; |
||||
namespaces[i] = item.NamespaceUri; |
||||
} |
||||
|
||||
return namespaces; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// User has changed the namespace prefix.
|
||||
/// </summary>
|
||||
void NamespacePrefixTextBoxTextChanged(object source, EventArgs e) |
||||
{ |
||||
if (!ignoreNamespacePrefixTextChanges) { |
||||
XmlSchemaAssociationListBoxItem item = fileExtensionComboBox.SelectedItem as XmlSchemaAssociationListBoxItem; |
||||
if (item != null) { |
||||
item.NamespacePrefix = namespacePrefixTextBox.Text; |
||||
item.IsDirty = true; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
* */ |
||||
} |
||||
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 2164 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Xml; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Represents an XmlText node in the tree.
|
||||
/// </summary>
|
||||
public class XmlTextTreeNode : XmlCharacterDataTreeNode |
||||
{ |
||||
public const string XmlTextTreeNodeImageKey = "XmlTextTreeNodeImage"; |
||||
public const string XmlTextTreeNodeGhostImageKey = "XmlTextTreeNodeGhostImage"; |
||||
|
||||
XmlText xmlText; |
||||
|
||||
public XmlTextTreeNode(XmlText xmlText) |
||||
: base(xmlText) |
||||
{ |
||||
this.xmlText = xmlText; |
||||
ImageKey = XmlTextTreeNodeImageKey; |
||||
SelectedImageKey = ImageKey; |
||||
Update(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the XmlText associated with this tree node.
|
||||
/// </summary>
|
||||
public XmlText XmlText { |
||||
get { |
||||
return xmlText; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether to show the ghost image which is
|
||||
/// displayed when cutting the node.
|
||||
/// </summary>
|
||||
public bool ShowGhostImage { |
||||
get { |
||||
return ImageKey == XmlTextTreeNodeGhostImageKey; |
||||
} |
||||
set { |
||||
if (value) { |
||||
ImageKey = XmlTextTreeNodeGhostImageKey; |
||||
} else { |
||||
ImageKey = XmlTextTreeNodeImageKey; |
||||
} |
||||
SelectedImageKey = ImageKey; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,578 @@
@@ -0,0 +1,578 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 2741 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.Windows.Forms; |
||||
using System.Xml; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Displays a tree of XML elements. This is a separate control so it can
|
||||
/// be unit tested. It has no SharpDevelop specific parts, for example,
|
||||
/// the context menus are defined in the XmlTreeViewContainerControl.
|
||||
/// </summary>
|
||||
public class XmlTreeViewControl : ExtTreeView |
||||
{ |
||||
const string ViewStatePropertyName = "XmlTreeViewControl.ViewState"; |
||||
|
||||
XmlDocument document; |
||||
|
||||
enum InsertionMode { |
||||
Before = 0, |
||||
After = 1 |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Raised when the delete key is pressed.
|
||||
/// </summary>
|
||||
public event EventHandler DeleteKeyPressed; |
||||
|
||||
public XmlTreeViewControl() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the xml document currently being displayed.
|
||||
/// </summary>
|
||||
[Browsable(false)] |
||||
public XmlDocument Document { |
||||
get { |
||||
return document; |
||||
} |
||||
set { |
||||
document = value; |
||||
|
||||
// Update display.
|
||||
BeginUpdate(); |
||||
try { |
||||
ShowDocument(); |
||||
} finally { |
||||
EndUpdate(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the selected element in the tree.
|
||||
/// </summary>
|
||||
public XmlElement SelectedElement { |
||||
get { |
||||
XmlElementTreeNode xmlElementTreeNode = SelectedElementNode; |
||||
if (xmlElementTreeNode != null) { |
||||
return xmlElementTreeNode.XmlElement; |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Determines whether an element is selected in the tree.
|
||||
/// </summary>
|
||||
public bool IsElementSelected { |
||||
get { |
||||
return SelectedElement != null; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the selected text node in the tree.
|
||||
/// </summary>
|
||||
public XmlText SelectedTextNode { |
||||
get { |
||||
XmlTextTreeNode xmlTextTreeNode = SelectedNode as XmlTextTreeNode; |
||||
if (xmlTextTreeNode != null) { |
||||
return xmlTextTreeNode.XmlText; |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the selected comment node in the tree.
|
||||
/// </summary>
|
||||
public XmlComment SelectedComment { |
||||
get { |
||||
XmlCommentTreeNode commentTreeNode = SelectedNode as XmlCommentTreeNode; |
||||
if (commentTreeNode != null) { |
||||
return commentTreeNode.XmlComment; |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Determines whether a text node is selected in the tree.
|
||||
/// </summary>
|
||||
public bool IsTextNodeSelected { |
||||
get { |
||||
return SelectedTextNode != null; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Saves the current state of the tree.
|
||||
/// </summary>
|
||||
public void SaveViewState(Properties properties) |
||||
{ |
||||
properties.Set(ViewStatePropertyName, TreeViewHelper.GetViewStateString(this)); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Restores the node state of the tree.
|
||||
/// </summary>
|
||||
public void RestoreViewState(Properties properties) |
||||
{ |
||||
TreeViewHelper.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>
|
||||
/// Appends a new child text node to the currently selected element.
|
||||
/// </summary>
|
||||
public void AppendChildTextNode(XmlText textNode) |
||||
{ |
||||
XmlElementTreeNode selectedNode = SelectedElementNode; |
||||
if (selectedNode != null) { |
||||
XmlTextTreeNode newNode = new XmlTextTreeNode(textNode); |
||||
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); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Removes the specified element from the tree.
|
||||
/// </summary>
|
||||
public void RemoveElement(XmlElement element) |
||||
{ |
||||
XmlElementTreeNode node = FindElement(element); |
||||
if (node != null) { |
||||
node.Remove(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Removes the specified text node from the tree.
|
||||
/// </summary>
|
||||
public void RemoveTextNode(XmlText textNode) |
||||
{ |
||||
XmlTextTreeNode node = FindTextNode(textNode); |
||||
if (node != null) { |
||||
node.Remove(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Inserts a text node before the currently selected
|
||||
/// node.
|
||||
/// </summary>
|
||||
public void InsertTextNodeBefore(XmlText textNode) |
||||
{ |
||||
InsertTextNode(textNode, InsertionMode.Before); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Inserts a text node after the currently selected
|
||||
/// node.
|
||||
/// </summary>
|
||||
public void InsertTextNodeAfter(XmlText textNode) |
||||
{ |
||||
InsertTextNode(textNode, InsertionMode.After); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Updates the corresponding tree node's text based on
|
||||
/// the textNode's value.
|
||||
/// </summary>
|
||||
public void UpdateTextNode(XmlText textNode) |
||||
{ |
||||
XmlTextTreeNode node = FindTextNode(textNode); |
||||
if (node != null) { |
||||
node.Update(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Updates the corresponding tree node's text based on
|
||||
/// the comment's value.
|
||||
/// </summary>
|
||||
public void UpdateComment(XmlComment comment) |
||||
{ |
||||
XmlCommentTreeNode node = FindComment(comment); |
||||
if (node != null) { |
||||
node.Update(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Appends a new child comment node to the currently selected element.
|
||||
/// </summary>
|
||||
public void AppendChildComment(XmlComment comment) |
||||
{ |
||||
XmlElementTreeNode selectedNode = SelectedElementNode; |
||||
if (selectedNode != null) { |
||||
XmlCommentTreeNode newNode = new XmlCommentTreeNode(comment); |
||||
newNode.AddTo(selectedNode); |
||||
selectedNode.Expand(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Removes the specified comment from the tree.
|
||||
/// </summary>
|
||||
public void RemoveComment(XmlComment comment) |
||||
{ |
||||
XmlCommentTreeNode node = FindComment(comment); |
||||
if (node != null) { |
||||
node.Remove(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Inserts a comment node before the currently selected
|
||||
/// node.
|
||||
/// </summary>
|
||||
public void InsertCommentBefore(XmlComment comment) |
||||
{ |
||||
InsertComment(comment, InsertionMode.Before); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Inserts a comment node after the currently selected
|
||||
/// node.
|
||||
/// </summary>
|
||||
public void InsertCommentAfter(XmlComment comment) |
||||
{ |
||||
InsertComment(comment, InsertionMode.After); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Updates the image so the corresponding tree node shows that
|
||||
/// it is in the process of being cut.
|
||||
/// </summary>
|
||||
public void ShowCut(XmlNode node) |
||||
{ |
||||
ShowCut(node, true); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Updates the image so the corresponding tree node no longer
|
||||
/// shows it is in the process of being cut.
|
||||
/// </summary>
|
||||
public void HideCut(XmlNode node) |
||||
{ |
||||
ShowCut(node, false); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// If no node is selected after a mouse click then we make
|
||||
/// sure the AfterSelect event is fired. Standard behaviour is
|
||||
/// for the AfterSelect event not to be fired when the user
|
||||
/// deselects all tree nodes.
|
||||
/// </summary>
|
||||
protected override void OnMouseDown(MouseEventArgs e) |
||||
{ |
||||
base.OnMouseDown(e); |
||||
if (SelectedNode == null) { |
||||
this.OnAfterSelect(new TreeViewEventArgs(null, TreeViewAction.ByMouse)); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Raises the DeleteKeyPressed event.
|
||||
/// </summary>
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) |
||||
{ |
||||
if (keyData == Keys.Delete && DeleteKeyPressed != null) { |
||||
DeleteKeyPressed(this, new EventArgs()); |
||||
} |
||||
return base.ProcessCmdKey(ref msg, keyData); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Displays the document in the xml tree.
|
||||
/// </summary>
|
||||
void ShowDocument() |
||||
{ |
||||
Nodes.Clear(); |
||||
if (document != null) { |
||||
foreach (XmlNode node in document.ChildNodes) { |
||||
switch (node.NodeType) { |
||||
case XmlNodeType.Element: |
||||
XmlElementTreeNode elementNode = new XmlElementTreeNode((XmlElement)node); |
||||
elementNode.AddTo(this); |
||||
break; |
||||
case XmlNodeType.Comment: |
||||
XmlCommentTreeNode commentNode = new XmlCommentTreeNode((XmlComment)node); |
||||
commentNode.AddTo(this); |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the selected xml element tree node.
|
||||
/// </summary>
|
||||
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) |
||||
{ |
||||
ExtTreeNode selectedNode = (ExtTreeNode)SelectedNode; |
||||
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); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Inserts a new text node either before or after the
|
||||
/// currently selected node.
|
||||
/// </summary>
|
||||
void InsertTextNode(XmlText textNode, InsertionMode insertionMode) |
||||
{ |
||||
ExtTreeNode selectedNode = (ExtTreeNode)SelectedNode; |
||||
if (selectedNode != null) { |
||||
XmlElementTreeNode parentNode = (XmlElementTreeNode)selectedNode.Parent; |
||||
XmlTextTreeNode newNode = new XmlTextTreeNode(textNode); |
||||
int index = parentNode.Nodes.IndexOf(selectedNode); |
||||
if (insertionMode == InsertionMode.After) { |
||||
index++; |
||||
} |
||||
newNode.Insert(index, parentNode); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Inserts a new comment node either before or after the
|
||||
/// currently selected node.
|
||||
/// </summary>
|
||||
void InsertComment(XmlComment comment, InsertionMode insertionMode) |
||||
{ |
||||
ExtTreeNode selectedNode = (ExtTreeNode)SelectedNode; |
||||
if (selectedNode != null) { |
||||
ExtTreeNode parentNode = (ExtTreeNode)selectedNode.Parent; |
||||
XmlCommentTreeNode newNode = new XmlCommentTreeNode(comment); |
||||
int index = 0; |
||||
if (parentNode != null) { |
||||
index = parentNode.Nodes.IndexOf(selectedNode); |
||||
} else { |
||||
index = Nodes.IndexOf(selectedNode); |
||||
} |
||||
if (insertionMode == InsertionMode.After) { |
||||
index++; |
||||
} |
||||
if (parentNode != null) { |
||||
newNode.Insert(index, parentNode); |
||||
} else { |
||||
newNode.Insert(index, this); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Looks at all the nodes in the tree view and returns the
|
||||
/// tree node that represents the specified element.
|
||||
/// </summary>
|
||||
XmlElementTreeNode FindElement(XmlElement element, TreeNodeCollection nodes) |
||||
{ |
||||
foreach (ExtTreeNode node in nodes) { |
||||
XmlElementTreeNode elementTreeNode = node as XmlElementTreeNode; |
||||
if (elementTreeNode != null) { |
||||
if (elementTreeNode.XmlElement == element) { |
||||
return elementTreeNode; |
||||
} |
||||
|
||||
// Look for a match in the element's child nodes.
|
||||
XmlElementTreeNode childElementTreeNode = FindElement(element, elementTreeNode.Nodes); |
||||
if (childElementTreeNode != null) { |
||||
return childElementTreeNode; |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Finds the corresponding XmlElementTreeNode.
|
||||
/// </summary>
|
||||
XmlElementTreeNode FindElement(XmlElement element) |
||||
{ |
||||
XmlElementTreeNode selectedElementTreeNode = SelectedNode as XmlElementTreeNode; |
||||
if (selectedElementTreeNode != null && selectedElementTreeNode.XmlElement == element) { |
||||
return selectedElementTreeNode; |
||||
} else { |
||||
return FindElement(element, Nodes); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Looks at all the nodes in the tree view and returns the
|
||||
/// tree node that represents the specified text node.
|
||||
/// </summary>
|
||||
XmlTextTreeNode FindTextNode(XmlText textNode, TreeNodeCollection nodes) |
||||
{ |
||||
foreach (ExtTreeNode node in nodes) { |
||||
XmlTextTreeNode textTreeNode = node as XmlTextTreeNode; |
||||
if (textTreeNode != null) { |
||||
if (textTreeNode.XmlText == textNode) { |
||||
return textTreeNode; |
||||
} |
||||
} else { |
||||
// Look for a match in the node's child nodes.
|
||||
XmlTextTreeNode childTextTreeNode = FindTextNode(textNode, node.Nodes); |
||||
if (childTextTreeNode != null) { |
||||
return childTextTreeNode; |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Finds the specified text node in the tree.
|
||||
/// </summary>
|
||||
XmlTextTreeNode FindTextNode(XmlText textNode) |
||||
{ |
||||
XmlTextTreeNode selectedTextTreeNode = SelectedNode as XmlTextTreeNode; |
||||
if (selectedTextTreeNode != null && selectedTextTreeNode.XmlText == textNode) { |
||||
return selectedTextTreeNode; |
||||
} else { |
||||
return FindTextNode(textNode, Nodes); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Looks at all the nodes in the tree view and returns the
|
||||
/// tree node that represents the specified comment node.
|
||||
/// </summary>
|
||||
XmlCommentTreeNode FindComment(XmlComment comment, TreeNodeCollection nodes) |
||||
{ |
||||
foreach (ExtTreeNode node in nodes) { |
||||
XmlCommentTreeNode commentTreeNode = node as XmlCommentTreeNode; |
||||
if (commentTreeNode != null) { |
||||
if (commentTreeNode.XmlComment == comment) { |
||||
return commentTreeNode; |
||||
} |
||||
} else { |
||||
// Look for a match in the node's child nodes.
|
||||
XmlCommentTreeNode childCommentTreeNode = FindComment(comment, node.Nodes); |
||||
if (childCommentTreeNode != null) { |
||||
return childCommentTreeNode; |
||||
} |
||||
} |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Locates the specified comment in the tree.
|
||||
/// </summary>
|
||||
XmlCommentTreeNode FindComment(XmlComment comment) |
||||
{ |
||||
XmlCommentTreeNode selectedCommentTreeNode = SelectedNode as XmlCommentTreeNode; |
||||
if (selectedCommentTreeNode != null && selectedCommentTreeNode.XmlComment == comment) { |
||||
return selectedCommentTreeNode; |
||||
} else { |
||||
return FindComment(comment, Nodes); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Shows the corresponding tree node with the ghosted image
|
||||
/// that indicates it is being cut.
|
||||
/// </summary>
|
||||
void ShowCutElement(XmlElement element, bool showGhostImage) |
||||
{ |
||||
XmlElementTreeNode node = FindElement(element); |
||||
node.ShowGhostImage = showGhostImage; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Shows the corresponding tree node with the ghosted image
|
||||
/// that indicates it is being cut.
|
||||
/// </summary>
|
||||
void ShowCutTextNode(XmlText textNode, bool showGhostImage) |
||||
{ |
||||
XmlTextTreeNode node = FindTextNode(textNode); |
||||
node.ShowGhostImage = showGhostImage; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Shows the corresponding tree node with the ghosted image
|
||||
/// that indicates it is being cut.
|
||||
/// </summary>
|
||||
void ShowCutComment(XmlComment comment, bool showGhostImage) |
||||
{ |
||||
XmlCommentTreeNode node = FindComment(comment); |
||||
node.ShowGhostImage = showGhostImage; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Shows the cut node with a ghost image.
|
||||
/// </summary>
|
||||
/// <param name="showGhostImage">True if the node should be
|
||||
/// shown with the ghost image.</param>
|
||||
void ShowCut(XmlNode node, bool showGhostImage) |
||||
{ |
||||
if (node is XmlElement) { |
||||
ShowCutElement((XmlElement)node, showGhostImage); |
||||
} else if (node is XmlText) { |
||||
ShowCutTextNode((XmlText)node, showGhostImage); |
||||
} else if (node is XmlComment) { |
||||
ShowCutComment((XmlComment)node, showGhostImage); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Determines whether the active XML document has been assigned
|
||||
/// an XSLT stylesheet.
|
||||
/// </summary>
|
||||
public class StylesheetAssignedCondition : IConditionEvaluator |
||||
{ |
||||
public bool IsValid(object caller, Condition condition) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
// IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
|
||||
// if (window != null) {
|
||||
// XmlView view = window.ActiveViewContent as XmlView;
|
||||
// if (view != null) {
|
||||
// return view.StylesheetFileName != null;
|
||||
// }
|
||||
// }
|
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Text; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// A string writer that allows you to specify the text encoding to
|
||||
/// be used when generating the string.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This class is used when generating xml strings using a writer and
|
||||
/// the encoding in the xml processing instruction needs to be changed.
|
||||
/// The xml encoding string will be the encoding specified in the constructor
|
||||
/// of this class (i.e. UTF-8, UTF-16)</remarks>
|
||||
public class EncodedStringWriter : StringWriter |
||||
{ |
||||
Encoding encoding = Encoding.UTF8; |
||||
|
||||
/// <summary>
|
||||
/// Creates a new string writer that will generate a string with the
|
||||
/// specified encoding.
|
||||
/// </summary>
|
||||
/// <remarks>The encoding will be used when generating the
|
||||
/// xml encoding header (i.e. UTF-8, UTF-16).</remarks>
|
||||
public EncodedStringWriter(Encoding encoding) |
||||
{ |
||||
this.encoding = encoding; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the text encoding that will be used when generating
|
||||
/// the string.
|
||||
/// </summary>
|
||||
public override Encoding Encoding { |
||||
get { |
||||
return encoding; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,92 @@
@@ -0,0 +1,92 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Text; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Utility class that will encode special XML characters.
|
||||
/// </summary>
|
||||
public sealed class XmlEncoder |
||||
{ |
||||
XmlEncoder() |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Encodes any special characters in the xml string.
|
||||
/// </summary>
|
||||
public static string Encode(string xml, char quoteCharacter) |
||||
{ |
||||
XmlEncoderTextWriter encoderWriter = new XmlEncoderTextWriter(); |
||||
using (XmlTextWriter writer = new XmlTextWriter(encoderWriter)) { |
||||
writer.WriteStartElement("root"); |
||||
writer.WriteStartAttribute("attribute"); |
||||
writer.QuoteChar = quoteCharacter; |
||||
|
||||
encoderWriter.BeginMarkup(); |
||||
writer.WriteString(xml); |
||||
return encoderWriter.Markup; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Special XmlTextWriter that will return the last item written to
|
||||
/// it from a certain point. This is used by the XmlEncoder to
|
||||
/// get the encoded attribute string so the XmlEncoder does not
|
||||
/// have to do the special character encoding itself, but can
|
||||
/// use the .NET framework to do the work.
|
||||
/// </summary>
|
||||
class XmlEncoderTextWriter : EncodedStringWriter |
||||
{ |
||||
StringBuilder markup = new StringBuilder(); |
||||
|
||||
public XmlEncoderTextWriter() : base(Encoding.UTF8) |
||||
{ |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Sets the point from which we are interested in
|
||||
/// saving the string written to the text writer.
|
||||
/// </summary>
|
||||
public void BeginMarkup() |
||||
{ |
||||
markup = new StringBuilder(); |
||||
} |
||||
|
||||
public void EndMarkup() |
||||
{ |
||||
BeginMarkup(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Returns the string written to this text writer after the
|
||||
/// BeginMarkup method was called.
|
||||
/// </summary>
|
||||
public string Markup { |
||||
get { |
||||
return markup.ToString(); |
||||
} |
||||
} |
||||
|
||||
public override void Write(string text) |
||||
{ |
||||
base.Write(text); |
||||
markup.Append(text); |
||||
} |
||||
|
||||
public override void Write(char value) |
||||
{ |
||||
base.Write(value); |
||||
markup.Append(value); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,66 @@
@@ -0,0 +1,66 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: 1662 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// A namespace Uri and a prefix.
|
||||
/// </summary>
|
||||
public class XmlNamespace |
||||
{ |
||||
string prefix = String.Empty; |
||||
string uri = String.Empty; |
||||
|
||||
const string prefixToStringStart = "Prefix ["; |
||||
const string uriToStringMiddle = "] Uri ["; |
||||
|
||||
public XmlNamespace(string prefix, string uri) |
||||
{ |
||||
this.prefix = prefix; |
||||
this.uri = uri; |
||||
} |
||||
|
||||
public string Prefix { |
||||
get { |
||||
return prefix; |
||||
} |
||||
} |
||||
|
||||
public string Uri { |
||||
get { |
||||
return uri; |
||||
} |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return String.Concat(prefixToStringStart, prefix, uriToStringMiddle, uri, "]"); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Creates an XmlNamespace instance from the given string that is in the
|
||||
/// format returned by ToString.
|
||||
/// </summary>
|
||||
public static XmlNamespace FromString(string s) |
||||
{ |
||||
int prefixIndex = s.IndexOf(prefixToStringStart); |
||||
if (prefixIndex >= 0) { |
||||
prefixIndex += prefixToStringStart.Length; |
||||
int uriIndex = s.IndexOf(uriToStringMiddle, prefixIndex); |
||||
if (uriIndex >= 0) { |
||||
string prefix = s.Substring(prefixIndex, uriIndex - prefixIndex); |
||||
uriIndex += uriToStringMiddle.Length; |
||||
string uri = s.Substring(uriIndex, s.Length - (uriIndex + 1)); |
||||
return new XmlNamespace(prefix, uri); |
||||
} |
||||
} |
||||
return new XmlNamespace(String.Empty, String.Empty); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,266 @@
@@ -0,0 +1,266 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
using System.Text; |
||||
using System.Xml; |
||||
|
||||
namespace ICSharpCode.XmlEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Holds information about the start of a fold in an xml string.
|
||||
/// </summary>
|
||||
public class XmlFoldStart |
||||
{ |
||||
int line = 0; |
||||
int col = 0; |
||||
string prefix = String.Empty; |
||||
string name = String.Empty; |
||||
string foldText = String.Empty; |
||||
|
||||
public XmlFoldStart(string prefix, string name, int line, int col) |
||||
{ |
||||
this.line = line; |
||||
this.col = col; |
||||
this.prefix = prefix; |
||||
this.name = name; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The line where the fold should start. Lines start from 0.
|
||||
/// </summary>
|
||||
public int Line { |
||||
get { |
||||
return line; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The column where the fold should start. Columns start from 0.
|
||||
/// </summary>
|
||||
public int Column { |
||||
get { |
||||
return col; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The name of the xml item with its prefix if it has one.
|
||||
/// </summary>
|
||||
public string Name { |
||||
get { |
||||
if (prefix.Length > 0) { |
||||
return String.Concat(prefix, ":", name); |
||||
} else { |
||||
return name; |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The text to be displayed when the item is folded.
|
||||
/// </summary>
|
||||
public string FoldText { |
||||
get { |
||||
return foldText; |
||||
} |
||||
|
||||
set { |
||||
foldText = value; |
||||
} |
||||
} |
||||
} |
||||
|
||||
/* |
||||
/// <summary>
|
||||
/// Determines folds for an xml string in the editor.
|
||||
/// </summary>
|
||||
public class XmlFoldingStrategy : IFoldingStrategy |
||||
{ |
||||
/// <summary>
|
||||
/// Flag indicating whether attributes should be displayed on folded
|
||||
/// elements.
|
||||
/// </summary>
|
||||
bool showAttributesWhenFolded = false; |
||||
|
||||
public XmlFoldingStrategy() |
||||
{ |
||||
} |
||||
|
||||
#region IFoldingStrategy
|
||||
|
||||
/// <summary>
|
||||
/// Adds folds to the text editor around each start-end element pair.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>If the xml is not well formed then no folds are created.</para>
|
||||
/// <para>Note that the xml text reader lines and positions start
|
||||
/// from 1 and the SharpDevelop text editor line information starts
|
||||
/// from 0.</para>
|
||||
/// </remarks>
|
||||
public List<FoldMarker> GenerateFoldMarkers(IDocument document, string fileName, object parseInformation) |
||||
{ |
||||
showAttributesWhenFolded = XmlEditorAddInOptions.ShowAttributesWhenFolded; |
||||
|
||||
List<FoldMarker> foldMarkers = new List<FoldMarker>(); |
||||
Stack stack = new Stack(); |
||||
|
||||
try { |
||||
string xml = document.TextContent; |
||||
XmlTextReader reader = new XmlTextReader(new StringReader(xml)); |
||||
while (reader.Read()) { |
||||
switch (reader.NodeType) { |
||||
case XmlNodeType.Element: |
||||
if (!reader.IsEmptyElement) { |
||||
XmlFoldStart newFoldStart = CreateElementFoldStart(reader); |
||||
stack.Push(newFoldStart); |
||||
} |
||||
break; |
||||
|
||||
case XmlNodeType.EndElement: |
||||
XmlFoldStart foldStart = (XmlFoldStart)stack.Pop(); |
||||
CreateElementFold(document, foldMarkers, reader, foldStart); |
||||
break; |
||||
|
||||
case XmlNodeType.Comment: |
||||
CreateCommentFold(document, foldMarkers, reader); |
||||
break; |
||||
} |
||||
} |
||||
} catch (Exception) { |
||||
// If the xml is not well formed keep the foldings
|
||||
// that already exist in the document.
|
||||
return new List<FoldMarker>(document.FoldingManager.FoldMarker); |
||||
} |
||||
|
||||
return foldMarkers; |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Creates a comment fold if the comment spans more than one line.
|
||||
/// </summary>
|
||||
/// <remarks>The text displayed when the comment is folded is the first
|
||||
/// line of the comment.</remarks>
|
||||
void CreateCommentFold(IDocument document, List<FoldMarker> foldMarkers, XmlTextReader reader) |
||||
{ |
||||
if (reader.Value != null) { |
||||
string comment = reader.Value.Replace("\r\n", "\n"); |
||||
string[] lines = comment.Split('\n'); |
||||
if (lines.Length > 1) { |
||||
|
||||
// Take off 5 chars to get the actual comment start (takes
|
||||
// into account the <!-- chars.
|
||||
|
||||
int startCol = reader.LinePosition - 5; |
||||
int startLine = reader.LineNumber - 1; |
||||
|
||||
// Add 3 to the end col value to take into account the '-->'
|
||||
int endCol = lines[lines.Length - 1].Length + startCol + 3; |
||||
int endLine = startLine + lines.Length - 1; |
||||
string foldText = String.Concat("<!--", lines[0], "-->"); |
||||
FoldMarker foldMarker = new FoldMarker(document, startLine, startCol, endLine, endCol, FoldType.TypeBody, foldText); |
||||
foldMarkers.Add(foldMarker); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Creates an XmlFoldStart for the start tag of an element.
|
||||
/// </summary>
|
||||
XmlFoldStart CreateElementFoldStart(XmlTextReader reader) |
||||
{ |
||||
// Take off 2 from the line position returned
|
||||
// from the xml since it points to the start
|
||||
// of the element name and not the beginning
|
||||
// tag.
|
||||
XmlFoldStart newFoldStart = new XmlFoldStart(reader.Prefix, reader.LocalName, reader.LineNumber - 1, reader.LinePosition - 2); |
||||
|
||||
if (showAttributesWhenFolded && reader.HasAttributes) { |
||||
newFoldStart.FoldText = String.Concat("<", newFoldStart.Name, " ", GetAttributeFoldText(reader), ">"); |
||||
} else { |
||||
newFoldStart.FoldText = String.Concat("<", newFoldStart.Name, ">"); |
||||
} |
||||
|
||||
return newFoldStart; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Create an element fold if the start and end tag are on
|
||||
/// different lines.
|
||||
/// </summary>
|
||||
void CreateElementFold(IDocument document, List<FoldMarker> foldMarkers, XmlTextReader reader, XmlFoldStart foldStart) |
||||
{ |
||||
int endLine = reader.LineNumber - 1; |
||||
if (endLine > foldStart.Line) { |
||||
int endCol = reader.LinePosition + foldStart.Name.Length; |
||||
FoldMarker foldMarker = new FoldMarker(document, foldStart.Line, foldStart.Column, endLine, endCol, FoldType.TypeBody, foldStart.FoldText); |
||||
foldMarkers.Add(foldMarker); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets the element's attributes as a string on one line that will
|
||||
/// be displayed when the element is folded.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Currently this puts all attributes from an element on the same
|
||||
/// line of the start tag. It does not cater for elements where attributes
|
||||
/// are not on the same line as the start tag.
|
||||
/// </remarks>
|
||||
string GetAttributeFoldText(XmlTextReader reader) |
||||
{ |
||||
StringBuilder text = new StringBuilder(); |
||||
|
||||
for (int i = 0; i < reader.AttributeCount; ++i) { |
||||
reader.MoveToAttribute(i); |
||||
|
||||
text.Append(reader.Name); |
||||
text.Append("="); |
||||
text.Append(reader.QuoteChar.ToString()); |
||||
text.Append(XmlEncodeAttributeValue(reader.Value, reader.QuoteChar)); |
||||
text.Append(reader.QuoteChar.ToString()); |
||||
|
||||
// Append a space if this is not the
|
||||
// last attribute.
|
||||
if (i < reader.AttributeCount - 1) { |
||||
text.Append(" "); |
||||
} |
||||
} |
||||
|
||||
return text.ToString(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Xml encode the attribute string since the string returned from
|
||||
/// the XmlTextReader is the plain unencoded string and .NET
|
||||
/// does not provide us with an xml encode method.
|
||||
/// </summary>
|
||||
static string XmlEncodeAttributeValue(string attributeValue, char quoteChar) |
||||
{ |
||||
StringBuilder encodedValue = new StringBuilder(attributeValue); |
||||
|
||||
encodedValue.Replace("&", "&"); |
||||
encodedValue.Replace("<", "<"); |
||||
encodedValue.Replace(">", ">"); |
||||
|
||||
if (quoteChar == '"') { |
||||
encodedValue.Replace("\"", """); |
||||
} else { |
||||
encodedValue.Replace("'", "'"); |
||||
} |
||||
|
||||
return encodedValue.ToString(); |
||||
} |
||||
} |
||||
|
||||
*/ |
||||
} |
||||
@ -0,0 +1,189 @@
@@ -0,0 +1,189 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
|
||||
// <version>$Revision: -1 $</version>
|
||||
// </file>
|
||||
|
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
using System; |
||||
using System.Collections; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
using System.Text; |
||||
using System.Xml; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.XmlBinding |
||||
{ |
||||
/// <summary>
|
||||
/// This class currently inserts the closing tags to typed openening tags
|
||||
/// and does smart indentation for xml files.
|
||||
/// </summary>
|
||||
public class XmlFormattingStrategy : DefaultFormattingStrategy |
||||
{ |
||||
public override void FormatLine(ITextEditor editor, char charTyped) |
||||
{ |
||||
editor.Document.StartUndoableAction(); |
||||
try { |
||||
if (charTyped == '>') { |
||||
StringBuilder stringBuilder = new StringBuilder(); |
||||
int offset = Math.Min(editor.Caret.Offset - 2, editor.Document.TextLength - 1); |
||||
while (true) { |
||||
if (offset < 0) { |
||||
break; |
||||
} |
||||
char ch = editor.Document.GetCharAt(offset); |
||||
if (ch == '<') { |
||||
string reversedTag = stringBuilder.ToString().Trim(); |
||||
if (!reversedTag.StartsWith("/") && !reversedTag.EndsWith("/")) { |
||||
bool validXml = true; |
||||
try { |
||||
XmlDocument doc = new XmlDocument(); |
||||
doc.LoadXml(editor.Document.Text); |
||||
} catch (Exception) { |
||||
validXml = false; |
||||
} |
||||
// only insert the tag, if something is missing
|
||||
if (!validXml) { |
||||
StringBuilder tag = new StringBuilder(); |
||||
for (int i = reversedTag.Length - 1; i >= 0 && !Char.IsWhiteSpace(reversedTag[i]); --i) { |
||||
tag.Append(reversedTag[i]); |
||||
} |
||||
string tagString = tag.ToString(); |
||||
if (tagString.Length > 0 && !tagString.StartsWith("!") && !tagString.StartsWith("?")) { |
||||
editor.Document.Insert(editor.Caret.Offset, "</" + tagString + ">"); |
||||
} |
||||
} |
||||
} |
||||
break; |
||||
} |
||||
stringBuilder.Append(ch); |
||||
--offset; |
||||
} |
||||
} |
||||
} catch (Exception e) { // Insanity check
|
||||
Debug.Assert(false, e.ToString()); |
||||
} |
||||
if (charTyped == '\n') { |
||||
IndentLine(editor, editor.Document.GetLineForOffset(editor.Caret.Offset)); |
||||
} |
||||
editor.Document.EndUndoableAction(); |
||||
} |
||||
|
||||
public override void IndentLine(ITextEditor editor, IDocumentLine line) |
||||
{ |
||||
editor.Document.StartUndoableAction(); |
||||
try { |
||||
TryIndent(editor, line.LineNumber, line.LineNumber); |
||||
} catch (XmlException ex) { |
||||
LoggingService.Debug(ex.ToString()); |
||||
} finally { |
||||
editor.Document.EndUndoableAction(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// This function sets the indentlevel in a range of lines.
|
||||
/// </summary>
|
||||
public override void IndentLines(ITextEditor editor, int begin, int end) |
||||
{ |
||||
editor.Document.StartUndoableAction(); |
||||
try { |
||||
TryIndent(editor, begin, end); |
||||
} catch (XmlException ex) { |
||||
LoggingService.Debug(ex.ToString()); |
||||
} finally { |
||||
editor.Document.EndUndoableAction(); |
||||
} |
||||
} |
||||
#region Smart Indentation
|
||||
private void TryIndent(ITextEditor editor, int begin, int end) |
||||
{ |
||||
string currentIndentation = ""; |
||||
Stack tagStack = new Stack(); |
||||
IDocument document = editor.Document; |
||||
string tab = editor.Options.IndentationString; |
||||
int nextLine = begin; // in #dev coordinates
|
||||
bool wasEmptyElement = false; |
||||
XmlNodeType lastType = XmlNodeType.XmlDeclaration; |
||||
using (StringReader stringReader = new StringReader(document.Text)) { |
||||
XmlTextReader r = new XmlTextReader(stringReader); |
||||
r.XmlResolver = null; // prevent XmlTextReader from loading external DTDs
|
||||
while (r.Read()) { |
||||
if (wasEmptyElement) { |
||||
wasEmptyElement = false; |
||||
if (tagStack.Count == 0) |
||||
currentIndentation = ""; |
||||
else |
||||
currentIndentation = (string)tagStack.Pop(); |
||||
} |
||||
if (r.NodeType == XmlNodeType.EndElement) { |
||||
if (tagStack.Count == 0) |
||||
currentIndentation = ""; |
||||
else |
||||
currentIndentation = (string)tagStack.Pop(); |
||||
} |
||||
|
||||
while (r.LineNumber >= nextLine) { // caution: here we compare 1-based and 0-based line numbers
|
||||
if (nextLine > end) break; |
||||
if (lastType == XmlNodeType.CDATA || lastType == XmlNodeType.Comment) { |
||||
nextLine++; |
||||
continue; |
||||
} |
||||
// set indentation of 'nextLine'
|
||||
IDocumentLine line = document.GetLine(nextLine); |
||||
string lineText = line.Text; |
||||
|
||||
string newText; |
||||
// special case: opening tag has closing bracket on extra line: remove one indentation level
|
||||
if (lineText.Trim() == ">") |
||||
newText = (string)tagStack.Peek() + lineText.Trim(); |
||||
else |
||||
newText = currentIndentation + lineText.Trim(); |
||||
|
||||
if (newText != lineText) { |
||||
document.Replace(line.Offset, line.Length, newText); |
||||
} |
||||
nextLine++; |
||||
} |
||||
if (r.LineNumber > end) |
||||
break; |
||||
wasEmptyElement = r.NodeType == XmlNodeType.Element && r.IsEmptyElement; |
||||
string attribIndent = null; |
||||
if (r.NodeType == XmlNodeType.Element) { |
||||
tagStack.Push(currentIndentation); |
||||
if (r.LineNumber < begin) |
||||
currentIndentation = DocumentUtilitites.GetIndentation(editor.Document, r.LineNumber - 1); |
||||
if (r.Name.Length < 16) |
||||
attribIndent = currentIndentation + new String(' ', 2 + r.Name.Length); |
||||
else |
||||
attribIndent = currentIndentation + tab; |
||||
currentIndentation += tab; |
||||
} |
||||
lastType = r.NodeType; |
||||
if (r.NodeType == XmlNodeType.Element && r.HasAttributes) { |
||||
int startLine = r.LineNumber; |
||||
r.MoveToAttribute(0); // move to first attribute
|
||||
if (r.LineNumber != startLine) |
||||
attribIndent = currentIndentation; // change to tab-indentation
|
||||
r.MoveToAttribute(r.AttributeCount - 1); |
||||
while (r.LineNumber >= nextLine) { |
||||
if (nextLine > end) break; |
||||
// set indentation of 'nextLine'
|
||||
IDocumentLine line = document.GetLine(nextLine); |
||||
string lineText = line.Text; |
||||
string newText = attribIndent + lineText.Trim(); |
||||
if (newText != lineText) { |
||||
document.Replace(line.Offset, line.Length, newText); |
||||
} |
||||
nextLine++; |
||||
} |
||||
} |
||||
} |
||||
r.Close(); |
||||
} |
||||
} |
||||
#endregion
|
||||
} |
||||
} |
||||
@ -0,0 +1,292 @@
@@ -0,0 +1,292 @@
|
||||
<AddIn name = "Xml Binding" |
||||
author = "Matt Ward" |
||||
copyright = "prj:///doc/copyright.txt" |
||||
description = "Xml Binding" |
||||
addInManagerHidden = "preinstalled"> |
||||
|
||||
<Runtime> |
||||
<Import assembly = "XmlBinding.dll"/> |
||||
</Runtime> |
||||
|
||||
<Runtime> |
||||
<Import assembly = "XmlEditor.dll"> |
||||
<ConditionEvaluator name = "StylesheetAssigned" class = "ICSharpCode.XmlEditor.StylesheetAssignedCondition"/> |
||||
</Import> |
||||
<Import assembly = ":ICSharpCode.SharpDevelop"/> |
||||
</Runtime> |
||||
|
||||
<Path name = "/AddIns/DefaultTextEditor/Formatter/XML"> |
||||
<Class id ="XmlFormatter" class = "ICSharpCode.XmlBinding.XmlFormattingStrategy"/> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpDevelop/Workbench/DisplayBindings"> |
||||
<DisplayBinding id = "XmlTreeView" |
||||
type = "Secondary" |
||||
insertbefore = "Text" |
||||
class = "ICSharpCode.XmlBinding.Gui.XmlDisplayBinding"/> |
||||
</Path> |
||||
|
||||
<!-- Xml parser used to initiate the folding update --> |
||||
<!-- <Path name = "/Workspace/Parser"> |
||||
<Parser id = "XmlFoldingParser" |
||||
supportedextensions = ".xml;.xsl;.xslt;.xsd;.manifest;.config;.addin;.xshd;.wxs;.wxi;.wxl;.proj;.csproj;.vbproj;.ilproj;.build;.xfrm;.targets;.xpt;.xft;.map;.wsdl;.disco" |
||||
class = "ICSharpCode.XmlEditor.Parser"/> |
||||
</Path>--> |
||||
|
||||
<!-- Extra project browser icons --> |
||||
<Path name = "/Workspace/Icons"> |
||||
<Icon id = "ExtraXmlFileIcon" |
||||
extensions = ".manifest;.config;.xshd;.wxs;.wxi;.wxl;.proj;.csproj;.vbproj;.ilproj;.xfrm;.targets;.xpt;.xft;.map;.wsdl;.disco;.xaml" |
||||
resource = "FileIcons.XmlIcon" /> |
||||
</Path> |
||||
|
||||
<!-- Xml file filter --> |
||||
<Path name = "/SharpDevelop/Workbench/FileFilter"> |
||||
<FileFilter id = "Xml" |
||||
insertbefore="AllFiles" |
||||
name = "${res:SharpDevelop.FileFilter.XmlFiles}" |
||||
extensions = "*.xml"/> |
||||
<FileFilter id = "Xsl" |
||||
insertbefore="AllFiles" |
||||
name = "${res:SharpDevelop.FileFilter.XslFiles} (*.xsl;*.xslt)" |
||||
extensions = "*.xsl;*.xslt"/> |
||||
</Path> |
||||
|
||||
<!-- XML menu --> |
||||
<Path name = "/SharpDevelop/Workbench/MainMenu"> |
||||
<Condition name = "WindowActive" activewindow="ICSharpCode.XmlEditor.XmlView"> |
||||
<MenuItem id = "Xml" insertafter="View" insertbefore="Tools" label="&XML" type = "Menu"> |
||||
<MenuItem id = "CreateSchema" |
||||
label = "${res:ICSharpCode.XmlEditor.CreateSchemaMenuLabel}" |
||||
class = "ICSharpCode.XmlEditor.CreateSchemaCommand" /> |
||||
<MenuItem id = "ValidateXml" |
||||
label = "${res:ICSharpCode.XmlEditor.ValidateXmlMenuLabel}" |
||||
class = "ICSharpCode.XmlEditor.ValidateXmlCommand" |
||||
shortcut = "Control|Shift|V" /> |
||||
<MenuItem id = "Separator1" type = "Separator"/> |
||||
<ComplexCondition action="Disable"> |
||||
<Not> |
||||
<Condition name = "WindowActive" activewindow = "ICSharpCode.XmlEditor.XslOutputView"/> |
||||
</Not> |
||||
<MenuItem id="AssignStylesheet" |
||||
label="${res:ICSharpCode.XmlEditor.AssignXSLT}" |
||||
class="ICSharpCode.XmlEditor.AssignStylesheetCommand"/> |
||||
<ComplexCondition action="Disable"> |
||||
<!-- evaluate StylesheetAssigned only when XmlView is active - important for lazy loading! --> |
||||
<And> |
||||
<Condition name = "WindowActive" activewindow = "ICSharpCode.XmlEditor.XmlView"/> |
||||
<Condition name = "StylesheetAssigned" action="Disable"/> |
||||
</And> |
||||
<MenuItem id="OpenStylesheet" |
||||
label="${res:ICSharpCode.XmlEditor.OpenXSLT}" |
||||
class="ICSharpCode.XmlEditor.OpenStylesheetCommand"/> |
||||
</ComplexCondition> |
||||
<MenuItem id="RunTransform" |
||||
label="${res:ICSharpCode.XmlEditor.RunXSLT}" |
||||
class="ICSharpCode.XmlEditor.RunXslTransformCommand" |
||||
shortcut="Control|Shift|T"/> |
||||
</ComplexCondition> |
||||
<MenuItem id = "Separator2" type = "Separator"/> |
||||
<MenuItem id = "Format" |
||||
label = "${res:XML.MainMenu.EditMenu.FormatMenu}" |
||||
class = "ICSharpCode.XmlEditor.FormatXmlCommand" /> |
||||
</MenuItem> |
||||
</Condition> |
||||
</Path> |
||||
|
||||
<!-- Right click menu --> |
||||
<Path name = "/SharpDevelop/ViewContent/XmlEditor/ContextMenu"> |
||||
<MenuItem id = "Cut" |
||||
label = "${res:XML.TextAreaContextMenu.Cut}" |
||||
icon = "Icons.16x16.CutIcon" |
||||
shortcut = "Control|X" |
||||
class = "ICSharpCode.SharpDevelop.Commands.Cut"/> |
||||
<MenuItem id = "Copy" |
||||
label = "${res:XML.TextAreaContextMenu.Copy}" |
||||
icon = "Icons.16x16.CopyIcon" |
||||
shortcut = "Control|C" |
||||
class = "ICSharpCode.SharpDevelop.Commands.Copy"/> |
||||
<MenuItem id = "Paste" |
||||
label = "${res:XML.TextAreaContextMenu.Paste}" |
||||
icon = "Icons.16x16.PasteIcon" |
||||
shortcut = "Control|V" |
||||
class = "ICSharpCode.SharpDevelop.Commands.Paste"/> |
||||
<MenuItem id = "Delete" |
||||
label = "${res:XML.MainMenu.EditMenu.Delete}" |
||||
icon = "Icons.16x16.DeleteIcon" |
||||
class = "ICSharpCode.SharpDevelop.Commands.Delete"/> |
||||
<MenuItem id = "Separator1" type = "Separator"/> |
||||
<MenuItem id = "Save" |
||||
label = "${res:XML.MainMenu.FileMenu.Save}" |
||||
icon = "Icons.16x16.SaveIcon" |
||||
shortcut = "Control|S" |
||||
class = "ICSharpCode.SharpDevelop.Commands.SaveFile"/> |
||||
<MenuItem id = "SaveAs" |
||||
label = "${res:XML.MainMenu.FileMenu.SaveAs}" |
||||
class = "ICSharpCode.SharpDevelop.Commands.SaveFileAs"/> |
||||
<MenuItem id = "File" |
||||
label = "${res:XML.MainMenu.FileMenu.Close}" |
||||
class = "ICSharpCode.SharpDevelop.Commands.CloseFile"/> |
||||
<MenuItem id = "Separator2" type = "Separator"/> |
||||
<MenuItem id = "Indent" |
||||
label = "${res:XML.TextAreaContextMenu.Indent}" |
||||
shortcut = "Control|I" |
||||
class = "ICSharpCode.SharpDevelop.DefaultEditor.Commands.IndentSelection" /> |
||||
<MenuItem id = "HideXPathResults" |
||||
label = "${res:ICSharpCode.XmlEditor.HideXPathResults}" |
||||
class = "ICSharpCode.XmlEditor.RemoveXPathHighlightingCommand"/> |
||||
<MenuItem id = "GoToDefinition" |
||||
label = "${res:ICSharpCode.NAntAddIn.GotoDefinitionMenuLabel}" |
||||
class = "ICSharpCode.XmlEditor.GoToSchemaDefinitionCommand"/> |
||||
<MenuItem id = "FileMode" label = "${res:XML.TextAreaContextMenu.FileMode}" type="Menu"> |
||||
<MenuItem id = "HighlightBuilder" type="Builder" class = "ICSharpCode.SharpDevelop.DefaultEditor.Commands.HighlightingTypeBuilder" /> |
||||
</MenuItem> |
||||
<MenuItem id = "Separator3" type = "Separator"/> |
||||
<MenuItem id = "Options" |
||||
label = "${res:XML.TextAreaContextMenu.BufferOptions}" |
||||
icon = "Icons.16x16.PropertiesIcon" |
||||
class ="ICSharpCode.SharpDevelop.DefaultEditor.Commands.ShowBufferOptions"/> |
||||
</Path> |
||||
|
||||
<!-- Options panel --> |
||||
<Path path = "/SharpDevelop/Dialogs/OptionsDialog/TextEditorOptions"> |
||||
<OptionPanel id = "XmlSchemasPanel" |
||||
insertafter = "Markers" |
||||
label = "${res:ICSharpCode.XmlEditor.XmlSchemasPanel.Title}" |
||||
class = "ICSharpCode.XmlEditor.XmlSchemasPanel" /> |
||||
<OptionPanel id = "XmlEditorOptionsPanel" |
||||
insertafter = "Markers" |
||||
insertbefore = "XmlSchemasPanel" |
||||
label = "${res:ICSharpCode.XmlEditor.XmlEditorOptionsPanel.Title}" |
||||
class = "ICSharpCode.XmlEditor.XmlEditorOptionsPanel" /> |
||||
</Path> |
||||
|
||||
<Path path = "/AddIns/XmlEditor/EditActions"> |
||||
<EditAction id = "XmlCompletionPopup" class = "ICSharpCode.XmlEditor.CodeCompletionPopupCommand" keys = "Control|Space"/> |
||||
<EditAction id = "GoToDefinition" class = "ICSharpCode.XmlEditor.GoToSchemaDefinitionEditAction" keys = "Control|Enter"/> |
||||
</Path> |
||||
|
||||
<!-- XPath Query pad --> |
||||
<Path name = "/SharpDevelop/Workbench/Pads"> |
||||
<Pad id = "XPathQueryPad" |
||||
category = "Tools" |
||||
icon = "PadIcons.XPathQuery" |
||||
title = "${res:ICSharpCode.XmlEditor.XPathQueryPad.Title}" |
||||
insertafter = "UnitTestingPad" |
||||
class = "ICSharpCode.XmlEditor.XPathQueryPad" |
||||
defaultPosition = "Bottom, Hidden" /> |
||||
</Path> |
||||
|
||||
<!-- Menu options to turn off XPath Query result highlighting --> |
||||
<Path name = "/SharpDevelop/Workbench/MainMenu/Edit/Format"> |
||||
<Condition name = "WindowActive" activewindow="ICSharpCode.XmlEditor.XmlView"> |
||||
<MenuItem id = "RemoveXPathHighlighting" |
||||
insertafter = "ShowCodeCoverage" |
||||
label = "${res:ICSharpCode.XmlEditor.HideXPathResults}" |
||||
class = "ICSharpCode.XmlEditor.RemoveXPathHighlightingCommand"/> |
||||
</Condition> |
||||
</Path> |
||||
|
||||
<!-- XML Tree context menu options --> |
||||
<Path name = "/AddIns/XmlEditor/XmlTree/AttributesGrid/ContextMenu"> |
||||
<Condition name = "Ownerstate" ownerstate="ElementSelected" action="Disable"> |
||||
<MenuItem id = "AddAttribute" |
||||
label = "${res:ICSharpCode.XmlEditor.XmlTreeView.AddAttributeMenuLabel}" |
||||
class = "ICSharpCode.XmlEditor.AddAttributeCommand"/> |
||||
</Condition> |
||||
<Condition name = "Ownerstate" ownerstate="AttributeSelected" action="Disable"> |
||||
<MenuItem id = "RemoveAttribute" |
||||
label = "${res:ICSharpCode.XmlEditor.XmlTreeView.RemoveAttributeMenuLabel}" |
||||
icon = "Icons.16x16.DeleteIcon" |
||||
class = "ICSharpCode.XmlEditor.RemoveAttributeCommand"/> |
||||
</Condition> |
||||
</Path> |
||||
|
||||
<Path name = "/AddIns/XmlEditor/XmlTree/ContextMenu"> |
||||
<MenuItem id = "Cut" |
||||
label = "${res:XML.TextAreaContextMenu.Cut}" |
||||
icon = "Icons.16x16.CutIcon" |
||||
shortcut = "Control|X" |
||||
class = "ICSharpCode.SharpDevelop.Commands.Cut"/> |
||||
<MenuItem id = "Copy" |
||||
label = "${res:XML.TextAreaContextMenu.Copy}" |
||||
icon = "Icons.16x16.CopyIcon" |
||||
shortcut = "Control|C" |
||||
class = "ICSharpCode.SharpDevelop.Commands.Copy"/> |
||||
<MenuItem id = "Paste" |
||||
label = "${res:XML.TextAreaContextMenu.Paste}" |
||||
icon = "Icons.16x16.PasteIcon" |
||||
shortcut = "Control|V" |
||||
class = "ICSharpCode.SharpDevelop.Commands.Paste"/> |
||||
<MenuItem id = "Delete" |
||||
label = "${res:XML.MainMenu.EditMenu.Delete}" |
||||
icon = "Icons.16x16.DeleteIcon" |
||||
class = "ICSharpCode.SharpDevelop.Commands.Delete"/> |
||||
<MenuItem id = "EditItemsSeparator" type = "Separator"/> |
||||
<ComplexCondition action = "Disable"> |
||||
<Or> |
||||
<Condition name = "Ownerstate" ownerstate = "CommentSelected"/> |
||||
<And> |
||||
<Condition name = "Ownerstate" ownerstate = "ElementSelected"/> |
||||
<Not> |
||||
<Condition name = "Ownerstate" ownerstate = "RootElementSelected"/> |
||||
</Not> |
||||
</And> |
||||
</Or> |
||||
<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> |
||||
<ComplexCondition action = "Disable"> |
||||
<Or> |
||||
<Condition name = "Ownerstate" ownerstate = "TextNodeSelected"/> |
||||
<Condition name = "Ownerstate" ownerstate = "CommentSelected"/> |
||||
<And> |
||||
<Condition name = "Ownerstate" ownerstate = "ElementSelected"/> |
||||
<Not> |
||||
<Condition name = "Ownerstate" ownerstate = "RootElementSelected"/> |
||||
</Not> |
||||
</And> |
||||
</Or> |
||||
<MenuItem id = "TextNodeCommandsSeparator" type = "Separator"/> |
||||
<MenuItem id = "InsertTextNodeBefore" |
||||
label = "${res:ICSharpCode.XmlEditor.XmlTreeView.InsertTextNodeBeforeMenuLabel}" |
||||
class = "ICSharpCode.XmlEditor.InsertTextNodeBeforeCommand"/> |
||||
<MenuItem id = "InsertTextNodeAfter" |
||||
label = "${res:ICSharpCode.XmlEditor.XmlTreeView.InsertTextNodeAfterMenuLabel}" |
||||
class = "ICSharpCode.XmlEditor.InsertTextNodeAfterCommand"/> |
||||
</ComplexCondition> |
||||
<Condition name = "Ownerstate" ownerstate = "ElementSelected" action = "Disable"> |
||||
<MenuItem id = "AddChildTextNode" |
||||
label = "${res:ICSharpCode.XmlEditor.XmlTreeView.AddChildTextNodeAfterMenuLabel}" |
||||
class = "ICSharpCode.XmlEditor.AddChildTextNodeCommand"/> |
||||
</Condition> |
||||
<ComplexCondition action = "Disable"> |
||||
<Or> |
||||
<Condition name = "Ownerstate" ownerstate = "TextNodeSelected"/> |
||||
<Condition name = "Ownerstate" ownerstate = "ElementSelected"/> |
||||
<Condition name = "Ownerstate" ownerstate = "CommentSelected"/> |
||||
</Or> |
||||
<MenuItem id = "CommentNodeCommandsSeparator" type = "Separator"/> |
||||
<MenuItem id = "InsertCommentBefore" |
||||
label = "${res:ICSharpCode.XmlEditor.XmlTreeView.InsertCommentBeforeMenuLabel}" |
||||
class = "ICSharpCode.XmlEditor.InsertCommentBeforeCommand"/> |
||||
<MenuItem id = "InsertCommentAfter" |
||||
label = "${res:ICSharpCode.XmlEditor.XmlTreeView.InsertCommentAfterMenuLabel}" |
||||
class = "ICSharpCode.XmlEditor.InsertCommentAfterCommand"/> |
||||
</ComplexCondition> |
||||
<Condition name = "Ownerstate" ownerstate = "ElementSelected" action = "Disable"> |
||||
<MenuItem id = "AddChildCommentNode" |
||||
label = "${res:ICSharpCode.XmlEditor.XmlTreeView.AddChildCommentMenuLabel}" |
||||
class = "ICSharpCode.XmlEditor.AddChildCommentCommand"/> |
||||
</Condition> |
||||
</Path> |
||||
</AddIn> |
||||
@ -0,0 +1,159 @@
@@ -0,0 +1,159 @@
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<ProjectGuid>{DCA2703D-250A-463E-A68A-07ED105AE6BD}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.XmlBinding</RootNamespace> |
||||
<AssemblyName>XmlBinding</AssemblyName> |
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> |
||||
<SourceAnalysisOverrideSettingsFile>C:\Users\Siegfried\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
<OutputPath>..\..\..\..\AddIns\AddIns\BackendBindings\XmlBinding\</OutputPath> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<Optimize>False</Optimize> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<Optimize>True</Optimize> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<PlatformTarget>x86</PlatformTarget> |
||||
<FileAlignment>4096</FileAlignment> |
||||
</PropertyGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Data.DataSetExtensions"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="System.Xml.Linq"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<None Include="XmlBinding.addin"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</None> |
||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
||||
<Compile Include="Src\XmlFormattingStrategy.cs"> |
||||
</Compile> |
||||
<Compile Include="Src\CodeCompletion\XmlCompletionData.cs" /> |
||||
<Compile Include="Src\CodeCompletion\XmlCompletionDataCollection.cs" /> |
||||
<Compile Include="Src\CodeCompletion\XmlCompletionDataImageList.cs" /> |
||||
<Compile Include="Src\CodeCompletion\XmlCompletionDataProvider.cs" /> |
||||
<Compile Include="Src\Commands\AddAttributeCommand.cs" /> |
||||
<Compile Include="Src\Commands\AddChildCommentCommand.cs" /> |
||||
<Compile Include="Src\Commands\AddChildElementCommand.cs" /> |
||||
<Compile Include="Src\Commands\AddChildTextNodeCommand.cs" /> |
||||
<Compile Include="Src\Commands\AssignStylesheetCommand.cs" /> |
||||
<Compile Include="Src\Commands\CodeCompletionPopupCommand.cs" /> |
||||
<Compile Include="Src\Commands\CreateSchemaCommand.cs" /> |
||||
<Compile Include="Src\Commands\FormatXmlCommand.cs" /> |
||||
<Compile Include="Src\Commands\GoToSchemaDefinitionCommand.cs" /> |
||||
<Compile Include="Src\Commands\InsertCommentAfterCommand.cs" /> |
||||
<Compile Include="Src\Commands\InsertCommentBeforeCommand.cs" /> |
||||
<Compile Include="Src\Commands\InsertElementAfterCommand.cs" /> |
||||
<Compile Include="Src\Commands\InsertElementBeforeCommand.cs" /> |
||||
<Compile Include="Src\Commands\InsertTextNodeAfterCommand.cs" /> |
||||
<Compile Include="Src\Commands\InsertTextNodeBeforeCommand.cs" /> |
||||
<Compile Include="Src\Commands\OpenStylesheetCommand.cs" /> |
||||
<Compile Include="Src\Commands\RemoveAttributeCommand.cs" /> |
||||
<Compile Include="Src\Commands\RemoveXPathHighlightingCommand.cs" /> |
||||
<Compile Include="Src\Commands\RunXslTransformCommand.cs" /> |
||||
<Compile Include="Src\Commands\ValidateXmlCommand.cs" /> |
||||
<Compile Include="Src\Gui\AddXmlNodeDialog.cs" /> |
||||
<Compile Include="Src\Gui\GoToSchemaDefinitionEditAction.cs" /> |
||||
<Compile Include="Src\Gui\IAddXmlNodeDialog.cs" /> |
||||
<Compile Include="Src\Gui\IXmlTreeView.cs" /> |
||||
<Compile Include="Src\Gui\SelectXmlSchemaForm.cs"> |
||||
<SubType>Form</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\Gui\XmlDisplayBinding.cs" /> |
||||
<Compile Include="Src\Gui\XmlTreeView.cs" /> |
||||
<Compile Include="Src\Gui\XPathQueryControl.cs" /> |
||||
<Compile Include="Src\Gui\XPathQueryPad.cs"> |
||||
</Compile> |
||||
<Compile Include="Src\Gui\XslOutputView.cs" /> |
||||
<Compile Include="Src\Parser\Parser.cs" /> |
||||
<Compile Include="Src\Parser\QualifiedName.cs" /> |
||||
<Compile Include="Src\Parser\QualifiedNameCollection.cs" /> |
||||
<Compile Include="Src\Parser\XmlElementPath.cs" /> |
||||
<Compile Include="Src\Parser\XmlParser.cs" /> |
||||
<Compile Include="Src\Src\XmlAttributePropertyDescriptor.cs" /> |
||||
<Compile Include="Src\Src\XmlAttributeTypeDescriptor.cs" /> |
||||
<Compile Include="Src\Src\XmlCharacterDataTreeNode.cs" /> |
||||
<Compile Include="Src\Src\XmlCommentTreeNode.cs" /> |
||||
<Compile Include="Src\Src\XmlEditorAddInOptions.cs" /> |
||||
<Compile Include="Src\Src\XmlEditorOptionsPanel.cs"> |
||||
<SubType>UserControl</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\Src\XmlElementTreeNode.cs" /> |
||||
<Compile Include="Src\Src\XmlSchemaAssociation.cs" /> |
||||
<Compile Include="Src\Src\XmlSchemaAssociationListBoxItem.cs" /> |
||||
<Compile Include="Src\Src\XmlSchemaCompletionData.cs" /> |
||||
<Compile Include="Src\Src\XmlSchemaCompletionDataCollection.cs" /> |
||||
<Compile Include="Src\Src\XmlSchemaListBoxItem.cs" /> |
||||
<Compile Include="Src\Src\XmlSchemaManager.cs" /> |
||||
<Compile Include="Src\Src\XmlSchemasPanel.cs"> |
||||
<SubType>UserControl</SubType> |
||||
</Compile> |
||||
<Compile Include="Src\Src\XmlTextTreeNode.cs" /> |
||||
<Compile Include="Src\Src\XmlTreeEditor.cs" /> |
||||
<Compile Include="Src\Src\XmlTreeViewContainerControl.cs" /> |
||||
<Compile Include="Src\Src\XmlTreeViewControl.cs" /> |
||||
<Compile Include="Src\Src\XPathNodeMatch.cs" /> |
||||
<Compile Include="Src\Src\XPathNodeTextMarker.cs" /> |
||||
<Compile Include="Src\StylesheetAssignedCondition.cs" /> |
||||
<Compile Include="Src\XmlFoldingStrategy.cs" /> |
||||
<Compile Include="Src\Xml\EncodedStringWriter.cs" /> |
||||
<Compile Include="Src\Xml\XmlEncoder.cs" /> |
||||
<Compile Include="Src\Xml\XmlNamespace.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Folder Include="Src" /> |
||||
<Folder Include="Src\CodeCompletion" /> |
||||
<Folder Include="Src\Commands" /> |
||||
<Folder Include="Src\Gui" /> |
||||
<Folder Include="Src\Xml" /> |
||||
<Folder Include="Src\Parser" /> |
||||
<Folder Include="Src\Src" /> |
||||
<ProjectReference Include="..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
||||
<Name>ICSharpCode.SharpDevelop</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Main\Core\Project\ICSharpCode.Core.csproj"> |
||||
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
||||
<Name>ICSharpCode.Core</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj"> |
||||
<Project>{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}</Project> |
||||
<Name>ICSharpCode.Core.WinForms</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj"> |
||||
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project> |
||||
<Name>ICSharpCode.SharpDevelop.Dom</Name> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
</Project> |
||||
Loading…
Reference in new issue