private static Element CreateResourceElement(string resourceSet, string label, ElementHandle elementHandle)
        {
            if (String.IsNullOrEmpty(resourceSet))
            {
                var dragAndDropInfo = new ElementDragAndDropInfo(typeof(IResourceKey));

                dragAndDropInfo.AddDropType(typeof(NamespaceFolderEntityToken));
                dragAndDropInfo.SupportsIndexedPosition = false;

                return(new Element(elementHandle, dragAndDropInfo)
                {
                    VisualData = new ElementVisualizedData
                    {
                        Label = label,
                        ToolTip = label,
                        HasChildren = false,
                        Icon = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                        OpenedIcon = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                    }
                });
            }

            return(new Element(elementHandle)
            {
                VisualData = new ElementVisualizedData
                {
                    Label = label,
                    ToolTip = label,
                    HasChildren = false,
                    Icon = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                    OpenedIcon = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                }
            });
        }
        public static Element CreateElement(ElementProviderContext context, string label, string resourceSet, string ns)
        {
            var folderHandle = context.CreateElementHandle(new NamespaceFolderEntityToken(resourceSet, ns));

            if (String.IsNullOrEmpty(resourceSet))
            {
                var dragAndDropInfo = new ElementDragAndDropInfo(typeof(NamespaceFolderEntityToken));

                dragAndDropInfo.AddDropType(typeof(NamespaceFolderEntityToken));
                dragAndDropInfo.AddDropType(typeof(IResourceKey));

                dragAndDropInfo.SupportsIndexedPosition = false;

                return(new Element(folderHandle, dragAndDropInfo)
                {
                    VisualData = new ElementVisualizedData
                    {
                        Label = label,
                        ToolTip = label,
                        HasChildren = true,
                        Icon = ResourceHandle.BuildIconFromDefaultProvider("datagroupinghelper-folder-closed"),
                        OpenedIcon = ResourceHandle.BuildIconFromDefaultProvider("datagroupinghelper-folder-open")
                    }
                });
            }

            return(new Element(folderHandle)
            {
                VisualData = new ElementVisualizedData
                {
                    Label = label,
                    ToolTip = label,
                    HasChildren = true,
                    Icon = ResourceHandle.BuildIconFromDefaultProvider("datagroupinghelper-folder-closed"),
                    OpenedIcon = ResourceHandle.BuildIconFromDefaultProvider("datagroupinghelper-folder-open")
                }
            });
        }
Example #3
0
        private List <Element> GetElements(List <KeyValuePair <PageLocaleState, IPage> > pages, bool rootPages)
        {
            //ElementDragAndDropInfo dragAndDropInfo = new ElementDragAndDropInfo(typeof(IPage));
            //dragAndDropInfo.AddDropType(typeof(IPage));
            //dragAndDropInfo.SupportsIndexedPosition = true;



            string editPageLabel       = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.EditPage");
            string editPageToolTip     = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.EditPageToolTip");
            string localizePageLabel   = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.LocalizePage");
            string localizePageToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.LocalizePageToolTip");
            string addNewPageLabel     = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.AddSubPage");
            string addNewPageToolTip   = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.AddSubPageToolTip");
            string deletePageLabel     = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.Delete");
            string deletePageToolTip   = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.DeleteToolTip");

            string urlMappingName = null;

            if (UserSettings.ForeignLocaleCultureInfo != null)
            {
                urlMappingName = DataLocalizationFacade.GetCultureTitle(UserSettings.ForeignLocaleCultureInfo);
            }

            var elements = new Element[pages.Count];

            ParallelFacade.For("PageElementProvider. Getting elements", 0, pages.Count, i =>
            {
                var kvp    = pages[i];
                IPage page = kvp.Value;

                EntityToken entityToken = page.GetDataEntityToken();

                var dragAndDropInfo = new ElementDragAndDropInfo(typeof(IPage));
                dragAndDropInfo.AddDropType(typeof(IPage));
                dragAndDropInfo.SupportsIndexedPosition = true;

                var element = new Element(_context.CreateElementHandle(entityToken), MakeVisualData(page, kvp.Key, urlMappingName, rootPages), dragAndDropInfo);

                element.PropertyBag.Add("Uri", "~/page({0})".FormatWith(page.Id));
                element.PropertyBag.Add("ElementType", "application/x-composite-page");
                element.PropertyBag.Add("DataId", page.Id.ToString());

                if (kvp.Key == PageLocaleState.Own)
                {
                    // Normal actions
                    element.AddAction(new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.Edit, EditPermissionTypes)))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label          = editPageLabel,
                            ToolTip        = editPageToolTip,
                            Icon           = PageElementProvider.EditPage,
                            Disabled       = false,
                            ActionLocation = new ActionLocation
                            {
                                ActionType  = ActionType.Edit,
                                IsInFolder  = false,
                                IsInToolbar = true,
                                ActionGroup = PrimaryActionGroup
                            }
                        }
                    });

                    element.AddAction(new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.Add, AddPermissionTypes)))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label          = addNewPageLabel,
                            ToolTip        = addNewPageToolTip,
                            Icon           = PageElementProvider.AddPage,
                            Disabled       = false,
                            ActionLocation = new ActionLocation
                            {
                                ActionType  = ActionType.Add,
                                IsInFolder  = false,
                                IsInToolbar = true,
                                ActionGroup = PrimaryActionGroup
                            }
                        }
                    });

                    element.AddAction(new ElementAction(new ActionHandle(new ProxyDataActionToken(ActionIdentifier.Delete, DeletePermissionTypes)))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label          = deletePageLabel,
                            ToolTip        = deletePageToolTip,
                            Icon           = DeletePage,
                            Disabled       = false,
                            ActionLocation = new ActionLocation
                            {
                                ActionType  = ActionType.Delete,
                                IsInFolder  = false,
                                IsInToolbar = true,
                                ActionGroup = PrimaryActionGroup
                            }
                        }
                    });

                    _pageAssociatedHelper.AttachElementActions(element, page);
                }
                else if (kvp.Key == PageLocaleState.ForeignActive)
                {
                    // Localized actions
                    bool addAction = false;

                    Guid parentId = page.GetParentId();
                    if (parentId == Guid.Empty)
                    {
                        addAction = true;
                    }
                    else
                    {
                        using (new DataScope(DataScopeIdentifier.Administrated, UserSettings.ActiveLocaleCultureInfo))
                        {
                            bool exists = DataFacade.GetData <IPage>(f => f.Id == parentId).Any();
                            if (exists)
                            {
                                addAction = true;
                            }
                        }
                    }


                    if (addAction)
                    {
                        element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.PageElementProvider.LocalizePageWorkflow"), LocalizePermissionTypes)))
                        {
                            VisualData = new ActionVisualizedData
                            {
                                Label          = localizePageLabel,
                                ToolTip        = localizePageToolTip,
                                Icon           = PageElementProvider.LocalizePage,
                                Disabled       = false,
                                ActionLocation = new ActionLocation
                                {
                                    ActionType  = ActionType.Edit,
                                    IsInFolder  = false,
                                    IsInToolbar = true,
                                    ActionGroup = PrimaryActionGroup
                                }
                            }
                        });
                    }
                }

                elements[i] = element;
            });

            return(new List <Element>(elements));
        }
Example #4
0
        public IEnumerable <Element> GetRoots(SearchToken searchToken)
        {
            int pages;

            using (new DataScope(DataScopeIdentifier.Administrated))
            {
                pages = PageServices.GetChildrenCount(Guid.Empty);
            }

            EntityToken entityToken = new PageElementProviderEntityToken(_context.ProviderName);

            var dragAndDropInfo = new ElementDragAndDropInfo();

            dragAndDropInfo.AddDropType(typeof(IPage));
            dragAndDropInfo.SupportsIndexedPosition = true;

            var element = new Element(_context.CreateElementHandle(entityToken), dragAndDropInfo)
            {
                VisualData = new ElementVisualizedData
                {
                    Label       = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.RootLabel"),
                    ToolTip     = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.RootLabelToolTip"),
                    HasChildren = pages != 0,
                    Icon        = PageElementProvider.RootClosed,
                    OpenedIcon  = PageElementProvider.RootOpen
                }
            };

            element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.PageElementProvider.AddNewPageWorkflow"), AddWebsitePermissionTypes)
            {
                DoIgnoreEntityTokenLocking = true
            }))
            {
                VisualData = new ActionVisualizedData
                {
                    Label          = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.AddPageAtRoot"),
                    ToolTip        = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.AddPageAtRootToolTip"),
                    Icon           = PageElementProvider.AddPage,
                    Disabled       = false,
                    ActionLocation = new ActionLocation
                    {
                        ActionType  = ActionType.Add,
                        IsInFolder  = false,
                        IsInToolbar = true,
                        ActionGroup = PrimaryActionGroup
                    }
                }
            });


            element.AddAction(new ElementAction(new ActionHandle(new ViewUnpublishedItemsActionToken()))
            {
                VisualData = new ActionVisualizedData
                {
                    //Label = "List unpublished Pages and Folder Data",
                    //ToolTip = "Get an overview of pages and page folder data that haven't been published yet.",
                    Label          = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.ViewUnpublishedItems"),
                    ToolTip        = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.ViewUnpublishedItemsToolTip"),
                    Icon           = PageElementProvider.ListUnpublishedItems,
                    Disabled       = false,
                    ActionLocation = new ActionLocation
                    {
                        ActionType  = ActionType.Other,
                        IsInFolder  = false,
                        IsInToolbar = true,
                        ActionGroup = ViewActionGroup
                    }
                }
            });

            element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Elements.ElementProviderHelpers.AssociatedDataElementProviderHelper.AddMetaDataWorkflow"), AssociatedDataElementProviderHelper <IPage> .AddAssociatedTypePermissionTypes)
            {
                DoIgnoreEntityTokenLocking = true
            }))
            {
                VisualData = new ActionVisualizedData
                {
                    Label          = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataTypeLabel"),
                    ToolTip        = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataTypeToolTip"),
                    Icon           = AddDataAssociationTypeIcon,
                    Disabled       = false,
                    ActionLocation = new ActionLocation
                    {
                        ActionType  = ActionType.Add,
                        IsInFolder  = false,
                        IsInToolbar = false,
                        ActionGroup = MetaDataAppendedActionGroup
                    }
                }
            });

            element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Elements.ElementProviderHelpers.AssociatedDataElementProviderHelper.EditMetaDataWorkflow"), AssociatedDataElementProviderHelper <IPage> .EditAssociatedTypePermissionTypes)))
            {
                VisualData = new ActionVisualizedData
                {
                    Label          = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.EditMetaDataTypeLabel"),
                    ToolTip        = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.EditMetaDataTypeToolTip"),
                    Icon           = EditDataAssociationTypeIcon,
                    Disabled       = false,
                    ActionLocation = new ActionLocation
                    {
                        ActionType  = ActionType.Edit,
                        IsInFolder  = false,
                        IsInToolbar = false,
                        ActionGroup = MetaDataAppendedActionGroup
                    }
                }
            });

            element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Elements.ElementProviderHelpers.AssociatedDataElementProviderHelper.DeleteMetaDataWorkflow"), AssociatedDataElementProviderHelper <IPage> .RemoveAssociatedTypePermissionTypes)))
            {
                VisualData = new ActionVisualizedData
                {
                    Label          = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.RemoveMetaDataTypeLabel"),
                    ToolTip        = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.RemoveMetaDataTypeToolTip"),
                    Icon           = RemoveDataAssociationTypeIcon,
                    Disabled       = false,
                    ActionLocation = new ActionLocation
                    {
                        ActionType  = ActionType.Delete,
                        IsInFolder  = false,
                        IsInToolbar = false,
                        ActionGroup = MetaDataAppendedActionGroup
                    }
                }
            });

            // Creates a problem for the front-end "toolbar caching" mechanism - dont re-introduce this right befroe a release
            // Reason: ActionTokin is always unique for a page, making the ActionKey (hash) unique
            //if (RuntimeInformation.IsDebugBuild)
            //{
            //    element.AddAction(new ElementAction(new ActionHandle(new DisplayLocalOrderingActionToken(Guid.Empty)))
            //    {
            //        VisualData = new ActionVisualizedData
            //        {
            //            Label = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.DisplayLocalOrderingLabel"),
            //            ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.DisplayLocalOrderingToolTip"),
            //            Icon = CommonElementIcons.Nodes,
            //            Disabled = false,
            //            ActionLocation = new ActionLocation
            //            {
            //                ActionType = ActionType.DeveloperMode,
            //                IsInFolder = false,
            //                IsInToolbar = false,
            //                ActionGroup = AppendedActionGroup
            //            }
            //        }
            //    });
            //}

            yield return(element);
        }
Example #5
0
        public IEnumerable <Element> GetRoots(SearchToken searchToken)
        {
            EntityToken entityToken = new PageElementProviderEntityToken(_context.ProviderName);

            if (UserValidationFacade.IsLoggedIn() &&
                !DataLocalizationFacade.ActiveLocalizationCultures.Contains(UserSettings.ActiveLocaleCultureInfo))
            {
                yield return(new Element(_context.CreateElementHandle(entityToken))
                {
                    VisualData = new ElementVisualizedData
                    {
                        Label = "No website access: Missing permissions to any Data Language",
                        Icon = PageElementProvider.DeactivateLocalization
                    }
                });

                yield break;
            }

            ICollection <Guid> pageIds = PageServices.GetChildrenIDs(Guid.Empty);

            var homePageIdFilter = (searchToken as PageSearchToken)?.HomePageId ?? Guid.Empty;

            if (homePageIdFilter != Guid.Empty)
            {
                pageIds = pageIds.Where(p => p == homePageIdFilter).ToList();
            }

            var dragAndDropInfo = new ElementDragAndDropInfo();

            dragAndDropInfo.AddDropType(typeof(IPage));
            dragAndDropInfo.SupportsIndexedPosition = true;

            var element = new Element(_context.CreateElementHandle(entityToken), dragAndDropInfo)
            {
                VisualData = new ElementVisualizedData
                {
                    Label       = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.RootLabel"),
                    ToolTip     = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.RootLabelToolTip"),
                    HasChildren = pageIds.Count != 0,
                    Icon        = PageElementProvider.RootClosed,
                    OpenedIcon  = PageElementProvider.RootOpen
                }
            };

            var allPageTypes = DataFacade.GetData <IPageType>().AsEnumerable();

            foreach (
                var pageType in
                allPageTypes.Where(f => f.HomepageRelation != nameof(PageTypeHomepageRelation.OnlySubPages))
                .OrderByDescending(f => f.Id))
            {
                element.AddAction(
                    new ElementAction(
                        new ActionHandle(new PageAddActionToken(pageType.Id, ActionIdentifier.Add, AddPermissionTypes)
                {
                    DoIgnoreEntityTokenLocking = true
                }))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label = string.Format(StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider",
                                                                                   "PageElementProvider.AddPageAtRootFormat"), pageType.Name),
                        ToolTip =
                            StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider",
                                                                 "PageElementProvider.AddPageAtRootToolTip"),
                        Icon           = PageElementProvider.AddPage,
                        Disabled       = false,
                        ActionLocation = new ActionLocation
                        {
                            ActionType   = ActionType.Add,
                            IsInFolder   = false,
                            IsInToolbar  = true,
                            ActionGroup  = PrimaryActionGroup,
                            ActionBundle = "AddWebsite"
                        }
                    }
                });
            }


            element.AddAction(new ElementAction(new ActionHandle(new ViewUnpublishedItemsActionToken()))
            {
                VisualData = new ActionVisualizedData
                {
                    //Label = "List unpublished Content",
                    //ToolTip = "Get an overview of pages and page folder data that haven't been published yet.",
                    Label          = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.ViewUnpublishedItems"),
                    ToolTip        = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.ViewUnpublishedItemsToolTip"),
                    Icon           = PageElementProvider.ListUnpublishedItems,
                    Disabled       = false,
                    ActionLocation = new ActionLocation
                    {
                        ActionType  = ActionType.Other,
                        IsInFolder  = false,
                        IsInToolbar = true,
                        ActionGroup = ViewActionGroup
                    }
                }
            });

            element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Elements.ElementProviderHelpers.AssociatedDataElementProviderHelper.AddMetaDataWorkflow"), AssociatedDataElementProviderHelper <IPage> .AddAssociatedTypePermissionTypes)
            {
                DoIgnoreEntityTokenLocking = true
            }))
            {
                VisualData = new ActionVisualizedData
                {
                    Label          = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataTypeLabel"),
                    ToolTip        = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.AddMetaDataTypeToolTip"),
                    Icon           = AddDataAssociationTypeIcon,
                    Disabled       = false,
                    ActionLocation = new ActionLocation
                    {
                        ActionType  = ActionType.Add,
                        IsInFolder  = false,
                        IsInToolbar = false,
                        ActionGroup = MetaDataAppendedActionGroup
                    }
                }
            });

            element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Elements.ElementProviderHelpers.AssociatedDataElementProviderHelper.EditMetaDataWorkflow"), AssociatedDataElementProviderHelper <IPage> .EditAssociatedTypePermissionTypes)))
            {
                VisualData = new ActionVisualizedData
                {
                    Label          = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.EditMetaDataTypeLabel"),
                    ToolTip        = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.EditMetaDataTypeToolTip"),
                    Icon           = EditDataAssociationTypeIcon,
                    Disabled       = false,
                    ActionLocation = new ActionLocation
                    {
                        ActionType  = ActionType.Edit,
                        IsInFolder  = false,
                        IsInToolbar = false,
                        ActionGroup = MetaDataAppendedActionGroup
                    }
                }
            });

            element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Elements.ElementProviderHelpers.AssociatedDataElementProviderHelper.DeleteMetaDataWorkflow"), AssociatedDataElementProviderHelper <IPage> .RemoveAssociatedTypePermissionTypes)))
            {
                VisualData = new ActionVisualizedData
                {
                    Label          = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.RemoveMetaDataTypeLabel"),
                    ToolTip        = StringResourceSystemFacade.GetString("Composite.Management", "AssociatedDataElementProviderHelper.RemoveMetaDataTypeToolTip"),
                    Icon           = RemoveDataAssociationTypeIcon,
                    Disabled       = false,
                    ActionLocation = new ActionLocation
                    {
                        ActionType  = ActionType.Delete,
                        IsInFolder  = false,
                        IsInToolbar = false,
                        ActionGroup = MetaDataAppendedActionGroup
                    }
                }
            });

            // Creates a problem for the front-end "toolbar caching" mechanism - dont re-introduce this right befroe a release
            // Reason: ActionTokin is always unique for a page, making the ActionKey (hash) unique
            //if (RuntimeInformation.IsDebugBuild)
            //{
            //    element.AddAction(new ElementAction(new ActionHandle(new DisplayLocalOrderingActionToken(Guid.Empty)))
            //    {
            //        VisualData = new ActionVisualizedData
            //        {
            //            Label = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.DisplayLocalOrderingLabel"),
            //            ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PageElementProvider", "PageElementProvider.DisplayLocalOrderingToolTip"),
            //            Icon = CommonElementIcons.Nodes,
            //            Disabled = false,
            //            ActionLocation = new ActionLocation
            //            {
            //                ActionType = ActionType.DeveloperMode,
            //                IsInFolder = false,
            //                IsInToolbar = false,
            //                ActionGroup = AppendedActionGroup
            //            }
            //        }
            //    });
            //}

            yield return(element);
        }
        private static IEnumerable <Element> GetNamespaceAndResourceElements(ElementProviderContext context, string ns)
        {
            var resources = LocalizationsFacade.GetResourceKeys(ns);

            var folders  = new List <string>();
            var elements = new List <Element>();

            foreach (var key in resources)
            {
                var label = key.Key;

                if (label == ns)
                {
                    continue;
                }

                var labelParts = label.Split('.');

                if (!String.IsNullOrEmpty(ns))
                {
                    var nsParts = ns.Split('.');

                    if (nsParts.Length > labelParts.Length)
                    {
                        continue;
                    }

                    labelParts = labelParts.Skip(nsParts.Length).ToArray();
                    label      = String.Join(".", labelParts);
                }

                if (labelParts.Length > 1)
                {
                    var folder = labelParts[0];

                    if (!folders.Contains(folder))
                    {
                        folders.Add(folder);
                    }
                }
                else if (labelParts.Length == 1)
                {
                    var token = key.GetDataEntityToken();

                    var dragAndDropInfo = new ElementDragAndDropInfo(typeof(IResourceKey));

                    dragAndDropInfo.AddDropType(typeof(NamespaceFolderEntityToken));
                    dragAndDropInfo.SupportsIndexedPosition = false;

                    var elementHandle = context.CreateElementHandle(token);
                    var element       = new Element(elementHandle, dragAndDropInfo)
                    {
                        VisualData = new ElementVisualizedData
                        {
                            Label       = label,
                            ToolTip     = label,
                            HasChildren = false,
                            Icon        = ResourceHandle.BuildIconFromDefaultProvider("localization-element-closed-root"),
                            OpenedIcon  = ResourceHandle.BuildIconFromDefaultProvider("localization-element-opened-root")
                        }
                    };

                    var editActionToken = new WorkflowActionToken(typeof(EditResourceWorkflow), new[] { PermissionType.Edit });
                    element.AddAction(new ElementAction(new ActionHandle(editActionToken))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label          = "Edit",
                            ToolTip        = "Edit",
                            Icon           = new ResourceHandle("Composite.Icons", "generated-type-data-edit"),
                            ActionLocation = Actions.ActionLocation
                        }
                    });

                    var deleteActionToken = new ConfirmWorkflowActionToken("Are you sure?", typeof(DeleteResourceActionToken));
                    element.AddAction(new ElementAction(new ActionHandle(deleteActionToken))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label          = "Delete",
                            ToolTip        = "Delete",
                            Icon           = new ResourceHandle("Composite.Icons", "generated-type-data-delete"),
                            ActionLocation = Actions.ActionLocation
                        }
                    });

                    elements.Add(element);
                }
            }

            foreach (var folder in folders.OrderBy(f => f))
            {
                var handleNamespace = folder;
                if (!String.IsNullOrEmpty(ns))
                {
                    handleNamespace = ns + "." + handleNamespace;
                }

                var folderElement = NamespaceFolderEntityToken.CreateElement(context, folder, handleNamespace);

                var deleteActionToken = new ConfirmWorkflowActionToken("Are you sure?", typeof(DeleteNamespaceActionToken));
                folderElement.AddAction(new ElementAction(new ActionHandle(deleteActionToken))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label          = "Delete",
                        ToolTip        = "Delete",
                        Icon           = new ResourceHandle("Composite.Icons", "generated-type-data-delete"),
                        ActionLocation = Actions.ActionLocation
                    }
                });

                folderElement.AddAction(Actions.GetAddAction());
                folderElement.AddAction(Actions.GetExportAction());

                yield return(folderElement);
            }

            foreach (var el in elements)
            {
                yield return(el);
            }
        }