protected void OnGenerateCode()
        {
            ProjectFile       pf       = CurrentNode.DataItem as ProjectFile;
            Project           project  = CurrentNode.GetParentDataItem(typeof(Project), true) as Project;
            GtkDesignInfo     info     = GtkDesignInfo.FromProject(project);
            GuiBuilderProject gproject = info.GuiBuilderProject;

            gproject.GenerateCode(pf.FilePath);
        }
        public override bool AddToProject(SolutionItem policyParent, Project project, string language, string directory, string name)
        {
            if (!GtkDesignInfo.SupportsDesigner(project))
            {
                ReferenceManager mgr = new ReferenceManager(project as DotNetProject);
                mgr.GtkPackageVersion = mgr.DefaultGtkVersion;
                mgr.Dispose();
            }

            GtkDesignInfo info = GtkDesignInfo.FromProject((DotNetProject)project);

            GuiBuilderProject gproject = info.GuiBuilderProject;

            string fileName = fileTemplate.GetFileName(policyParent, project, language, directory, name);

            fileTemplate.AddToProject(policyParent, project, language, directory, name);

#if TRUNK
            ProjectDomService.Parse(project, fileName);
#else
            ProjectDomService.Parse(project, fileName, null);
#endif

            DotNetProject netProject = project as DotNetProject;
            string        ns         = netProject != null?netProject.GetDefaultNamespace(fileName) : "";

            string cname    = Path.GetFileNameWithoutExtension(fileName);
            string fullName = ns.Length > 0 ? ns + "." + cname : cname;
            string[,] tags =
            {
                { "Name",      cname    },
                { "Namespace", ns       },
                { "FullName",  fullName }
            };

            XmlElement widgetElem = steticTemplate ["widget"];
            if (widgetElem != null)
            {
                string content = widgetElem.OuterXml;
                content = StringParserService.Parse(content, tags);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(content);

                gproject.AddNewComponent(doc.DocumentElement);
                gproject.Save(false);
                gproject.GenerateCode(fileName);
                IdeApp.ProjectOperations.Save(project);
                return(true);
            }

            widgetElem = steticTemplate ["action-group"];
            if (widgetElem != null)
            {
                string content = widgetElem.OuterXml;
                content = StringParserService.Parse(content, tags);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(content);

                Stetic.Project sproject = gproject.SteticProject;
                sproject.AddNewActionGroup(doc.DocumentElement);
                gproject.Save(false);
                gproject.GenerateCode(fileName);
                IdeApp.ProjectOperations.Save(project);
                return(true);
            }

            throw new InvalidOperationException("<widget> or <action-group> element not found in widget template.");
        }