Express > Examples > Saving and Loading Settings of Objects Tree Workbook
A time series database workbook enables the user to load and save its settings and settings for indicators tree.
The following settings are saved and loaded:
Attributes and their order.
Filtering parameters for each attribute.
Sorting order for each attribute.
Names of levels for attribute dimensions.
Determined alternate hierarchy.
Parameters of the Calculation Results panel.
Settings are saved only for the time series databases, which series are used in the workbook.
Executing the example requires a form with the following components:
The Save button with the SaveButton identifier.
The Load button with the LoadButton identifier.
The LanerBox component.
The LanerResultsBox component.
The UiErAnalyzer component named UiErAnalyzer1. This component contains a workbook of time series database that is a data source of the LanerBox and LanerResultsBox components.
The MetaAttributesBreadcrumb component named MetaAttributesBreadcrumb1. This component must use the same time series database as workbook that is loaded to UiErAnalyzer1.
The MetaAttributesTreeList component linked with MetaAttributesBreadcrumb1.
Add links to the Metabase, Express, Xml, and Cubes system assemblies.
Clicking the Save button saves workbook settings, and clicking the Load button saves the settings.
This procedure is a handler of the OnClick event for the SaveButton button.
Sub SaveButtonOnClick(Sender: Object; Args: IMouseEventArgs);
Var
Doc: FreeThreadedDOMDocument60;
Element: IXmlDomElement;
Ea: IEaxAnalyzer;
Wb: IEaxWorkbook;
WbTree: IEaxWorkbookMetaAttributesTree;
Rub: IRubricator;
OpList: IEaxWorkbookRubricatorOptionsList;
Options: IEaxWorkbookRubricatorOptions;
Statistics: IEaxWorkbookStatistics;
Begin
// Save the MetaAttributesBreadcrumb1 settings to XML
Doc := New FreeThreadedDOMDocument60.Create;
Element := Doc.createElement("Breadcrumb");
MetaAttributesBreadcrumb1.SaveState(Element);
Doc.appendChild(Element);
// Get workbook
Ea := UiErAnalyzer1.ErAnalyzer;
Wb := Ea As IEaxWorkbook;
// Get object tree settings
WbTree := Wb.MetaAttributesTree;
Rub := MetaAttributesBreadcrumb1.Rubricator.Rubricator;
// Get directory settings, connected to the object tree
OpList := WbTree.RubricatorsOptions;
// Clear settings
OpList.Clear;
If Options = Null Then
Options := OpList.Add(Rub As IMetabaseObjectDescriptor);
Debug.WriteLine(Time series database: + Options.RubricatorObject.Name);
End If;
// Set indicators tree parameters
Options.HierarchyAttributes := Doc.xml;
// Set settings for the Calculation results panel
Statistics := Wb.Statistics;
Statistics.Enabled := True;
Statistics.Visible := False;
// Save workbook
(Ea As IMetabaseObject).Save;
End Sub SaveButtonOnClick;
After executing the example all settings that are determined for the workbook loaded to LanerBox are saved.
This example is a handler of the OnClick event for the LoadButton component.
Sub LoadButtonOnClick(Sender: Object; Args: IMouseEventArgs);
Var
Rub: IRubricator;
RubKey: Integer;
Doc: FreeThreadedDOMDocument60;
Element: IXmlDomElement;
Ea: IEaxAnalyzer;
Wb: IEaxWorkbook;
WbTree: IEaxWorkbookMetaAttributesTree;
OpList: IEaxWorkbookRubricatorOptionsList;
Options: IEaxWorkbookRubricatorOptions;
Begin
// Get time series,
// linked with MetaAttributesBreadcrumb1
Rub := MetaAttributesBreadcrumb1.Rubricator.Rubricator;
RubKey := (Rub As IMetabaseObjectDescriptor).Key;
// Get workbook
Ea := UiErAnalyzer1.ErAnalyzer;
Wb := Ea As IEaxWorkbook;
// Get object tree settings
WbTree := Wb.MetaAttributesTree;
// Get directory settings, connected to the object tree
OpList := WbTree.RubricatorsOptions;
Options := OpList.Item(RubKey);
// Load saved settings from the workbook MetaAttributesBreadcrumb1
If Options <> Null Then
Doc := New FreeThreadedDOMDocument60.Create;
If (Doc.loadXML(Options.HierarchyAttributes)) Then
Element := Doc.selectSingleNode("Breadcrumb") As IXmlDomElement;
If (Element <> Null) Then
MetaAttributesBreadcrumb1.LoadState(Element);
End If;
Else
Debug.WriteLine(Error loading an XML);
End If;
End If;
// Load saved setting from the workbook of the Calculation Results panel
LanerResultsBox1.ContainerVisible(LanerBoxContainerType.Results) := Wb.Statistics.Visible;
End Sub LoadButtonOnClick;
After executing the example all saved settings are loaded for the workbook loaded to LanerBox.
See also: