Browse Source

Fixed SD2-654: Get file types to register from AddIn tree.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1048 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
8f779b2ffb
  1. 33
      data/schemas/AddIn.xsd
  2. 11
      doc/technotes/ConditionList.html
  3. 41
      doc/technotes/DoozerList.html
  4. 10
      src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.addin
  5. 64
      src/AddIns/Misc/FiletypeRegisterer/Project/FiletypeRegisterer.addin
  6. 4
      src/AddIns/Misc/FiletypeRegisterer/Project/FiletypeRegisterer.csproj
  7. 107
      src/AddIns/Misc/FiletypeRegisterer/Project/Src/FiletypeAssociationDoozer.cs
  8. 82
      src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesCommand.cs
  9. 18
      src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesPanel.cs
  10. 17
      src/AddIns/Misc/FiletypeRegisterer/Project/filetypes/Filetypes.xml
  11. 4
      src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs
  12. 3
      src/Main/Core/Project/ICSharpCode.Core.csproj
  13. 17
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultConditionEvaluators/CompareConditionEvaluator.cs
  14. 39
      src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/StringDoozer.cs
  15. 1
      src/Main/Core/Project/Src/AddInTree/AddInTree.cs
  16. 16
      src/Main/Core/Project/Src/Services/StringParser/StringParser.cs

33
data/schemas/AddIn.xsd

@ -73,6 +73,7 @@
<xs:element ref="Pad" /> <xs:element ref="Pad" />
<xs:element ref="Parser" /> <xs:element ref="Parser" />
<xs:element ref="SchemeExtension" /> <xs:element ref="SchemeExtension" />
<xs:element ref="String" />
<xs:element ref="SyntaxMode" /> <xs:element ref="SyntaxMode" />
<xs:element ref="ToolbarItem" /> <xs:element ref="ToolbarItem" />
</xs:choice> </xs:choice>
@ -94,6 +95,7 @@
<xs:attribute name="activeextension" type="xs:string" use="optional" /> <xs:attribute name="activeextension" type="xs:string" use="optional" />
<xs:attribute name="activeproject" type="xs:string" use="optional" /> <xs:attribute name="activeproject" type="xs:string" use="optional" />
<xs:attribute name="activewindow" type="xs:string" use="optional" /> <xs:attribute name="activewindow" type="xs:string" use="optional" />
<xs:attribute name="comparisonType" type="xs:string" use="optional" />
<xs:attribute name="debuggersupports" type="xs:string" use="optional" /> <xs:attribute name="debuggersupports" type="xs:string" use="optional" />
<xs:attribute name="equals" type="xs:string" use="optional" /> <xs:attribute name="equals" type="xs:string" use="optional" />
<xs:attribute name="openwindow" type="xs:string" use="optional" /> <xs:attribute name="openwindow" type="xs:string" use="optional" />
@ -140,6 +142,7 @@
<xs:element ref="Pad" /> <xs:element ref="Pad" />
<xs:element ref="Parser" /> <xs:element ref="Parser" />
<xs:element ref="SchemeExtension" /> <xs:element ref="SchemeExtension" />
<xs:element ref="String" />
<xs:element ref="SyntaxMode" /> <xs:element ref="SyntaxMode" />
<xs:element ref="ToolbarItem" /> <xs:element ref="ToolbarItem" />
</xs:choice> </xs:choice>
@ -203,7 +206,7 @@
<xs:element name="Class" type="Class"> <xs:element name="Class" type="Class">
<xs:annotation> <xs:annotation>
<xs:documentation> <xs:documentation>
Creates object instances by invocing a type's parameterless constructor Creates object instances by invocating a type's parameterless constructor
via System.Reflection. via System.Reflection.
</xs:documentation> </xs:documentation>
</xs:annotation> </xs:annotation>
@ -298,6 +301,7 @@
<xs:element ref="ComplexCondition" /> <xs:element ref="ComplexCondition" />
<xs:element ref="Condition" /> <xs:element ref="Condition" />
<xs:element ref="DialogPanel" /> <xs:element ref="DialogPanel" />
<xs:element ref="Include" />
</xs:choice> </xs:choice>
<xs:attribute name="class" use="optional" type="xs:string"> <xs:attribute name="class" use="optional" type="xs:string">
<xs:annotation> <xs:annotation>
@ -513,8 +517,9 @@
<xs:element name="Include" type="Include"> <xs:element name="Include" type="Include">
<xs:annotation> <xs:annotation>
<xs:documentation> <xs:documentation>
Builds one or multiple items from another location in the addin tree. Includes one or multiple items from another location in the addin tree.
This doozer can use the "item" OR the "path" attribute. You can use the attribute "item" (to include a single item) OR the
attribute "path" (to include all items from the target path).
</xs:documentation> </xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
@ -566,6 +571,7 @@
<xs:element ref="ComplexCondition" /> <xs:element ref="ComplexCondition" />
<xs:element ref="Condition" /> <xs:element ref="Condition" />
<xs:element ref="MenuItem" /> <xs:element ref="MenuItem" />
<xs:element ref="Include" />
</xs:choice> </xs:choice>
<xs:attribute name="label" use="required" type="xs:string"> <xs:attribute name="label" use="required" type="xs:string">
<xs:annotation> <xs:annotation>
@ -758,6 +764,26 @@
</xs:documentation> </xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
<xs:complexType name="String">
<xs:complexContent>
<xs:extension base="AbstractCodon">
<xs:attribute name="text" use="required" type="xs:string">
<xs:annotation>
<xs:documentation>
The string to return.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="String" type="String">
<xs:annotation>
<xs:documentation>
Creates a string.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="SyntaxMode"> <xs:complexType name="SyntaxMode">
<xs:complexContent> <xs:complexContent>
<xs:extension base="AbstractCodon"> <xs:extension base="AbstractCodon">
@ -800,6 +826,7 @@
<xs:element ref="ComplexCondition" /> <xs:element ref="ComplexCondition" />
<xs:element ref="Condition" /> <xs:element ref="Condition" />
<xs:element ref="MenuItem" /> <xs:element ref="MenuItem" />
<xs:element ref="Include" />
</xs:choice> </xs:choice>
<xs:attribute name="icon" use="optional" type="xs:string"> <xs:attribute name="icon" use="optional" type="xs:string">
<xs:annotation> <xs:annotation>

11
doc/technotes/ConditionList.html

@ -5,7 +5,7 @@
</head><body> </head><body>
<h1>Condition List</h1> <h1>Condition List</h1>
<p class="notice">This file was generated by the tool 'BuildAddinDocumentation'. <p class="notice">This file was generated by the tool 'BuildAddinDocumentation'.
It is based on SharpDevelop 2.0.0.783.</p> It is based on SharpDevelop 2.0.0.1045.</p>
<ul> <ul>
<li><a href="#ActiveContentExtension">ActiveContentExtension</a> <li><a href="#ActiveContentExtension">ActiveContentExtension</a>
<li><a href="#ActiveViewContentUntitled">ActiveViewContentUntitled</a> <li><a href="#ActiveViewContentUntitled">ActiveViewContentUntitled</a>
@ -135,8 +135,15 @@ It is based on SharpDevelop 2.0.0.783.</p>
The second string. The second string.
</td> </td>
</tr> </tr>
<tr>
<th colspan=2>comparisonType:</td>
<td>
The mode of the comparison: a field of the System.StringComparison enumeration. The default is
'InvariantCultureIgnoreCase'.
</td>
</tr>
</table> </table>
<p><span class="exampleTitle">Example: Test if the browser is showing a HtmlHelp page</span> <p><span class="exampleTitle">Example: Check the value of a property in the PropertyService</span>
<br><pre> <br><pre>
&lt;Condition name = "Compare" string = "${property:SharpDevelop.FiletypesRegisterStartup}" equals = "True"&gt;</pre></p> &lt;Condition name = "Compare" string = "${property:SharpDevelop.FiletypesRegisterStartup}" equals = "True"&gt;</pre></p>
</div> </div>

41
doc/technotes/DoozerList.html

@ -5,7 +5,7 @@
</head><body> </head><body>
<h1>Doozer List</h1> <h1>Doozer List</h1>
<p class="notice">This file was generated by the tool 'BuildAddinDocumentation'. <p class="notice">This file was generated by the tool 'BuildAddinDocumentation'.
It is based on SharpDevelop 2.0.0.783.</p> It is based on SharpDevelop 2.0.0.1045.</p>
<ul> <ul>
<li><a href="#Class">Class</a> <li><a href="#Class">Class</a>
<li><a href="#CodeCompletionBinding">CodeCompletionBinding</a> <li><a href="#CodeCompletionBinding">CodeCompletionBinding</a>
@ -22,13 +22,14 @@ It is based on SharpDevelop 2.0.0.783.</p>
<li><a href="#Pad">Pad</a> <li><a href="#Pad">Pad</a>
<li><a href="#Parser">Parser</a> <li><a href="#Parser">Parser</a>
<li><a href="#SchemeExtension">SchemeExtension</a> <li><a href="#SchemeExtension">SchemeExtension</a>
<li><a href="#String">String</a>
<li><a href="#SyntaxMode">SyntaxMode</a> <li><a href="#SyntaxMode">SyntaxMode</a>
<li><a href="#ToolbarItem">ToolbarItem</a> <li><a href="#ToolbarItem">ToolbarItem</a>
</ul> </ul>
<div> <div>
<h2><a name="Class">Class</a></h2> <h2><a name="Class">Class</a></h2>
<p> <p>
Creates object instances by invocing a type's parameterless constructor Creates object instances by invocating a type's parameterless constructor
via System.Reflection. via System.Reflection.
</p> </p>
<table> <table>
@ -309,9 +310,9 @@ It is based on SharpDevelop 2.0.0.783.</p>
<p><span class="exampleTitle">Example: Secondary display binding: Form designer</span> <p><span class="exampleTitle">Example: Secondary display binding: Form designer</span>
<br><pre> <br><pre>
&lt;Path name = "/SharpDevelop/Workbench/DisplayBindings"&gt; &lt;Path name = "/SharpDevelop/Workbench/DisplayBindings"&gt;
&lt;DisplayBinding id = "FormDesigner" &lt;DisplayBinding id = "FormsDesigner"
type = "Secondary" type = "Secondary"
class = "ICSharpCode.FormDesigner.FormDesignerSecondaryDisplayBinding" class = "ICSharpCode.FormsDesigner.FormsDesignerSecondaryDisplayBinding"
fileNamePattern = "\.(cs|vb)$" /&gt; fileNamePattern = "\.(cs|vb)$" /&gt;
&lt;/Path&gt;</pre></p> &lt;/Path&gt;</pre></p>
</div> </div>
@ -441,8 +442,9 @@ It is based on SharpDevelop 2.0.0.783.</p>
<div> <div>
<h2><a name="Include">Include</a></h2> <h2><a name="Include">Include</a></h2>
<p> <p>
Builds one or multiple items from another location in the addin tree. Includes one or multiple items from another location in the addin tree.
This doozer can use the "item" OR the "path" attribute. You can use the attribute "item" (to include a single item) OR the
attribute "path" (to include all items from the target path).
</p> </p>
<table> <table>
<tr> <tr>
@ -765,6 +767,33 @@ It is based on SharpDevelop 2.0.0.783.</p>
</tr> </tr>
</table> </table>
</div> </div>
<div>
<h2><a name="String">String</a></h2>
<p>
Creates a string.
</p>
<table>
<tr>
<th colspan=2>Doozer name:</td>
<td>ICSharpCode.Core.StringDoozer</td>
</tr>
<tr><td colspan=3><hr><h3>Attributes:</h3></td></tr>
<tr>
<th>text:</td>
<td class="userequired">required</td>
<td>
The string to return.
</td>
</tr>
<tr><td colspan=3><hr></td></tr>
<tr>
<th colspan=2>Returns:</td>
<td>
The string specified by 'text', passed through the StringParser.
</td>
</tr>
</table>
</div>
<div> <div>
<h2><a name="SyntaxMode">SyntaxMode</a></h2> <h2><a name="SyntaxMode">SyntaxMode</a></h2>
<p> <p>

10
src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.addin

@ -22,6 +22,16 @@
extensions = "*.boo"/> extensions = "*.boo"/>
</Path> </Path>
<Path name = "/AddIns/FileTypeRegisterer/FileTypes">
<FiletypeAssociation
id = "booproj"
insertafter = "sln"
insertbefore = "sdaddin"
autoRegister = "True"
icon = "${AddInPath:ICSharpCode.FiletypeRegisterer}/filetypes/prjx.ico"
text = "Boo ${res:ICSharpCode.FiletypeRegisterer.Project}"/>
</Path>
<Path name = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/ProjectActions/Convert"> <Path name = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/ProjectActions/Convert">
<Condition name = "ProjectActive" activeproject="VBNet"> <Condition name = "ProjectActive" activeproject="VBNet">
<MenuItem id = "VBToBooConverter" <MenuItem id = "VBToBooConverter"

64
src/AddIns/Misc/FiletypeRegisterer/Project/FiletypeRegisterer.addin

@ -8,9 +8,71 @@
</Manifest> </Manifest>
<Runtime> <Runtime>
<Import assembly = "ICSharpCode.FiletypeRegisterer.dll"/> <Import assembly = "ICSharpCode.FiletypeRegisterer.dll">
<Doozer name = "FiletypeAssociation"
class = "ICSharpCode.FiletypeRegisterer.FiletypeAssociationDoozer"/>
</Import>
</Runtime> </Runtime>
<Path name = "/AddIns/FileTypeRegisterer/FileTypes">
<FiletypeAssociation
id = "sln"
autoRegister = "True"
icon = "${AddInPath:ICSharpCode.FiletypeRegisterer}/filetypes/cmbx.ico"
text = "${res:ICSharpCode.FiletypeRegisterer.SolutionFileAssozisation}"/>
<FiletypeAssociation
id = "csproj"
autoRegister = "True"
icon = "${AddInPath:ICSharpCode.FiletypeRegisterer}/filetypes/prjx.ico"
text = "C# ${res:ICSharpCode.FiletypeRegisterer.Project}"/>
<FiletypeAssociation
id = "vbproj"
autoRegister = "True"
icon = "${AddInPath:ICSharpCode.FiletypeRegisterer}/filetypes/prjx.ico"
text = "VB ${res:ICSharpCode.FiletypeRegisterer.Project}"/>
<FiletypeAssociation
id = "sdaddin"
autoRegister = "True"
icon = "${AddInPath:ICSharpCode.FiletypeRegisterer}/filetypes/addin.ico"
text = "SharpDevelop ${res:AddInManager.FileAssociation}"/>
<FiletypeAssociation
id = "cs"
icon = "${AddInPath:ICSharpCode.FiletypeRegisterer}/filetypes/cs.ico"
text = "${res:ICSharpCode.FiletypeRegisterer.CSharpSourceFileAssozisation}"/>
<FiletypeAssociation
id = "vb"
icon = "${AddInPath:ICSharpCode.FiletypeRegisterer}/filetypes/vb.ico"
text = "${res:ICSharpCode.FiletypeRegisterer.VBNetSourceFileAssozisation}"/>
<!--<FiletypeAssociation
id = "java"
icon = "${AddInPath:ICSharpCode.FiletypeRegisterer}/filetypes/java.ico"
text = "${res:ICSharpCode.FiletypeRegisterer.JavaSourceFileAssozisation}"/>-->
<FiletypeAssociation
id = "xfrm"
icon = "${AddInPath:ICSharpCode.FiletypeRegisterer}/filetypes/xfrm.ico"
text = "${res:ICSharpCode.FiletypeRegisterer.XMLFormFileAssozisation}"/>
<FiletypeAssociation
id = "resx"
icon = "${AddInPath:ICSharpCode.FiletypeRegisterer}/filetypes/resx.ico"
text = "${res:ICSharpCode.FiletypeRegisterer.ResXResourceFilesFileAssozisation}"/>
<FiletypeAssociation
id = "resources"
icon = "${AddInPath:ICSharpCode.FiletypeRegisterer}/filetypes/resx.ico"
text = "${res:ICSharpCode.FiletypeRegisterer.BinaryResourceFilesFileAssozisation}"/>
<FiletypeAssociation
id = "xml"
icon = "${AddInPath:ICSharpCode.FiletypeRegisterer}/filetypes/xml.ico"
text = "${res:ICSharpCode.FiletypeRegisterer.XmlFileAssozisation}"/>
<FiletypeAssociation
id = "cmbx"
icon = "${AddInPath:ICSharpCode.FiletypeRegisterer}/filetypes/cmbx.ico"
text = "SharpDevelop 1.x Combine"/>
<FiletypeAssociation
id = "prjx"
icon = "${AddInPath:ICSharpCode.FiletypeRegisterer}/filetypes/prjx.ico"
text = "SharpDevelop 1.x ${res:ICSharpCode.FiletypeRegisterer.Project}"/>
</Path>
<Path name = "/Workspace/Autostart"> <Path name = "/Workspace/Autostart">
<Condition name = "Compare" string = "${property:SharpDevelop.FiletypesRegisterStartup}" equals = "True"> <Condition name = "Compare" string = "${property:SharpDevelop.FiletypesRegisterStartup}" equals = "True">
<Class id = "RegisterFiletypes" <Class id = "RegisterFiletypes"

4
src/AddIns/Misc/FiletypeRegisterer/Project/FiletypeRegisterer.csproj

@ -46,9 +46,6 @@
<None Include="filetypes\cmbx.ico"> <None Include="filetypes\cmbx.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<None Include="filetypes\Filetypes.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="filetypes\java.ico"> <None Include="filetypes\java.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
@ -67,6 +64,7 @@
<None Include="filetypes\xml.ico"> <None Include="filetypes\xml.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<Compile Include="Src\FiletypeAssociationDoozer.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> <ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">

107
src/AddIns/Misc/FiletypeRegisterer/Project/Src/FiletypeAssociationDoozer.cs

@ -0,0 +1,107 @@
/*
* Created by SharpDevelop.
* User: Daniel Grunwald
* Date: 29.01.2006
* Time: 15:33
*/
using System;
using System.Collections;
using System.Collections.Generic;
using ICSharpCode.Core;
namespace ICSharpCode.FiletypeRegisterer
{
public class FiletypeAssociation
{
string id;
string icon;
string text;
bool isDefault;
public FiletypeAssociation(string id, string icon, string text, bool isDefault)
{
this.id = id;
this.icon = icon;
this.text = text;
this.isDefault = isDefault;
}
public string Extension {
get {
return id;
}
}
public string Icon {
get {
return icon;
}
}
public string Text {
get {
return text;
}
}
public bool IsDefault {
get {
return isDefault;
}
}
}
/// <summary>
/// Creates FiletypeAssociation instances.
/// </summary>
/// <attribute name="id" use="required">
/// The extension (without dot) to be registered.
/// </attribute>
/// <attribute name="icon" use="required">
/// The full path to a .ico file on the disk.
/// </attribute>
/// <attribute name="text" use="required">
/// The description text.
/// </attribute>
/// <attribute name="autoRegister" use="optional">
/// Boolean value that specifies if the file type is registered on every startup, even if another
/// application has already registered it. Default=false
/// </attribute>
/// <returns>
/// A FiletypeAssociation describing the specified values.
/// </returns>
public class FiletypeAssociationDoozer : IDoozer
{
public static List<FiletypeAssociation> GetList()
{
List<FiletypeAssociation> list = new List<FiletypeAssociation>();
foreach (FiletypeAssociation ass in AddInTree.BuildItems("/AddIns/FileTypeRegisterer/FileTypes", null, true)) {
list.Add(ass);
}
return list;
}
/// <summary>
/// Gets if the doozer handles codon conditions on its own.
/// If this property return false, the item is excluded when the condition is not met.
/// </summary>
public bool HandleConditions {
get {
return false;
}
}
/// <summary>
/// Creates an item with the specified sub items. And the current
/// Condition status for this item.
/// </summary>
public object BuildItem(object caller, Codon codon, ArrayList subItems)
{
return new FiletypeAssociation(codon.Id,
StringParser.Parse(codon.Properties["icon"]),
StringParser.Parse(codon.Properties["text"]),
bool.TrueString.Equals(codon.Properties["autoRegister"], StringComparison.OrdinalIgnoreCase));
}
}
}

82
src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesCommand.cs

@ -6,11 +6,10 @@
// </file> // </file>
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Drawing; using System.Text;
using System.Windows.Forms;
using System.Reflection; using System.Reflection;
using System.Xml;
using Microsoft.Win32; using Microsoft.Win32;
@ -31,78 +30,67 @@ namespace ICSharpCode.FiletypeRegisterer {
const int SHCNE_ASSOCCHANGED = 0x08000000; const int SHCNE_ASSOCCHANGED = 0x08000000;
const int SHCNF_IDLIST = 0x0; const int SHCNF_IDLIST = 0x0;
public static string DefaultExtensions = "sln|csproj|vbproj|booproj"; public static string GetDefaultExtensions(List<FiletypeAssociation> list)
public static string[,] GetFileTypes()
{ {
try { StringBuilder b = new StringBuilder();
foreach (FiletypeAssociation a in list) {
XmlDocument doc = new XmlDocument(); if (a.IsDefault) {
if (b.Length > 0)
doc.Load(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "filetypes\\Filetypes.xml")); b.Append('|');
b.Append(a.Extension);
XmlNodeList nodes = doc.DocumentElement.ChildNodes;
string[,] ret = new string[doc.DocumentElement.ChildNodes.Count, 3];
for(int i = 0; i < nodes.Count; ++i) {
if (nodes[i].NodeType == XmlNodeType.Comment)
continue;
XmlElement el = (XmlElement)nodes[i];
ret[i, 0] = el.InnerText;
ret[i, 1] = el.Attributes["ext"].InnerText;
ret[i, 2] = el.Attributes["icon"].InnerText;
} }
return ret;
} catch (Exception ex) {
MessageService.ShowError(ex);
return new string[0, 0];
} }
return b.ToString();
} }
public override void Run() public override void Run()
{ {
List<FiletypeAssociation> list = FiletypeAssociationDoozer.GetList();
// register Combine and Project by default // register Combine and Project by default
RegisterFiletypes(PropertyService.Get(uiFiletypesProperty, DefaultExtensions)); RegisterFiletypes(list, PropertyService.Get(uiFiletypesProperty, GetDefaultExtensions(list)));
RegisterUnknownFiletypes(); RegisterUnknownFiletypes(list);
} }
public static void RegisterFiletypes(string types) public static void RegisterFiletypes(List<FiletypeAssociation> allTypes, string types)
{ {
string[] singleTypes = types.Split('|'); string[] singleTypes = types.Split('|');
string mainExe = Assembly.GetEntryAssembly().Location; string mainExe = Assembly.GetEntryAssembly().Location;
string[,] FileTypes = GetFileTypes();
string resPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "filetypes") + Path.DirectorySeparatorChar; foreach (FiletypeAssociation type in allTypes) {
foreach(string type in singleTypes) { if (Array.IndexOf(singleTypes, type.Extension) >= 0) {
for(int i = 0; i < FileTypes.GetLength(0); ++i) { RegisterFiletype(type.Extension,
if(FileTypes[i, 1] == type) { type.Text,
RegisterFiletype(type, FileTypes[i, 0], '"' + Path.GetFullPath(mainExe) + '"' + " \"%1\"", Path.GetFullPath(resPath + FileTypes[i, 2])); '"' + Path.GetFullPath(mainExe) + '"' + " \"%1\"",
} Path.GetFullPath(type.Icon));
} }
} }
} }
public static void RegisterUnknownFiletypes() public static void RegisterUnknownFiletypes(List<FiletypeAssociation> allTypes)
{ {
string mainExe = Assembly.GetEntryAssembly().Location; string mainExe = Assembly.GetEntryAssembly().Location;
string[,] FileTypes = GetFileTypes();
string resPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "filetypes") + Path.DirectorySeparatorChar; string resPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "filetypes") + Path.DirectorySeparatorChar;
for(int i = 0; i < FileTypes.GetLength(0); ++i) { foreach (FiletypeAssociation type in allTypes) {
if (FileTypes[i, 0] == null) continue; if (!IsRegisteredFileType(type.Extension)) {
if (!IsRegisteredFileType(FileTypes[i, 1])) { RegisterFiletype(type.Extension,
RegisterFiletype(FileTypes[i, 1], FileTypes[i, 0], '"' + Path.GetFullPath(mainExe) + '"' + " \"%1\"", Path.GetFullPath(resPath + FileTypes[i, 2])); type.Text,
'"' + Path.GetFullPath(mainExe) + '"' + " \"%1\"",
Path.GetFullPath(type.Icon));
} }
} }
} }
public static bool IsRegisteredFileType(string extension) public static bool IsRegisteredFileType(string extension)
{ {
RegistryKey key = Registry.ClassesRoot.OpenSubKey("." + extension); using (RegistryKey key = Registry.ClassesRoot.OpenSubKey("." + extension)) {
if (key == null) if (key != null)
return false; return true;
key.Close(); }
return true; using (RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Classes\\." + extension)) {
return key != null;
}
} }
public static void RegisterFiletype(string extension, string description, string command, string icon) public static void RegisterFiletype(string extension, string description, string command, string icon)

18
src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesPanel.cs

@ -11,6 +11,7 @@ using System;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using ICSharpCode.SharpDevelop.Internal.ExternalTool; using ICSharpCode.SharpDevelop.Internal.ExternalTool;
using ICSharpCode.Core; using ICSharpCode.Core;
@ -28,13 +29,17 @@ namespace ICSharpCode.FiletypeRegisterer
Hashtable wasChecked = new Hashtable(); Hashtable wasChecked = new Hashtable();
List<FiletypeAssociation> allTypes;
public RegisterFiletypesPanel() public RegisterFiletypesPanel()
{ {
allTypes = FiletypeAssociationDoozer.GetList();
// Initialize dialog controls // Initialize dialog controls
InitializeComponent(); InitializeComponent();
// Set previous values // Set previous values
SelectFiletypes(PropertyService.Get(RegisterFiletypesCommand.uiFiletypesProperty, RegisterFiletypesCommand.DefaultExtensions)); SelectFiletypes(PropertyService.Get(RegisterFiletypesCommand.uiFiletypesProperty, RegisterFiletypesCommand.GetDefaultExtensions(allTypes)));
regChk.Checked = PropertyService.Get(RegisterFiletypesCommand.uiRegisterStartupProperty, true); regChk.Checked = PropertyService.Get(RegisterFiletypesCommand.uiRegisterStartupProperty, true);
} }
@ -42,7 +47,7 @@ namespace ICSharpCode.FiletypeRegisterer
{ {
if (message == DialogMessage.OK) { if (message == DialogMessage.OK) {
UnRegisterFiletypes(); UnRegisterFiletypes();
RegisterFiletypesCommand.RegisterFiletypes(SelectedFiletypes); RegisterFiletypesCommand.RegisterFiletypes(allTypes, SelectedFiletypes);
PropertyService.Set(RegisterFiletypesCommand.uiFiletypesProperty, SelectedFiletypes); PropertyService.Set(RegisterFiletypesCommand.uiFiletypesProperty, SelectedFiletypes);
PropertyService.Set(RegisterFiletypesCommand.uiRegisterStartupProperty, regChk.Checked); PropertyService.Set(RegisterFiletypesCommand.uiRegisterStartupProperty, regChk.Checked);
} }
@ -112,13 +117,10 @@ namespace ICSharpCode.FiletypeRegisterer
void FillList(ListView list) void FillList(ListView list)
{ {
string[,] Items = RegisterFiletypesCommand.GetFileTypes(); foreach (FiletypeAssociation type in allTypes) {
for(int i = 0; i < Items.GetLength(0); ++i) {
if (Items[i, 0] == null) continue;
ListViewItem lv; ListViewItem lv;
lv = new ListViewItem(StringParser.Parse(Items[i, 0]) + " (." + Items[i, 1] + ")"); lv = new ListViewItem(type.Text + " (." + type.Extension + ")");
lv.Tag = Items[i, 1]; lv.Tag = type.Extension;
list.Items.Add(lv); list.Items.Add(lv);
} }
} }

17
src/AddIns/Misc/FiletypeRegisterer/Project/filetypes/Filetypes.xml

@ -1,17 +0,0 @@
<?xml version="1.0" ?>
<Filetypes>
<Filetype ext="cmbx" icon="cmbx.ico">SharpDevelop 1.x Combine</Filetype>
<Filetype ext="prjx" icon="prjx.ico">SharpDevelop 1.x ${res:ICSharpCode.FiletypeRegisterer.Project}</Filetype>
<Filetype ext="sln" icon="cmbx.ico">${res:ICSharpCode.FiletypeRegisterer.SolutionFileAssozisation}</Filetype>
<Filetype ext="csproj" icon="prjx.ico">C# ${res:ICSharpCode.FiletypeRegisterer.Project}</Filetype>
<Filetype ext="vbproj" icon="prjx.ico">VB ${res:ICSharpCode.FiletypeRegisterer.Project}</Filetype>
<Filetype ext="booproj" icon="prjx.ico">Boo ${res:ICSharpCode.FiletypeRegisterer.Project}</Filetype>
<Filetype ext="sdaddin" icon="addin.ico">SharpDevelop ${res:AddInManager.FileAssociation}</Filetype>
<Filetype ext="cs" icon="cs.ico">${res:ICSharpCode.FiletypeRegisterer.CSharpSourceFileAssozisation}</Filetype>
<Filetype ext="vb" icon="vb.ico">${res:ICSharpCode.FiletypeRegisterer.VBNetSourceFileAssozisation}</Filetype>
<!--<Filetype ext="java" icon="java.ico">${res:ICSharpCode.FiletypeRegisterer.JavaSourceFileAssozisation}</Filetype>-->
<Filetype ext="xfrm" icon="xfrm.ico">${res:ICSharpCode.FiletypeRegisterer.XMLFormFileAssozisation}</Filetype>
<Filetype ext="resx" icon="resx.ico">${res:ICSharpCode.FiletypeRegisterer.ResXResourceFilesFileAssozisation}</Filetype>
<Filetype ext="resources" icon="resx.ico">${res:ICSharpCode.FiletypeRegisterer.BinaryResourceFilesFileAssozisation}</Filetype>
<Filetype ext="xml" icon="xml.ico">${res:ICSharpCode.FiletypeRegisterer.XmlFileAssozisation}</Filetype>
</Filetypes>

4
src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs

@ -317,9 +317,9 @@ namespace ICSharpCode.Core
/// A signed integer indicating the relative sort ranking /// A signed integer indicating the relative sort ranking
/// of item <paramref name="x"/> relative to item /// of item <paramref name="x"/> relative to item
/// <paramref name="y"/>. /// <paramref name="y"/>.
/// Return value greater than zero: x > y. /// Return value greater than zero: x &gt; y.
/// Return value is zero: x == y. /// Return value is zero: x == y.
/// Return value is less than zero: x \< y. /// Return value is less than zero: x &lt; y.
/// </returns> /// </returns>
public int Compare(object x, object y) { public int Compare(object x, object y) {
ListViewItem a = (ListViewItem)x; // List item a ListViewItem a = (ListViewItem)x; // List item a

3
src/Main/Core/Project/ICSharpCode.Core.csproj

@ -142,6 +142,7 @@
<Compile Include="Src\AddInTree\AddIn\AddInReference.cs" /> <Compile Include="Src\AddInTree\AddIn\AddInReference.cs" />
<Compile Include="Src\AddInTree\CoreStartup.cs" /> <Compile Include="Src\AddInTree\CoreStartup.cs" />
<Compile Include="Src\AddInTree\AddInManager.cs" /> <Compile Include="Src\AddInTree\AddInManager.cs" />
<Compile Include="Src\AddInTree\AddIn\DefaultDoozers\StringDoozer.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Src\Services\LoggingService" /> <Folder Include="Src\Services\LoggingService" />
@ -150,4 +151,4 @@
</Content> </Content>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
</Project> </Project>

17
src/Main/Core/Project/Src/AddInTree/AddIn/DefaultConditionEvaluators/CompareConditionEvaluator.cs

@ -23,14 +23,27 @@ namespace ICSharpCode.Core
/// <attribute name="equals"> /// <attribute name="equals">
/// The second string. /// The second string.
/// </attribute> /// </attribute>
/// <example title="Test if the browser is showing a HtmlHelp page"> /// <attribute name="comparisonType">
/// The mode of the comparison: a field of the System.StringComparison enumeration. The default is
/// 'InvariantCultureIgnoreCase'.
/// </attribute>
/// <example title="Check the value of a property in the PropertyService">
/// &lt;Condition name = "Compare" string = "${property:SharpDevelop.FiletypesRegisterStartup}" equals = "True"&gt; /// &lt;Condition name = "Compare" string = "${property:SharpDevelop.FiletypesRegisterStartup}" equals = "True"&gt;
/// </example> /// </example>
public class CompareConditionEvaluator : IConditionEvaluator public class CompareConditionEvaluator : IConditionEvaluator
{ {
public bool IsValid(object caller, Condition condition) public bool IsValid(object caller, Condition condition)
{ {
return StringParser.Parse(condition.Properties["string"]) == StringParser.Parse(condition.Properties["equals"]); string comparisonTypeText = condition.Properties["comparisonType"];
StringComparison comparisonType;
if (string.IsNullOrEmpty(comparisonTypeText))
comparisonType = StringComparison.InvariantCultureIgnoreCase;
else
comparisonType = (StringComparison)Enum.Parse(typeof(StringComparison), comparisonTypeText);
return string.Equals(StringParser.Parse(condition.Properties["string"]),
StringParser.Parse(condition.Properties["equals"]),
comparisonType);
} }
} }
} }

39
src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/StringDoozer.cs

@ -0,0 +1,39 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections;
namespace ICSharpCode.Core
{
/// <summary>
/// Creates a string.
/// </summary>
/// <attribute name="text" use="required">
/// The string to return.
/// </attribute>
/// <returns>
/// The string specified by 'text', passed through the StringParser.
/// </returns>
public class StringDoozer : IDoozer
{
/// <summary>
/// Gets if the doozer handles codon conditions on its own.
/// If this property return false, the item is excluded when the condition is not met.
/// </summary>
public bool HandleConditions {
get {
return false;
}
}
public object BuildItem(object caller, Codon codon, ArrayList subItems)
{
return StringParser.Parse(codon.Properties["text"]);
}
}
}

1
src/Main/Core/Project/Src/AddInTree/AddInTree.cs

@ -28,6 +28,7 @@ namespace ICSharpCode.Core
{ {
doozers.Add("Class", new ClassDoozer()); doozers.Add("Class", new ClassDoozer());
doozers.Add("FileFilter", new FileFilterDoozer()); doozers.Add("FileFilter", new FileFilterDoozer());
doozers.Add("String", new StringDoozer());
doozers.Add("Icon", new IconDoozer()); doozers.Add("Icon", new IconDoozer());
doozers.Add("MenuItem", new MenuItemDoozer()); doozers.Add("MenuItem", new MenuItemDoozer());
doozers.Add("ToolbarItem", new ToolbarItemDoozer()); doozers.Add("ToolbarItem", new ToolbarItemDoozer());

16
src/Main/Core/Project/Src/Services/StringParser/StringParser.cs

@ -195,20 +195,28 @@ namespace ICSharpCode.Core
if (k <= 0) if (k <= 0)
return null; return null;
string prefix = propertyName.Substring(0, k); string prefix = propertyName.Substring(0, k);
propertyName = propertyName.Substring(k + 1);
switch (prefix.ToUpperInvariant()) { switch (prefix.ToUpperInvariant()) {
case "ADDINPATH":
foreach (AddIn addIn in AddInTree.AddIns) {
if (addIn.Manifest.Identities.ContainsKey(propertyName)) {
return System.IO.Path.GetDirectoryName(addIn.FileName);
}
}
return null;
case "ENV": case "ENV":
return Environment.GetEnvironmentVariable(propertyName.Substring(k + 1)); return Environment.GetEnvironmentVariable(propertyName);
case "RES": case "RES":
try { try {
return Parse(ResourceService.GetString(propertyName.Substring(k + 1)), customTags); return Parse(ResourceService.GetString(propertyName), customTags);
} catch (ResourceNotFoundException) { } catch (ResourceNotFoundException) {
return null; return null;
} }
case "PROPERTY": case "PROPERTY":
return PropertyService.Get(propertyName.Substring(k + 1)); return PropertyService.Get(propertyName);
default: default:
if (propertyObjects.ContainsKey(prefix)) { if (propertyObjects.ContainsKey(prefix)) {
return Get(propertyObjects[prefix], propertyName.Substring(k + 1)); return Get(propertyObjects[prefix], propertyName);
} else { } else {
return null; return null;
} }

Loading…
Cancel
Save