* Makefile.am:
[monodevelop.git] / main / src / addins / MonoDevelop.DesignerSupport / MonoDevelop.DesignerSupport.Toolbox / TextToolboxNode.cs
blobb7c0bc82bcd8651d70e040c2e1080d37cbe2a07c
1 /*
2 * TextToolboxNode.cs - A ToolboxNode for text fragments
3 *
4 * Authors:
5 * Michael Hutchinson <m.j.hutchinson@gmail.com>
6 *
7 * Copyright (C) 2006 Michael Hutchinson
9 * This sourcecode is licenced under The MIT License:
11 * Permission is hereby granted, free of charge, to any person obtaining
12 * a copy of this software and associated documentation files (the
13 * "Software"), to deal in the Software without restriction, including
14 * without limitation the rights to use, copy, modify, merge, publish,
15 * distribute, sublicense, and/or sell copies of the Software, and to permit
16 * persons to whom the Software is furnished to do so, subject to the
17 * following conditions:
19 * The above copyright notice and this permission notice shall be included in
20 * all copies or substantial portions of the Software.
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
25 * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
26 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
27 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
28 * USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System;
32 using System.ComponentModel;
33 using MonoDevelop.Core;
35 namespace MonoDevelop.DesignerSupport.Toolbox
37 [Serializable]
38 public class TextToolboxNode : ItemToolboxNode, ITextToolboxNode
40 private string text = string.Empty;
41 string domain = MonoDevelop.Core.GettextCatalog.GetString ("Text Snippets");
43 public TextToolboxNode (string text)
45 Text = text;
46 ItemFilters.Add (new ToolboxItemFilterAttribute ("text/plain", ToolboxItemFilterType.Allow));
49 public override bool Filter (string keyword)
51 return base.Filter (keyword)
52 || ((Text==null)? false : (Text.IndexOf (keyword, StringComparison.InvariantCultureIgnoreCase) >= 0));
55 public override bool Equals (object o)
57 TextToolboxNode n = o as TextToolboxNode;
58 return n != null && text == n.text && base.Equals (o);
61 public override int GetHashCode ()
63 int code = base.GetHashCode ();
64 if (text != null)
65 code += text.GetHashCode ();
66 return code;
69 [LocalizedDescription ("The text that will be inserted into the document.")]
70 public string Text {
71 get { return text; }
72 set { text = value; }
75 public virtual string GetTextForFile (string path, MonoDevelop.Projects.Project project)
77 return text;
80 [Browsable(false)]
81 public override string ItemDomain {
82 get { return domain; }
85 public bool IsCompatibleWith (string fileName, MonoDevelop.Projects.Project project)
87 return true;