Displaying Mailing Window in Dashboard

Operating system requirements: iOS 5.0 or later.

Mobile device: iPad.

Description

This example displays dashboard growth indicator and then a modal window with a message. They are hidden in three seconds. After that a mailing window is displayed.

The development environment console also displays the number of dashboard settings, dashboard data description, a modal window message and a dimension panel title.

Source Code

Executing the example requires to place the following code instead of the executeExample method of the ViewController class (see the Displaying of Dashboard section):

// Get custom example placed in the body of this method
-(void) executeExample {
    // Get dashboard controller
    MABaseReportViewController *controller = m_controller;
    // Enter the number of dashboard settings
    NSDictionary *settings = [[controller delegate] reportSettings];
    if(settings != nil){
        NSLog(@"Number of dashboard settings: %i", [settings count]);
    }
    // Display dashboard loading indicator
    [controller showActivityIndicator];
    // Continue executing the example after a pause
    [self performSelector:@selector(continueExample:) withObject:controller afterDelay:3];
}
// Continue executing the example
-(void) continueExample:(MABaseReportViewController *)controller {
    // Get dashboard title
    NSString *title = @"";
    if ([[(MADashboardReportViewController*)controller delegate] title]) {
        title = [[(MADashboardReportViewController*)controller delegate] title];
    }
    // Display modal window with message
    [controller showWaiterWithTitle:title andMessage:@" Loading"];
    // Display modal window message
    NSString *message = [[controller waiterView] message];
    NSLog(@"Modal window message: %@", message);
    // Start time for three seconds
    [NSTimer scheduledTimerWithTimeInterval:3.0f target:self selector:@selector(timerEvent)userInfo:nil repeats:NO];
}
// Handle time event
-(void) timerEvent {
    // Get dashboard controller
    MADashboardReportViewController *controller = (MADashboardReportViewController*)m_controller;
    // Display dashboard data description
    NSData *dashboardData = [[controller delegate] dashboardData];
    if(dashboardData != nil)
    NSLog(@"Dashboard data description: %@", dashboardData);
    // Display dimension panel title
    NSString *dimPanelTitle = [[[controller delegate] dimensionsPanel] title];
    if(dimPanelTitle != nil)
    NSLog(@"Dimension panel title: %@", dimPanelTitle);
    // Hide modal window with message
    [controller hideWaiter];
    // Hide loading indicator
    [controller hideActivityIndicator];
    // Display mailing window
    [controller composeMail];
}

It is also required to replace the code in the static example file MADashboardReportViewController.mm with the code given in the drop-down list:

Substitution code for the MADashboardReportViewController.mm file.

Replace the body of the addDimensionPanelControlWithKey:syncIndexKey: method in the MADashboardReportViewControllerDelegateImpl class with the following code:

// Determine dimension key
int64 dimensionKey = -1;
// Determine array of observer dimensions
NSMutableArray *listenerKeys = [NSMutableArray array];
// Get dimension key and array of observer dimension keys
N_FOREACH(SPPLDashboardSynchronizationDimension, i, m_dashboardReport->synchronizationDimensions()->dimensions()) {
    SPPLDashboardDataSourceDimensionObject dimensionObject = i->dimensionObject();
        if (i->syncIndexKey() == syncIndexKey && dimensionObject->isOriginal()) {
            dimensionKey = dimensionObject->key();
            [listenerKeys addObject:dimensionObject->dataSourceObject()->dashboardRelatedId()->nsString()];
        }
 }
// Creates an object describing dashboard control
[self addDimensionPanelControlWithKey:key dimensionKey:dimensionKey listenerKeys:listenerKeys];

Replace the code of the createReport:metabase: method in the MADashboardReportViewControllerFactory.m file with the following code:

// Create a controller delegate for working with dashboard
MADashboardReportDelegateImpl *delegate = [[[MADashboardReportDelegateImpl alloc] initWithDashboardReport:dashboardReport metabase:metabase] autorelease];
// Create a dashboard based on delegate
MADashboardReportViewController *report = [[[MADashboardReportViewController alloc] initWithDelegate:delegate] autorelease];
// Set dimension panel
report.panelViewController.contentViewController = delegate.dimensionsPanel;
return report;

After executing the example the dashboard loading indicator is displayed:

A modal window with a message is displayed against the shaded background in three seconds:

The development environment console also displays information about dashboard:

Modal window message: Loading

The dashboard loading indicator and the message window are hidden in three seconds, after that the mailing window is displayed:

See also:

Example of Component Use