diff --git a/data/schemas/AddIn.xsd b/data/schemas/AddIn.xsd index ec1f00a172..f65ba65caa 100644 --- a/data/schemas/AddIn.xsd +++ b/data/schemas/AddIn.xsd @@ -73,6 +73,7 @@ + @@ -94,6 +95,7 @@ + @@ -140,6 +142,7 @@ + @@ -203,7 +206,7 @@ - Creates object instances by invocing a type's parameterless constructor + Creates object instances by invocating a type's parameterless constructor via System.Reflection. @@ -298,6 +301,7 @@ + @@ -513,8 +517,9 @@ - Builds one or multiple items from another location in the addin tree. - This doozer can use the "item" OR the "path" attribute. + Includes one or multiple items from another location in the addin tree. + You can use the attribute "item" (to include a single item) OR the + attribute "path" (to include all items from the target path). @@ -566,6 +571,7 @@ + @@ -758,6 +764,26 @@ + + + + + + + The string to return. + + + + + + + + + + Creates a string. + + + @@ -800,6 +826,7 @@ + diff --git a/doc/technotes/ConditionList.html b/doc/technotes/ConditionList.html index 2272815da5..438700fe4d 100644 --- a/doc/technotes/ConditionList.html +++ b/doc/technotes/ConditionList.html @@ -5,7 +5,7 @@

Condition List

This file was generated by the tool 'BuildAddinDocumentation'. -It is based on SharpDevelop 2.0.0.783.

+It is based on SharpDevelop 2.0.0.1045.

  • ActiveContentExtension
  • ActiveViewContentUntitled @@ -135,8 +135,15 @@ It is based on SharpDevelop 2.0.0.783.

    The second string. + + comparisonType: + + The mode of the comparison: a field of the System.StringComparison enumeration. The default is + 'InvariantCultureIgnoreCase'. + + -

    Example: Test if the browser is showing a HtmlHelp page +

    Example: Check the value of a property in the PropertyService

                 <Condition name = "Compare" string = "${property:SharpDevelop.FiletypesRegisterStartup}" equals = "True">

    diff --git a/doc/technotes/DoozerList.html b/doc/technotes/DoozerList.html index c23a15e6f3..8438f0375f 100644 --- a/doc/technotes/DoozerList.html +++ b/doc/technotes/DoozerList.html @@ -5,7 +5,7 @@

    Doozer List

    This file was generated by the tool 'BuildAddinDocumentation'. -It is based on SharpDevelop 2.0.0.783.

    +It is based on SharpDevelop 2.0.0.1045.

    Class

    - Creates object instances by invocing a type's parameterless constructor + Creates object instances by invocating a type's parameterless constructor via System.Reflection.

    @@ -309,9 +310,9 @@ It is based on SharpDevelop 2.0.0.783.

    Example: Secondary display binding: Form designer

                 <Path name = "/SharpDevelop/Workbench/DisplayBindings">
    -              <DisplayBinding id  = "FormDesigner"
    +              <DisplayBinding id  = "FormsDesigner"
                                   type  = "Secondary"
    -                              class = "ICSharpCode.FormDesigner.FormDesignerSecondaryDisplayBinding"
    +                              class = "ICSharpCode.FormsDesigner.FormsDesignerSecondaryDisplayBinding"
                                   fileNamePattern = "\.(cs|vb)$" />
                 </Path>

    @@ -441,8 +442,9 @@ It is based on SharpDevelop 2.0.0.783.

    Include

    - Builds one or multiple items from another location in the addin tree. - This doozer can use the "item" OR the "path" attribute. + Includes one or multiple items from another location in the addin tree. + You can use the attribute "item" (to include a single item) OR the + attribute "path" (to include all items from the target path).

    @@ -765,6 +767,33 @@ It is based on SharpDevelop 2.0.0.783.

    +
    +

    String

    +

    + Creates a string. +

    + + + + + + + + + + + + + +
    Doozer name: + ICSharpCode.Core.StringDoozer

    Attributes:

    text: + required + The string to return. +

    Returns: + + The string specified by 'text', passed through the StringParser. +
    +

    SyntaxMode

    diff --git a/src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.addin b/src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.addin index 400fe7d28c..6a8cad543f 100644 --- a/src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.addin +++ b/src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.addin @@ -22,6 +22,16 @@ extensions = "*.boo"/> + + + + - + + + + + + + + + + + + + + + + + + + Always - - Always - Always @@ -67,6 +64,7 @@ Always + diff --git a/src/AddIns/Misc/FiletypeRegisterer/Project/Src/FiletypeAssociationDoozer.cs b/src/AddIns/Misc/FiletypeRegisterer/Project/Src/FiletypeAssociationDoozer.cs new file mode 100644 index 0000000000..ed6c934377 --- /dev/null +++ b/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; + } + } + } + + ///

    + /// Creates FiletypeAssociation instances. + /// + /// + /// The extension (without dot) to be registered. + /// + /// + /// The full path to a .ico file on the disk. + /// + /// + /// The description text. + /// + /// + /// Boolean value that specifies if the file type is registered on every startup, even if another + /// application has already registered it. Default=false + /// + /// + /// A FiletypeAssociation describing the specified values. + /// + public class FiletypeAssociationDoozer : IDoozer + { + public static List GetList() + { + List list = new List(); + foreach (FiletypeAssociation ass in AddInTree.BuildItems("/AddIns/FileTypeRegisterer/FileTypes", null, true)) { + list.Add(ass); + } + return list; + } + + /// + /// 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. + /// + public bool HandleConditions { + get { + return false; + } + } + + /// + /// Creates an item with the specified sub items. And the current + /// Condition status for this item. + /// + 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)); + } + } +} diff --git a/src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesCommand.cs b/src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesCommand.cs index 60931323ec..b6761c0cfc 100644 --- a/src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesCommand.cs +++ b/src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesCommand.cs @@ -6,11 +6,10 @@ // using System; +using System.Collections.Generic; using System.IO; -using System.Drawing; -using System.Windows.Forms; +using System.Text; using System.Reflection; -using System.Xml; using Microsoft.Win32; @@ -31,78 +30,67 @@ namespace ICSharpCode.FiletypeRegisterer { const int SHCNE_ASSOCCHANGED = 0x08000000; const int SHCNF_IDLIST = 0x0; - public static string DefaultExtensions = "sln|csproj|vbproj|booproj"; - - public static string[,] GetFileTypes() + public static string GetDefaultExtensions(List list) { - try { - - XmlDocument doc = new XmlDocument(); - - doc.Load(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "filetypes\\Filetypes.xml")); - - 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; + StringBuilder b = new StringBuilder(); + foreach (FiletypeAssociation a in list) { + if (a.IsDefault) { + if (b.Length > 0) + b.Append('|'); + b.Append(a.Extension); } - return ret; - } catch (Exception ex) { - MessageService.ShowError(ex); - return new string[0, 0]; } + return b.ToString(); } public override void Run() { + List list = FiletypeAssociationDoozer.GetList(); + // 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 allTypes, string types) { string[] singleTypes = types.Split('|'); string mainExe = Assembly.GetEntryAssembly().Location; - string[,] FileTypes = GetFileTypes(); - string resPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "filetypes") + Path.DirectorySeparatorChar; - foreach(string type in singleTypes) { - for(int i = 0; i < FileTypes.GetLength(0); ++i) { - if(FileTypes[i, 1] == type) { - RegisterFiletype(type, FileTypes[i, 0], '"' + Path.GetFullPath(mainExe) + '"' + " \"%1\"", Path.GetFullPath(resPath + FileTypes[i, 2])); - } + foreach (FiletypeAssociation type in allTypes) { + if (Array.IndexOf(singleTypes, type.Extension) >= 0) { + RegisterFiletype(type.Extension, + type.Text, + '"' + Path.GetFullPath(mainExe) + '"' + " \"%1\"", + Path.GetFullPath(type.Icon)); } } } - public static void RegisterUnknownFiletypes() + public static void RegisterUnknownFiletypes(List allTypes) { string mainExe = Assembly.GetEntryAssembly().Location; - string[,] FileTypes = GetFileTypes(); string resPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "filetypes") + Path.DirectorySeparatorChar; - for(int i = 0; i < FileTypes.GetLength(0); ++i) { - if (FileTypes[i, 0] == null) continue; - if (!IsRegisteredFileType(FileTypes[i, 1])) { - RegisterFiletype(FileTypes[i, 1], FileTypes[i, 0], '"' + Path.GetFullPath(mainExe) + '"' + " \"%1\"", Path.GetFullPath(resPath + FileTypes[i, 2])); + foreach (FiletypeAssociation type in allTypes) { + if (!IsRegisteredFileType(type.Extension)) { + RegisterFiletype(type.Extension, + type.Text, + '"' + Path.GetFullPath(mainExe) + '"' + " \"%1\"", + Path.GetFullPath(type.Icon)); } } } public static bool IsRegisteredFileType(string extension) { - RegistryKey key = Registry.ClassesRoot.OpenSubKey("." + extension); - if (key == null) - return false; - key.Close(); - return true; + using (RegistryKey key = Registry.ClassesRoot.OpenSubKey("." + extension)) { + if (key != null) + 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) diff --git a/src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesPanel.cs b/src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesPanel.cs index 164f0e59b6..6f84f8e4e1 100644 --- a/src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesPanel.cs +++ b/src/AddIns/Misc/FiletypeRegisterer/Project/Src/RegisterFiletypesPanel.cs @@ -11,6 +11,7 @@ using System; using System.Drawing; using System.Windows.Forms; using System.Collections; +using System.Collections.Generic; using ICSharpCode.SharpDevelop.Internal.ExternalTool; using ICSharpCode.Core; @@ -28,13 +29,17 @@ namespace ICSharpCode.FiletypeRegisterer Hashtable wasChecked = new Hashtable(); + List allTypes; + public RegisterFiletypesPanel() { + allTypes = FiletypeAssociationDoozer.GetList(); + // Initialize dialog controls InitializeComponent(); // 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); } @@ -42,7 +47,7 @@ namespace ICSharpCode.FiletypeRegisterer { if (message == DialogMessage.OK) { UnRegisterFiletypes(); - RegisterFiletypesCommand.RegisterFiletypes(SelectedFiletypes); + RegisterFiletypesCommand.RegisterFiletypes(allTypes, SelectedFiletypes); PropertyService.Set(RegisterFiletypesCommand.uiFiletypesProperty, SelectedFiletypes); PropertyService.Set(RegisterFiletypesCommand.uiRegisterStartupProperty, regChk.Checked); } @@ -112,13 +117,10 @@ namespace ICSharpCode.FiletypeRegisterer void FillList(ListView list) { - string[,] Items = RegisterFiletypesCommand.GetFileTypes(); - - for(int i = 0; i < Items.GetLength(0); ++i) { - if (Items[i, 0] == null) continue; + foreach (FiletypeAssociation type in allTypes) { ListViewItem lv; - lv = new ListViewItem(StringParser.Parse(Items[i, 0]) + " (." + Items[i, 1] + ")"); - lv.Tag = Items[i, 1]; + lv = new ListViewItem(type.Text + " (." + type.Extension + ")"); + lv.Tag = type.Extension; list.Items.Add(lv); } } diff --git a/src/AddIns/Misc/FiletypeRegisterer/Project/filetypes/Filetypes.xml b/src/AddIns/Misc/FiletypeRegisterer/Project/filetypes/Filetypes.xml deleted file mode 100644 index 8861655dbb..0000000000 --- a/src/AddIns/Misc/FiletypeRegisterer/Project/filetypes/Filetypes.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - SharpDevelop 1.x Combine - SharpDevelop 1.x ${res:ICSharpCode.FiletypeRegisterer.Project} - ${res:ICSharpCode.FiletypeRegisterer.SolutionFileAssozisation} - C# ${res:ICSharpCode.FiletypeRegisterer.Project} - VB ${res:ICSharpCode.FiletypeRegisterer.Project} - Boo ${res:ICSharpCode.FiletypeRegisterer.Project} - SharpDevelop ${res:AddInManager.FileAssociation} - ${res:ICSharpCode.FiletypeRegisterer.CSharpSourceFileAssozisation} - ${res:ICSharpCode.FiletypeRegisterer.VBNetSourceFileAssozisation} - - ${res:ICSharpCode.FiletypeRegisterer.XMLFormFileAssozisation} - ${res:ICSharpCode.FiletypeRegisterer.ResXResourceFilesFileAssozisation} - ${res:ICSharpCode.FiletypeRegisterer.BinaryResourceFilesFileAssozisation} - ${res:ICSharpCode.FiletypeRegisterer.XmlFileAssozisation} - diff --git a/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs b/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs index ac34131964..ec7c9ea89c 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskView.cs +++ b/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 /// of item relative to item /// . - /// Return value greater than zero: x > y. + /// Return value greater than zero: x > y. /// Return value is zero: x == y. - /// Return value is less than zero: x \< y. + /// Return value is less than zero: x < y. /// public int Compare(object x, object y) { ListViewItem a = (ListViewItem)x; // List item a diff --git a/src/Main/Core/Project/ICSharpCode.Core.csproj b/src/Main/Core/Project/ICSharpCode.Core.csproj index d1907a2f31..bb723a5765 100644 --- a/src/Main/Core/Project/ICSharpCode.Core.csproj +++ b/src/Main/Core/Project/ICSharpCode.Core.csproj @@ -142,6 +142,7 @@ + @@ -150,4 +151,4 @@ - + \ No newline at end of file diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultConditionEvaluators/CompareConditionEvaluator.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultConditionEvaluators/CompareConditionEvaluator.cs index 14e7bad4ed..c419fdd5b6 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultConditionEvaluators/CompareConditionEvaluator.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultConditionEvaluators/CompareConditionEvaluator.cs @@ -23,14 +23,27 @@ namespace ICSharpCode.Core /// /// The second string. /// - /// + /// + /// The mode of the comparison: a field of the System.StringComparison enumeration. The default is + /// 'InvariantCultureIgnoreCase'. + /// + /// /// <Condition name = "Compare" string = "${property:SharpDevelop.FiletypesRegisterStartup}" equals = "True"> /// public class CompareConditionEvaluator : IConditionEvaluator { 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); } } } diff --git a/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/StringDoozer.cs b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/StringDoozer.cs new file mode 100644 index 0000000000..93b5bee058 --- /dev/null +++ b/src/Main/Core/Project/Src/AddInTree/AddIn/DefaultDoozers/StringDoozer.cs @@ -0,0 +1,39 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections; + +namespace ICSharpCode.Core +{ + /// + /// Creates a string. + /// + /// + /// The string to return. + /// + /// + /// The string specified by 'text', passed through the StringParser. + /// + public class StringDoozer : IDoozer + { + /// + /// 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. + /// + public bool HandleConditions { + get { + return false; + } + } + + public object BuildItem(object caller, Codon codon, ArrayList subItems) + { + return StringParser.Parse(codon.Properties["text"]); + } + } +} diff --git a/src/Main/Core/Project/Src/AddInTree/AddInTree.cs b/src/Main/Core/Project/Src/AddInTree/AddInTree.cs index bd216b5a20..aab1b61e04 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddInTree.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddInTree.cs @@ -28,6 +28,7 @@ namespace ICSharpCode.Core { doozers.Add("Class", new ClassDoozer()); doozers.Add("FileFilter", new FileFilterDoozer()); + doozers.Add("String", new StringDoozer()); doozers.Add("Icon", new IconDoozer()); doozers.Add("MenuItem", new MenuItemDoozer()); doozers.Add("ToolbarItem", new ToolbarItemDoozer()); diff --git a/src/Main/Core/Project/Src/Services/StringParser/StringParser.cs b/src/Main/Core/Project/Src/Services/StringParser/StringParser.cs index 947950ea2e..f5a20c42d9 100644 --- a/src/Main/Core/Project/Src/Services/StringParser/StringParser.cs +++ b/src/Main/Core/Project/Src/Services/StringParser/StringParser.cs @@ -195,20 +195,28 @@ namespace ICSharpCode.Core if (k <= 0) return null; string prefix = propertyName.Substring(0, k); + propertyName = propertyName.Substring(k + 1); 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": - return Environment.GetEnvironmentVariable(propertyName.Substring(k + 1)); + return Environment.GetEnvironmentVariable(propertyName); case "RES": try { - return Parse(ResourceService.GetString(propertyName.Substring(k + 1)), customTags); + return Parse(ResourceService.GetString(propertyName), customTags); } catch (ResourceNotFoundException) { return null; } case "PROPERTY": - return PropertyService.Get(propertyName.Substring(k + 1)); + return PropertyService.Get(propertyName); default: if (propertyObjects.ContainsKey(prefix)) { - return Get(propertyObjects[prefix], propertyName.Substring(k + 1)); + return Get(propertyObjects[prefix], propertyName); } else { return null; }