Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example displays dimension panel controller view and dimension type selection controller view. The development environment console displays the following information:
Parameters of the Indicators dimension, the Education element and its first child element.
Whether data and menu loading indicator is displayed on selecting dimension elements.
It is required to add the following file to the base example Displaying of Express Report:
MADimensionRoleAcceptorProtocolImpl.h/.m. Dimension type selection delegate.
Executing the example requires to place the following code in the body of the executeExample method of the ViewController class (see the Displaying of Express Report section):
// Get dashboard controller MAExpressAnalysisReportViewController *contr = (MAExpressAnalysisReportViewController *)m_controller; // Get express report delegate EAReportDelegateImpl *delegate = [contr delegate]; // Get pivot object for building data tables SPPLPivot pivot = PPLPivot::pivot([delegate olapReport]); // Create a dimension panel delegate MADimensionsPanelTableViewDelegate *panelDelegate = [[MADimensionsPanelTableViewDelegate alloc] initWithPivot: pivot]; // Create a dimension panel data source MADimensionsPanelTableViewDataSource *panelDataSource = [[MADimensionsPanelTableViewDataSource alloc] initWithPivot: [panelDelegate pivot]]; // Create a panel dimension controller MADimensionsPanelTableViewController *tableViewCtrl = [MADimensionsPanelTableViewController new]; [tableViewCtrl setPanelDataSource: panelDataSource]; [tableViewCtrl setPanelDelegate: panelDelegate]; NSLog(@"Number of dimensions: %d", [tableViewCtrl dimensionsCount]); // Get table used for view markup UITableView *tableView = [tableViewCtrl tableView]; if(tableView != nil) { NSLog(@"Table row height for view markup: %f", [tableView rowHeight]); } else { NSLog(@"Markup table for view is not specified"); } // Get the Indicators dimension MADimensionsPanelDimensionDescriptor *dimension = nil; // Get number of dimensions NSUInteger dimensionsCount = [panelDataSource dimensionsPanelTableViewDimensionsCount: tableViewCtrl]; for (int i = 0; i < dimensionsCount; i++) { // Get first dimension description MADimensionsPanelDimensionDescriptor *dimDescriptor = [panelDataSource dimensionsPanelTableView: tableViewCtrl dimensionAtIndex:i]; if ([[dimDescriptor title] isEqualToString:@"Indicators"]) { dimension = dimDescriptor; } } if (dimension == nil) { return; } NSLog(@"Dimension key: %lld", [dimension dimensionKey]); NSLog(@"Dimension identifier: %@", [dimension dimensionId]); NSLog(@"Dimension title: %@", [dimension title]); NSLog(@"Dimension subtitle: %@", [dimension subtitle]); // Get dimension as a pplib++ library object PPLDimension *pplDimension = [dimension dimension]; NSLog(@"Number of elements of this dimension: %d", pplDimension->elements()->itemsCount()); // Set this dimension [dimension setDimension: pplDimension]; // Determine dimension type NSString *dimensionRole = [NSString string]; switch ([dimension role]) { case kDRNone: dimensionRole = @"no type"; break; case kDRTopHeader: dimensionRole = @"Top title"; break; case kDRLeftHeader: dimensionRole = @"Left title"; break; case kDRFixedHeader: dimensionRole = @"Fixed title"; break; default: break; } NSLog(@"Dimension type: %@", dimensionRole); // Determine selection type in dimension NSString *selectionType = [NSString string]; switch ([dimension selectionType]) { case kDESTMultiSelect: selectionType = @"single selection"; break; case kDESTSingleSelect: selectionType = @"multiple selection"; break; default: break; } NSLog(@"Selection type in dimension: %@", selectionType); NSString *elementName = @"Education"; // Get number of elements with the text "Education" NSUInteger number = [panelDataSource dimensionsPanelTableView: tableViewCtrl numberOfElementOfDimension:dimension satisfyingToSearchString: elementName]; NSLog(@"Number of elements with the text "%@": %d", elementName, number); if (number > 0) { // Get first element description in dimension MADimensionsPanelDimensionElementDescriptor *elementDescriptor = [panelDataSource dimensionsPanelTableView: tableViewCtrl element:0 ofDimension:dimension satisfyingToSearchString: [panelDataSource searchString]]; if (elementDescriptor == nil) { return; } NSLog(@"Element key: %lld", [elementDescriptor key]); NSLog(@"Element title: %@", [elementDescriptor title]); // Determine whether element is selected if ([elementDescriptor selected]) { NSLog(@"Element is selected"); } else { NSLog(@"Element is not selected"); } // Get number of child elements of the first dimension NSUInteger childElementsCount = [panelDataSource dimensionsPanelTableView:tableViewCtrl numberOfChildrenOfElement:elementDescriptor ofDimension:dimension]; NSLog(@"Number of child elements of the first dimension: %d", childElementsCount); if (childElementsCount > 0) { [elementDescriptor setHasChildren: YES]; } else { [elementDescriptor setHasChildren: NO]; } if ([elementDescriptor hasChildren]) { // Get first child element MADimensionsPanelDimensionElementDescriptor *childElement = [panelDataSource dimensionsPanelTableView:tableViewCtrl childElement:0 ofElement:elementDescriptor ofDimension:dimension]; if (childElement) { NSLog(@"First element key: %lld", [childElement key]); NSLog(@"First child element title: %@", [childElement title]); // Get dimension element as a pplib++ library object SPPLDimensionElement dimensionElement = [childElement dimensionElement]; printf("Parent key for first child element: %lld\n", dimensionElement->parentKey()); // Set dimension element [childElement setDimensionElement: dimensionElement]; // Get dimension parent element MADimensionsPanelDimensionElementDescriptor *parentDimensionElement = [childElement parentDimensionElement]; NSLog(@"Parent element title: %@", [parentDimensionElement title]); // Set dimension parent element [childElement setParentDimensionElement: parentDimensionElement]; } } else { NSLog(@"Dimension does not contain child elements"); } // Get whether loading indicator is displayed on selecting dimension element bool isShowActivity = [panelDelegate dimensionsPanelTableViewShouldShowActivityIndicator: tableViewCtrl]; if (isShowActivity) { NSLog(@"Data loading indicator is displayed on selecting dimension elements"); } else { NSLog(@"Data loading indicator is not displayed on selecting dimension elements"); } // Get whether menu is displayed for selected dimension element bool isShowMenu = [panelDelegate dimensionsPanelTableView: tableViewCtrl shouldShowMenuForElement:elementDescriptor inDimension:dimension]; if (isShowMenu) { NSLog(@"Menu is displayed for selected dimension element"); } else { NSLog(@"Menu is not displayed for selected dimension element"); } // Refresh panel data [tableViewCtrl reloadData]; // Delete all window subviews NSArray *subviews = [self.view subviews]; for (UIView *subView in subviews) { [subView removeFromSuperview]; } // Display controller view UIView *view = [tableViewCtrl view]; [view setFrame: CGRectMake(0, 0, self.view.frame.size.width / 2, self.view.frame.size.height / 2)]; [[self view] addSubview: view]; }
After executing the example the dimension panel controller view is loaded in the application window:
The development environment console displays information about the Indicators dimension, the Culture element and its first child element:
Number of dimensions: 3
Table row height for view markup: 44.000000
Dimension key: 1557
Dimension identifier: FACTS_WDI_COPY_1557
Dimension title: Indicators
Dimension subtitle: Gross regional product
Number of elements of this dimension: 1374
Dimension type: fixed title
Selection type in dimension: multiple selection.
Number of elements with the text "Culture": 42
Element key: 524
Element title: Culture
Element is not selected
Number of child elements of the first dimension: 4
First child element key: 525
Child element title: Coverage of public libraries,
institutions per 100 thousands of population
Parent key for the first child element: 524
Parent key element title: Culture
It is also displayed whether data and menu loading indicator is displayed on selecting dimension elements:
Data loading indicator is displayed on selecting dimension elements
Menu is not displayed for selected dimension element
Them select all elements of the Indicators dimension and deselect only the Education element. To do this, add the following code to the example:
// Select all dimension elements [panelDelegate dimensionsPanelTableView: tableViewCtrl didSelectAllElementsInDimension:dimension]; // Deselect the Education dimension [panelDelegate dimensionsPanelTableView: tableViewCtrl didDeselectElement:elementDescriptor inDimension:dimension];
After executing the example all elements of the Indicators dimension are selected except for the Education element:
Then invert dimension element selection by adding the following code fragment to the example:
// Deselect the dimension [panelDelegate dimensionsPanelTableView: tableViewCtrl didDeselectAllElementsInDimension:dimension]; // Select first dimension element [panelDelegate dimensionsPanelTableView: tableViewCtrl didSelectElement:elementDescriptor inDimension:dimension];
After executing the example only one element of the Indicators dimension is selected:
Display dimension type selection controller view by adding the following code to the example:
// Get dimension type selection controller MADimensionsPanelRoleSelectorViewController *roleSelectorViewCtrl = (MADimensionsPanelRoleSelectorViewController*)[panelDelegate dimensionsPanelTableView: tableViewCtrl roleSelectorViewControllerForDimension:dimension withCurrentDimensionElement:elementDescriptor]; // Create a popup window displaying view UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController: roleSelectorViewCtrl]; [popover presentPopoverFromRect:CGRectMake(0, 0, 200, 500) inView:[tableViewCtrl view] permittedArrowDirections:NULL animated: YES]; // Create a dimension type setting delegate MADimensionRoleAcceptorProtocolImpl *acceptorProtocolImpl = [[MADimensionRoleAcceptorProtocolImpl new] autorelease]; // Set this delegate [roleSelectorViewCtrl setRoleAcceptorDelegate: acceptorProtocolImpl];
After executing the example the dimension type selection controller view is displayed:
See also: