Exemplo n.º 1
0
        public void GenerateLink(AttributeElement att, AttributesElement gridAtts)
        {
            // Process attributes that use links but don't have one already.
            if (att.Autolink && att.Link == null)
            {
                LevelElement levelToLink = FindLevelToLink(att,gridAtts);
                if (levelToLink != null)
                {
                    LinkElement link = new LinkElement();
                    att.Links.Add(link);
                    //link = new LinkElement();
                    link.Webpanel = levelToLink.View.ObjectName;
                    bool isTemCallBack = false;
                    if (gridAtts.Instance.Settings.Template.TabFunction == SettingsTemplateElement.TabFunctionValue.TreeViewAnchor)
                    {
                        link.Parameters.Add(new ParameterElement("TrnMode.Update"));
                    }
                    foreach (ParameterElement parameter in levelToLink.View.Parameters)
                    {
                        if (parameter.Name == "&" + HPatternInstance.PARMCALLBACK)
                        {
                            isTemCallBack = true;
                        }
                        link.Parameters.Add(parameter.Clone());
                    }
                    if (isTemCallBack == false && gridAtts.Instance.Settings.Template.GenerateCallBackLink)
                    {
                        ParameterElement parm = new ParameterElement("&" + HPatternInstance.PARMCALLBACK);
                        parm.Domain = Domain.Get(gridAtts.Instance.Model,HPatternInstance.PARMCALLBACK);
                        link.Parameters.Add(parm);
                    }
                    /*
                    bool isSuperTypeLink = (General.NodeName(attriNode) != levelToLink.Level.DescriptionAttribute);

                    // Avoid self-links.
                    if (IsAcceptableLink(filename, attriNode, levelToLink, isSuperTypeLink))
                    {
                        attriNode.Attributes["link"].Value = ExtractLinkName(levelToLink.Filename);
                        attriNode.Attributes["level"].Value = levelToLink.Level.Name;

                        if (isSuperTypeLink)
                            AddSupertypeLinkParams(attriNode, levelToLink);
                    }
                    */
                }
            }
        }
Exemplo n.º 2
0
        private LevelElement FindLevelToLink(AttributeElement att, AttributesElement gridAtts)
        {
            foreach (HPatternInstance instance in m_Instances)
            {
                if (instance.Settings.Grid.BuildAutoLink)
                {
                    foreach (LevelElement level in instance.Levels)
                    {
                        // Don't include a link to the same view in tabs.
                        if (level.View != null && level.View.Parameters != null && level.DescriptionAttribute != null && level.DescriptionAttribute.Attribute == att.Attribute)
                        {
                            bool isTemTodos = true;
                            foreach (ParameterElement par in level.View.Parameters)
                            {
                                if (par.IsAttribute && gridAtts.FindAttribute(par.Name) == null)
                                {
                                    isTemTodos = false;
                                    break;
                                }

                            }
                            if (isTemTodos)
                            {
                                return level;
                            }
                        }
                    }
                }
            }

            // Nothing found.
            return null;
        }