Browse Source

File extensions that are to be opened in the XML Editor are now defined in the XmlEditor.addin file and not by the text editor library. This means that a user can add a new extension by editing the XmlEditor.addin file without needing to edit and recompile the text editor library.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1642 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 19 years ago
parent
commit
449f921eac
  1. 3
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlEditorAddInOptions.cs
  2. 36
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs

3
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlEditorAddInOptions.cs

@ -76,7 +76,8 @@ namespace ICSharpCode.XmlEditor @@ -76,7 +76,8 @@ namespace ICSharpCode.XmlEditor
/// </remarks>
public static XmlSchemaAssociation GetSchemaAssociation(string extension)
{
string property = Properties.Get("ext" + extension, "");
extension = extension.ToLower();
string property = Properties.Get("ext" + extension, String.Empty);
XmlSchemaAssociation association = null;
if (property.Length > 0) {

36
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlView.cs

@ -101,6 +101,14 @@ namespace ICSharpCode.XmlEditor @@ -101,6 +101,14 @@ namespace ICSharpCode.XmlEditor
/// </summary>
public static string[] GetXmlFileExtensions()
{
foreach (ParserDescriptor parser in (ParserDescriptor[])AddInTree.BuildItems("/Workspace/Parser", null, false).ToArray(typeof(ParserDescriptor))) {
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(XmlView.Language);
if (strategy != null) {
return strategy.Extensions;
@ -165,16 +173,21 @@ namespace ICSharpCode.XmlEditor @@ -165,16 +173,21 @@ namespace ICSharpCode.XmlEditor
/// </summary>
public override string FileName {
set {
if (Path.GetExtension(FileName) != Path.GetExtension(value)) {
string extension = Path.GetExtension(value);
if (Path.GetExtension(FileName) != extension) {
if (xmlEditor.Document.HighlightingStrategy != null) {
xmlEditor.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategyForFile(value);
if (XmlView.IsXmlFileExtension(extension)) {
xmlEditor.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(XmlView.Language);
} else {
xmlEditor.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategyForFile(value);
}
xmlEditor.Refresh();
}
}
base.FileName = value;
base.TitleName = Path.GetFileName(value);
SetDefaultSchema(Path.GetExtension(value));
SetDefaultSchema(extension);
}
}
@ -302,7 +315,7 @@ namespace ICSharpCode.XmlEditor @@ -302,7 +315,7 @@ namespace ICSharpCode.XmlEditor
public override void Load(string fileName)
{
xmlEditor.IsReadOnly = IsFileReadOnly(fileName);
xmlEditor.LoadFile(fileName);
xmlEditor.LoadFile(fileName, false, true);
FileName = fileName;
TitleName = Path.GetFileName(fileName);
IsDirty = false;
@ -487,19 +500,12 @@ namespace ICSharpCode.XmlEditor @@ -487,19 +500,12 @@ namespace ICSharpCode.XmlEditor
/// </summary>
static bool IsXmlFileExtension(string extension)
{
bool isXmlFileExtension = false;
IHighlightingStrategy strategy = HighlightingManager.Manager.FindHighlighter(XmlView.Language);
if (strategy != null) {
foreach (string currentExtension in strategy.Extensions) {
if (String.Compare(extension, currentExtension, true) == 0) {
isXmlFileExtension = true;
break;
}
foreach (string currentExtension in GetXmlFileExtensions()) {
if (String.Compare(extension, currentExtension, true) == 0) {
return true;
}
}
return isXmlFileExtension;
return false;
}
/// <summary>

Loading…
Cancel
Save