Пример #1
0
        private static IEnumerable <Element> GetRoots(string providerName, SearchToken searchToken, bool performSecurityCheck, bool useForeign)
        {
            if (providerName == null)
            {
                throw new ArgumentNullException("providerName");
            }

            IEnumerable <Element> roots;

            if (!useForeign || !ElementProviderPluginFacade.IsLocaleAwareElementProvider(providerName))
            {
                roots = ElementProviderPluginFacade.GetRoots(providerName, searchToken).ToList();
            }
            else
            {
                roots = ElementProviderPluginFacade.GetForeignRoots(providerName, searchToken).ToList();
            }

            if (performSecurityCheck)
            {
                roots = roots.FilterElements();
            }

            ElementActionProviderFacade.AddActions(roots, providerName);

            if (performSecurityCheck)
            {
                return(roots.FilterActions());
            }

            return(roots);
        }
        public IEnumerable<Element> GetChildren(EntityToken entityToken, SearchToken seachToken)
        {
            if (entityToken.Id == DeveloperApplicationProviderEntityToken.TreeRootFolderId)
            {
                foreach (string treeDefinitionFilename in this.TreeDefinitionFilenames)
                {
                    string filename = Path.GetFileName(treeDefinitionFilename);

                    Element treeDefintionElement = new Element(_context.CreateElementHandle(
                        new DeveloperApplicationProviderEntityToken(DeveloperApplicationProviderEntityToken.TreeDefinitionId, filename)))
                    {
                        VisualData = new ElementVisualizedData
                        {
                            Label = filename,
                            ToolTip = filename,
                            Icon = TreeDefinitionIcon
                        }
                    };

                    treeDefintionElement.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.DeleteTreeDefinitionWorkflow"), PermissionTypePredefined.Delete)))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "TreeDeleteTreeDefinitionWorkflow.Delete.Label"),
                            ToolTip = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "TreeDeleteTreeDefinitionWorkflow.Delete.ToolTip"),
                            Icon = TreeDefinitionIconDelete,
                            Disabled = false,
                            ActionLocation = ActionLocation.DeletePrimaryActionLocation
                        }
                    });

                    treeDefintionElement.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.EditTreeDefinitionWorkflow"), PermissionTypePredefined.Edit)))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "TreeDeleteTreeDefinitionWorkflow.Edit.Label"),
                            ToolTip = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "TreeDeleteTreeDefinitionWorkflow.Edit.ToolTip"),
                            Icon = TreeDefinitionIconEdit,
                            Disabled = false,
                            ActionLocation = ActionLocation.EditPrimaryActionLocation
                        }
                    });

                    yield return treeDefintionElement;
                }

                yield break;
            }
            else if (entityToken.Id == DeveloperApplicationProviderEntityToken.TreeDefinitionId)
            {
                //DeveloperApplicationProviderEntityToken castedEntityToken = (DeveloperApplicationProviderEntityToken)entityToken;

                //foreach (Element element in TreeFacade.GetElementsByTreeId(castedEntityToken.Filename, entityToken, new Dictionary<string, string>()))
                //{
                //    yield return element;
                //}
            }

            yield break;
        }
Пример #3
0
        /// <exclude />
        public static IEnumerable <Element> GetChildren(ElementHandle elementHandle, SearchToken searchToken)
        {
            if (elementHandle == null)
            {
                throw new ArgumentNullException("elementHandle");
            }

            return(GetChildren(elementHandle, searchToken, true, false));
        }
Пример #4
0
        private static SearchToken DeserializeLegacy(string serializedSearchToken)
        {
            Verify.ArgumentNotNullOrEmpty(serializedSearchToken, nameof(serializedSearchToken));
            Verify.ArgumentCondition(serializedSearchToken.IndexOf('|') > -1, nameof(serializedSearchToken), "Malformed serializedSearchToken - must be formated like '<class name>|<serialized values>'");

            string[] parts = serializedSearchToken.Split('|');

            string className = parts[0];
            string serializedSearchTokenWithoutClassName = parts[1];

            Type searchTokenType = TypeManager.GetType(className);

            SearchToken searchToken = (SearchToken)SerializationFacade.Deserialize(searchTokenType, serializedSearchTokenWithoutClassName);

            return(searchToken);
        }
Пример #5
0
        private static IEnumerable <Element> GetRoots(string providerName, SearchToken searchToken, bool performSecurityCheck, bool useForeign)
        {
            if (providerName == null)
            {
                throw new ArgumentNullException("providerName");
            }

            IEnumerable <Element> roots;

            try
            {
                if (!useForeign || !ElementProviderPluginFacade.IsLocaleAwareElementProvider(providerName))
                {
                    roots = ElementProviderPluginFacade.GetRoots(providerName, searchToken).ToList();
                }
                else
                {
                    roots = ElementProviderPluginFacade.GetForeignRoots(providerName, searchToken).ToList();
                }
            }
            catch (Exception ex) when(providerName != ElementProviderRegistry.RootElementProviderName)
            {
                Log.LogError(nameof(ElementFacade), $"Failed to get root elements for element provider '{providerName}'");
                Log.LogError(nameof(ElementFacade), ex);

                return(Enumerable.Empty <Element>());
            }


            if (performSecurityCheck)
            {
                roots = roots.FilterElements();
            }

            ElementActionProviderFacade.AddActions(roots, providerName);

            if (performSecurityCheck)
            {
                return(roots.FilterActions());
            }

            return(roots);
        }
Пример #6
0
        public IEnumerable<Element> GetChildren(EntityToken entityToken, SearchToken seachToken)
        {
            if ((entityToken is PackageElementProviderRootEntityToken))
            {
                return GetRootChildren(seachToken);
            }
            if ((entityToken is PackageElementProviderAvailablePackagesFolderEntityToken))
            {
                return GetAvailablePackagesFolderChildren(seachToken);
            }
            if ((entityToken is PackageElementProviderAvailablePackagesGroupFolderEntityToken))
            {
                var castedToken = entityToken as PackageElementProviderAvailablePackagesGroupFolderEntityToken;

                return GetAvailablePackageGroupFolderChildren(castedToken.GroupName, seachToken);
            }
            if ((entityToken is PackageElementProviderInstalledPackageFolderEntityToken))
            {
                return GetInstalledPackageFolderChildren(seachToken);
            }
            if ((entityToken is PackageElementProviderPackageSourcesFolderEntityToken))
            {
                return GetPackageSourcesFolderChildren(seachToken);
            }
            if ((entityToken is PackageElementProviderInstalledPackageLocalPackagesFolderEntityToken))
            {
                return GetInstalledLocalPackagesFolderChildren(seachToken);
            }
            if ((entityToken is PackageElementProviderInstalledPackageGroupFolderEntityToken))
            {
                var castedToken = entityToken as PackageElementProviderInstalledPackageGroupFolderEntityToken;

                return GetInstalledPackageGroupFolderChildren(castedToken.GroupName, seachToken);
            }

            throw new InvalidOperationException("Unexpected entity token type: " + entityToken.GetType());
        }
Пример #7
0
        private IEnumerable<Element> GetAvailablePackagesFolderChildren(SearchToken seachToken)
        {
            IEnumerable<string> groupNames =
                (from description in PackageSystemServices.GetFilteredAllAvailablePackages()
                 select description.GroupName).Distinct();

            foreach (string groupName in groupNames.OrderBy(f=>f))
            {
                Element element = new Element(_context.CreateElementHandle(new PackageElementProviderAvailablePackagesGroupFolderEntityToken(groupName)));
                element.VisualData = new ElementVisualizedData
                {
                    Label = groupName,
                    ToolTip = groupName,
                    HasChildren = true,
                    Icon = AvailablePackagesGroupClosedIcon,
                    OpenedIcon = AvailablePackagesGroupOpenedIcon
                };

                yield return element;
            }
        }
Пример #8
0
        private IEnumerable<Element> GetInstalledPackageGroupFolderChildren(string groupName, SearchToken seachToken)
        {
            IEnumerable<InstalledPackageInformation> installedPackageInformations =
                from info in PackageManager.GetInstalledPackages()
                where info.GroupName == groupName &&
                      info.IsLocalInstalled == false
                orderby info.Name
                select info;

            foreach (InstalledPackageInformation installedPackageInformation in installedPackageInformations)
            {
                Element element = new Element(_context.CreateElementHandle(new PackageElementProviderInstalledPackageItemEntityToken(
                    installedPackageInformation.Id,
                    installedPackageInformation.GroupName,
                    installedPackageInformation.IsLocalInstalled,
                    installedPackageInformation.CanBeUninstalled)));

                element.VisualData = new ElementVisualizedData
                {
                    Label = installedPackageInformation.Name,
                    ToolTip = installedPackageInformation.Name,
                    HasChildren = false,
                    Icon = GetIconForPackageItem(installedPackageInformation.Id),
                };

                element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.PackageElementProvider.ViewInstalledPackageInfoWorkflow"), ActionPermissions)))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "ViewInstalledInformationLabel"),
                        ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "ViewInstalledInformationToolTip"),
                        Icon = ViewInstalledInformationIcon,
                        Disabled = false,
                        ActionLocation = new ActionLocation
                        {
                            ActionType = ActionType.Edit,
                            IsInFolder = false,
                            IsInToolbar = true,
                            ActionGroup = PrimaryActionGroup
                        }

                    }
                });

                yield return element;
            }
        }
 /// <exclude />
 protected abstract IEnumerable<IFunctionTreeBuilderLeafInfo> OnGetFunctionInfos(SearchToken searchToken);
Пример #10
0
        public IEnumerable<Element> GetRoots(SearchToken seachToken)
        {
            Element element = new Element(_context.CreateElementHandle(new PackageElementProviderRootEntityToken()));
            element.VisualData = new ElementVisualizedData
            {
                Label = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "RootFolderLabel"),
                ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "RootFolderToolTip"),
                HasChildren = true,
                Icon = RootClosedIcon,
                OpenedIcon = RootOpenedIcon
            };

            AddInstallLocalPackageAction(element);

            yield return element;
        }
        public IEnumerable<Element> GetRoots(SearchToken seachToken)
        {
            Element element = new Element(_context.CreateElementHandle(new PackageCreatorElementProviderEntityToken()))
            {
                VisualData = new ElementVisualizedData()
                {
                    Label = PackageCreatorFacade.GetLocalization("PackageCreatorElementProviderEntityToken.Label"),
                    ToolTip = PackageCreatorFacade.GetLocalization("PackageCreatorElementProviderEntityToken.ToolTip"),
                    HasChildren = true,
                    Icon = new ResourceHandle("Composite.Icons", "blocks"),
                    OpenedIcon = new ResourceHandle("Composite.Icons", "blocks")
                }
            };

            element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(typeof(CreatePackageWorkflow), new PermissionType[] { PermissionType.Administrate })))
            {
                VisualData = new ActionVisualizedData
                {
                    Label = PackageCreatorFacade.GetLocalization("CreatePackage.Label"),
                    ToolTip = PackageCreatorFacade.GetLocalization("CreatePackage.ToolTip"),
                    Icon = new ResourceHandle("Composite.Icons", "blocks"),
                    ActionLocation = new ActionLocation
                    {
                        ActionType = PackageCreatorFacade.ActionType,
                        IsInFolder = false,
                        IsInToolbar = true,
                        ActionGroup = new ActionGroup("Develop", ActionGroupPriority.PrimaryLow)
                    }
                }
            });

            element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(typeof(UploadConfigWorkflow), new PermissionType[] { PermissionType.Administrate })))
            {
                VisualData = new ActionVisualizedData
                {
                    Label = PackageCreatorFacade.GetLocalization("UploadConfig.Label"),
                    ToolTip = PackageCreatorFacade.GetLocalization("UploadConfig.ToolTip"),
                    Icon = new ResourceHandle("Composite.Icons", "package-install-local-package"),
                    ActionLocation = new ActionLocation
                    {
                        ActionType = PackageCreatorFacade.ActionType,
                        IsInFolder = false,
                        IsInToolbar = false,
                        ActionGroup = new ActionGroup("Develop", ActionGroupPriority.PrimaryLow)
                    }
                }
            });

            if (UserSettings.C1ConsoleUiLanguage.Name != "en-US")
            {
                element.AddAction(new ElementAction(new ActionHandle(new CreatePackageWorkflowActionToken(string.Format("Composite.Localization.C1Console.{0}", new CultureInfo(UserSettings.C1ConsoleUiLanguage.TwoLetterISOLanguageName).EnglishName), new AddLocalizationActionToken(UserSettings.C1ConsoleUiLanguage.Name))))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label = string.Format(PackageCreatorFacade.GetLocalization("CreateLocalizationPackage.Label"), StringResourceSystemFacade.GetString("Composite.Cultures", UserSettings.C1ConsoleUiLanguage.Name)),
                        ToolTip = string.Format(PackageCreatorFacade.GetLocalization("CreateLocalizationPackage.ToolTip"), StringResourceSystemFacade.GetString("Composite.Cultures", UserSettings.C1ConsoleUiLanguage.Name)),
                        Icon = new ResourceHandle("Composite.Icons", "package-element-closed-availableitem"),
                        ActionLocation = new ActionLocation
                        {
                            ActionType = PackageCreatorFacade.ActionType,
                            IsInFolder = false,
                            IsInToolbar = false,
                            ActionGroup = new ActionGroup("Develop", ActionGroupPriority.PrimaryLow)
                        }
                    }
                });
            }

            yield return element;

            yield return GetXmlNodeElement(PCCompositeConfig.Source, string.Empty, PCCompositeConfig.Source);
            yield return GetXmlNodeElement(PCWebConfig.Source, string.Empty, PCWebConfig.Source);
        }
        /// <exclude />
        public IEnumerable<Element> GetChildren(EntityToken entityToken, SearchToken searchToken)
        {
            BaseFunctionFolderElementEntityToken castedEntityToken = (BaseFunctionFolderElementEntityToken)entityToken;

            string id = castedEntityToken.Id;

            int index = castedEntityToken.Id.IndexOf('.');
            if (index != -1)
            {
                id = id.Remove(0, index + 1);
            }

            NamespaceTreeBuilder builder = new NamespaceTreeBuilder(OnGetFunctionInfos(searchToken).Cast<INamespaceTreeBuilderLeafInfo>());

            NamespaceTreeBuilderFolder folderNode;

            if (castedEntityToken.Id == CreateId("", _context.ProviderName))
            {
                folderNode = builder.RootFolder;
            }
            else
            {
                folderNode = builder.GetFolder(id);
            }

            List<Element> result = new List<Element>();
            if (searchToken == null)
            {
                if (folderNode != null)
                {
                    foreach (NamespaceTreeBuilderFolder node in folderNode.SubFolders.OrderBy(f => f.Name))
                    {
                        Element element = CreateFolderElement(node);
                        result.Add(element);
                    }

                    foreach (IFunctionTreeBuilderLeafInfo function in folderNode.Leafs)
                    {
                        Element element = CreateFunctionElement(function);

                        element.PropertyBag.Add("ElementType", "application/x-composite-function");
                        element.PropertyBag.Add("ElementId", IMetaFunctionExtensionMethods.CompositeName(function.Namespace, function.Name));

                        result.Add(element);
                    }
                }
            }
            else
            {
                if (folderNode != null)
                {
                    foreach (NamespaceTreeBuilderFolder node in folderNode.SubFolders.OrderBy(f => f.Name))
                    {
                        if (SubTreeContainsToken(node, searchToken))
                        {
                            Element element = CreateFolderElement(node);
                            result.Add(element);
                        }
                    }

                    foreach (IFunctionTreeBuilderLeafInfo function in folderNode.Leafs)
                    {
                        if (searchToken.Keyword == null || function.Name.Contains(searchToken.Keyword))
                        {
                            Element element = CreateFunctionElement(function);

                            element.PropertyBag.Add("ElementType", "application/x-composite-function");
                            element.PropertyBag.Add("ElementId", IMetaFunctionExtensionMethods.CompositeName(function.Namespace, function.Name));

                            result.Add(element);
                        }
                    }
                }
            }

            return result;
        }
Пример #13
0
        private static IEnumerable<Element> GetRoots(string providerName, SearchToken searchToken, bool performSecurityCheck, bool useForeign)
        {
            if (providerName == null) throw new ArgumentNullException("providerName");
            
            IEnumerable<Element> roots;
            if ((useForeign == false) || (ElementProviderPluginFacade.IsLocaleAwareElementProvider(providerName) == false))
            {
                roots = ElementProviderPluginFacade.GetRoots(providerName, searchToken).ToList();
            }
            else
            {
                roots = ElementProviderPluginFacade.GetForeignRoots(providerName, searchToken).ToList();
            }

            ElementActionProviderFacade.AddActions(roots, providerName);

            if (performSecurityCheck)
            {
                return roots.FilterActions();
            }
            else
            {
                return roots;
            }
        }
        public IEnumerable<Element> GetRoots(SearchToken seachToken)
        {
            Element rootFolderElement = new Element(_context.CreateElementHandle(new PageTemplateFeatureEntityToken(PageTemplateFeatureEntityToken.RootFolderId)))
            {
                VisualData = new ElementVisualizedData
                {
                    Label = StringResourceSystemFacade.GetString("Composite.Plugins.PageTemplateFeatureElementProvider", "ElementProvider.RootLabel"),
                    ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PageTemplateFeatureElementProvider", "ElementProvider.RootToolTip"),
                    HasChildren = this.PageTemplateFeatureFilenames.Any(),
                    Icon = PageTemplateFeatureRootIcon,
                    OpenedIcon = PageTemplateFeatureRootIconOpen
                }
            };

            rootFolderElement.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.PageTemplateFeatureElementProvider.AddPageTemplateFeatureWorkflow"), PermissionTypePredefined.Add)))
            {
                VisualData = new ActionVisualizedData
                {
                    Label = StringResourceSystemFacade.GetString("Composite.Plugins.PageTemplateFeatureElementProvider", "ElementProvider.AddTemplateFeature"),
                    ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PageTemplateFeatureElementProvider", "ElementProvider.AddTemplateFeatureToolTip"),
                    Icon = PageTemplateFeatureIconAdd,
                    Disabled = false,
                    ActionLocation = ActionLocation.AddPrimaryActionLocation
                }
            });

            yield return rootFolderElement;
        }
Пример #15
0
        public IEnumerable<Element> GetChildren(EntityToken entityToken, SearchToken seachToken)
        {
            if ((entityToken is UserGroupElementProviderRootEntityToken) == false) return new Element[] { };

            IEnumerable<IUserGroup> userGroups =
                (from ug in DataFacade.GetData<IUserGroup>()
                 orderby ug.Name
                 select ug).Evaluate();

            List<Element> elements = new List<Element>();

            foreach (IUserGroup userGroup in userGroups)
            {
                Element element = new Element(_elementProviderContext.CreateElementHandle(userGroup.GetDataEntityToken()))
                {
                    VisualData = new ElementVisualizedData
                    {
                        Label = userGroup.Name,
                        ToolTip = userGroup.Name,
                        HasChildren = false,
                        Icon = UserGroupElementProvider.UserGroupIcon,
                        OpenedIcon = UserGroupElementProvider.UserGroupIcon
                    }
                };

                element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.UserGroupElementProvider.EditUserGroupWorkflow"), EditUserGroupPermissionTypes)))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label = StringResourceSystemFacade.GetString("Composite.Plugins.UserGroupElementProvider", "UserGroupElementProvider.EditUserGroupLabel"),
                        ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.UserGroupElementProvider", "UserGroupElementProvider.EditUserGroupToolTip"),
                        Icon = UserGroupElementProvider.EditUserGroupIcon,
                        Disabled = false,
                        ActionLocation = new ActionLocation
                        {
                            ActionType = ActionType.Edit,
                            IsInFolder = false,
                            IsInToolbar = true,
                            ActionGroup = PrimaryActionGroup
                        }
                    }
                });

                element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.UserGroupElementProvider.DeleteUserGroupWorkflow"), DeleteUserGroupPermissionTypes)))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label = StringResourceSystemFacade.GetString("Composite.Plugins.UserGroupElementProvider", "UserGroupElementProvider.DeleteUserGroupLabel"),
                        ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.UserGroupElementProvider", "UserGroupElementProvider.DeleteUserGroupToolTip"),
                        Icon = UserGroupElementProvider.DeleteUserGroupIcon,
                        Disabled = false,
                        ActionLocation = new ActionLocation
                        {
                            ActionType = ActionType.Delete,
                            IsInFolder = false,
                            IsInToolbar = true,
                            ActionGroup = PrimaryActionGroup
                        }
                    }
                });

                elements.Add(element);
            }

            return elements;
        }
Пример #16
0
        /// <exclude />
        public static IEnumerable<Element> GetRootsWithNoSecurity(ElementProviderHandle elementProviderHandle, SearchToken searchToken)
        {
            if (elementProviderHandle == null) throw new ArgumentNullException("elementProviderHandle");

            return GetRoots(elementProviderHandle.ProviderName, searchToken, false, false);
        }
Пример #17
0
        public IEnumerable<Element> GetRoots(SearchToken seachToken)
        {
            int userGroupCount = DataFacade.GetData<IUserGroup>().Count();

            Element element = new Element(_elementProviderContext.CreateElementHandle(new UserGroupElementProviderRootEntityToken()))
            {
                VisualData = new ElementVisualizedData
                {
                    Label = StringResourceSystemFacade.GetString("Composite.Plugins.UserGroupElementProvider", "UserGroupElementProvider.RootLabel"),
                    ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.UserGroupElementProvider", "UserGroupElementProvider.RootToolTip"),
                    HasChildren = userGroupCount > 0,
                    Icon = UserGroupElementProvider.RootClosedIcon,
                    OpenedIcon = UserGroupElementProvider.RootOpenIcon
                }
            };

            element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.UserGroupElementProvider.AddNewUserGroupWorkflow"), AddNewUserGroupPermissionTypes)))
            {
                VisualData = new ActionVisualizedData
                {
                    Label = StringResourceSystemFacade.GetString("Composite.Plugins.UserGroupElementProvider", "UserGroupElementProvider.AddNewUserGroupLabel"),
                    ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.UserGroupElementProvider", "UserGroupElementProvider.AddNewUserGroupToolTip"),
                    Icon = UserGroupElementProvider.AddUserGroupIcon,
                    Disabled = false,
                    ActionLocation = new ActionLocation
                    {
                        ActionType = ActionType.Add,
                        IsInFolder = false,
                        IsInToolbar = true,
                        ActionGroup = PrimaryActionGroup
                    }
                }
            });

            yield return element;
        }
Пример #18
0
        /// <exclude />
        public static IEnumerable <Element> GetForeignRoots(ElementProviderHandle elementProviderHandle, SearchToken searchToken)
        {
            if (elementProviderHandle == null)
            {
                throw new ArgumentNullException("elementProviderHandle");
            }

            return(GetRoots(elementProviderHandle.ProviderName, searchToken, true, true));
        }
Пример #19
0
 /// <exclude />
 public static IEnumerable <Element> GetForeignRoots(SearchToken searchToken)
 {
     return(GetRoots(ElementProviderRegistry.RootElementProviderName, searchToken, true, true));
 }
Пример #20
0
        private IEnumerable<Element> GetRootChildren(SearchToken seachToken)
        {
            Element availablePackagesElement = new Element(_context.CreateElementHandle(new PackageElementProviderAvailablePackagesFolderEntityToken()));
            availablePackagesElement.VisualData = new ElementVisualizedData
            {
                Label = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "AvailablePackagesFolderLabel"),
                ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "AvailablePackagesFolderToolTip"),
                HasChildren = true,
                Icon = AvailablePackagesClosedIcon,
                OpenedIcon = AvailablePackagesOpenedIcon
            };
            availablePackagesElement.AddAction(new ElementAction(new ActionHandle(new ClearServerCacheActionToken()))
            {
                VisualData = new ActionVisualizedData
                {
                    Label = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "ClearServerCacheLabel"),
                    ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "ClearServerCacheToolTip"),
                    Disabled = false,
                    Icon = ClearServerCacheIcon,
                    ActionLocation = new ActionLocation
                    {
                        ActionType = ActionType.Other,
                        IsInFolder = false,
                        IsInToolbar = false,
                        ActionGroup = PrimaryActionGroup
                    }
                }
            });
            yield return availablePackagesElement;

            Element installedPackagesElement = new Element(_context.CreateElementHandle(new PackageElementProviderInstalledPackageFolderEntityToken()));
            installedPackagesElement.VisualData = new ElementVisualizedData
            {
                Label = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "InstalledPackageFolderLabel"),
                ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "InstalledPackageFolderToolTip"),
                HasChildren = true,
                Icon = InstalledPackagesClosedIcon,
                OpenedIcon = InstalledPackagesOpenedIcon
            };
            yield return installedPackagesElement;

            Element packageSourcesElement = new Element(_context.CreateElementHandle(new PackageElementProviderPackageSourcesFolderEntityToken()));
            packageSourcesElement.VisualData = new ElementVisualizedData
            {
                Label = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "PackageSourcesFolderLabel"),
                ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "PackageSourcesFolderToolTip"),
                HasChildren = DataFacade.GetData<IPackageServerSource>().Count() > 0,
                Icon = PackageSourcesClosedIcon,
                OpenedIcon = PackageSourcesOpenedIcon
            };
            packageSourcesElement.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.PackageElementProvider.AddPackageSourceWorkflow"), new PermissionType[] { PermissionType.Administrate })))
            {
                VisualData = new ActionVisualizedData
                {
                    Label = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "AddPackageSourceLabel"),
                    ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "AddPackageSourceToolTip"),
                    Disabled = false,
                    Icon = AddPackageSourceIcon,
                    ActionLocation = new ActionLocation
                    {
                        ActionType = ActionType.Add,
                        IsInFolder = false,
                        IsInToolbar = true,
                        ActionGroup = PrimaryActionGroup
                    }
                }
            });
            yield return packageSourcesElement;
        }
Пример #21
0
        private static IEnumerable<Element> GetChildren(ElementHandle elementHandle, SearchToken searchToken, bool performSecurityCheck, bool useForeign)
        {
            if (elementHandle == null) throw new ArgumentNullException("elementHandle");

            IPerformanceCounterToken performanceToken = PerformanceCounterFacade.BeginElementCreation();

            IEnumerable<Element> children;
            if (ElementProviderRegistry.ElementProviderNames.Contains(elementHandle.ProviderName))
            {
                if ((useForeign == false) || (ElementProviderPluginFacade.IsLocaleAwareElementProvider(elementHandle.ProviderName) == false))
                {
                    children = ElementProviderPluginFacade.GetChildren(elementHandle.ProviderName, elementHandle.EntityToken, searchToken).Evaluate();
                }
                else
                {
                    children = ElementProviderPluginFacade.GetForeignChildren(elementHandle.ProviderName, elementHandle.EntityToken, searchToken).Evaluate();
                }
            }
            else if (ElementAttachingProviderRegistry.ElementAttachingProviderNames.Contains(elementHandle.ProviderName))
            {
                children = ElementAttachingProviderPluginFacade.GetChildren(elementHandle.ProviderName, elementHandle.EntityToken, elementHandle.Piggyback).Evaluate();
            }
            else
            {
                throw new InvalidOperationException(string.Format("No element provider named '{0}' found", elementHandle.ProviderName));
            }

            foreach (Element element in children)
            {
                if (element.VisualData.HasChildren == false)
                {
                    element.VisualData.HasChildren = ElementAttachingProviderFacade.HaveCustomChildElements(element.ElementHandle.EntityToken, element.ElementHandle.Piggyback);
                }
            }
                        
            children = ElementAttachingProviderFacade.AttachElements(elementHandle.EntityToken, elementHandle.Piggyback, children).Evaluate();

            int totalElementCount = children.Count();

            ElementActionProviderFacade.AddActions(children, elementHandle.ProviderName);

            if (performSecurityCheck)
            {
                children = children.FilterActions().Evaluate();
            }

            PerformanceCounterFacade.EndElementCreation(performanceToken, children.Count(), totalElementCount);

            return children;
        }
Пример #22
0
        private static IEnumerable <Element> GetChildrenFromProvider(ElementHandle elementHandle, SearchToken searchToken, bool useForeign)
        {
            if (ElementProviderRegistry.ElementProviderNames.Contains(elementHandle.ProviderName))
            {
                if (!useForeign || !ElementProviderPluginFacade.IsLocaleAwareElementProvider(elementHandle.ProviderName))
                {
                    return(ElementProviderPluginFacade.GetChildren(elementHandle.ProviderName, elementHandle.EntityToken, searchToken));
                }

                return(ElementProviderPluginFacade.GetForeignChildren(elementHandle.ProviderName, elementHandle.EntityToken, searchToken));
            }

            if (ElementAttachingProviderRegistry.ElementAttachingProviderNames.Contains(elementHandle.ProviderName))
            {
                return(ElementAttachingProviderPluginFacade.GetChildren(elementHandle.ProviderName, elementHandle.EntityToken, elementHandle.Piggyback));
            }

            throw new InvalidOperationException($"No element provider named '{elementHandle.ProviderName}' found");
        }
Пример #23
0
 /// <exclude />
 public static IEnumerable<Element> GetForeignRoots(SearchToken searchToken)
 {
     return GetRoots(ElementProviderRegistry.RootElementProviderName, searchToken, true, true);
 }
        public IEnumerable<Element> GetChildren(EntityToken entityToken, SearchToken seachToken)
        {
            if (entityToken.Id == PageTemplateFeatureEntityToken.RootFolderId)
            {
                foreach (string pageTemplateFeratureFilename in this.PageTemplateFeatureFilenames)
                {
                    string filename = Path.GetFileName(pageTemplateFeratureFilename);
                    string featureName = Path.GetFileNameWithoutExtension(filename);

                    bool isHtml = Path.GetExtension(filename) == ".html";

                    Element featureElement = new Element(_context.CreateElementHandle(
                        PageTemplateFeatureEntityToken.BuildFeatureEntityToken(featureName)))
                    {
                        VisualData = new ElementVisualizedData
                        {
                            Label = featureName,
                            ToolTip = filename,
                            Icon = PageTemplateFeatureIcon
                        }
                    };

                    featureElement.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.PageTemplateFeatureElementProvider.EditPageTemplateFeatureWorkflow"), PermissionTypePredefined.Edit)))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label = StringResourceSystemFacade.GetString("Composite.Plugins.PageTemplateFeatureElementProvider", "ElementProvider.EditTemplateFeature"),
                            ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PageTemplateFeatureElementProvider", "ElementProvider.EditTemplateFeatureToolTip"),
                            Icon = PageTemplateFeatureIconEdit,
                            Disabled = false,
                            ActionLocation = ActionLocation.EditPrimaryActionLocation
                        }
                    });

                    featureElement.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.PageTemplateFeatureElementProvider.DeletePageTemplateFeatureWorkflow"), PermissionTypePredefined.Delete)))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label = StringResourceSystemFacade.GetString("Composite.Plugins.PageTemplateFeatureElementProvider", "ElementProvider.DeleteTemplateFeature"),
                            ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PageTemplateFeatureElementProvider", "ElementProvider.DeleteTemplateFeatureToolTip"),
                            Icon = PageTemplateFeatureIconDelete,
                            Disabled = false,
                            ActionLocation = ActionLocation.DeletePrimaryActionLocation
                        }
                    });

                    featureElement.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.PageTemplateFeatureElementProvider.TogglePageTemplateFeatureEditorWorkflow"), PermissionTypePredefined.Edit)))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label = StringResourceSystemFacade.GetString("Composite.Plugins.PageTemplateFeatureElementProvider", "ElementProvider.EditVisually"),
                            ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PageTemplateFeatureElementProvider", "ElementProvider.EditVisuallyToolTip"),
                            Icon = PageTemplateFeatureIconEdit,
                            Disabled = false,
                            ActionCheckedStatus = isHtml ? ActionCheckedStatus.Checked : ActionCheckedStatus.Unchecked,
                            ActionLocation = new ActionLocation
                            {
                                ActionType = ActionType.Other,
                                IsInFolder = false,
                                IsInToolbar = false,
                                ActionGroup = PrimaryFolderToolsActionGroup
                            },

                        }
                    });

                    yield return featureElement;
                }

                yield break;
            }

            yield break;
        }
Пример #25
0
        /// <exclude />
        public static IEnumerable<Element> GetForeignRoots(ElementProviderHandle elementProviderHandle, SearchToken searchToken)
        {
            if (elementProviderHandle == null) throw new ArgumentNullException("elementProviderHandle");

            return GetRoots(elementProviderHandle.ProviderName, searchToken, true, true);
        }
        public IEnumerable<Element> GetChildren(EntityToken entityToken, SearchToken seachToken)
        {
            if (entityToken is PackageCreatorElementProviderEntityToken)
            {
                IEnumerable<string> packages = PackageCreatorFacade.GetPackageNames();
                foreach (var package in packages)
                {
                    bool isActivePackage = PackageCreatorFacade.ActivePackageName == package;

                    var icon = isActivePackage ? (new ResourceHandle("Composite.Icons", "inbox-green")) : new ResourceHandle("Composite.Icons", "inbox");
                    var element = new Element(_context.CreateElementHandle(new PackageCreatorPackageElementProviderEntityToken(package)))
                    {
                        VisualData = new ElementVisualizedData()
                        {
                            Label = package,
                            ToolTip = package,
                            HasChildren = true,
                            Icon = icon,
                            OpenedIcon = icon
                        }
                    };

                    element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(typeof(EditPackageWorkflow), new[] { PermissionType.Administrate })))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label = PackageCreatorFacade.GetLocalization("EditPackage.Label"),
                            ToolTip = PackageCreatorFacade.GetLocalization("EditPackage.ToolTip"),
                            Icon = new ResourceHandle("Composite.Icons", "page-edit-page"),
                            ActionLocation = new ActionLocation
                            {
                                ActionType = ActionType.Other,
                                IsInFolder = false,
                                IsInToolbar = true,
                                ActionGroup = new ActionGroup("Develop", ActionGroupPriority.PrimaryLow)
                            }
                        }
                    });

                    if (!isActivePackage)
                    {
                        element.AddAction(new ElementAction(new ActionHandle(new SetActivePackageActionToken()))
                        {
                            VisualData = new ActionVisualizedData
                            {
                                Label = PackageCreatorFacade.GetLocalization("SetActivePackage.Label"),
                                ToolTip = PackageCreatorFacade.GetLocalization("SetActivePackage.ToolTip"),
                                Icon = new ResourceHandle("Composite.Icons", "accept"),
                                ActionLocation = new ActionLocation
                                {
                                    ActionType = ActionType.Other,
                                    IsInFolder = false,
                                    IsInToolbar = true,
                                    ActionGroup = new ActionGroup("Develop", ActionGroupPriority.PrimaryLow)
                                }
                            }
                        });
                    }

                    element.AddAction(new ElementAction(new ActionHandle(new ConfirmWorkflowActionToken("Are you sure?", typeof(DeleteConfigPackageCreatorActionToken))))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label = PackageCreatorFacade.GetLocalization("DeleteConfigPackageCreator.Label"),
                            ToolTip = PackageCreatorFacade.GetLocalization("DeleteConfigPackageCreator.ToolTip"),
                            Icon = new ResourceHandle("Composite.Icons", "generated-type-delete"),
                            ActionLocation = new ActionLocation
                            {
                                ActionType = PackageCreatorFacade.ActionType,
                                IsInFolder = false,
                                IsInToolbar = false,
                                ActionGroup = new ActionGroup("Other", ActionGroupPriority.PrimaryLow)
                            }
                        }
                    });

                    element.AddAction(new ElementAction(new ActionHandle(new DownloadPackageActionToken("package")))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label = PackageCreatorFacade.GetLocalization("DownloadPackageButton.Label"),
                            ToolTip = PackageCreatorFacade.GetLocalization("DownloadPackageButton.ToolTip"),
                            Icon = new ResourceHandle("Composite.Icons", "package-install-local-package"),
                            ActionLocation = new ActionLocation
                            {
                                ActionType = PackageCreatorFacade.ActionType,
                                IsInFolder = false,
                                IsInToolbar = true,
                                ActionGroup = new ActionGroup("Download", ActionGroupPriority.PrimaryLow)
                            }
                        }
                    });

                    element.AddAction(new ElementAction(new ActionHandle(new DownloadPackageActionToken("config")))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label = PackageCreatorFacade.GetLocalization("DownloadConfigButton.Label"),
                            ToolTip = PackageCreatorFacade.GetLocalization("DownloadConfigButton.ToolTip"),
                            Icon = new ResourceHandle("Composite.Icons", "package-install-local-package"),
                            ActionLocation = new ActionLocation
                            {
                                ActionType = PackageCreatorFacade.ActionType,
                                IsInFolder = false,
                                IsInToolbar = false,
                                ActionGroup = new ActionGroup("Download", ActionGroupPriority.PrimaryLow)
                            }
                        }
                    });

                    yield return element;
                }
            }
            else if (entityToken is PackageCreatorPackageElementProviderEntityToken)
            {
                var categories = PackageCreatorFacade.GetCategories(entityToken.Source);
                foreach (var category in categories)
                {
                    var element = new Element(_context.CreateElementHandle(new PackageCreatorCategoryElementProviderEntityToken(entityToken.Source, category.Name)))
                    {
                        VisualData = new ElementVisualizedData()
                        {
                            Label = category.GetLabel(),
                            ToolTip = category.GetLabel(),
                            HasChildren = true,
                            Icon = new ResourceHandle("Composite.Icons", "folder"),
                            OpenedIcon = new ResourceHandle("Composite.Icons", "folder-open")
                        }
                    };
                    yield return element;
                }

            }
            else if (entityToken is PackageCreatorCategoryElementProviderEntityToken)
            {
                var items = PackageCreatorFacade.GetItems(entityToken.Type, entityToken.Source);
                foreach (var item in items.OrderBy(d => d.Id))
                {
                    var element = new Element(_context.CreateElementHandle(new PackageCreatorItemElementProviderEntityToken(item.Id, entityToken.Source, entityToken.Type)))
                    {
                        VisualData = new ElementVisualizedData()
                        {
                            Label = item.GetLabel(),
                            ToolTip = item.Id,
                            HasChildren = false,
                            Icon = item.ItemIcon,
                            OpenedIcon = item.ItemIcon
                        }
                    };

                    element.AddAction(new ElementAction(new ActionHandle(new DeleteItemPackageCreatorActionToken()))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label = PackageCreatorFacade.GetLocalization("DeleteItemPackageCreator.Label"),
                            ToolTip = PackageCreatorFacade.GetLocalization("DeleteItemPackageCreator.ToolTip"),
                            Icon = new ResourceHandle("Composite.Icons", "page-delete-page"),
                            ActionLocation = new ActionLocation
                            {
                                ActionType = ActionType.Other,
                                IsInFolder = false,
                                IsInToolbar = true,
                                ActionGroup = new ActionGroup("Develop", ActionGroupPriority.PrimaryLow)
                            }
                        }
                    });

                    yield return element;
                }
            }
            else if (entityToken is XmlNodeElementProviderEntityToken)
            {
                var configuration = PackageCreatorFacade.GetConfigurationDocument(entityToken.Source);
                var xpath = (entityToken as XmlNodeElementProviderEntityToken).XPath;
                XContainer container = xpath == string.Empty ? configuration as XContainer : configuration.XPathSelectElement(xpath) as XContainer;
                var element = container as XElement;
                var counter = new Dictionary<string, int>();

                if (container != null)
                {
                    var xmlElements = new List<Element>();
                    foreach (XElement item in container.Elements())
                    {
                        string position = string.Empty;
                        string name = item.Name.ToString();
                        if (counter.ContainsKey(name))
                        {
                            position = string.Format("[{0}]", ++counter[name]);
                        }
                        else
                        {
                            counter.Add(name, 1);
                        }
                        if (item.Attribute("name") != null)
                        {
                            position = string.Format("[@name='{0}']", item.Attribute("name").Value);
                        }

                        string description = item.IndexAttributeValue();

                        xmlElements.Add(GetXmlNodeElement(entityToken.Source, string.Format("{0}/{1}{2}", xpath, name, position), name + (string.IsNullOrEmpty(description) ? string.Empty : string.Format("({0})", description))));
                    }

                    xmlElements.Sort((a, b) => string.Compare(a.VisualData.Label,
                                                              b.VisualData.Label,
                                                              StringComparison.InvariantCulture));

                    foreach (var e in xmlElements) yield return e;
                }

                if (element != null)
                {
                    var elementPath = Regex.Replace(xpath, @"\[[^\]]*\]$", "");
                    foreach (var attribute in element.Attributes())
                    {
                        string name = attribute.Name.ToString();
                        yield return GetXmlAttributeElement(entityToken.Source, string.Format("{0}[@{1}='{2}']", elementPath, name, attribute.Value), string.Format("{0}={1}", name, attribute.Value));
                    }
                }
            }
        }
Пример #27
0
        /// <exclude />
        public static IEnumerable<Element> GetForeignChildren(ElementHandle elementHandle, SearchToken searchToken)
        {
            if (elementHandle == null) throw new ArgumentNullException("elementHandle");

            return GetChildren(elementHandle, searchToken, true, true);
        }
        /// <exclude />
        public IEnumerable<Element> GetRoots(SearchToken searchToken)
        {
            NamespaceTreeBuilder builder = new NamespaceTreeBuilder(OnGetFunctionInfos(searchToken).Cast<INamespaceTreeBuilderLeafInfo>());

            bool hasChildren = (builder.RootFolder.SubFolders.Count != 0) || (builder.RootFolder.Leafs.Count != 0);

            Element element = new Element(_context.CreateElementHandle(new BaseFunctionFolderElementEntityToken(CreateId("", _context.ProviderName))))
                {
                    VisualData = new ElementVisualizedData()
                        {
                            Label = RootFolderLabel,
                            ToolTip = RootFolderToolTip,
                            HasChildren = hasChildren,
                            Icon = hasChildren ? this.FolderIcon : this.EmptyFolderIcon,
                            OpenedIcon = OpenFolderIcon
                        }
                };
            element.TreeLockBehavior = OnGetTreeLockBehavior();

            IEnumerable<ElementAction> actions = OnGetFolderActions();
            if (actions != null)
            {
                foreach (ElementAction action in actions)
                {
                    element.AddAction(action);
                }
            }

            return new List<Element> { element };
        }
        public IEnumerable<Element> GetRoots(SearchToken seachToken)
        {
            Element element = new Element(_context.CreateElementHandle(new LocalizationElementProviderRootEntityToken()));
            element.VisualData = new ElementVisualizedData
            {
                Label = StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "ElementProvider.RootFolderLabel"),
                ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "ElementProvider.RootFolderToolTip"),
                HasChildren = true,
                Icon = RootClosedIcon,
                OpenedIcon = RootOpenedIcon
            };

            element.AddAction(new ElementAction(new ActionHandle(
                new WorkflowActionToken(
                    WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.LocalizationElementProvider.AddSystemLocaleWorkflow"),
                    new PermissionType[] { PermissionType.Administrate }
                )))
            {
                VisualData = new ActionVisualizedData
                {
                    Label = StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "AddSystemLocaleWorkflow.AddElementActionLabel"),
                    ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "AddSystemLocaleWorkflow.AddElementActionToolTip"),
                    Icon = AddSystemLocaleIcon,
                    Disabled = false,
                    ActionLocation = new ActionLocation
                    {
                        ActionType = ActionType.Add,
                        IsInFolder = false,
                        IsInToolbar = true,
                        ActionGroup = PrimaryActionGroup
                    }
                }
            });

            yield return element;
        }
        private bool SubTreeContainsToken(NamespaceTreeBuilderFolder folder, SearchToken searchToken)
        {
            if (string.IsNullOrEmpty(searchToken.Keyword))
            {
                return true;

            }

            if (folder.Name.Contains(searchToken.Keyword))
            {
                return true;
            }

            foreach (INamespaceTreeBuilderLeafInfo leaf in folder.Leafs)
            {
                if (leaf.Name.Contains(searchToken.Keyword))
                {
                    return true;
                }
            }
            foreach (NamespaceTreeBuilderFolder subFolder in folder.SubFolders)
            {
                if (SubTreeContainsToken(subFolder, searchToken))
                {
                    return true;
                }
            }

            return false;
        }
Пример #31
0
        /// <exclude />
        public static IEnumerable <Element> GetRootsWithNoSecurity(ElementProviderHandle elementProviderHandle, SearchToken searchToken)
        {
            if (elementProviderHandle == null)
            {
                throw new ArgumentNullException("elementProviderHandle");
            }

            return(GetRoots(elementProviderHandle.ProviderName, searchToken, false, false));
        }
Пример #32
0
        private IEnumerable<Element> GetAvailablePackageGroupFolderChildren(string groupName, SearchToken seachToken)
        {
            IEnumerable<PackageDescription> packageDescriptions =
                (from description in PackageSystemServices.GetFilteredAllAvailablePackages()
                 where description.GroupName == groupName
                 orderby description.Name
                 select description);

            foreach (PackageDescription packageDescription in packageDescriptions)
            {
                ResourceHandle packageIcon = (packageDescription.PriceAmmount > 0 ? AvailableCommercialPackageItemIcon : AvailablePackageItemIcon);

                Element element = new Element(_context.CreateElementHandle(new PackageElementProviderAvailablePackagesItemEntityToken(
                    packageDescription.Id.ToString(),
                    packageDescription.GroupName)));
                element.VisualData = new ElementVisualizedData
                {
                    Label = packageDescription.Name,
                    ToolTip = packageDescription.Name,
                    HasChildren = false,
                    Icon = packageIcon,
                };

                element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.PackageElementProvider.ViewAvailablePackageInfoWorkflowWorkflow"), ActionPermissions)))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "ViewAvailableInformationLabel"),
                        ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "ViewAvailableInformationToolTip"),
                        Icon = ViewInstalledInformationIcon,
                        Disabled = false,
                        ActionLocation = new ActionLocation
                        {
                            ActionType = ActionType.Edit,
                            IsInFolder = false,
                            IsInToolbar = true,
                            ActionGroup = PrimaryActionGroup
                        }

                    }
                });

                yield return element;
            }
        }
Пример #33
0
        private static IEnumerable <Element> GetChildren(ElementHandle elementHandle, SearchToken searchToken, bool performSecurityCheck, bool useForeign)
        {
            if (elementHandle == null)
            {
                throw new ArgumentNullException("elementHandle");
            }

            IPerformanceCounterToken performanceToken = PerformanceCounterFacade.BeginElementCreation();

            IEnumerable <Element> children;

            if (ElementProviderRegistry.ElementProviderNames.Contains(elementHandle.ProviderName))
            {
                if ((useForeign == false) || (ElementProviderPluginFacade.IsLocaleAwareElementProvider(elementHandle.ProviderName) == false))
                {
                    children = ElementProviderPluginFacade.GetChildren(elementHandle.ProviderName, elementHandle.EntityToken, searchToken).Evaluate();
                }
                else
                {
                    children = ElementProviderPluginFacade.GetForeignChildren(elementHandle.ProviderName, elementHandle.EntityToken, searchToken).Evaluate();
                }
            }
            else if (ElementAttachingProviderRegistry.ElementAttachingProviderNames.Contains(elementHandle.ProviderName))
            {
                children = ElementAttachingProviderPluginFacade.GetChildren(elementHandle.ProviderName, elementHandle.EntityToken, elementHandle.Piggyback).Evaluate();
            }
            else
            {
                throw new InvalidOperationException(string.Format("No element provider named '{0}' found", elementHandle.ProviderName));
            }

            foreach (Element element in children)
            {
                if (element.VisualData.HasChildren == false)
                {
                    element.VisualData.HasChildren = ElementAttachingProviderFacade.HaveCustomChildElements(element.ElementHandle.EntityToken, element.ElementHandle.Piggyback);
                }
            }

            children = ElementAttachingProviderFacade.AttachElements(elementHandle.EntityToken, elementHandle.Piggyback, children).Evaluate();

            int totalElementCount = children.Count();

            ElementActionProviderFacade.AddActions(children, elementHandle.ProviderName);

            if (performSecurityCheck)
            {
                children = children.FilterActions().Evaluate();
            }

            PerformanceCounterFacade.EndElementCreation(performanceToken, children.Count(), totalElementCount);

            return(children);
        }
Пример #34
0
        private IEnumerable<Element> GetInstalledPackageFolderChildren(SearchToken seachToken)
        {
            bool hasLocalPackageChildren =
                (from info in PackageManager.GetInstalledPackages()
                 where info.IsLocalInstalled
                 select info.Name).FirstOrDefault() != null;

            Element localPackagesElement = new Element(_context.CreateElementHandle(new PackageElementProviderInstalledPackageLocalPackagesFolderEntityToken()));
            localPackagesElement.VisualData = new ElementVisualizedData
            {
                Label = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "LocalPackagesFolderLabel"),
                ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "LocalPackagesFolderToolTip"),
                HasChildren = hasLocalPackageChildren,
                Icon = LocalPackagesClosedIcon,
                OpenedIcon = LocalPackagesOpenedIcon
            };

            AddInstallLocalPackageAction(localPackagesElement);

            yield return localPackagesElement;

            IEnumerable<string> groupNames =
                (from info in PackageManager.GetInstalledPackages()
                 where info.IsLocalInstalled == false
                 orderby info.GroupName
                 select info.GroupName).Distinct();

            foreach (string groupName in groupNames)
            {
                Element element = new Element(_context.CreateElementHandle(new PackageElementProviderInstalledPackageGroupFolderEntityToken(groupName)));
                element.VisualData = new ElementVisualizedData
                {
                    Label = groupName,
                    ToolTip = groupName,
                    HasChildren = true,
                    Icon = InstalledPackagesGroupClosedIcon,
                    OpenedIcon = InstalledPackagesGroupOpenedIcon
                };

                yield return element;
            }
        }
        public IEnumerable<Element> GetRoots(SearchToken searchToken)
        {
            Element element = new Element(_context.CreateElementHandle(new PageTemplateRootEntityToken()));

            bool hasChildren = PageTemplateFacade.GetPageTemplates().Any();

            element.VisualData = new ElementVisualizedData
                         {
                             Label = SR.GetString("Composite.Plugins.PageTemplateElementProvider", "PageTemplateElementProvider.RootLabel"),
                             ToolTip = SR.GetString("Composite.Plugins.PageTemplateElementProvider", "PageTemplateElementProvider.RootLabelToolTip"),
                             HasChildren = hasChildren,
                             Icon = PageTemplateElementProvider.RootClosed,
                             OpenedIcon = PageTemplateElementProvider.RootOpen
                         };

            const string addTemplateWorkflowType = "Composite.Plugins.Elements.ElementProviders.PageTemplateElementProvider.AddNewPageTemplateWorkflow";

            element.AddWorkflowAction(addTemplateWorkflowType, new[] { PermissionType.Add },
                                      new ActionVisualizedData
            {
                Label = SR.GetString("Composite.Plugins.PageTemplateElementProvider", "PageTemplateElementProvider.AddTemplate"),
                ToolTip = SR.GetString("Composite.Plugins.PageTemplateElementProvider", "PageTemplateElementProvider.AddTemplateToolTip"),
                Icon = PageTemplateElementProvider.AddTemplate,
                Disabled = false,
                ActionLocation = new ActionLocation
                {
                    ActionType = ActionType.Add,
                    IsInFolder = false,
                    IsInToolbar = true,
                    ActionGroup = PrimaryActionGroup
                }
            });

            foreach(var pageTemplateProviderName in PageTemplateProviderRegistry.ProviderNames)
            {
                var provider = PageTemplateProviderPluginFacade.GetProvider(pageTemplateProviderName);

                Verify.IsNotNull(provider, "Failed to get provider by name '{0}'", pageTemplateProviderName);

                IEnumerable<ElementAction> actions = provider.GetRootActions();

                element.AddAction(actions);
            }

            return new [] { element };
        }
Пример #36
0
        private IEnumerable<Element> GetPackageSourcesFolderChildren(SearchToken seachToken)
        {
            List<IPackageServerSource> packageServerSources =
                (from a in DataFacade.GetData<IPackageServerSource>()
                 orderby a.Url
                 select a).ToList();

            foreach (IPackageServerSource packageServerSource in packageServerSources)
            {
                Element element = new Element(_context.CreateElementHandle(packageServerSource.GetDataEntityToken()));
                element.VisualData = new ElementVisualizedData
                {
                    Label = packageServerSource.Url,
                    ToolTip = packageServerSource.Url,
                    HasChildren = false,
                    Icon = PackageSourceItemClosedIcon
                };

                element.AddAction(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.PackageElementProvider.DeletePackageSourceWorkflow"), new PermissionType[] { PermissionType.Administrate })))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "DeletePackageSourceLabel"),
                        ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "DeletePackageSourceToolTip"),
                        Icon = DeletePackageSourceIcon,
                        Disabled = false,
                        ActionLocation = new ActionLocation
                        {
                            ActionType = ActionType.Delete,
                            IsInFolder = false,
                            IsInToolbar = true,
                            ActionGroup = PrimaryActionGroup
                        }

                    }
                });

                yield return element;
            }
        }
        private IEnumerable<Element> GetSharedCodeElements(SearchToken searchToken)
        {
            var result = new List<Element>();

            foreach(SharedFile sharedFile in PageTemplateFacade.GetSharedFiles())
            {
                string relativeFilePath = sharedFile.RelativeFilePath;

                string fullPath = relativeFilePath.StartsWith("~") ? PathUtil.Resolve(relativeFilePath) : relativeFilePath;
                var websiteFile = new WebsiteFile(fullPath);

                Element element = new Element(_context.CreateElementHandle(new SharedCodeFileEntityToken(relativeFilePath)))
                {
                    VisualData = new ElementVisualizedData()
                    {
                        Label = websiteFile.FileName,
                        ToolTip = websiteFile.FileName,
                        HasChildren = false,
                        Icon = FileElementProvider.WebsiteFileIcon(websiteFile.MimeType),
                        OpenedIcon = FileElementProvider.WebsiteFileIcon(websiteFile.MimeType)
                    }
                };

                element.PropertyBag.Add("Uri", PathUtil.GetWebsitePath(websiteFile.FullPath));
                element.PropertyBag.Add("ElementType", websiteFile.MimeType);

                // Adding "Edit" action for text-editable files
                if (sharedFile.DefaultEditAction && MimeTypeInfo.IsTextFile(websiteFile.MimeType))
                {
                    element.AddWorkflowAction(
                        "Composite.Plugins.Elements.ElementProviders.PageTemplateElementProvider.EditSharedCodeFileWorkflow",
                        new[] {PermissionType.Edit},
                        new ActionVisualizedData
                            {
                                Label = GetResourceString("EditSharedCodeFile.Label"),
                                ToolTip = GetResourceString("EditSharedCodeFile.ToolTip"),
                                Icon = CommonCommandIcons.Edit,
                                Disabled = websiteFile.IsReadOnly,
                                ActionLocation = new ActionLocation
                                                        {
                                                            ActionType = ActionType.Edit,
                                                            IsInFolder = false,
                                                            IsInToolbar = true,
                                                            ActionGroup = EditCodeFileActionGroup
                                                        }
                            });
                }

                var customActions = sharedFile.GetActions();
                foreach(var action in customActions)
                {
                    element.AddAction(action);
                }

                result.Add(element);
            }

            return result;
        }
        public IEnumerable<Element> GetChildren(EntityToken entityToken, SearchToken seachToken)
        {
            if ((entityToken is LocalizationElementProviderRootEntityToken) == false) throw new InvalidOperationException();

            IEnumerable<ISystemActiveLocale> locales = DataFacade.GetData<ISystemActiveLocale>().ToList();

            List<Element> elements = new List<Element>();

            foreach (ISystemActiveLocale locale in locales)
            {
                bool isDefault = LocalizationFacade.IsDefaultLocale(locale.CultureName);

                ResourceHandle iconHandle = LocaleItemIcon;
                if (isDefault)
                {
                    //lable = string.Format("{0} ({1})", lable, StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "ElementProvider.DefaultLabel"));
                    iconHandle = DefaultLocaleItemIcon;
                }

                Element element = new Element(_context.CreateElementHandle(locale.GetDataEntityToken()));
                element.VisualData = new ElementVisualizedData
                {
                    Label = DataLocalizationFacade.GetCultureTitle(new CultureInfo(locale.CultureName)),
                    ToolTip = DataLocalizationFacade.GetCultureTitle(new CultureInfo(locale.CultureName)),
                    HasChildren = false,
                    Icon = iconHandle
                };

                element.AddAction(new ElementAction(new ActionHandle(
                    new WorkflowActionToken(
                        WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.LocalizationElementProvider.EditSystemLocaleWorkflow"),
                        new PermissionType[] { PermissionType.Administrate }
                    )))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label = StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "EditSystemLocaleWorkflow.EditElementActionLabel"),
                        ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "EditSystemLocaleWorkflow.EditElementActionToolTip"),
                        Icon = EditSystemLocaleIcon,
                        Disabled = false,
                        ActionLocation = new ActionLocation
                        {
                            ActionType = ActionType.Edit,
                            IsInFolder = false,
                            IsInToolbar = true,
                            ActionGroup = PrimaryActionGroup
                        }
                    }
                });

                if (isDefault == false)
                {
                    element.AddAction(new ElementAction(new ActionHandle(
                        new WorkflowActionToken(
                            WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.LocalizationElementProvider.DefineDefaultActiveLocaleWorkflow"),
                            new PermissionType[] { PermissionType.Administrate }
                        )))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label = StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "DefineDefaultActiveLocaleWorkflow.ElementActionLabel"),
                            ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "DefineDefaultActiveLocaleWorkflow.ElementActionToolTip"),
                            Icon = SetAsDefaultIcon,
                            Disabled = false,
                            ActionLocation = new ActionLocation
                            {
                                ActionType = ActionType.Edit,
                                IsInFolder = false,
                                IsInToolbar = true,
                                ActionGroup = PrimaryActionGroup
                            }
                        }
                    });

                    element.AddAction(new ElementAction(new ActionHandle(
                        new WorkflowActionToken(
                            WorkflowFacade.GetWorkflowType("Composite.Plugins.Elements.ElementProviders.LocalizationElementProvider.RemoveSystemLocaleWorkflow"),
                            new PermissionType[] { PermissionType.Administrate }
                        )))
                    {
                        VisualData = new ActionVisualizedData
                        {
                            Label = StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "RemoveSystemLocaleWorkflow.RemoveElementActionLabel"),
                            ToolTip = StringResourceSystemFacade.GetString("Composite.Plugins.LocalizationElementProvider", "RemoveSystemLocaleWorkflow.RemoveElementActionToolTip"),
                            Icon = RemoveSystemLocaleIcon,
                            Disabled = false,
                            ActionLocation = new ActionLocation
                            {
                                ActionType = ActionType.Delete,
                                IsInFolder = false,
                                IsInToolbar = true,
                                ActionGroup = PrimaryActionGroup
                            }
                        }
                    });
                }

                elements.Add(element);
            }

            return elements.OrderBy(f => f.VisualData.Label);
        }
Пример #39
0
        private static IEnumerable <Element> GetChildren(ElementHandle elementHandle, SearchToken searchToken, bool performSecurityCheck, bool useForeign)
        {
            Verify.ArgumentNotNull(elementHandle, nameof(elementHandle));

            var performanceToken = PerformanceCounterFacade.BeginElementCreation();

            var children = GetChildrenFromProvider(elementHandle, searchToken, useForeign).Evaluate();

            var originalChildren = children;

            children = ElementAttachingProviderFacade.AttachElements(elementHandle.EntityToken, elementHandle.Piggyback, children).Evaluate();

            int totalElementCount = children.Count;

            if (performSecurityCheck)
            {
                children = children.FilterElements().Evaluate();
            }

            // Evaluating HasChildren for not attached elements
            foreach (Element element in originalChildren)
            {
                if (children.Contains(element) && !element.VisualData.HasChildren)
                {
                    element.VisualData.HasChildren = ElementAttachingProviderFacade.HaveCustomChildElements(element.ElementHandle.EntityToken, element.ElementHandle.Piggyback);
                }
            }

            ElementActionProviderFacade.AddActions(children, elementHandle.ProviderName);

            if (performSecurityCheck)
            {
                children = children.FilterActions().Evaluate();
            }

            PerformanceCounterFacade.EndElementCreation(performanceToken, children.Count, totalElementCount);

            return(children);
        }
Пример #40
0
 /// <summary>
 /// This method return <value>true</value> if the <paramref name="searchToken"/> is NOT null and the keyword is NOT null or empty
 /// </summary>
 /// <param name="searchToken"></param>
 /// <returns></returns>
 public static bool IsValidKeyword(this SearchToken searchToken)
 {
     return(searchToken != null && !searchToken.Keyword.IsNullOrEmpty());
 }
        public IEnumerable<Element> GetChildren(EntityToken entityToken, SearchToken searchToken)
        {
            if (entityToken is SharedCodeFolderEntityToken)
            {
                return GetSharedCodeElements(searchToken);
            }

            if ((entityToken is PageTemplateRootEntityToken) == false) return new Element[] { };

            bool sharedFilesExist = PageTemplateFacade.GetSharedFiles().Any();

            IEnumerable<Element> result = sharedFilesExist
                ? new [] { GetSharedCodeElement()}
                : new Element[0];

            var pageTemplates = PageTemplateFacade.GetPageTemplates();

            if (searchToken.IsValidKeyword())
            {
                string keyword = searchToken.Keyword.ToLowerInvariant();

                pageTemplates = pageTemplates
                    .Where(t => t.Title.IndexOf(keyword, StringComparison.InvariantCultureIgnoreCase) > 0);
            }

            pageTemplates = pageTemplates.OrderBy(template => template.Title).ToList();

            return result.Concat( GetElements(pageTemplates) );
        }