Exemplo n.º 1
0
        private Tab BuildTab(object data,
                             RibbonBuildContext rbc,
                             string contextualGroupId)
        {
            Tab    tab;
            string id          = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.ID);
            string title       = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.TITLE);
            string description = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.DESCRIPTION);
            string command     = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.COMMAND);
            string cssclass    = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.CSSCLASS);

            if (string.IsNullOrEmpty(contextualGroupId))
            {
                tab = Ribbon.CreateTab(id,
                                       title,
                                       description,
                                       command,
                                       cssclass);
            }
            else
            {
                tab = Ribbon.CreateContextualTab(id,
                                                 title,
                                                 description,
                                                 command,
                                                 contextualGroupId,
                                                 cssclass);
                // Make sure that the tabs that are in the initially shown contextual groups are visible
                if (!CUIUtility.IsNullOrUndefined(RibbonBuildOptions.InitiallyVisibleContextualGroups) &&
                    RibbonBuildOptions.InitiallyVisibleContextualGroups.ContainsKey(contextualGroupId) &&
                    RibbonBuildOptions.InitiallyVisibleContextualGroups[contextualGroupId])
                {
                    tab.VisibleInternal = true;
                }
            }

            // If the Tab is being inited in a shallow way, then we set the callback so that
            // the builder will be called if the Tab is selected.
            // We set up the Tab to be delay initialized and give it its own copy of the build context
            JSObject[] children = DataNodeWrapper.GetNodeChildren(data);
            if (children.Length == 0)
            {
                tab.SetDelayedInitData(new DelayedInitHandler(DelayInitTab), data, rbc.Clone());
            }
            else
            {
                FillTab(tab, data, rbc);
            }

            return(tab);
        }