Exemplo n.º 1
0
        private Component DelayInitTab(Component component,
                                       object data,
                                       object buildContext)
        {
            RibbonBuildContext rbc = (RibbonBuildContext)buildContext;
            Tab tab = (Tab)component;

            rbc.InitializedTab = (Tab)component;
            // If the data node does not have children, then it means that this tab
            // was shallowly fetched from the server.  In this case we need to run
            // a query to get the whole node with all of its controls from the server.
            JSObject[] children = DataNodeWrapper.GetNodeChildren(data);
            if (children.Length == 0)
            {
                // TODO: implement this so that the asynchronous part works
                // Find out if we even need to fetch the tabs asynchronously
                // or if we can get away with just initializing them asynchronously
                DataQuery query = new DataQuery();
                query.TabQuery  = true;
                query.Id        = rbc.InitializedTab.Id;
                query.QueryType = DataQueryType.RibbonTab;
                query.Handler   = new DataReturnedEventHandler(this.OnReturnTab);
                query.Data      = rbc;
                DataSource.RunQuery(query);
                return(null);
            }

            FillTab(tab, data, rbc);
            tab.OnDelayedInitFinished(true);
            // TODO(josefl): this should later be an idle task registration instead of a hard call
            Ribbon.Refresh();

            return(tab);
        }