ExtensionNodeTypeCollection GetAllowedChildTypes(TreeIter it)
        {
            ExtensionNodeTypeCollection types = null;

            Extension ext = (Extension)store.GetValue(it, ColExtension);

            if (ext != null)
            {
                if (ext.Parent == null)
                {
                    ExtensionPoint ep = (ExtensionPoint)store.GetValue(it, ColExtensionPoint);
                    types = ep.NodeSet.GetAllowedNodeTypes();
                }
                else
                {
                    types = ext.GetAllowedNodeTypes();
                }
            }

            ExtensionNodeDescription node = (ExtensionNodeDescription)store.GetValue(it, ColNode);

            if (node != null)
            {
                ExtensionNodeType tn = node.GetNodeType();
                if (tn != null)
                {
                    types = tn.GetAllowedNodeTypes();
                }
            }
            return(types);
        }
        public ExtensionEditor(ExtensionNodeDescription node)
        {
            HBox fieldsBox = new HBox();

            fieldsBox.Spacing = 3;
            Gtk.Label lab = new Gtk.Label();
            lab.Markup = "<b>" + node.NodeName + "</b>";
            fieldsBox.PackStart(lab, false, false, 0);
            ExtensionNodeType nt = node.GetNodeType();

            if (nt == null)
            {
                fieldsBox.PackStart(new Gtk.Label("Unknown node type"), false, false, 0);
            }
            else
            {
                AddAttribute(fieldsBox, node, "id", "System.String", false);
                Console.WriteLine("ppAA: " + nt.Attributes.Count);
                foreach (NodeTypeAttribute at in nt.Attributes)
                {
                    AddAttribute(fieldsBox, node, at.Name, at.Type, at.Required);
                }
            }
            PackStart(fieldsBox, false, false, 0);
            ShowAll();
        }
        ExtensionNodeTypeCollection GetAllowedChildTypes()
        {
            ExtensionNodeInfo en     = (ExtensionNodeInfo)CurrentNode.DataItem;
            object            parent = en.Node.Parent;

            Extension ext = parent as Extension;

            if (ext != null)
            {
                return(ext.GetAllowedNodeTypes());
            }
            else
            {
                ExtensionNodeDescription node = (ExtensionNodeDescription)parent;
                if (node != null)
                {
                    ExtensionNodeType tn = node.GetNodeType();
                    if (tn != null)
                    {
                        return(tn.GetAllowedNodeTypes());
                    }
                }
            }
            return(new ExtensionNodeTypeCollection());
        }
        void UpdateButtons()
        {
            TreeIter iter;

            if (!tree.Selection.GetSelected(out iter))
            {
                addNodeButton.Sensitive = false;
                buttonRemove.Sensitive  = false;
                DisposeEditor();
                return;
            }

            DisposeEditor();

            ExtensionNodeDescription node = store.GetValue(iter, ColNode) as ExtensionNodeDescription;

            if (node == null)
            {
                ExtensionPoint ep = (ExtensionPoint)store.GetValue(iter, ColExtensionPoint);
                if (ep != null)
                {
                    addNodeButton.Sensitive = true;
                    buttonRemove.Sensitive  = false;
                }
                else
                {
                    addNodeButton.Sensitive = false;
                    buttonRemove.Sensitive  = false;
                }
                return;
            }

            ExtensionNodeType nt = node.GetNodeType();

            if (nt == null)
            {
                return;
            }

            NodeEditorWidget editor = new NodeEditorWidget(data.Project, data.AddinRegistry, nt, adesc, node.GetParentPath(), node);

            editorBox.AddWithViewport(editor);
            editor.Show();
            editor.BorderWidth = 3;
            currentEditor      = editor;

            ExtensionNodeTypeCollection types = GetAllowedChildTypes(iter);

            addNodeButton.Sensitive = types != null && types.Count > 0;
            buttonRemove.Sensitive  = true;
        }
Exemplo n.º 5
0
        public void Fill(ExtensionNodeDescription node)
        {
            ExtensionNodeType ntype = node.GetNodeType();

            labelName.Markup = "<small>Extension Node</small>\n<big><b>" + GLib.Markup.EscapeText(ntype.NodeName) + "</b></big>";

            if (!string.IsNullOrEmpty(ntype.Description))
            {
                labelDesc.Text = ntype.Description;
            }
            else
            {
                labelDesc.Text = AddinManager.CurrentLocalizer.GetString("No additional documentation");
            }

            uint row = 0;

            foreach (var att in node.Attributes)
            {
                Gtk.Label lab = new Gtk.Label();
                lab.Markup       = "<b>" + GLib.Markup.EscapeText(att.Name) + ":</b>";
                lab.UseUnderline = false;
                lab.Xalign       = 0;
                tableAtts.Attach(lab, 0, 1, row, row + 1);
                Gtk.Table.TableChild ct = (Gtk.Table.TableChild)tableAtts [lab];
                ct.XOptions = Gtk.AttachOptions.Fill;

                lab = new Gtk.Label(att.Value);
                lab.UseUnderline = false;
                lab.Xalign       = 0;
                lab.Wrap         = true;
                tableAtts.Attach(lab, 1, 2, row, row + 1);
                ct          = (Gtk.Table.TableChild)tableAtts [lab];
                ct.XOptions = Gtk.AttachOptions.Fill;
                row++;
            }
            tableAtts.ShowAll();
        }