Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@novell.com>2010-03-17 15:35:28 +0300
committerLluis Sanchez <lluis@novell.com>2010-03-17 15:35:28 +0300
commit8fa37870e9cc22ffccdd494fa951b2c3807d7978 (patch)
treebda14806802947c51676c183b08f166878964c40 /main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes
parentf1a8582658af8aeb0f6fa459965a2e4d0684c347 (diff)
parent585086f0ea0a49166046bb8f48d2def87907d0e0 (diff)
Merged MD.Projects into MD.Core, and MD.Projects.Gui, MD.Core.Gui and MD.Components into MD.Ide.
svn path=/trunk/monodevelop/; revision=153730
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes')
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/CommandCategoryCodon.cs49
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/CommandCodon.cs204
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/CommandItemCodon.cs55
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/ItemSetCodon.cs72
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/LinkItemCodon.cs59
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/LocalCommandItemCodon.cs50
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/SchemeExtensionNode.cs109
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/SeparatorItemCodon.cs48
8 files changed, 646 insertions, 0 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/CommandCategoryCodon.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/CommandCategoryCodon.cs
new file mode 100644
index 0000000000..cf973ae9f0
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/CommandCategoryCodon.cs
@@ -0,0 +1,49 @@
+//
+// CommandCategoryCodon.cs
+//
+// Author:
+// Lluis Sanchez Gual
+//
+
+//
+// Copyright (C) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+using Mono.Addins;
+
+namespace MonoDevelop.Components.Commands.ExtensionNodes
+{
+ [ExtensionNode (Description="A command category")]
+ internal class CommandCategoryCodon : ExtensionNode
+ {
+ [NodeAttribute ("_name", true, "Name", Localizable=true)]
+ string name;
+
+ public string Name {
+ get {
+ return name;
+ }
+ }
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/CommandCodon.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/CommandCodon.cs
new file mode 100644
index 0000000000..b84dc02dff
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/CommandCodon.cs
@@ -0,0 +1,204 @@
+//
+// CommandCodon.cs
+//
+// Author:
+// Lluis Sanchez Gual
+//
+
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+using System.Collections;
+using MonoDevelop.Core;
+using MonoDevelop.Components.Commands;
+using Mono.Addins;
+using System.ComponentModel;
+
+namespace MonoDevelop.Components.Commands.ExtensionNodes
+{
+ [ExtensionNode (Description="A user interface command. The 'id' of the command must match the full name of an existing enumeration. An arbitrary string can also be used as an id for the command by just using '@' as prefix for the string.")]
+ internal class CommandCodon : TypeExtensionNode
+ {
+ [NodeAttribute ("_label", true, "Label", Localizable=true)]
+ string label;
+
+ [NodeAttribute ("_description", "Description of the command", Localizable=true)]
+ string _description;
+
+ [NodeAttribute ("shortcut", "Key combination that triggers the command. Control, Alt, Meta, Super and Shift modifiers can be specified using '+' as a separator. Multi-state key bindings can be specified using a '|' between the mode and accel. For example 'Control+D' or 'Control+X|Control+S'")]
+ string shortcut;
+
+ [NodeAttribute ("macShortcut", "Mac version of the shortcut. Format is that same as 'shortcut', but the 'Meta' modifier corresponds to the Command key.")]
+ string macShortcut;
+
+ [NodeAttribute("icon", "Icon of the command. The provided value must be a registered stock icon. A resource icon can also be specified using 'res:' as prefix for the name, for example: 'res:customIcon.png'")]
+ string icon;
+
+ [NodeAttribute("disabledVisible", "Set to 'false' if the command has to be hidden when disabled. 'true' by default.")]
+ bool disabledVisible = true;
+
+ [NodeAttribute("type", "Type of the command. It can be: normal (the default), check, radio or array.")]
+ string type = "normal";
+
+ [NodeAttribute("widget", "Class of the widget to create when type is 'custom'.")]
+ string widget = null;
+
+ [NodeAttribute("defaultHandler", "Class that handles this command. This property is optional.")]
+ string defaultHandler;
+
+ public override object CreateInstance ()
+ {
+ ActionType ct = ActionType.Normal;
+ bool isArray = false;
+ bool custom = false;
+ bool isAction = false;
+
+ foreach (string p in type.Split ('|')) {
+ switch (p) {
+ case "check":
+ ct = ActionType.Check;
+ if (isAction)
+ throw new InvalidOperationException ("Action type specified twice.");
+ isAction = true;
+ break;
+
+ case "radio":
+ ct = ActionType.Radio;
+ if (isAction)
+ throw new InvalidOperationException ("Action type specified twice.");
+ isAction = true;
+ break;
+
+ case "normal":
+ ct = ActionType.Normal;
+ if (isAction)
+ throw new InvalidOperationException ("Action type specified twice.");
+ isAction = true;
+ break;
+
+ case "custom":
+ if (widget == null)
+ throw new InvalidOperationException ("Widget type not specified in custom command.");
+ custom = true;
+ break;
+
+ case "array":
+ isArray = true;
+ break;
+
+ default:
+ throw new InvalidOperationException ("Unknown command type: " + p);
+ }
+ }
+
+ if (isAction && custom)
+ throw new InvalidOperationException ("Invalid command type combination: " + type);
+
+ Command cmd;
+
+ if (custom) {
+ if (isArray)
+ throw new InvalidOperationException ("Array custom commands are not allowed.");
+
+ CustomCommand ccmd = new CustomCommand ();
+ ccmd.Text = label;
+ ccmd.WidgetType = Addin.GetType (widget);
+ if (ccmd.WidgetType == null)
+ throw new InvalidOperationException ("Could not find command type '" + widget + "'.");
+ cmd = ccmd;
+ } else {
+ if (widget != null)
+ throw new InvalidOperationException ("Widget type can only be specified for custom commands.");
+
+ ActionCommand acmd = new ActionCommand ();
+ acmd.ActionType = ct;
+ acmd.CommandArray = isArray;
+
+ if (defaultHandler != null)
+ acmd.SetDefaultHandlerTypeInfo (Addin, defaultHandler);
+
+ cmd = acmd;
+ }
+
+ cmd.Id = ParseCommandId (this);
+ cmd.Text = StringParserService.Parse (label);
+ if ((_description != null) && (_description.Length > 0)){
+ cmd.Description = _description;
+ }
+ cmd.Description = cmd.Description;
+
+ if (icon != null)
+ cmd.Icon = GetStockId (Addin, icon);
+
+ cmd.AccelKey = KeyBindingManager.CanonicalizeBinding (PropertyService.IsMac? macShortcut : shortcut);
+
+ cmd.DisabledVisible = disabledVisible;
+
+ // Assign the category of the command
+ CommandCategoryCodon cat = Parent as CommandCategoryCodon;
+ if (cat != null)
+ cmd.Category = cat.Name;
+
+ return cmd;
+ }
+
+ internal static object ParseCommandId (ExtensionNode codon)
+ {
+ string id = codon.Id;
+ if (id.StartsWith ("@"))
+ return id.Substring (1);
+
+ return id;
+/* Type enumType = null;
+ string typeName = id;
+
+ int i = id.LastIndexOf (".");
+ if (i != -1)
+ typeName = id.Substring (0,i);
+
+ enumType = codon.Addin.GetType (typeName);
+
+ if (enumType == null)
+ enumType = Type.GetType (typeName);
+
+ if (enumType == null)
+ enumType = typeof(Command).Assembly.GetType (typeName);
+
+ if (enumType == null || !enumType.IsEnum)
+ throw new InvalidOperationException ("Could not find an enum type for the command '" + id + "'.");
+
+ try {
+ return Enum.Parse (enumType, id.Substring (i+1));
+ } catch {
+ throw new InvalidOperationException ("Could not find an enum value for the command '" + id + "'.");
+ }*/
+ }
+
+ internal static string GetStockId (RuntimeAddin addin, string icon)
+ {
+ return icon;
+ }
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/CommandItemCodon.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/CommandItemCodon.cs
new file mode 100644
index 0000000000..0c2768f18d
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/CommandItemCodon.cs
@@ -0,0 +1,55 @@
+//
+// CommandItemCodon.cs
+//
+// Author:
+// Lluis Sanchez Gual
+//
+
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using MonoDevelop.Components.Commands;
+using Mono.Addins;
+
+namespace MonoDevelop.Components.Commands.ExtensionNodes
+{
+ [ExtensionNode (Description="A command menu or toolbar item. The id of the element must match the id of a registered command.")]
+ internal class CommandItemCodon : InstanceExtensionNode
+ {
+ [NodeAttribute ("_label", "Label", Localizable=true)]
+ string label;
+
+ [NodeAttribute ("disabledVisible", "Visible when disabled")]
+ bool disabledVisible = true;
+
+ public override object CreateInstance ()
+ {
+ object id = CommandCodon.ParseCommandId (this);
+ return new CommandEntry (id, label, disabledVisible);
+ }
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/ItemSetCodon.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/ItemSetCodon.cs
new file mode 100644
index 0000000000..eeaa7f74ef
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/ItemSetCodon.cs
@@ -0,0 +1,72 @@
+//
+// ItemSetCodon.cs
+//
+// Author:
+// Lluis Sanchez Gual
+//
+
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using MonoDevelop.Components.Commands;
+using MonoDevelop.Core;
+using Mono.Addins;
+
+namespace MonoDevelop.Components.Commands.ExtensionNodes
+{
+ [ExtensionNode (Description="A submenu")]
+ internal class ItemSetCodon : InstanceExtensionNode
+ {
+ [NodeAttribute ("_label", "Label of the submenu", Localizable=true)]
+ string label;
+
+ [NodeAttribute("icon", "Icon of the submenu. The provided value must be a registered stock icon. A resource icon can also be specified using 'res:' as prefix for the name, for example: 'res:customIcon.png'")]
+ string icon;
+
+ [NodeAttribute("autohide", "Whether the submenu should be hidden when it contains no items.")]
+ bool autohide;
+
+ public override object CreateInstance ()
+ {
+ if (label == null) label = Id;
+
+ label = StringParserService.Parse (label);
+ if (icon != null) icon = CommandCodon.GetStockId (Addin, icon);
+ CommandEntrySet cset = new CommandEntrySet (label, icon);
+ cset.CommandId = Id;
+ cset.AutoHide = autohide;
+ foreach (InstanceExtensionNode e in ChildNodes) {
+ CommandEntry ce = e.CreateInstance () as CommandEntry;
+ if (ce != null)
+ cset.Add (ce);
+ else
+ throw new InvalidOperationException ("Invalid ItemSet child: " + e);
+ }
+ return cset;
+ }
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/LinkItemCodon.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/LinkItemCodon.cs
new file mode 100644
index 0000000000..c4b35fde16
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/LinkItemCodon.cs
@@ -0,0 +1,59 @@
+//
+// LinkItemCodon.cs
+//
+// Author:
+// Lluis Sanchez Gual
+//
+
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using MonoDevelop.Components.Commands;
+using MonoDevelop.Core;
+using Mono.Addins;
+
+namespace MonoDevelop.Components.Commands.ExtensionNodes
+{
+ [ExtensionNode (Description="A menu or toolbar item that opens an URL when activated")]
+ internal class LinkItemCodon : InstanceExtensionNode
+ {
+ [NodeAttribute ("_label", "Label of the item.", Localizable=true)]
+ string label;
+
+ [NodeAttribute ("link", "URL to open.")]
+ string link;
+
+// [XmlMemberAttribute("description")]
+// string description;
+
+ public override object CreateInstance ()
+ {
+ // FIXME: Use internal resource
+ return new LinkCommandEntry (label, link, "md-web-search-icon");
+ }
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/LocalCommandItemCodon.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/LocalCommandItemCodon.cs
new file mode 100644
index 0000000000..38250172be
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/LocalCommandItemCodon.cs
@@ -0,0 +1,50 @@
+//
+// LocalCommandItemCodon.cs
+//
+// Author:
+// Lluis Sanchez Gual
+//
+
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using MonoDevelop.Core;
+using MonoDevelop.Components.Commands;
+using Mono.Addins;
+
+namespace MonoDevelop.Components.Commands.ExtensionNodes
+{
+ [ExtensionNode (Description="Allows the definition of a complete command item inside a menu or toolbar description")]
+ internal class LocalCommandItemCodon : CommandCodon
+ {
+ public override object CreateInstance ()
+ {
+ Command cmd = (Command) base.CreateInstance ();
+ return new CommandEntry (cmd);
+ }
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/SchemeExtensionNode.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/SchemeExtensionNode.cs
new file mode 100644
index 0000000000..4d55f72f48
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/SchemeExtensionNode.cs
@@ -0,0 +1,109 @@
+// SchemeExtensionNode.cs
+//
+// Author:
+// Lluis Sanchez Gual
+//
+// Copyright (c) 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+//
+
+using System;
+using System.IO;
+using Mono.Addins;
+using System.Xml;
+using MonoDevelop.Core;
+
+namespace MonoDevelop.Components.Commands.ExtensionNodes
+{
+ internal class SchemeExtensionNode: ExtensionNode, KeyBindingScheme
+ {
+ [NodeAttribute ("_name", "Name of the key bindings scheme", Localizable=true)]
+ string name;
+
+ [NodeAttribute ("file", "Name of the key bindings file")]
+ string file;
+
+ [NodeAttribute ("forMac", "Whether the keybinding file is for Macs.")]
+ bool isForMac;
+
+ [NodeAttribute ("resource", "Name of the resource containing the key bindings file.")]
+ string resource;
+
+ KeyBindingSet cachedSet;
+
+ public string Name {
+ get { return name ?? Id; }
+ }
+
+ public string File {
+ get {
+ return file;
+ }
+ }
+
+ public string Resource {
+ get {
+ return resource;
+ }
+ }
+
+ public bool IsForMac {
+ get { return isForMac; }
+ }
+
+ public Stream GetKeyBindingsSchemeStream ()
+ {
+ if (!string.IsNullOrEmpty (file))
+ return System.IO.File.OpenRead (Addin.GetFilePath (file));
+ if (!string.IsNullOrEmpty (resource))
+ return Addin.GetResource (resource, true);
+ throw new InvalidOperationException ("File or resource name not specified");
+ }
+
+ public KeyBindingSet GetKeyBindingSet ()
+ {
+ if (cachedSet != null)
+ return cachedSet;
+
+ XmlTextReader reader = null;
+ Stream stream = null;
+
+ try {
+ stream = GetKeyBindingsSchemeStream ();
+ if (stream != null) {
+ reader = new XmlTextReader (stream);
+ cachedSet = new KeyBindingSet (KeyBindingService.DefaultKeyBindingSet);
+ cachedSet.LoadScheme (reader, Id);
+ return cachedSet;
+ }
+ } catch (Exception e) {
+ LoggingService.LogError ("Error reading keybindings definition '{0}' in addin '{1}'.\n {2}",
+ file ?? resource, Addin.Id, e.ToString ());
+ } finally {
+ if (reader != null)
+ reader.Close ();
+ if (stream != null)
+ stream.Close ();
+ }
+ return null;
+ }
+ }
+}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/SeparatorItemCodon.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/SeparatorItemCodon.cs
new file mode 100644
index 0000000000..c19e9fac86
--- /dev/null
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.Commands.ExtensionNodes/SeparatorItemCodon.cs
@@ -0,0 +1,48 @@
+//
+// SeparatorItemCodon.cs
+//
+// Author:
+// Lluis Sanchez Gual
+//
+
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using MonoDevelop.Components.Commands;
+using Mono.Addins;
+
+namespace MonoDevelop.Components.Commands.ExtensionNodes
+{
+ [ExtensionNode (Description="A separator menu or toolbar item")]
+ internal class SeparatorItemCodon : InstanceExtensionNode
+ {
+ public override object CreateInstance ()
+ {
+ return new CommandEntry (Command.Separator);
+ }
+ }
+}