Ejemplo n.º 1
0
        protected override IEnumerable <Element> OnGetElements(EntityToken parentEntityToken, TreeNodeDynamicContext dynamicContext)
        {
            var entityToken = new TreeSimpleElementEntityToken(
                this.Id,
                this.Tree.TreeId,
                EntityTokenSerializer.Serialize(parentEntityToken));

            Element element = new Element(new ElementHandle(
                                              dynamicContext.ElementProviderName,
                                              entityToken,
                                              dynamicContext.Piggybag.PreparePiggybag(this.ParentNode, parentEntityToken)
                                              ));


            if (parentEntityToken is TreePerspectiveEntityToken)
            {
                element.ElementHandle.Piggyback[StringConstants.PiggybagTreeId] = Tree.TreeId;
            }

            var replaceContext = new DynamicValuesHelperReplaceContext(parentEntityToken, dynamicContext.Piggybag);

            element.VisualData = new ElementVisualizedData
            {
                Label       = this.LabelDynamicValuesHelper.ReplaceValues(replaceContext),
                ToolTip     = this.ToolTipDynamicValuesHelper.ReplaceValues(replaceContext),
                HasChildren = ChildNodes.Any(),
                Icon        = this.Icon,
                OpenedIcon  = this.OpenIcon
            };

            yield return(element);
        }
Ejemplo n.º 2
0
        protected override IEnumerable<Element> OnGetElements(EntityToken parentEntityToken, TreeNodeDynamicContext dynamicContext)
        {
            var entityToken = new TreeSimpleElementEntityToken(
                this.Id, 
                this.Tree.TreeId, 
                EntityTokenSerializer.Serialize(parentEntityToken));                

            Element element = new Element(new ElementHandle(
                dynamicContext.ElementProviderName,
                entityToken,
                dynamicContext.Piggybag.PreparePiggybag(this.ParentNode, parentEntityToken)
                ));


            if (parentEntityToken is TreePerspectiveEntityToken)
            {
                element.ElementHandle.Piggyback[StringConstants.PiggybagTreeId] = Tree.TreeId;
            }

            var replaceContext = new DynamicValuesHelperReplaceContext(parentEntityToken, dynamicContext.Piggybag);

            element.VisualData = new ElementVisualizedData
            {
                Label = this.LabelDynamicValuesHelper.ReplaceValues(replaceContext),
                ToolTip = this.ToolTipDynamicValuesHelper.ReplaceValues(replaceContext),
                HasChildren = ChildNodes.Any(),
                Icon = this.Icon,
                OpenedIcon = this.OpenIcon
            };

            yield return element;
        }
Ejemplo n.º 3
0
        public override IEnumerable <EntityToken> GetEntityTokens(EntityToken childEntityToken, TreeNodeDynamicContext dynamicContext)
        {
            EntityToken possibleCurrentEntityToken;

            TreeSimpleElementEntityToken treeSimpleElementEntityToken = childEntityToken as TreeSimpleElementEntityToken;

            if (treeSimpleElementEntityToken != null)
            {
                possibleCurrentEntityToken = treeSimpleElementEntityToken.ParentEntityToken;
            }
            else
            {
                possibleCurrentEntityToken = childEntityToken;
            }

            foreach (EntityToken entityToken in this.ParentNode.GetEntityTokens(possibleCurrentEntityToken, dynamicContext))
            {
                yield return(new TreeSimpleElementEntityToken(this.Id, this.Tree.TreeId, EntityTokenSerializer.Serialize(entityToken)));
            }
        }
Ejemplo n.º 4
0
        public override IEnumerable <EntityToken> GetEntityTokens(EntityToken childEntityToken, TreeNodeDynamicContext dynamicContext)
        {
            TreeSimpleElementEntityToken treeSimpleElementEntityToken = childEntityToken as TreeSimpleElementEntityToken;

            if (treeSimpleElementEntityToken != null)
            {
                yield return(treeSimpleElementEntityToken.ParentEntityToken);
            }
            else
            {
                AncestorMatch ancestorFromFilter = GetAncestorFromParentFilter(dynamicContext);

                foreach (IAttachmentPoint attachmentPoint in this.Tree.AttachmentPoints)
                {
                    if (attachmentPoint is DynamicDataItemAttachmentPoint &&
                        ancestorFromFilter != null)
                    {
                        var dynamicAttachmentPoint = attachmentPoint as DynamicDataItemAttachmentPoint;

                        if (ancestorFromFilter.InterfaceType == dynamicAttachmentPoint.InterfaceType)
                        {
                            if (dynamicAttachmentPoint.KeyValue.Equals(ancestorFromFilter.KeyValue))
                            {
                                foreach (var e in dynamicAttachmentPoint.GetEntityTokens(null, null))
                                {
                                    yield return(e);
                                }
                            }
                            continue;
                        }
                    }

                    foreach (EntityToken entityToken in attachmentPoint.GetEntityTokens(childEntityToken, dynamicContext))
                    {
                        yield return(entityToken);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        internal override IEnumerable <EntityToken> FilterParentGeneretedEntityTokens(EntityToken selfEntityToken, IEnumerable <EntityToken> parentGeneretedEntityTokens, TreeNodeDynamicContext dynamicContext)
        {
            // Check below ensures that the parent EntityToken actually present in a tree and not been filtered out

            TreeSimpleElementEntityToken treeSimpleElementEntityToken = (TreeSimpleElementEntityToken)selfEntityToken;
            EntityToken parentEntityToken = treeSimpleElementEntityToken.ParentEntityToken;

            foreach (EntityToken entityToken in parentGeneretedEntityTokens)
            {
                if (parentEntityToken.Equals(entityToken))
                {
                    return(new[] { parentEntityToken });
                }

                TreeSimpleElementEntityToken castedEntityToken = entityToken as TreeSimpleElementEntityToken;
                if ((castedEntityToken != null) &&
                    (parentEntityToken.Equals(castedEntityToken.ParentEntityToken)))
                {
                    return(new [] { parentEntityToken });
                }
            }

            return(new EntityToken[0]);
        }
        protected override IEnumerable <Element> OnGetElements(EntityToken parentEntityToken, TreeNodeDynamicContext dynamicContext)
        {
            var entityToken = new TreeSimpleElementEntityToken(
                this.Id,
                this.Tree.TreeId,
                EntityTokenSerializer.Serialize(parentEntityToken));

            var element = new Element(new ElementHandle(
                                          dynamicContext.ElementProviderName,
                                          entityToken,
                                          dynamicContext.Piggybag.PreparePiggybag(this.ParentNode, parentEntityToken)
                                          ));


            if (this.BrowserUrl != null)
            {
                var url = this.BrowserUrl;

                if (!url.Contains("//"))
                {
                    url = Core.WebClient.UrlUtils.ResolvePublicUrl(url);
                }

                element.PropertyBag.Add("BrowserUrl", url);
                element.PropertyBag.Add("BrowserToolingOn", "false");
            }


            if (this.BrowserImage != null)
            {
                var url = this.BrowserImage;

                if (!url.Contains("//"))
                {
                    url = Core.WebClient.UrlUtils.ResolvePublicUrl(url);
                }

                element.PropertyBag.Add("ListViewImage", url);

                if (this.BrowserUrl == null)
                {
                    element.PropertyBag.Add("DetailViewImage", url);
                }
            }


            if (parentEntityToken is TreePerspectiveEntityToken)
            {
                element.ElementHandle.Piggyback[StringConstants.PiggybagTreeId] = Tree.TreeId;
            }

            var replaceContext = new DynamicValuesHelperReplaceContext(parentEntityToken, dynamicContext.Piggybag);

            element.VisualData = new ElementVisualizedData
            {
                Label       = this.LabelDynamicValuesHelper.ReplaceValues(replaceContext),
                ToolTip     = this.ToolTipDynamicValuesHelper.ReplaceValues(replaceContext),
                HasChildren = ChildNodes.Any(),
                Icon        = this.Icon,
                OpenedIcon  = this.OpenIcon
            };

            yield return(element);
        }