private ColorPicker BuildColorPicker(object data, BuildContext bc) { ColorPickerProperties properties = DataNodeWrapper.GetNodeAttributes(data).To <ColorPickerProperties>(); JSObject[] colorNodes = DataNodeWrapper.GetNodeChildren( DataNodeWrapper.GetFirstChildNodeWithName(data, DataNodeWrapper.Colors)); int numColors = colorNodes.Length; ColorStyle[] colors = new ColorStyle[numColors]; for (int i = 0; i < numColors; i++) { ColorStyle color = new ColorStyle(); JSObject dict = DataNodeWrapper.GetNodeAttributes(colorNodes[i]); string title = DataNodeWrapper.GetAttribute(dict, DataNodeWrapper.TITLE); color.Title = string.IsNullOrEmpty(title) ? DataNodeWrapper.GetAttribute(dict, DataNodeWrapper.ALT) : title; color.Color = DataNodeWrapper.GetAttribute(dict, DataNodeWrapper.COLOR); color.DisplayColor = DataNodeWrapper.GetAttribute(dict, DataNodeWrapper.DISPLAYCOLOR); color.Style = DataNodeWrapper.GetAttribute(dict, DataNodeWrapper.STYLE); colors[i] = color; } ColorPicker cp = new ColorPicker(Root, properties.Id, properties, colors); return(cp); }
private void OnReturnJewel(DataQueryResult dqr) { JewelBuildContext jbc = (JewelBuildContext)dqr.ContextData; // Apply any extensions to the data. dqr.QueryData = ApplyDataExtensions(dqr.QueryData); JSObject jewelNode = DataNodeWrapper.GetFirstChildNodeWithName(dqr.QueryData, DataNodeWrapper.JEWEL); Jewel = BuildJewelInternal(jewelNode, jbc); Jewel.JewelBuilder = this; BuildClient.OnComponentCreated(Jewel, Jewel.Id); if (JewelBuildOptions.AttachToDOM) { Jewel.AttachInternal(true); } else { Jewel.RefreshInternal(); Placeholder.AppendChild(Jewel.ElementInternal); Utility.EnsureCSSClassOnElement(Placeholder, "loaded"); } OnRootBuilt(Jewel); BuildClient.OnComponentBuilt(Jewel, Jewel.Id); }
private void HandleRow(Row row, JSObject data, DeclarativeTemplateBuildContext bc) { JSObject[] children = DataNodeWrapper.GetNodeChildren(data); for (int i = 0; i < children.Length; i++) { string name = DataNodeWrapper.GetNodeName(children[i]); Component comp = null; if (name == DataNodeWrapper.CONTROL) { comp = CreateControlComponentFromData(children[i], bc); } else if (name == DataNodeWrapper.OVERFLOWAREA) { HandleOverflow(children[i], bc, row, i); } else { comp = CreateStripFromData(children[i], bc, row, i); } if (!CUIUtility.IsNullOrUndefined(comp)) { row.AddChild(comp); } } }
private QAT BuildQATInternal(object data, QATBuildContext qbc) { if (CUIUtility.IsNullOrUndefined(data)) { throw new ArgumentNullException("No QAT element was present in the data"); } QAT = new QAT(DataNodeWrapper.GetAttribute(data, "Id"), DataNodeWrapper.GetNodeAttributes(data).To <QATProperties>()); // Handle the controls in the QAT // The XML structure looks like <QAT><Controls><Control></Control><Control></Control>... JSObject controlsParent = DataNodeWrapper.GetFirstChildNodeWithName(data, DataNodeWrapper.CONTROLS); JSObject[] controls = DataNodeWrapper.GetNodeChildren(controlsParent); for (int j = 0; j < controls.Length; j++) { if (!IsNodeTrimmed(controls[j])) { Control control = BuildControl(controls[j], qbc); QAT.AddChild(control.CreateComponentForDisplayMode("Small")); } } return(QAT); }
private GalleryButton BuildGalleryButton(object data, BuildContext bc, string strElmDims) { GalleryElementDimensions elmDims; // If elmDims is null, try to get the value from data if (string.IsNullOrEmpty(strElmDims)) { JSObject attrs = DataNodeWrapper.GetNodeAttributes(data); strElmDims = DataNodeWrapper.GetAttribute(attrs, DataNodeWrapper.ELEMENTDIMENSIONS); } // If elmDims is still null (no value defined in data), default to 32x32 if (string.IsNullOrEmpty(strElmDims)) { elmDims = GalleryElementDimensions.Size32by32; } else { elmDims = Gallery.ConvertStringToGalleryElementDimensions(strElmDims); } GalleryButtonProperties properties = DataNodeWrapper.GetNodeAttributes(data).To <GalleryButtonProperties>(); GalleryButton gb = new GalleryButton(Root, properties.Id, properties, elmDims); return(gb); }
private Strip CreateStripFromData(object data, DeclarativeTemplateBuildContext bc, Component parent, int rowComponentNumber) { JSObject[] children = DataNodeWrapper.GetNodeChildren(data); Strip strip = bc.Ribbon.CreateStrip(parent.Id + "-" + rowComponentNumber); for (int i = 0; i < children.Length; i++) { string name = DataNodeWrapper.GetNodeName(children[i]); if (name == DataNodeWrapper.CONTROL) { ControlComponent comp = CreateControlComponentFromData(children[i], bc); if (!CUIUtility.IsNullOrUndefined(comp)) { strip.AddChild(comp); } } else { HandleOverflow(children[i], bc, strip, i); } } // If there are no children in the strip then there is no reason to add it // If we ever support dynamically adding and removing components out of the ribbon // then this will need to be revisitited. if (strip.Children.Count == 0) { return(null); } return(strip); }
public override Group CreateGroup(SPRibbon ribbon, string id, GroupProperties properties, string title, string description, string command, Dictionary <string, List <Control> > controls, Dictionary <string, string> pars) { DeclarativeTemplateBuildContext bc = new DeclarativeTemplateBuildContext(); bc.Ribbon = ribbon; bc.Controls = controls; bc.Parameters = pars; Group group = ribbon.CreateGroup(id, properties, title, description, command); // Loop through the Layouts for this group and create them. JSObject[] children = DataNodeWrapper.GetNodeChildren(_data); for (int i = 0; i < children.Length; i++) { Layout layout = CreateLayoutFromData(children[i], group, bc); if (!CUIUtility.IsNullOrUndefined(layout)) { group.AddChild(layout); } } return(group); }
internal void AttachAndBuildJewelFromData(object jewelData) { if (!_hasJewel) { return; } _elmJewelPlaceholder.Style.Display = "block"; JewelBuildContext jbc = new JewelBuildContext(); jbc.JewelId = DataNodeWrapper.GetAttribute(jewelData, "Id"); // Build Jewel JewelBuildOptions options = new JewelBuildOptions(); options.TrimmedIds = _builder.Options.TrimmedIds; JewelBuilder builder = new JewelBuilder(options, _elmJewelPlaceholder, _builder.BuildClient); builder.BuildJewelFromData(jewelData, jbc); this.Jewel = builder.Jewel; }
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); }
internal ButtonDock CreateButtonDock(object data, ToolbarBuildContext buildContext) { ButtonDockProperties properties = DataNodeWrapper.GetNodeAttributes(data).To <ButtonDockProperties>(); ButtonDock dock = new ButtonDock(Root, properties.Id, properties); return(dock); }
private ToggleButton BuildToggleButton(object data, BuildContext bc) { ToggleButtonProperties properties = DataNodeWrapper.GetNodeAttributes(data).To <ToggleButtonProperties>(); ToggleButton fsbc = new ToggleButton(Root, properties.Id, properties); return(fsbc); }
private CheckBox BuildCheckBox(object data, BuildContext bc) { CheckBoxProperties properties = DataNodeWrapper.GetNodeAttributes(data).To <CheckBoxProperties>(); CheckBox cb = new CheckBox(Root, properties.Id, properties); return(cb); }
public void LoadTemplates(object data) { JSObject templatesNode = DataNodeWrapper.GetFirstChildNodeWithName(data, DataNodeWrapper.RIBBONTEMPLATES); JSObject[] children = DataNodeWrapper.GetNodeChildren(templatesNode); for (int i = 0; i < children.Length; i++) { LoadGroupTemplate(children[i]); } }
private InsertTable BuildInsertTable(object data, BuildContext bc) { InsertTableProperties properties = DataNodeWrapper.GetNodeAttributes(data).To <InsertTableProperties>(); InsertTable fsit = new InsertTable(Root, properties.Id, properties); return(fsit); }
private SPButton BuildButton(object data, BuildContext bc) { ButtonProperties properties = DataNodeWrapper.GetNodeAttributes(data).To <ButtonProperties>(); SPButton fsea = new SPButton(Root, properties.Id, properties); return(fsea); }
private Separator BuildSeparator(object data, BuildContext bc) { SeparatorProperties properties = DataNodeWrapper.GetNodeAttributes(data).To <SeparatorProperties>(); Separator sep = new Separator(Root, properties.Id, properties); return(sep); }
private SPLabel BuildLabel(object data, BuildContext bc) { LabelProperties properties = DataNodeWrapper.GetNodeAttributes(data).To <LabelProperties>(); SPLabel fslb = new SPLabel(Root, properties.Id, properties); return(fslb); }
private TextBox BuildTextBox(object data, BuildContext bc) { TextBoxProperties properties = DataNodeWrapper.GetNodeAttributes(data).To <TextBoxProperties>(); TextBox fstb = new TextBox(Root, properties.Id, properties); return(fstb); }
private Spinner BuildSpinner(object data, BuildContext bc) { SpinnerProperties properties = DataNodeWrapper.GetNodeAttributes(data).To <SpinnerProperties>(); Spinner fssp = new Spinner(Root, properties.Id, properties, BuildUnits(data)); return(fssp); }
private string[] BuildUnitAbbreviations(JSObject[] children) { int l = children.Length; string[] abbreviations = new string[l]; for (int i = 0; i < l; i++) { abbreviations[i] = DataNodeWrapper.GetAttribute(children[i], DataNodeWrapper.VALUE); } return(abbreviations); }
private SPRibbon BuildRibbon(object data, RibbonBuildContext rbc) { JSObject ribbonElement = DataNodeWrapper.GetFirstChildNodeWithName(data, DataNodeWrapper.RIBBON); if (CUIUtility.IsNullOrUndefined(ribbonElement)) { throw new ArgumentNullException("No ribbon element was present in the data"); } Ribbon = new SPRibbon(DataNodeWrapper.GetAttribute(ribbonElement, "Id"), DataNodeWrapper.GetNodeAttributes(ribbonElement).To <RibbonProperties>()); //REVIEW(josefl) Should this be configurable? Ribbon.UseDataCookie = true; // Handle the Tabs // The XML structure that we are looking at is <Ribbon><Tabs><Tab/><Tab/>... JSObject[] tabChildren = DataNodeWrapper.GetNodeChildren( DataNodeWrapper.GetFirstChildNodeWithName(ribbonElement, DataNodeWrapper.TABS)); AddTabsToRibbon(tabChildren, "", rbc); // Handle the Contextual Tab Groups // The XML structure that we are looking at is <Ribbon><ContextualTabs><ContextualGroup>... object contextualTabs = DataNodeWrapper.GetFirstChildNodeWithName(ribbonElement, DataNodeWrapper.CONTEXTUALTABS); if (!CUIUtility.IsNullOrUndefined(contextualTabs)) { JSObject[] cgChildren = DataNodeWrapper.GetNodeChildren(contextualTabs); bool shownContextualGroupsSpecified = !CUIUtility.IsNullOrUndefined(RibbonBuildOptions.ShownContextualGroups); for (int j = 0; j < cgChildren.Length; j++) { if (shownContextualGroupsSpecified) { // Show the contextual group if it has been explicitly requested/ made available string cgId = DataNodeWrapper.GetAttribute(cgChildren[j], DataNodeWrapper.ID); if (!string.IsNullOrEmpty(cgId)) { if (!RibbonBuildOptions.ShownContextualGroups.ContainsKey(cgId) || CUIUtility.IsNullOrUndefined(RibbonBuildOptions.ShownContextualGroups[cgId])) { continue; } } } AddContextualGroup(cgChildren[j], rbc); } } return(Ribbon); }
private MenuSection BuildMenuSection(JSObject data, BuildContext bc) { string displayMode = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.DISPLAYMODE); if (CUIUtility.IsNullOrUndefined(displayMode)) { displayMode = "Menu"; } string id = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.ID); string title = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.TITLE); string description = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.DESCRIPTION); bool scrollable = Utility.IsTrue(DataNodeWrapper.GetAttribute(data, DataNodeWrapper.SCROLLABLE)); string maxheight = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.MAXHEIGHT); MenuSection ms = Root.CreateMenuSection(id, title, description, scrollable, maxheight, displayMode); JSObject[] menuSectionChildren = DataNodeWrapper.GetNodeChildren(data); JSObject msChild = menuSectionChildren[0]; string msChildName = DataNodeWrapper.GetNodeName(msChild); if (msChildName == DataNodeWrapper.CONTROLS) { // Get the <MenuSection><Controls> node's children JSObject[] individualControls = DataNodeWrapper.GetNodeChildren(msChild); int l = individualControls.Length; JSObject child = null; for (int i = 0; i < l; i++) { child = individualControls[i]; if (IsNodeTrimmed(child)) { continue; } Control control = BuildControl(child, bc); ms.AddChild(control.CreateComponentForDisplayMode(displayMode)); } } else if (msChildName == DataNodeWrapper.GALLERY) { Gallery gallery = BuildGallery(msChild, bc, true); ms.AddChild(gallery); } return(ms); }
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); }
/// <summary> /// The toolbar doesn't require scaling code -- it just builds with a static set of display modes, /// since it only supports one display mode per control type. /// </summary> private Component BuildToolbarControlComponent(object data, ToolbarBuildContext buildContext) { Control control = null; string name = DataNodeWrapper.GetNodeName(data); string displayMode = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.DISPLAYMODE); switch (name) { case DataNodeWrapper.Button: control = BuildControl(data, buildContext); return(control.CreateComponentForDisplayMode( string.IsNullOrEmpty(displayMode) ? "Small" : displayMode)); case DataNodeWrapper.CheckBox: control = BuildControl(data, buildContext); return(control.CreateComponentForDisplayMode( string.IsNullOrEmpty(displayMode) ? "Small" : displayMode)); case DataNodeWrapper.ComboBox: control = BuildControl(data, buildContext); return(control.CreateComponentForDisplayMode("Medium")); case DataNodeWrapper.FlyoutAnchor: control = BuildControl(data, buildContext); return(control.CreateComponentForDisplayMode( string.IsNullOrEmpty(displayMode) ? "Medium" : displayMode)); case DataNodeWrapper.Label: control = BuildControl(data, buildContext); return(control.CreateComponentForDisplayMode( string.IsNullOrEmpty(displayMode) ? "Small" : displayMode)); case DataNodeWrapper.Separator: control = BuildControl(data, buildContext); return(control.CreateComponentForDisplayMode("Small")); case DataNodeWrapper.TextBox: control = BuildControl(data, buildContext); return(control.CreateComponentForDisplayMode( string.IsNullOrEmpty(displayMode) ? "Medium" : displayMode)); case DataNodeWrapper.ToggleButton: control = BuildControl(data, buildContext); return(control.CreateComponentForDisplayMode( string.IsNullOrEmpty(displayMode) ? "Small" : displayMode)); default: throw new InvalidOperationException("Invalid control type."); } }
private ComboBox BuildComboBox(object data, BuildContext bc) { ComboBoxProperties properties = DataNodeWrapper.GetNodeAttributes(data).To <ComboBoxProperties>(); JSObject[] children = DataNodeWrapper.GetNodeChildren(data); Menu menu = null; MenuLauncherControlProperties launcherProperties = DataNodeWrapper.GetNodeAttributes(data).To <MenuLauncherControlProperties>(); Dictionary <string, string> menuItems = null; if (!Utility.IsTrue(launcherProperties.PopulateDynamically)) { // Since PopulateDynamically is not true, we pass in "false" for LazyInit menu = BuildMenu(children[0], bc, false); // Parse XML subtree to build MenuItem list for auto-complete menuItems = new Dictionary <string, string>(); JSObject[] sections = DataNodeWrapper.GetNodeChildren(children[0]); int l = sections.Length; for (int i = 0; i < l; i++) { // Get children of the MenuSection node JSObject[] sectionChildren = DataNodeWrapper.GetNodeChildren(sections[i]); // Get children of the Controls node within the MenuSection // There should only be 1 Controls node within the MenuSection subtree JSObject[] items = DataNodeWrapper.GetNodeChildren(sectionChildren[0]); int m = items.Length; for (int j = 0; j < m; j++) { string labeltext = DataNodeWrapper.GetAttribute(items[j], DataNodeWrapper.LABELTEXT); string menuitemid = DataNodeWrapper.GetAttribute(items[j], DataNodeWrapper.MENUITEMID); menuItems[labeltext] = menuitemid; } } } ComboBox fscb = new ComboBox(Root, properties.Id, properties, menu); fscb.MenuItems = menuItems; return(fscb); }
private ControlComponent CreateControlComponentFromData(object data, DeclarativeTemplateBuildContext bc) { string alias = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.TEMPLATEALIAS); string displayMode = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.DISPLAYMODE); ControlComponent comp = null; List <Control> control = bc.Controls.ContainsKey(alias) ? bc.Controls[alias] : null; // If there is more than one control that is using the same TemplateAlias and the template // slot is a ControlRef, then the slot remains empty so that the problem can be detected and resolved. if (!CUIUtility.IsNullOrUndefined(control) && control.Count > 1) { comp = control[0].CreateComponentForDisplayMode(displayMode); } return(comp); }
private void LoadGroupTemplate(object data) { string id = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.ID); string className = DataNodeWrapper.GetAttribute(data, DataNodeWrapper.CLASSNAME); // If the template is already loaded, then we don't load it again if (!CUIUtility.IsNullOrUndefined(GetTemplate(id))) { return; } if (string.IsNullOrEmpty(className)) { AddTemplate(new DeclarativeTemplate(data), id); } }
public static JSObject GetFirstChildNodeWithName(object data, string name) { JSObject[] children = DataNodeWrapper.GetNodeChildren(data); int l = children.Length; for (int i = 0; i < l; i++) { JSObject child = children[i]; string nm = DataNodeWrapper.GetNodeName(child); if (nm == name) { return(child); } } return(null); }
private Jewel BuildJewelInternal(object data, JewelBuildContext jbc) { if (CUIUtility.IsNullOrUndefined(data)) { throw new ArgumentNullException("No Jewel element was present in the data"); } Jewel = new Jewel(DataNodeWrapper.GetAttribute(data, "Id"), DataNodeWrapper.GetNodeAttributes(data).To <JewelProperties>()); // Handle the Jewel Menu Launcher control JewelMenuLauncher jml = BuildJewelMenuLauncher(data, jbc); Jewel.AddChild(jml.CreateComponentForDisplayMode("Default")); Jewel.JewelMenuLauncher = jml; return(Jewel); }
private SplitButton BuildSplitButton(object data, BuildContext bc) { SplitButtonProperties properties = DataNodeWrapper.GetNodeAttributes(data).To <SplitButtonProperties>(); JSObject[] children = DataNodeWrapper.GetNodeChildren(data); Menu menu = null; if (!Utility.IsTrue(properties.PopulateDynamically)) { menu = BuildMenu(children[0], bc, true); } SplitButton fseo = new SplitButton(Root, properties.Id, properties, menu); return(fseo); }