void FillNodes(TreeIter iter, ExtensionNodeSet ns, ExtensionNodeDescriptionCollection nodes)
        {
            ExtensionNodeTypeCollection ntypes = ns.GetAllowedNodeTypes();

            foreach (ExtensionNodeDescription node in nodes)
            {
                if (node.IsCondition)
                {
                    FillNodes(iter, ns, nodes);
                    continue;
                }

                string            id = node.Id;
                ExtensionNodeType nt = ntypes [node.NodeName];

                // The node can only be extended if it has an ID and if it accepts child nodes
                if (id.Length > 0 && (nt.NodeTypes.Count > 0 || nt.NodeSets.Count > 0))
                {
                    TreeIter citer = GetBranch(iter, id + " (" + nt.NodeName + ")", null);
                    store.SetValue(citer, ColObject, node);
                    store.SetValue(citer, ColShowCheck, true);
                    store.SetValue(citer, ColChecked, false);
                    FillExtensionNodeSet(citer, nt);
                    FillNodes(citer, nt, node.ChildNodes);
                }
            }
        }
示例#2
0
        internal ExtensionNodeType FindType(ExtensionNodeSet nset, string name, string callingAddinId)
        {
            if (nset == null)
            {
                return(null);
            }

            foreach (ExtensionNodeType nt in nset.NodeTypes)
            {
                if (nt.Id == name)
                {
                    return(nt);
                }
            }

            foreach (string ns in nset.NodeSets)
            {
                ExtensionNodeSet regSet;
                if (!nodeSets.TryGetValue(ns, out regSet))
                {
                    ReportError("Unknown node set: " + ns, callingAddinId, null, false);
                    return(null);
                }
                ExtensionNodeType nt = FindType(regSet, name, callingAddinId);
                if (nt != null)
                {
                    return(nt);
                }
            }
            return(null);
        }
        protected virtual void OnRemoveNodeButtonClicked(object sender, System.EventArgs e)
        {
            TreeIter iter;

            tree.Selection.GetSelected(out iter);
            ExtensionNodeSet ns = (ExtensionNodeSet)store.GetValue(iter, ColObject);

            if (ns is ExtensionNodeType)
            {
                ((ExtensionNodeSet)ns.Parent).NodeTypes.Remove(ns);
            }
            else
            {
                string nid = ns.Id;
                if (store.IterParent(out iter, iter))
                {
                    ExtensionNodeSet pns = (ExtensionNodeSet)store.GetValue(iter, ColObject);
                    pns.NodeSets.Remove(nid);
                }
                else
                {
                    nodeSet.NodeSets.Remove(nid);
                }
            }
            Update();
        }
        void GetNodes(AddinDescription desc, ExtensionNodeSet nset, ArrayList list, Hashtable visited)
        {
            if (visited.Contains(nset))
            {
                return;
            }
            visited.Add(nset, nset);

            foreach (ExtensionNodeType nt in nset.NodeTypes)
            {
                if (!visited.Contains(nt.Id + " " + nt.TypeName))
                {
                    list.Add(nt);
                    visited.Add(nt.Id + " " + nt.TypeName, nt);
                }
            }

            foreach (string nsid in nset.NodeSets)
            {
                ExtensionNodeSet rset = desc.ExtensionNodeSets [nsid];
                if (rset != null)
                {
                    GetNodes(desc, rset, list, visited);
                }
            }
        }
        bool GetNodeBranch(TreeIter parent, string name, ExtensionNodeSet nset, out TreeIter citer, out ExtensionNodeSet cset)
        {
            TreeIter iter;
            bool     more;

            if (!parent.Equals(TreeIter.Zero))
            {
                more = store.IterChildren(out iter, parent);
            }
            else
            {
                more = store.GetIterFirst(out iter);
            }

            if (more)
            {
                do
                {
                    if (((string)store.GetValue(iter, ColLabel)) == name)
                    {
                        ExtensionNodeDescription node = (ExtensionNodeDescription)store.GetValue(iter, ColObject);
                        ExtensionNodeType        nt   = nset.GetAllowedNodeTypes() [node.NodeName];
                        cset  = nt;
                        citer = iter;
                        return(true);
                    }
                } while (store.IterNext(ref iter));
            }
            citer = iter;
            cset  = null;
            return(false);
        }
 void ScanNodeSet(AddinDescription config, ExtensionNodeSet nset, ArrayList assemblies, Hashtable internalNodeSets)
 {
     foreach (ExtensionNodeType nt in nset.NodeTypes)
     {
         ScanNodeType(config, nt, assemblies, internalNodeSets);
     }
 }
示例#7
0
        protected virtual void OnComboChanged(object sender, System.EventArgs e)
        {
            ExtensionNodeSet ns = (ExtensionNodeSet)sets [combo.Entry.Text];

            nodeseteditor.Fill(project, registry, desc, ns);
            buttonOk.Sensitive = combo.Entry.Text.Length > 0;
        }
示例#8
0
        public void RegisterNodeSet(AddinDescription description, ExtensionNodeSet nset)
        {
            List <RootExtensionPoint> extensions;

            if (nodeSetHash.TryGetValue(nset.Id, out extensions))
            {
                // Extension point already registered
                List <ExtensionPoint> compatExtensions = GetCompatibleExtensionPoints(nset.Id, description, description.MainModule, extensions);
                if (compatExtensions.Count > 0)
                {
                    foreach (ExtensionPoint einfo in compatExtensions)
                    {
                        einfo.NodeSet.MergeWith(null, nset);
                    }
                    return;
                }
            }
            // Create a new extension set
            RootExtensionPoint rep = new RootExtensionPoint();

            rep.ExtensionPoint = new ExtensionPoint();
            rep.ExtensionPoint.SetNodeSet(nset);
            rep.ExtensionPoint.RootAddin = description.AddinId;
            rep.ExtensionPoint.Path      = nset.Id;
            rep.Description = description;
            if (extensions == null)
            {
                extensions            = new List <RootExtensionPoint> ();
                nodeSetHash [nset.Id] = extensions;
            }
            extensions.Add(rep);
        }
 public void Fill(DotNetProject project, AddinRegistry registry, AddinDescription adesc, ExtensionNodeSet nset)
 {
     this.nodeSet  = nset;
     this.registry = registry;
     this.adesc    = adesc;
     this.project  = project;
     Update();
 }
        void FillExtensionPoint(TreeIter iter, ExtensionPoint ep)
        {
            // Add extension node types

            FillExtensionNodeSet(iter, ep.NodeSet);

            // Add extension nodes from known add-ins

            ArrayList extensions = new ArrayList();

            CollectExtensions(ep.ParentAddinDescription, ep.Path, extensions);
            foreach (Dependency dep in ep.ParentAddinDescription.MainModule.Dependencies)
            {
                AddinDependency adep = dep as AddinDependency;
                if (adep == null)
                {
                    continue;
                }
                Addin addin = registry.GetAddin(adep.FullAddinId);
                if (addin != null)
                {
                    CollectExtensions(addin.Description, ep.Path, extensions);
                }
            }

            // Sort the extensions, to make sure they are added in the correct order
            // That is, deepest children last.
            extensions.Sort(new ExtensionComparer());

//			iter = store.AppendValues (iter, "Extensions", null, ep, false, false, null, false, true);

            // Add the nodes
            foreach (Extension ext in extensions)
            {
                string           subp  = ext.Path.Substring(ep.Path.Length);
                TreeIter         citer = iter;
                ExtensionNodeSet ns    = ep.NodeSet;
                bool             found = true;
                foreach (string p in subp.Split('/'))
                {
                    if (p.Length == 0)
                    {
                        continue;
                    }
                    if (!GetNodeBranch(citer, p, ns, out citer, out ns))
                    {
                        found = false;
                        break;
                    }
                }
                if (found)
                {
                    FillNodes(citer, ns, ext.ExtensionNodes);
                }
            }
        }
示例#11
0
        public void RegisterNodeSet(AddinDescription description, ExtensionNodeSet nset)
        {
            string id = Addin.GetFullId(description.Namespace, nset.Id, description.Version);

            foreach (ExtensionPoint einfo in GetExtensionInfo(nodeSetHash, id, description, description.MainModule, false))
            {
                if (einfo.RootAddin == null || database.AddinDependsOn(einfo.RootAddin, description.AddinId))
                {
                    einfo.RootAddin = description.AddinId;
                }
                einfo.NodeSet.MergeWith(null, nset);
            }
        }
示例#12
0
        internal string GetNodeTypeAddin(ExtensionNodeSet nset, string type, string callingAddinId)
        {
            ExtensionNodeType nt = FindType(nset, type, callingAddinId);

            if (nt != null)
            {
                return(nt.AddinId);
            }
            else
            {
                return(null);
            }
        }
示例#13
0
 void PrintExtensionNodeSetXml(XmlWriter tw, AddinDescription desc, ExtensionNodeSet nset, ArrayList list, Hashtable visited)
 {
     foreach (ExtensionNodeType nt in nset.GetAllowedNodeTypes())
     {
         tw.WriteStartElement("ExtensionNode");
         tw.WriteAttributeString("name", nt.Id);
         string id = RegisterNodeXml(nt, list, visited);
         tw.WriteAttributeString("id", id.ToString());
         if (nt.Description.Length > 0)
         {
             tw.WriteElementString("Description", nt.Description);
         }
         tw.WriteEndElement();
     }
 }
示例#14
0
        void GetNodeTypes(AddinRegistry reg, ExtensionNodeSet nset, List <ExtensionNodeType> list)
        {
            foreach (ExtensionNodeType nt in nset.NodeTypes)
            {
                list.Add(nt);
            }

            foreach (string ns in nset.NodeSets)
            {
                ExtensionNodeSet cset = FindNodeSet(reg, nset.ParentAddinDescription, ns);
                if (cset != null)
                {
                    GetNodeTypes(reg, nset, list);
                }
            }
        }
        void FillExtensionNodeSet(TreeIter iter, ExtensionNodeSet ns)
        {
            // Add extension node types

/*			ExtensionNodeTypeCollection col = ns.GetAllowedNodeTypes ();
 *                      foreach (ExtensionNodeType nt in col) {
 *                              string nname;
 *                              if (nt.Description.Length > 0) {
 *                                      nname = GLib.Markup.EscapeText (nt.NodeName) + "\n";
 *                                      nname += "<small>" + GLib.Markup.EscapeText (nt.Description) + "</small>";
 *                              }
 *                              else
 *                                      nname = GLib.Markup.EscapeText (nt.NodeName);
 *
 *                              store.AppendValues (iter, nname, nt, null, true, selection.Contains (nt), null, false, true);
 *                      }
 */     }
示例#16
0
        public void RegisterAddinRootNodeSet(AddinDescription description, ExtensionNodeSet nodeSet)
        {
            ArrayList list = (ArrayList)nodeSetHash [nodeSet.Id];

            if (list == null)
            {
                list = new ArrayList();
                nodeSetHash [nodeSet.Id] = list;
            }

            RootExtensionPoint rep = new RootExtensionPoint();

            rep.Description = description;
            ExtensionPoint ep = new ExtensionPoint();

            ep.RootAddin = description.AddinId;
            ep.SetNodeSet(nodeSet);
            rep.ExtensionPoint = ep;
            list.Add(rep);
        }
示例#17
0
        void LoadModuleExtensionNodes(Extension extension, string addinId, ExtensionNodeSet nset, ArrayList loadedNodes)
        {
            // Now load the extensions
            ArrayList addedNodes = new ArrayList();

            tree.LoadExtension(addinId, extension, addedNodes);

            RuntimeAddin ad = AddinManager.SessionService.GetAddin(addinId);

            if (ad != null)
            {
                foreach (TreeNode nod in addedNodes)
                {
                    // Don't call OnAddinLoaded here. Do it when the entire extension point has been loaded.
                    if (nod.ExtensionNode != null)
                    {
                        loadedNodes.Add(nod);
                    }
                }
            }
        }
示例#18
0
        ExtensionNodeSet FindNodeSet(AddinRegistry reg, AddinDescription adesc, string name)
        {
            ExtensionNodeSet nset = adesc.ExtensionNodeSets [name];

            if (nset != null)
            {
                return(nset);
            }
            foreach (AddinDependency adep in adesc.MainModule.Dependencies)
            {
                Addin addin = reg.GetAddin(adep.FullAddinId);
                if (addin != null)
                {
                    nset = adesc.ExtensionNodeSets [name];
                    if (nset != null)
                    {
                        return(nset);
                    }
                }
            }
            return(null);
        }
 void Fill(TreeIter it, ExtensionNodeSet nset, Hashtable visited, bool isReference)
 {
     if (visited.Contains(nset))
     {
         return;
     }
     visited [nset] = nset;
     foreach (ExtensionNodeType nt in nset.NodeTypes)
     {
         TreeIter cit;
         if (it.Equals(TreeIter.Zero))
         {
             cit = store.AppendValues(nt, "md-extension-node-type", nt.NodeName, nt.TypeName, nt.Description, isReference);
         }
         else
         {
             cit = store.AppendValues(it, nt, "md-extension-node-type", nt.NodeName, nt.TypeName, nt.Description, isReference);
         }
         Fill(cit, nt, visited, isReference);
     }
     foreach (string ns in nset.NodeSets)
     {
         TreeIter         cit;
         ExtensionNodeSet rns = FindNodeSet(ns);
         if (it.Equals(TreeIter.Zero))
         {
             cit = store.AppendValues(rns, "md-extension-node-set", ns, string.Empty, string.Empty, isReference);
         }
         else
         {
             cit = store.AppendValues(it, rns, "md-extension-node-set", ns, string.Empty, string.Empty, isReference);
         }
         if (rns != null)
         {
             Fill(cit, rns, visited, false);
         }
     }
 }
        void ScanNodeType(AddinDescription config, ExtensionNodeType nt, ArrayList assemblies, Hashtable internalNodeSets)
        {
            if (nt.TypeName.Length == 0)
            {
                nt.TypeName = "Mono.Addins.TypeExtensionNode";
            }

            Type ntype = FindAddinType(nt.TypeName, assemblies);

            if (ntype == null)
            {
                return;
            }

            // Add type information declared with attributes in the code
            ExtensionNodeAttribute nodeAtt = (ExtensionNodeAttribute)Attribute.GetCustomAttribute(ntype, typeof(ExtensionNodeAttribute), true);

            if (nodeAtt != null)
            {
                if (nt.Id.Length == 0 && nodeAtt.NodeName.Length > 0)
                {
                    nt.Id = nodeAtt.NodeName;
                }
                if (nt.Description.Length == 0 && nodeAtt.Description.Length > 0)
                {
                    nt.Description = nodeAtt.Description;
                }
            }
            else
            {
                // Use the node type name as default name
                if (nt.Id.Length == 0)
                {
                    nt.Id = ntype.Name;
                }
            }

            // Add information about attributes
            object[] fieldAtts = ntype.GetCustomAttributes(typeof(NodeAttributeAttribute), true);
            foreach (NodeAttributeAttribute fatt in fieldAtts)
            {
                NodeTypeAttribute natt = new NodeTypeAttribute();
                natt.Name     = fatt.Name;
                natt.Required = fatt.Required;
                if (fatt.Type != null)
                {
                    natt.Type = fatt.Type.FullName;
                }
                if (fatt.Description.Length > 0)
                {
                    natt.Description = fatt.Description;
                }
                nt.Attributes.Add(natt);
            }

            // Check if the type has NodeAttribute attributes applied to fields.
            foreach (FieldInfo field in ntype.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
            {
                NodeAttributeAttribute fatt = (NodeAttributeAttribute)Attribute.GetCustomAttribute(field, typeof(NodeAttributeAttribute));
                if (fatt != null)
                {
                    NodeTypeAttribute natt = new NodeTypeAttribute();
                    if (fatt.Name.Length > 0)
                    {
                        natt.Name = fatt.Name;
                    }
                    else
                    {
                        natt.Name = field.Name;
                    }
                    if (fatt.Description.Length > 0)
                    {
                        natt.Description = fatt.Description;
                    }
                    natt.Type     = field.FieldType.FullName;
                    natt.Required = fatt.Required;
                    nt.Attributes.Add(natt);
                }
            }

            // Check if the extension type allows children by looking for [ExtensionNodeChild] attributes.
            // First of all, look in the internalNodeSets hashtable, which is being used as cache

            string childSet = (string)internalNodeSets [nt.TypeName];

            if (childSet == null)
            {
                object[] ats = ntype.GetCustomAttributes(typeof(ExtensionNodeChildAttribute), true);
                if (ats.Length > 0)
                {
                    // Create a new node set for this type. It is necessary to create a new node set
                    // instead of just adding child ExtensionNodeType objects to the this node type
                    // because child types references can be recursive.
                    ExtensionNodeSet internalSet = new ExtensionNodeSet();
                    internalSet.Id = ntype.Name + "_" + Guid.NewGuid().ToString();
                    foreach (ExtensionNodeChildAttribute at in ats)
                    {
                        ExtensionNodeType internalType = new ExtensionNodeType();
                        internalType.Id       = at.NodeName;
                        internalType.TypeName = at.ExtensionNodeType.FullName;
                        internalSet.NodeTypes.Add(internalType);
                    }
                    config.ExtensionNodeSets.Add(internalSet);
                    nt.NodeSets.Add(internalSet.Id);

                    // Register the new set in a hashtable, to allow recursive references to the
                    // same internal set.
                    internalNodeSets [nt.TypeName] = internalSet.Id;
                    internalNodeSets [ntype.AssemblyQualifiedName] = internalSet.Id;
                    ScanNodeSet(config, internalSet, assemblies, internalNodeSets);
                }
            }
            else
            {
                if (childSet.Length == 0)
                {
                    // The extension type does not declare children.
                    return;
                }
                // The extension type can have children. The allowed children are
                // defined in this extension set.
                nt.NodeSets.Add(childSet);
                return;
            }

            ScanNodeSet(config, nt, assemblies, internalNodeSets);
        }
示例#21
0
 public void UnregisterNodeSet(ExtensionNodeSet nset)
 {
     nodeSets.Remove(nset.Id);
 }
示例#22
0
 public void RegisterNodeSet(ExtensionNodeSet nset)
 {
     nodeSets [nset.Id] = nset;
 }
 internal void RegisterNodeSet(string addinId, ExtensionNodeSet nset)
 {
     nset.SourceAddinId = addinId;
     nodeSets [nset.Id] = nset;
 }