protected virtual void OnToolboxConsumerChanged(IToolboxConsumer consumer) { if (ToolboxConsumerChanged != null) { ToolboxConsumerChanged(this, new ToolboxConsumerChangedEventArgs(consumer)); } }
public IEnumerable <ItemToolboxNode> GetDynamicItems(IToolboxConsumer consumer) { var file = filePath; if (file.IsNullOrEmpty) { if (!(consumer is FileDocumentController content) || !consumer.IsTextEditor(out var _)) { yield break; } file = content.FilePath; } foreach (CodeTemplate ct in CodeTemplateService.GetCodeTemplatesForFile(file)) { if (ct.CodeTemplateContext != CodeTemplateContext.Standard) { continue; } yield return(new TemplateToolboxNode(ct) { Category = category, Icon = ImageService.GetIcon("md-template", Gtk.IconSize.Menu) }); } }
public bool IsSupported(ItemToolboxNode node, IToolboxConsumer consumer) { if (consumer is ICustomFilteringToolboxConsumer) { return(((ICustomFilteringToolboxConsumer)consumer).SupportsItem(node)); } //if something has no filters it is more useful and efficient //to show it for everything than to show it for nothing if (node.ItemFilters == null || node.ItemFilters.Count == 0) { return(true); } //check all of host's filters foreach (ToolboxItemFilterAttribute desFa in consumer.ToolboxFilterAttributes) { if (!FilterPermitted(node, desFa, node.ItemFilters, consumer)) { return(false); } } //check all of item's filters foreach (ToolboxItemFilterAttribute itemFa in node.ItemFilters) { if (!FilterPermitted(node, itemFa, consumer.ToolboxFilterAttributes, consumer)) { return(false); } } //we assume permitted, so only return false when blocked by a filter return(true); }
protected virtual void OnToolboxUsed(IToolboxConsumer consumer, ItemToolboxNode item) { if (ToolboxUsed != null) { ToolboxUsed(this, new ToolboxUsedEventArgs(consumer, item)); } }
public static bool IsTextView(this IToolboxConsumer consumer, out ITextView view) { if (consumer.DefaultItemDomain != "Text") { view = null; return(false); } view = GetDocument(consumer)?.GetContent <ITextView> (true); return(view != null); }
public System.Collections.Generic.IEnumerable<ItemToolboxNode> GetDynamicItems (IToolboxConsumer consumer) { var editor = consumer as IReadonlyTextDocument; if (editor != null) { foreach (CodeTemplate ct in CodeTemplateService.GetCodeTemplatesForFile (editor.FileName)) { if (ct.CodeTemplateContext != CodeTemplateContext.Standard) continue; yield return new TemplateToolboxNode (ct) { Category = category, Icon = ImageService.GetIcon ("md-template", Gtk.IconSize.Menu) }; } } yield break; }
public System.Collections.Generic.IEnumerable<ItemToolboxNode> GetDynamicItems (IToolboxConsumer consumer) { MonoDevelop.Ide.Gui.Content.IExtensibleTextEditor editor = consumer as MonoDevelop.Ide.Gui.Content.IExtensibleTextEditor; if (editor != null) { foreach (CodeTemplate ct in CodeTemplateService.GetCodeTemplatesForFile (editor.Name)) { if (ct.CodeTemplateContext != CodeTemplateContext.Standard) continue; yield return new TemplateToolboxNode (ct) { Category = category, Icon = ImageService.GetPixbuf ("md-template", Gtk.IconSize.Menu) }; } } yield break; }
private bool TryGetConsumer(out IToolboxConsumer toolboxConsumer) { if (cocoaTextView.Properties.TryGetProperty <DocumentController> (typeof(DocumentController), out var controller)) { if (controller.GetContent <IToolboxConsumer> () is IToolboxConsumer consumer) { var selectedItem = DesignerSupport.DesignerSupport.Service.ToolboxService.SelectedItem; if (DesignerSupport.DesignerSupport.Service.ToolboxService.IsSupported(selectedItem, consumer)) { toolboxConsumer = consumer; return(true); } } } toolboxConsumer = null; return(false); }
public System.Collections.Generic.IEnumerable<ItemToolboxNode> GetDynamicItems (IToolboxConsumer consumer) { var content = consumer as ViewContent; if (content == null || !content.IsFile) yield break; // Hack: Ensure that this category is only filled if the current page is a text editor. if (!(content is ITextEditorResolver)) yield break; foreach (CodeTemplate ct in CodeTemplateService.GetCodeTemplatesForFile (content.ContentName)) { if (ct.CodeTemplateContext != CodeTemplateContext.Standard) continue; yield return new TemplateToolboxNode (ct) { Category = category, Icon = ImageService.GetIcon ("md-template", Gtk.IconSize.Menu) }; } }
public IEnumerable <ItemToolboxNode> GetDynamicItems(IToolboxConsumer consumer) { var contentType = TextView?.TextBuffer?.ContentType; if (contentType == null) { yield break; } foreach (var template in Imports.ExpansionManager.EnumerateExpansions(contentType, false, null, true, false)) { yield return(new SnippetToolboxNode(template) { Category = category, Icon = ImageService.GetIcon("md-template", Gtk.IconSize.Menu) }); } }
public IEnumerable<ItemToolboxNode> GetDynamicItems (IToolboxConsumer consumer) { GuiBuilderView view = consumer as GuiBuilderView; if (view == null) return null; ComponentType[] types = view.GetComponentTypes (); if (types == null) return null; Hashtable refs = new Hashtable (); Hashtable projects = new Hashtable (); string of = FileService.GetFullPath (view.Project.GetOutputFileName (IdeApp.Workspace.ActiveConfiguration)); projects [of] = view.Project.Name; foreach (ProjectReference pr in ((DotNetProject)view.Project).References) foreach (string f in pr.GetReferencedFileNames (IdeApp.Workspace.ActiveConfiguration)) { if (pr.ReferenceType == ReferenceType.Project) projects[FileService.GetFullPath (f)] = pr.Reference; else refs[FileService.GetFullPath (f)] = f; } List<ItemToolboxNode> list = new List<ItemToolboxNode> (); foreach (ComponentType type in types) { if (type.Category == "window") continue; string fullName = null; if (!String.IsNullOrEmpty (type.Library)) fullName = FileService.GetFullPath (type.Library); if (type.ClassName == "Gtk.Action" || (fullName != null && refs.Contains (fullName))) { ComponentToolboxNode node = new ComponentToolboxNode (type); list.Add (node); } else if (fullName != null && projects.Contains (fullName)) { ComponentToolboxNode node = new ComponentToolboxNode (type); node.Category = (string) projects [fullName]; list.Add (node); } } list.Sort (); return list; }
public async Task <bool> Initialize(IToolboxConsumer currentConsumer) { using (ProgressMonitor monitor = new MessageDialogProgressMonitor(true, true, false, true)) { index = await DesignerSupport.Service.ToolboxService.GetComponentIndex(monitor); if (monitor.CancellationToken.IsCancellationRequested) { return(false); } } List <string> list = new List <string> (); foreach (ComponentIndexFile ifile in index.Files) { foreach (ItemToolboxNode co in ifile.Components) { if (!list.Contains(co.ItemDomain)) { list.Add(co.ItemDomain); } } } string defaultDomain = null; if (currentConsumer != null) { defaultDomain = currentConsumer.DefaultItemDomain; } for (int n = 0; n < list.Count; n++) { string s = list [n]; comboType.AppendText(s); if (s == defaultDomain) { comboType.Active = n + 1; } } return(true); }
public IList <ItemToolboxNode> GetToolboxItems(IToolboxConsumer consumer) { List <ItemToolboxNode> arr = new List <ItemToolboxNode> (); Hashtable nodes = new Hashtable(); if (consumer != null) { //get the user items foreach (ItemToolboxNode node in Configuration.ItemList) { //hide unknown nodes -- they're only there because deserialisation has failed, so they won't actually be usable if (!(node is UnknownToolboxNode)) { if (!nodes.Contains(node) && IsSupported(node, consumer)) { arr.Add(node); nodes.Add(node, node); } } } //merge the list of dynamic items from each provider foreach (IToolboxDynamicProvider prov in dynamicProviders) { IEnumerable <ItemToolboxNode> dynItems = prov.GetDynamicItems(consumer); if (dynItems != null) { foreach (ItemToolboxNode node in dynItems) { if (!nodes.Contains(node)) { arr.Add(node); nodes.Add(node, node); } } } } } //arr.Sort (); return(arr); }
public IEnumerable <ItemToolboxNode> GetDynamicItems(IToolboxConsumer consumer) { var content = consumer as ViewContent; if (content == null || !content.IsFile) { yield break; } if (!(content is ITextEditorResolver)) { yield break; } yield return(new TextToolboxNode("Test 1") { Category = "Test Toolbox Category", Name = "Test 1", Icon = ImageService.GetIcon("md-template", Gtk.IconSize.Menu) }); }
protected virtual void OnToolboxUsed (IToolboxConsumer consumer, ItemToolboxNode item) { if (ToolboxUsed != null) ToolboxUsed (this, new ToolboxUsedEventArgs (consumer, item)); }
protected virtual void OnToolboxConsumerChanged (IToolboxConsumer consumer) { if (ToolboxConsumerChanged != null) ToolboxConsumerChanged (this, new ToolboxConsumerChangedEventArgs (consumer)); }
public IList<ItemToolboxNode> GetToolboxItems (IToolboxConsumer consumer) { List<ItemToolboxNode> arr = new List<ItemToolboxNode> (); Hashtable nodes = new Hashtable (); if (consumer != null) { //get the user items foreach (ItemToolboxNode node in Configuration.ItemList) //hide unknown nodes -- they're only there because deserialisation has failed, so they won't actually be usable if ( !(node is UnknownToolboxNode)) if (!nodes.Contains (node) && IsSupported (node, consumer)) { arr.Add (node); nodes.Add (node, node); } //merge the list of dynamic items from each provider foreach (IToolboxDynamicProvider prov in dynamicProviders) { IEnumerable<ItemToolboxNode> dynItems = prov.GetDynamicItems (consumer); if (dynItems != null) { foreach (ItemToolboxNode node in dynItems) { if (!nodes.Contains (node)) { arr.Add (node); nodes.Add (node, node); } } } } } //arr.Sort (); return arr; }
public static bool IsTextView(this IToolboxConsumer consumer) => IsTextView(consumer, out _);
/// <summary> /// Returns true if the consumer is a text editor and can handle text toolbox nodes /// </summary> public static bool IsTextEditor(this IToolboxConsumer consumer, out TextEditor editor) { editor = consumer.DefaultItemDomain == "Text" ? GetDocument(consumer)?.Editor : null; return(editor != null); }
/// <summary> /// If the consumer is a ViewContent, get content from it by type /// </summary> public static T GetContent <T> (this IToolboxConsumer consumer) where T : class { return((consumer as ViewContent)?.GetContent <T> ()); }
public ToolboxConsumerChangedEventArgs (IToolboxConsumer consumer) { this.consumer = consumer; }
public async Task<bool> Initialize (IToolboxConsumer currentConsumer) { using (ProgressMonitor monitor = new MessageDialogProgressMonitor (true, true, false, true)) { index = await DesignerSupport.Service.ToolboxService.GetComponentIndex (monitor); if (monitor.CancellationToken.IsCancellationRequested) return false; } List<string> list = new List<string> (); foreach (ComponentIndexFile ifile in index.Files) { foreach (ItemToolboxNode co in ifile.Components) { if (!list.Contains (co.ItemDomain)) list.Add (co.ItemDomain); } } string defaultDomain = null; if (currentConsumer != null) defaultDomain = currentConsumer.DefaultItemDomain; for (int n = 0; n < list.Count; n++) { string s = list [n]; comboType.AppendText (s); if (s == defaultDomain) comboType.Active = n + 1; } return true; }
public IEnumerable <ItemToolboxNode> GetDynamicItems(IToolboxConsumer consumer) { DesignerPage view = consumer as DesignerPage; if (view == null) { return(null); } ComponentType[] types = view.GetComponentTypes(); if (types == null) { return(null); } Hashtable refs = new Hashtable(); Hashtable projects = new Hashtable(); string of = FileService.GetFullPath(view.Project.GetOutputFileName(IdeApp.Workspace.ActiveConfiguration)); projects [of] = view.Project.Name; foreach (ProjectReference pr in ((DotNetProject)view.Project).References) { foreach (string f in pr.GetReferencedFileNames(IdeApp.Workspace.ActiveConfiguration)) { if (pr.ReferenceType == ReferenceType.Project) { projects[FileService.GetFullPath(f)] = pr.Reference; } else { refs[FileService.GetFullPath(f)] = f; } } } List <ItemToolboxNode> list = new List <ItemToolboxNode> (); foreach (ComponentType type in types) { if (type.Category == "window") { continue; } string fullName = null; if (!String.IsNullOrEmpty(type.Library)) { fullName = FileService.GetFullPath(type.Library); } if (type.ClassName == "Gtk.Action" || (fullName != null && refs.Contains(fullName))) { ComponentToolboxNode node = new ComponentToolboxNode(type); list.Add(node); } else if (fullName != null && projects.Contains(fullName)) { ComponentToolboxNode node = new ComponentToolboxNode(type); node.Category = (string)projects [fullName]; list.Add(node); } } list.Sort(); return(list); }
public abstract IEnumerable<ItemToolboxNode> GetDynamicItems(IToolboxConsumer consumer);
public System.Collections.Generic.IEnumerable <ItemToolboxNode> GetDynamicItems(IToolboxConsumer consumer) { var editor = consumer as IReadonlyTextDocument; if (editor != null) { foreach (CodeTemplate ct in CodeTemplateService.GetCodeTemplatesForFile(editor.FileName)) { if (ct.CodeTemplateContext != CodeTemplateContext.Standard) { continue; } yield return(new TemplateToolboxNode(ct) { Category = category, Icon = ImageService.GetIcon("md-template", Gtk.IconSize.Menu) }); } } yield break; }
public bool IsSupported (ItemToolboxNode node, IToolboxConsumer consumer) { if (consumer is ICustomFilteringToolboxConsumer) return ((ICustomFilteringToolboxConsumer)consumer).SupportsItem (node); //if something has no filters it is more useful and efficient //to show it for everything than to show it for nothing if (node.ItemFilters == null || node.ItemFilters.Count == 0) return true; //check all of host's filters foreach (ToolboxItemFilterAttribute desFa in consumer.ToolboxFilterAttributes) { if (!FilterPermitted (node, desFa, node.ItemFilters, consumer)) return false; } //check all of item's filters foreach (ToolboxItemFilterAttribute itemFa in node.ItemFilters) { if (!FilterPermitted (node, itemFa, consumer.ToolboxFilterAttributes, consumer)) return false; } //we assume permitted, so only return false when blocked by a filter return true; }
public System.Collections.Generic.IEnumerable <ItemToolboxNode> GetDynamicItems(IToolboxConsumer consumer) { var content = consumer as ViewContent; if (content == null || !content.IsFile) { yield break; } // Hack: Ensure that this category is only filled if the current page is a text editor. if (!(content is ITextEditorResolver)) { yield break; } foreach (CodeTemplate ct in CodeTemplateService.GetCodeTemplatesForFile(content.ContentName)) { if (ct.CodeTemplateContext != CodeTemplateContext.Standard) { continue; } yield return(new TemplateToolboxNode(ct) { Category = category, Icon = ImageService.GetIcon("md-template", Gtk.IconSize.Menu) }); } }
//evaluate a filter attribute against a list, and check whether permitted private bool FilterPermitted (ItemToolboxNode node, ToolboxItemFilterAttribute desFa, ICollection<ToolboxItemFilterAttribute> filterAgainst, IToolboxConsumer consumer) { switch (desFa.FilterType) { case ToolboxItemFilterType.Allow: //this is really for matching some other filter string against return true; case ToolboxItemFilterType.Custom: return consumer.CustomFilterSupports (node); case ToolboxItemFilterType.Prevent: //if host and toolboxitem have same filterstring, then not permitted foreach (ToolboxItemFilterAttribute itemFa in filterAgainst) if (desFa.Match (itemFa)) return false; return true; case ToolboxItemFilterType.Require: //if host and toolboxitem have same filterstring, then permitted, unless one is prevented foreach (ToolboxItemFilterAttribute itemFa in filterAgainst) if (desFa.Match (itemFa) && (desFa.FilterType != ToolboxItemFilterType.Prevent)) return true; return false; } throw new InvalidOperationException ("Unexpected ToolboxItemFilterType value."); }
public System.Collections.Generic.IEnumerable <ItemToolboxNode> GetDynamicItems(IToolboxConsumer consumer) { MonoDevelop.Ide.Gui.Content.IExtensibleTextEditor editor = consumer as MonoDevelop.Ide.Gui.Content.IExtensibleTextEditor; if (editor != null) { foreach (CodeTemplate ct in CodeTemplateService.GetCodeTemplatesForFile(editor.Name)) { if (ct.CodeTemplateContext != CodeTemplateContext.Standard) { continue; } yield return(new TemplateToolboxNode(ct) { Category = category, Icon = ImageService.GetPixbuf("md-template", Gtk.IconSize.Menu) }); } } yield break; }
public ToolboxUsedEventArgs (IToolboxConsumer consumer, ItemToolboxNode item) { this.item = item; this.consumer = consumer; }
public IEnumerable<ItemToolboxNode> GetDynamicItems (IToolboxConsumer consumer) { foreach (TextToolboxNode item in clipboardRing) yield return item; //FIXME: make this work again // CategoryToolboxNode category = new CategoryToolboxNode (GettextCatalog.GetString ("Clipboard ring")); // category.IsDropTarget = false; // category.CanIconizeItems = false; // category.IsSorted = false; // foreach (TextToolboxNode item in clipboardRing) { // category.Add (item); // } // // if (clipboardRing.Count == 0) { // TextToolboxNode item = new TextToolboxNode (null); // item.Category = GettextCatalog.GetString ("Clipboard ring"); // item.Name = null; // //category.Add (item); // } // return new BaseToolboxNode [] { category }; }
/// <summary> /// If the consumer is a ViewContent, returns its parent Document /// </summary> public static Document GetDocument(this IToolboxConsumer consumer) { return((consumer as ViewContent)?.WorkbenchWindow?.Document); }
/// <summary> /// If the consumer is a ViewContent, returns its parent Document /// </summary> public static Document GetDocument(this IToolboxConsumer consumer) { return((consumer as DocumentController)?.Document); }
//evaluate a filter attribute against a list, and check whether permitted private bool FilterPermitted(ItemToolboxNode node, ToolboxItemFilterAttribute desFa, ICollection <ToolboxItemFilterAttribute> filterAgainst, IToolboxConsumer consumer) { switch (desFa.FilterType) { case ToolboxItemFilterType.Allow: //this is really for matching some other filter string against return(true); case ToolboxItemFilterType.Custom: return(consumer.CustomFilterSupports(node)); case ToolboxItemFilterType.Prevent: //if host and toolboxitem have same filterstring, then not permitted foreach (ToolboxItemFilterAttribute itemFa in filterAgainst) { if (desFa.Match(itemFa)) { return(false); } } return(true); case ToolboxItemFilterType.Require: //if host and toolboxitem have same filterstring, then permitted, unless one is prevented foreach (ToolboxItemFilterAttribute itemFa in filterAgainst) { if (desFa.Match(itemFa) && (desFa.FilterType != ToolboxItemFilterType.Prevent)) { return(true); } } return(false); } throw new InvalidOperationException("Unexpected ToolboxItemFilterType value."); }
public override IEnumerable<ItemToolboxNode> GetDynamicItems(IToolboxConsumer consumer) { foreach (ItemToolboxNode item in toolboxItems) { item.Category = GettextCatalog.GetString ("Class Diagram"); yield return item; } }
public ComponentSelectorDialog (IToolboxConsumer currentConsumer) { using (IProgressMonitor monitor = new MessageDialogProgressMonitor (true, true, false, true)) { index = DesignerSupport.Service.ToolboxService.GetComponentIndex (monitor); } this.Build(); store = new TreeStore (typeof(bool), typeof(string), typeof(string), typeof(string), typeof(string), typeof(Gdk.Pixbuf), typeof(ItemToolboxNode), typeof(bool), typeof(int)); TreeViewColumn col; col = new TreeViewColumn (); Gtk.CellRendererToggle crt = new CellRendererToggle (); col.PackStart (crt, false); col.AddAttribute (crt, "active", ColChecked); col.AddAttribute (crt, "visible", ColShowCheck); crt.Toggled += OnToggleItem; col.SortColumnId = ColChecked; listView.AppendColumn (col); col = new TreeViewColumn (); col.Spacing = 3; col.Title = GettextCatalog.GetString ("Name"); var crp = new CellRendererPixbuf (); CellRendererText crx = new CellRendererText (); crx.Width = 150; col.PackStart (crp, false); col.PackStart (crx, false); col.AddAttribute (crp, "pixbuf", ColIcon); col.AddAttribute (crp, "visible", ColShowCheck); col.AddAttribute (crx, "text", ColName); col.AddAttribute (crx, "weight", ColBold); listView.AppendColumn (col); col.Resizable = true; col.SortColumnId = ColName; col = listView.AppendColumn (GettextCatalog.GetString ("Library"), new CellRendererText (), "text", ColLibrary); col.Resizable = true; col.SortColumnId = ColLibrary; col = listView.AppendColumn (GettextCatalog.GetString ("Location"), new CellRendererText (), "text", ColPath); col.Resizable = true; col.SortColumnId = ColPath; store.SetSortColumnId (ColName, SortType.Ascending); listView.SearchColumn = ColName; listView.Model = store; foreach (ItemToolboxNode it in DesignerSupport.Service.ToolboxService.UserItems) currentItems [it] = it; List<string> list = new List<string> (); foreach (ComponentIndexFile ifile in index.Files) { foreach (ItemToolboxNode co in ifile.Components) { if (!list.Contains (co.ItemDomain)) list.Add (co.ItemDomain); } } string defaultDomain = null; if (currentConsumer != null) defaultDomain = currentConsumer.DefaultItemDomain; comboType.AppendText (GettextCatalog.GetString ("All")); comboType.Active = 0; for (int n=0; n<list.Count; n++) { string s = list [n]; comboType.AppendText (s); if (s == defaultDomain) comboType.Active = n+1; } }
public ToolboxConsumerChangedEventArgs(IToolboxConsumer consumer) { this.consumer = consumer; }
public ToolboxUsedEventArgs(IToolboxConsumer consumer, ItemToolboxNode item) { this.item = item; this.consumer = consumer; }
/// <summary> /// If the consumer is a ViewContent, get content from it by type /// </summary> public static T GetContent <T> (this IToolboxConsumer consumer) where T : class { return((consumer as DocumentController)?.GetContent <T> ()); }