internal void Shutdown () { AppDomain.CurrentDomain.AssemblyLoad -= new AssemblyLoadEventHandler (OnAssemblyLoaded); defaultContext = null; loadedAddins.Clear (); defaultContext = null; }
public SdiWorkspaceWindow (DefaultWorkbench workbench, IViewContent content, Notebook tabControl, TabLabel tabLabel) : base () { this.workbench = workbench; this.tabControl = tabControl; this.content = content; this.tabLabel = tabLabel; this.tabPage = content.Control; ShadowType = ShadowType.None; box = new VBox (); Add (box); box.PackStart (content.Control); fileTypeCondition.SetFileName (content.ContentName ?? content.UntitledName); extensionContext = AddinManager.CreateExtensionContext (); extensionContext.RegisterCondition ("FileType", fileTypeCondition); content.WorkbenchWindow = this; content.ContentNameChanged += new EventHandler(SetTitleEvent); content.DirtyChanged += new EventHandler(SetTitleEvent); content.BeforeSave += new EventHandler(BeforeSave); content.ContentChanged += new EventHandler (OnContentChanged); box.Show (); SetTitleEvent(null, null); commandHandler = new ViewCommandHandlers (this); Show (); }
protected override void InitializeContext (ExtensionContext extensionContext) { base.InitializeContext (extensionContext); extensionContext.RegisterCondition ("ItemType", new ItemTypeCondition (DataObject.GetType ())); extensionContext.RegisterCondition ("ActiveLanguage", new ProjectLanguageCondition (DataObject)); if (DataObject is Project) { extensionContext.RegisterCondition ("SupportsTarget", new SupportsTargetCondition ((Project)DataObject)); } }
internal void DisposeChildContext (ExtensionContext ctx) { lock (conditionTypes) { foreach (WeakReference wref in childContexts) { if (wref.Target == ctx) { childContexts.Remove (wref); return; } } } }
internal ExtensionContext CreateChildContext () { lock (conditionTypes) { if (childContexts == null) childContexts = new ArrayList (); ExtensionContext ctx = new ExtensionContext (); ctx.parentContext = this; WeakReference wref = new WeakReference (ctx); childContexts.Add (wref); return ctx; } }
internal void DisposeChildContext(ExtensionContext ctx) { lock (conditionTypes) { foreach (WeakReference wref in childContexts) { if (wref.Target == ctx) { childContexts.Remove(wref); return; } } } }
public WriterManager(string[] flags) { // Create a new extension context ctx = AddinManager.CreateExtensionContext (); // Register the flags condition in the new context FlagsCondition condition = new FlagsCondition (flags); ctx.RegisterCondition ("HasFlag", condition); ctx.AddExtensionNodeHandler ("/WriterService/Writers", delegate { if (Changed != null) Changed (this, EventArgs.Empty); }); }
internal ExtensionContext CreateChildContext() { lock (conditionTypes) { if (childContexts == null) { childContexts = new ArrayList(); } ExtensionContext ctx = new ExtensionContext(); ctx.parentContext = this; WeakReference wref = new WeakReference(ctx); childContexts.Add(wref); return(ctx); } }
public override bool Evaluate(ExtensionContext ctx) { if (!base.Evaluate(ctx)) { return(false); } foreach (BaseCondition cond in conditions) { if (!cond.Evaluate(ctx)) { return(false); } } return(true); }
internal void NotifyConditionChanged(ConditionType cond) { try { fireEvents = true; ConditionInfo info = (ConditionInfo)conditionTypes [cond.Id]; if (info != null && info.BoundConditions != null) { Hashtable parentsToNotify = new Hashtable(); foreach (BaseCondition c in info.BoundConditions) { ArrayList nodeList = (ArrayList)conditionsToNodes [c]; if (nodeList != null) { foreach (TreeNode node in nodeList) { parentsToNotify [node.Parent] = null; } } } foreach (TreeNode node in parentsToNotify.Keys) { if (node.NotifyChildrenChanged()) { NotifyExtensionsChanged(new ExtensionEventArgs(node.GetPath())); } } } } finally { fireEvents = false; } // Notify child contexts lock (conditionTypes) { if (childContexts != null) { foreach (WeakReference wref in childContexts) { ExtensionContext ctx = wref.Target as ExtensionContext; if (ctx != null) { ctx.NotifyConditionChanged(cond); } } } } }
internal void NotifyAddinLoaded(RuntimeAddin ad) { tree.NotifyAddinLoaded(ad, true); lock (conditionTypes) { if (childContexts != null) { foreach (WeakReference wref in childContexts) { ExtensionContext ctx = wref.Target as ExtensionContext; if (ctx != null) { ctx.NotifyAddinLoaded(ad); } } } } }
public OptionsDialog (Gtk.Window parentWindow, object dataObject, string extensionPath, bool removeEmptySections) { this.Build(); this.removeEmptySections = removeEmptySections; extensionContext = AddinManager.CreateExtensionContext (); this.mainDataObject = dataObject; this.extensionPath = extensionPath; if (parentWindow != null) TransientFor = parentWindow; store = new TreeStore (typeof(OptionsDialogSection), typeof(string), typeof(string), typeof(bool), typeof(string)); tree.Model = store; tree.HeadersVisible = false; TreeViewColumn col = new TreeViewColumn (); CellRendererIcon crp = new CellRendererIcon (); crp.StockSize = (uint) IconSize.Menu; col.PackStart (crp, false); col.AddAttribute (crp, "stock-id", 1); col.AddAttribute (crp, "visible", 3); col.AddAttribute (crp, "cell-background", 4); CellRendererText crt = new CellRendererText (); col.PackStart (crt, true); col.AddAttribute (crt, "markup", 2); col.AddAttribute (crt, "cell-background", 4); tree.AppendColumn (col); tree.Selection.Changed += OnSelectionChanged; Child.ShowAll (); InitializeContext (extensionContext); FillTree (); ExpandCategories (); this.DefaultResponse = Gtk.ResponseType.Ok; }
public OptionsDialog (Gtk.Window parentWindow, object dataObject, string extensionPath, bool removeEmptySections) { this.Build(); this.removeEmptySections = removeEmptySections; extensionContext = AddinManager.CreateExtensionContext (); this.mainDataObject = dataObject; this.extensionPath = extensionPath; if (parentWindow != null) TransientFor = parentWindow; ImageService.EnsureStockIconIsLoaded (emptyCategoryIcon, treeIconSize); ImageService.EnsureStockIconIsLoaded (emptyCategoryIcon, headerIconSize); store = new TreeStore (typeof(OptionsDialogSection)); tree.Model = store; tree.HeadersVisible = false; TreeViewColumn col = new TreeViewColumn (); var crp = new CellRendererPixbuf (); col.PackStart (crp, false); col.SetCellDataFunc (crp, PixbufCellDataFunc); var crt = new CellRendererText (); col.PackStart (crt, true); col.SetCellDataFunc (crt, TextCellDataFunc); tree.AppendColumn (col); tree.Selection.Changed += OnSelectionChanged; Child.ShowAll (); InitializeContext (extensionContext); FillTree (); ExpandCategories (); this.DefaultResponse = Gtk.ResponseType.Ok; }
public override bool Evaluate(ExtensionContext ctx) { if (!base.Evaluate(ctx)) { return(false); } ConditionType type = ctx.GetCondition(typeId); if (type == null) { AddinManager.ReportError("Condition '" + typeId + "' not found in current extension context.", null, null, false); return(false); } try { return(type.Evaluate(node)); } catch (Exception ex) { AddinManager.ReportError("Error while evaluating condition '" + typeId + "'", null, ex, false); return(false); } }
public ExtensionTree(ExtensionContext context) : base("") { this.context = context; }
public override bool Evaluate (ExtensionContext ctx) { if (!base.Evaluate (ctx)) return false; ConditionType type = ctx.GetCondition (typeId); if (type == null) { AddinManager.ReportError ("Condition '" + typeId + "' not found in current extension context.", null, null, false); return false; } try { return type.Evaluate (node); } catch (Exception ex) { AddinManager.ReportError ("Error while evaluating condition '" + typeId + "'", null, ex, false); return false; } }
internal void ActivateAddinExtensions(string id) { // Looks for loaded extension points which are extended by the provided // add-in, and adds the new nodes try { fireEvents = true; Addin addin = AddinManager.Registry.GetAddin(id); if (addin == null) { AddinManager.ReportError("Required add-in not found", id, null, false); return; } // Look for loaded extension points Hashtable eps = new Hashtable(); foreach (ModuleDescription mod in addin.Description.AllModules) { foreach (Extension ext in mod.Extensions) { ExtensionPoint ep = tree.FindExtensionPoint(ext.Path); if (ep != null && !eps.Contains(ep)) { eps.Add(ep, ep); } } } // Add the new nodes ArrayList loadedNodes = new ArrayList(); foreach (ExtensionPoint ep in eps.Keys) { ExtensionLoadData data = GetAddinExtensions(id, ep); if (data != null) { foreach (Extension ext in data.Extensions) { TreeNode node = GetNode(ext.Path); if (node != null && node.ExtensionNodeSet != null) { LoadModuleExtensionNodes(ext, data.AddinId, node.ExtensionNodeSet, loadedNodes); } else { AddinManager.ReportError("Extension node not found or not extensible: " + ext.Path, id, null, false); } } // Global extension change event. Other events are fired by LoadModuleExtensionNodes. NotifyExtensionsChanged(new ExtensionEventArgs(ep.Path)); } } // Call the OnAddinLoaded method on nodes, if the add-in is already loaded foreach (TreeNode nod in loadedNodes) { nod.ExtensionNode.OnAddinLoaded(); } } finally { fireEvents = false; } // Do the same in child contexts lock (conditionTypes) { if (childContexts != null) { foreach (WeakReference wref in childContexts) { ExtensionContext ctx = wref.Target as ExtensionContext; if (ctx != null) { ctx.ActivateAddinExtensions(id); } } } } }
protected override void OnDestroyed () { IsDestroyed = true; UnregisterAdjustments (); extensionContext = null; view = null; var disposableSyntaxMode = Document.SyntaxMode as IDisposable; if (disposableSyntaxMode != null) { disposableSyntaxMode.Dispose (); Document.SyntaxMode = null; } base.OnDestroyed (); if (Options != null) { Options.Dispose (); base.Options = null; } }
public override bool Evaluate (ExtensionContext ctx) { if (!base.Evaluate (ctx)) return false; foreach (BaseCondition cond in conditions) if (!cond.Evaluate (ctx)) return false; return true; }
public void ShowContextMenu (ExtensionContext ctx, string addinPath) { ShowContextMenu (CreateCommandEntrySet (ctx, addinPath)); }
public override bool Evaluate(ExtensionContext ctx) { return(!baseCond.Evaluate(ctx)); }
internal void Initialize () { defaultContext = new ExtensionContext (); ActivateRoots (); AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler (OnAssemblyLoaded); }
internal void Initialize() { defaultContext = new ExtensionContext(); ActivateRoots(); AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(OnAssemblyLoaded); }
internal void ActivateAddinExtensions(string id) { // Looks for loaded extension points which are extended by the provided // add-in, and adds the new nodes try { fireEvents = true; Addin addin = AddinManager.Registry.GetAddin(id); if (addin == null) { AddinManager.ReportError("Required add-in not found", id, null, false); return; } // Take note that this add-in has been enabled at run-time // Needed because loaded add-in descriptions may not include this add-in. RegisterRuntimeEnabledAddin(id); // Look for loaded extension points Hashtable eps = new Hashtable(); ArrayList newExtensions = new ArrayList(); foreach (ModuleDescription mod in addin.Description.AllModules) { foreach (Extension ext in mod.Extensions) { if (!newExtensions.Contains(ext.Path)) { newExtensions.Add(ext.Path); } ExtensionPoint ep = tree.FindLoadedExtensionPoint(ext.Path); if (ep != null && !eps.Contains(ep)) { eps.Add(ep, ep); } } } // Add the new nodes ArrayList loadedNodes = new ArrayList(); foreach (ExtensionPoint ep in eps.Keys) { ExtensionLoadData data = GetAddinExtensions(id, ep); if (data != null) { foreach (Extension ext in data.Extensions) { TreeNode node = GetNode(ext.Path); if (node != null && node.ExtensionNodeSet != null) { if (node.ChildrenLoaded) { LoadModuleExtensionNodes(ext, data.AddinId, node.ExtensionNodeSet, loadedNodes); } } else { AddinManager.ReportError("Extension node not found or not extensible: " + ext.Path, id, null, false); } } } } // Call the OnAddinLoaded method on nodes, if the add-in is already loaded foreach (TreeNode nod in loadedNodes) { nod.ExtensionNode.OnAddinLoaded(); } // Global extension change event. Other events are fired by LoadModuleExtensionNodes. // The event is called for all extensions, even for those not loaded. This is for coherence, // although that something that it doesn't make much sense to do (subcribing the ExtensionChanged // event without first getting the list of nodes that may change). foreach (string newExt in newExtensions) { NotifyExtensionsChanged(new ExtensionEventArgs(newExt)); } } finally { fireEvents = false; } // Do the same in child contexts lock (conditionTypes) { if (childContexts != null) { foreach (WeakReference wref in childContexts) { ExtensionContext ctx = wref.Target as ExtensionContext; if (ctx != null) { ctx.ActivateAddinExtensions(id); } } } } }
/// <summary> /// Shows a context menu. /// </summary> /// <param name='parent'> /// Widget for which the context menu is being shown /// </param> /// <param name='evt'> /// Current event object /// </param> /// <param name='ctx'> /// Extension context to use to query the extension path /// </param> /// <param name='addinPath'> /// Extension path to the definition of the menu /// </param> public void ShowContextMenu (Gtk.Widget parent, Gdk.EventButton evt, ExtensionContext ctx, string addinPath) { ShowContextMenu (parent, evt, CreateCommandEntrySet (ctx, addinPath)); }
protected virtual void InitializeContext (ExtensionContext extensionContext) { }
public override bool Evaluate (ExtensionContext ctx) { if (!base.Evaluate (ctx)) return false; if (!string.IsNullOrEmpty (addin)) { // Make sure the add-in that implements the condition is loaded addinEngine.LoadAddin (null, addin, true); addin = null; // Don't try again } ConditionType type = ctx.GetCondition (typeId); if (type == null) { addinEngine.ReportError ("Condition '" + typeId + "' not found in current extension context.", null, null, false); return false; } try { return type.Evaluate (node); } catch (Exception ex) { addinEngine.ReportError ("Error while evaluating condition '" + typeId + "'", null, ex, false); return false; } }
public override bool Evaluate (ExtensionContext ctx) { return !base.Evaluate (ctx); }
public override bool Evaluate(ExtensionContext ctx) { return(false); }
public ExtensionTree (ExtensionContext context): base ("") { this.context = context; }
public ExtensionTree(AddinEngine addinEngine, ExtensionContext context) : base(addinEngine, "") { this.context = context; }
public virtual bool Evaluate(ExtensionContext ctx) { return(parent == null || parent.Evaluate(ctx)); }
void CheckWriters(string test, ExtensionContext ctx, string path, params string[] values) { IWriter[] nodes; if (ctx != null) nodes = (IWriter[]) ctx.GetExtensionObjects (path, typeof(IWriter)); else nodes = (IWriter[]) AddinManager.GetExtensionObjects (path, typeof(IWriter)); Assert.AreEqual (nodes.Length, values.Length, test + " (count)"); for (int n=0; n<values.Length; n++) { Assert.AreEqual (values[n], nodes[n].Write(), test + " (result #" + n + ")"); } }
public virtual bool Evaluate (ExtensionContext ctx) { return parent == null || parent.Evaluate (ctx); }
public override bool Evaluate (ExtensionContext ctx) { return false; }
public OptionsDialog (Gtk.Window parentWindow, object dataObject, string extensionPath, bool removeEmptySections) { buttonCancel = new Gtk.Button (Gtk.Stock.Cancel); AddActionWidget (this.buttonCancel, ResponseType.Cancel); buttonOk = new Gtk.Button (Gtk.Stock.Ok); this.ActionArea.PackStart (buttonOk); buttonOk.Clicked += OnButtonOkClicked; mainHBox = new HBox (); tree = new TreeView (); var sw = new ScrolledWindow (); sw.Add (tree); sw.HscrollbarPolicy = PolicyType.Never; sw.VscrollbarPolicy = PolicyType.Automatic; sw.ShadowType = ShadowType.None; var fboxTree = new HeaderBox (); fboxTree.SetMargins (0, 1, 0, 1); fboxTree.SetPadding (0, 0, 0, 0); fboxTree.BackgroundColor = new Gdk.Color (255, 255, 255); fboxTree.Add (sw); mainHBox.PackStart (fboxTree, false, false, 0); Realized += delegate { fboxTree.BackgroundColor = tree.Style.Base (Gtk.StateType.Normal); }; var vbox = new VBox (); mainHBox.PackStart (vbox, true, true, 0); var headerBox = new HBox (false, 6); image = new Image (); // headerBox.PackStart (image, false, false, 0); labelTitle = new Label (); labelTitle.Xalign = 0; headerBox.PackStart (labelTitle, true, true, 0); headerBox.BorderWidth = 12; var fboxHeader = new HeaderBox (); fboxHeader.SetMargins (0, 1, 0, 0); fboxHeader.Add (headerBox); // fbox.GradientBackround = true; // fbox.BackgroundColor = new Gdk.Color (255, 255, 255); Realized += delegate { var c = new HslColor (Style.Background (Gtk.StateType.Normal)); c.L += 0.09; fboxHeader.BackgroundColor = c; }; vbox.PackStart (fboxHeader, false, false, 0); pageFrame = new HBox (); var fbox = new HeaderBox (); fbox.SetMargins (0, 1, 0, 0); fbox.ShowTopShadow = true; fbox.Add (pageFrame); vbox.PackStart (fbox, true, true, 0); this.VBox.PackStart (mainHBox, true, true, 0); this.removeEmptySections = removeEmptySections; extensionContext = AddinManager.CreateExtensionContext (); this.mainDataObject = dataObject; this.extensionPath = extensionPath; if (parentWindow != null) TransientFor = parentWindow; ImageService.EnsureStockIconIsLoaded (emptyCategoryIcon, treeIconSize); ImageService.EnsureStockIconIsLoaded (emptyCategoryIcon, headerIconSize); store = new TreeStore (typeof(OptionsDialogSection)); tree.Model = store; tree.HeadersVisible = false; // Column 0 is used to add some padding at the left of the expander TreeViewColumn col0 = new TreeViewColumn (); col0.MinWidth = 6; tree.AppendColumn (col0); TreeViewColumn col = new TreeViewColumn (); var crp = new CellRendererPixbuf (); col.PackStart (crp, false); col.SetCellDataFunc (crp, PixbufCellDataFunc); var crt = new CellRendererText (); col.PackStart (crt, true); col.SetCellDataFunc (crt, TextCellDataFunc); tree.AppendColumn (col); tree.ExpanderColumn = col; tree.Selection.Changed += OnSelectionChanged; Child.ShowAll (); InitializeContext (extensionContext); FillTree (); ExpandCategories (); this.DefaultResponse = Gtk.ResponseType.Ok; DefaultWidth = 722; DefaultHeight = 502; }
/// <summary> /// Creates a command entry set. /// </summary> /// <returns> /// The command entry set. /// </returns> /// <param name='ctx'> /// Extension context to use to query the extension path /// </param> /// <param name='addinPath'> /// Extension path with the command definitions /// </param> public CommandEntrySet CreateCommandEntrySet (ExtensionContext ctx, string addinPath) { CommandEntrySet cset = new CommandEntrySet (); object[] items = ctx.GetExtensionObjects (addinPath, false); foreach (CommandEntry e in items) cset.Add (e); return cset; }
public override void Setup() { base.Setup (); pinfo = new ParameterInfoCondition (); pinfo.Value = "res"; GlobalInfoCondition.Value = "res"; ctx = AddinManager.CreateExtensionContext (); ctx.RegisterCondition ("InputParameter", pinfo); }