Example #1
0
        public bool HaveCustomChildElements(EntityToken parentEntityToken, Dictionary <string, string> piggybag)
        {
            TreeSharedRootsFacade.Initialize(Context.ProviderName);

            foreach (Tree tree in TreeFacade.GetTreesByEntityToken(parentEntityToken))
            {
                if (tree.RootTreeNode.ChildNodes.Any())
                {
                    return(true);
                }
            }

            return(false);
        }
Example #2
0
        public IEnumerable <ElementAttachingProviderResult> GetAlternateElementLists(EntityToken parentEntityToken, Dictionary <string, string> piggybag)
        {
            TreeSharedRootsFacade.Initialize(Context.ProviderName);

            IEnumerable <Tree> trees = TreeFacade.GetTreesByEntityToken(parentEntityToken);

            foreach (Tree tree in trees)
            {
                foreach (IAttachmentPoint attachmentPoint in tree.GetAttachmentPoints(parentEntityToken))
                {
                    TreeNodeDynamicContext dynamicContext = new TreeNodeDynamicContext(TreeNodeDynamicContextDirection.Down)
                    {
                        ElementProviderName = this.Context.ProviderName,
                        Piggybag            = piggybag,
                        CurrentEntityToken  = parentEntityToken,
                        CurrentTreeNode     = tree.RootTreeNode,
                        IsRoot = true
                    };

                    ElementAttachingProviderResult result = null;
                    try
                    {
                        result = new ElementAttachingProviderResult()
                        {
                            Elements         = tree.RootTreeNode.GetElements(parentEntityToken, dynamicContext).Evaluate(),
                            Position         = attachmentPoint.Position,
                            PositionPriority = 0
                        };
                    }
                    catch (Exception ex)
                    {
                        LoggingService.LogError("TreeFacade", string.Format("Getting elements from the three '{0}' failed", tree.TreeId));
                        LoggingService.LogError("TreeFacade", ex);

                        Element errorElement = ShowErrorElementHelper.CreateErrorElement(
                            StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "KeyFacade.ErrorTreeNode.Label"),
                            tree.TreeId,
                            ex.Message);

                        result = new ElementAttachingProviderResult()
                        {
                            Elements = new List <Element>()
                            {
                                errorElement
                            },
                            Position         = attachmentPoint.Position,
                            PositionPriority = 0
                        };
                    }

                    yield return(result);
                }
            }

            foreach (CustomTreePerspectiveInfo info in TreeSharedRootsFacade.SharedRootFolders.Values)
            {
                if (info.AttachmentPoint.IsAttachmentPoint(parentEntityToken))
                {
                    Element element = new Element(new ElementHandle(info.Element.ElementHandle.ProviderName, info.Element.ElementHandle.EntityToken))
                    {
                        VisualData = info.Element.VisualData
                    };

                    int counter = 0;
                    foreach (Tree tree in info.Trees)
                    {
                        string key = StringConstants.PiggybagSharedTreeId + (counter++);
                        element.ElementHandle.Piggyback[key] = tree.TreeId;
                    }

                    ElementAttachingProviderResult result = new ElementAttachingProviderResult
                    {
                        Elements         = new [] { info.Element },
                        Position         = info.AttachmentPoint.Position,
                        PositionPriority = 10000
                    };

                    yield return(result);
                }
            }
        }
        public IEnumerable <ElementAction> GetActions(EntityToken entityToken)
        {
            if (TreeFacade.HasPossibleAttachmentPoints(entityToken))
            {
                yield return(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.AddApplicationWorkflow"), AddPermissionTypes)
                {
                    DoIgnoreEntityTokenLocking = true
                }))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "AddApplicationWorkflow.AddApplication.Label"),
                        ToolTip = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "AddApplicationWorkflow.AddApplication.ToolTip"),
                        Icon = AddApplicationIcon,
                        Disabled = false,
                        ActionLocation = new ActionLocation
                        {
                            ActionType = ActionType.Other,
                            IsInFolder = false,
                            IsInToolbar = false,
                            ActionGroup = ApplicationsActionGroup
                        }
                    }
                });


                yield return(new ElementAction(new ActionHandle(new WorkflowActionToken(WorkflowFacade.GetWorkflowType("Composite.C1Console.Trees.Workflows.RemoveApplicationWorkflow"), RemovePermissionTypes)
                {
                    DoIgnoreEntityTokenLocking = true
                }))
                {
                    VisualData = new ActionVisualizedData
                    {
                        Label = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "RemoveApplicationWorkflow.RemoveApplication.Label"),
                        ToolTip = StringResourceSystemFacade.GetString("Composite.C1Console.Trees", "RemoveApplicationWorkflow.RemoveApplication.ToolTip"),
                        Icon = RemoveApplicationIcon,
                        Disabled = false,
                        ActionLocation = new ActionLocation
                        {
                            ActionType = ActionType.Other,
                            IsInFolder = false,
                            IsInToolbar = false,
                            ActionGroup = ApplicationsActionGroup
                        }
                    }
                });
            }


            List <ElementAction> elementActions = new List <ElementAction>();

            foreach (Tree tree in TreeFacade.GetTreesByEntityToken(entityToken))
            {
                TreeNodeDynamicContext dynamicContext = new TreeNodeDynamicContext(TreeNodeDynamicContextDirection.Down)
                {
                    CurrentTreeNode    = tree.RootTreeNode,
                    CurrentEntityToken = entityToken,
                    Piggybag           = new Dictionary <string, string>()
                };

                foreach (ActionNode actionNode in tree.RootTreeNode.ActionNodes)
                {
                    actionNode.AddAction(f => elementActions.Add(f), entityToken, dynamicContext);
                }
            }


            foreach (ElementAction elementAction in elementActions)
            {
                yield return(elementAction);
            }
        }