Пример #1
0
        public static ToolboxItem GetToolboxItem(this ToolboxesConfig config, Type type)
        {
            if (config == null || type == null)
            {
                return(null);
            }

            if (!type.Name.Contains("Controller"))
            {
                return(null);
            }

            foreach (var configElement in config.Toolboxes)
            {
                var toolbox = (Toolbox)configElement;

                foreach (var section in toolbox.Sections)
                {
                    foreach (var toolboxItem in section.Tools)
                    {
                        if (toolboxItem.ControllerType == type.FullName)
                        {
                            return(toolboxItem);
                        }
                    }
                }
            }

            return(null);
        }
Пример #2
0
        private static ToolboxSection GetFormsToolboxSection(ToolboxesConfig toolboxesConfig)
        {
            var            formsControls = toolboxesConfig.Toolboxes[FormsConstants.FormControlsToolboxName];
            var            sectionName   = FormsConstants.CommonSectionName;
            ToolboxSection section       = formsControls.Sections.Where <ToolboxSection>(e => e.Name == sectionName).FirstOrDefault();

            return(section);
        }
Пример #3
0
        private static ToolboxSection GetFormsToolboxSection(ToolboxesConfig toolboxesConfig)
        {
            var formsControls = toolboxesConfig.Toolboxes[FormsConstants.FormControlsToolboxName];
            var sectionName = FormsConstants.CommonSectionName;
            ToolboxSection section = formsControls.Sections.Where<ToolboxSection>(e => e.Name == sectionName).FirstOrDefault();

            return section;
        }
 public BaseControllerParameters
 (
     [Named("IsDesignMode")] bool isDesignMode,
     [Named("DefaultGenericDesignView")] string defaultGenericDesignView,
     [Named("DefaultGenericUnconfiguredWidgetView")] string defaultUnconfiguredWidgetView,
     ToolboxesConfig toolboxesConfig
 )
 {
     IsDesignMode                  = isDesignMode;
     DefaultGenericDesignView      = defaultGenericDesignView;
     DefaultUnconfiguredWidgetView = defaultUnconfiguredWidgetView;
     ToolboxesConfig               = toolboxesConfig;
 }
Пример #5
0
        /// <summary>
        /// Gets existing or create a tool box section for the grid controls.
        /// </summary>
        /// <param name="toolboxConfig">The toolbox configuration.</param>
        /// <returns></returns>
        protected virtual ToolboxSection GetOrCreateToolBoxSection(ToolboxesConfig toolboxConfig)
        {
            var layoutsToolbox = toolboxConfig.Toolboxes["PageLayouts"];

            var htmlLayoutsSection = layoutsToolbox.Sections.FirstOrDefault <ToolboxSection>(s => s.Name == "HtmlLayouts");

            if (htmlLayoutsSection == null)
            {
                htmlLayoutsSection      = new ToolboxSection(layoutsToolbox.Sections);
                htmlLayoutsSection.Name = "HtmlLayouts";
                //TODO: Set resource class id and use resource keys for Title and Description.
                htmlLayoutsSection.Title = "Bootstrap grid widgets";

                layoutsToolbox.Sections.Add(htmlLayoutsSection);
            }
            return(htmlLayoutsSection);
        }
        /// <summary>
        /// Gets existing or create a tool box section for the grid controls.
        /// </summary>
        /// <param name="toolboxConfig">The toolbox configuration.</param>
        /// <returns></returns>
        protected virtual ToolboxSection GetOrCreateToolBoxSection(ToolboxesConfig toolboxConfig)
        {
            var layoutsToolbox = toolboxConfig.Toolboxes["PageLayouts"];

            var htmlLayoutsSection = layoutsToolbox.Sections.FirstOrDefault<ToolboxSection>(s => s.Name == "HtmlLayouts");
            if (htmlLayoutsSection == null)
            {
                htmlLayoutsSection = new ToolboxSection(layoutsToolbox.Sections);
                htmlLayoutsSection.Name = "HtmlLayouts";

                /// TODO: Set resource class id and use resource keys for Title and Description.
                htmlLayoutsSection.Title = "Bootstrap grid widgets";

                layoutsToolbox.Sections.Add(htmlLayoutsSection);
            }

            return htmlLayoutsSection;
        }
Пример #7
0
        /// <summary>
        /// Gets existing or create a tool box section for the grid controls.
        /// </summary>
        /// <param name="toolboxConfig">The toolbox configuration.</param>
        /// <param name="sectionName">Name of the section.</param>
        /// <param name="sectionTitle">The section title.</param>
        /// <returns></returns>
        protected virtual ToolboxSection GetOrCreateToolBoxSection(ToolboxesConfig toolboxConfig, string sectionName, string sectionTitle, ref bool needsSaveSection)
        {
            var layoutsToolbox = toolboxConfig.Toolboxes["PageLayouts"];

            var htmlLayoutsSection = layoutsToolbox.Sections.FirstOrDefault <ToolboxSection>(s => s.Name == sectionName);

            if (htmlLayoutsSection == null)
            {
                htmlLayoutsSection      = new ToolboxSection(layoutsToolbox.Sections);
                htmlLayoutsSection.Name = sectionName;

                /// TODO: Set resource class id and use resource keys for Title and Description.
                htmlLayoutsSection.Title = sectionTitle;

                layoutsToolbox.Sections.Add(htmlLayoutsSection);
                needsSaveSection = true;
            }

            return(htmlLayoutsSection);
        }
 /// <inheritdoc />
 public ToolboxSection PublicCreateToolBoxSection(ToolboxesConfig toolboxConfig)
 {
     return this.GetOrCreateToolBoxSection(toolboxConfig);
 }
Пример #9
0
        /// <inheritdoc />
        public ToolboxSection PublicCreateToolBoxSection(ToolboxesConfig toolboxConfig, string sectionName, string sectionTitle)
        {
            bool needsSaveSection = false;

            return(this.GetOrCreateToolBoxSection(toolboxConfig, sectionName, sectionTitle, ref needsSaveSection));
        }
Пример #10
0
        /// <summary>
        /// Gets the toolbox section where the dynamic widget will be placed.
        /// </summary>
        /// <param name="dynamicModule">The dynamic module.</param>
        /// <param name="toolboxesConfig">The toolboxes configuration.</param>
        /// <returns></returns>
        private static ToolboxSection GetModuleToolboxSection(DynamicModule dynamicModule, ToolboxesConfig toolboxesConfig)
        {
            var            pageControls      = toolboxesConfig.Toolboxes["PageControls"];
            var            moduleSectionName = string.Concat(DynamicModuleType.defaultNamespace, ".", MvcWidgetInstaller.moduleNameValidationRegex.Replace(dynamicModule.Name, string.Empty));
            ToolboxSection section           = pageControls.Sections.Where <ToolboxSection>(e => e.Name == moduleSectionName).FirstOrDefault();

            if (section == null)
            {
                var sectionDescription = string.Format(MvcWidgetInstaller.ModuleSectionDescription, dynamicModule.GetTitle());
                section = new ToolboxSection(pageControls.Sections)
                {
                    Name        = moduleSectionName,
                    Title       = dynamicModule.Title,
                    Description = sectionDescription
                };

                pageControls.Sections.Add(section);
            }

            return(section);
        }
Пример #11
0
 /// <inheritdoc />
 public ToolboxSection PublicCreateToolBoxSection(ToolboxesConfig toolboxConfig)
 {
     return(this.GetOrCreateToolBoxSection(toolboxConfig));
 }
Пример #12
0
        private bool AddControllerToPageToolbox(ControllerInfoExtended controllerInfo, ToolboxesConfig toolboxConfig)
        {
            if (!controllerInfo.IncludeInToolbox)
            {
                return(false);
            }

            bool saveRequired = false;

            // get the pages toolbox
            var toolboxName = string.IsNullOrEmpty(controllerInfo.Toolbox) ? "PageControls" : controllerInfo.Toolbox;
            var toolbox     = toolboxConfig.Toolboxes[toolboxName];

            // create the new toolbox section
            var controllerSection = toolbox.Sections
                                    .Where <ToolboxSection>(s => s.Name == controllerInfo.DefaultToolboxSectionName).SingleOrDefault();

            if (controllerSection == null)
            {
                saveRequired            = true;
                controllerSection       = new ToolboxSection(toolbox.Sections);
                controllerSection.Name  = controllerInfo.DefaultToolboxSectionName;
                controllerSection.Title = controllerInfo.DefaultToolboxSectionName;
                toolbox.Sections.Add(controllerSection);
            }

            // create the controller toolbox item
            ToolboxItem toolboxItem = controllerSection.Tools.Where <ToolboxItem>(t => t.Name == controllerInfo.DefaultToolboxItemName).SingleOrDefault();

            if (toolboxItem == null)
            {
                saveRequired = true;
                string mvcWidgetProxyFullName = this.GetMvcWidgetProxyFullName();

                toolboxItem                = new ToolboxItem(controllerSection.Tools);
                toolboxItem.Title          = controllerInfo.DefaultToolboxItemTitle;
                toolboxItem.Name           = controllerInfo.DefaultToolboxItemName;
                toolboxItem.ControlType    = mvcWidgetProxyFullName;
                toolboxItem.ControllerType = controllerInfo.ControllerType.FullName;
                toolboxItem.ModuleName     = controllerInfo.DefaultToolboxModuleName;
                toolboxItem.CssClass       = controllerInfo.DefaultToolboxCssClass;

                toolboxItem.Parameters.Add("ControllerName", controllerInfo.ControllerType.FullName);
                toolboxItem.Parameters.Add("WidgetName", controllerInfo.WidgetName);

                controllerSection.Tools.Add(toolboxItem);
            }

            return(saveRequired);
        }
Пример #13
0
 /// <inheritdoc />
 public ToolboxSection PublicCreateToolBoxSection(ToolboxesConfig toolboxConfig, string sectionName, string sectionTitle)
 {
     return(this.GetOrCreateToolBoxSection(toolboxConfig, sectionName, sectionTitle));
 }
Пример #14
0
        /// <summary>
        /// Gets the toolbox section where the dynamic widget will be placed.
        /// </summary>
        /// <param name="dynamicModule">The dynamic module.</param>
        /// <param name="toolboxesConfig">The toolboxes configuration.</param>
        /// <returns></returns>
        private static ToolboxSection GetModuleToolboxSection(DynamicModule dynamicModule, ToolboxesConfig toolboxesConfig)
        {
            var pageControls = toolboxesConfig.Toolboxes["PageControls"];
            var moduleSectionName = string.Concat(DynamicModuleType.defaultNamespace, ".", MvcWidgetInstaller.moduleNameValidationRegex.Replace(dynamicModule.Name, string.Empty));
            ToolboxSection section = pageControls.Sections.Where<ToolboxSection>(e => e.Name == moduleSectionName).FirstOrDefault();

            if (section == null)
            {
                var sectionDescription = string.Format(MvcWidgetInstaller.ModuleSectionDescription, dynamicModule.GetTitle());
                section = new ToolboxSection(pageControls.Sections)
                {
                    Name = moduleSectionName,
                    Title = dynamicModule.Title,
                    Description = sectionDescription
                };

                pageControls.Sections.Add(section);
            }

            return section;
        }
 /// <inheritdoc />
 public ToolboxSection PublicCreateToolBoxSection(ToolboxesConfig toolboxConfig, string sectionName, string sectionTitle)
 {
     return this.GetOrCreateToolBoxSection(toolboxConfig, sectionName, sectionTitle);
 }