Purpose
This tutorial covers how to manage images in the Resource Manager by using the Object Model.
Overview
Resource Manager is a user interface utility for loading, managing, and sharing pictures in Interactive Reporting documents. You can store one copy of an image in Resource Manager and reference that copy when you reuse the image elsewhere in the document. In the way, Resource Manager reduces the size of an Interactive Reporting document, and improves the performance when opening the document. For example, a company logo might appear several times in an Interactive Reporting document, in Report headings and in Dashboards. With Resource Manager, only one copy is stored and reused by reference to its resource name.
Instead of using the Interactive Reporting Studio interface to directly access the images in Resource Manager, you can use script automation to search for, count, add or remove images stored in Resource Manager by way of the Object Model.
You can select from the following methods to manage images in Resource Manager:
Add() | Adds specified images to Resource Manager and assigns selected display name. | |
Item() | Searches image entry by using image uid as a search criterion. | |
FindItems() | Searches images by using displayName as search criterion. | |
Count | Holds number of images registered in Resource Manager. | |
CreateIterator() | Sequentially accesses all collection items. | |
Remove() | Removes specified images from Resource Manager. | |
RemoveAll() | Removes all images from Resource Manager. |
These methods are supported in Interactive Reporting Studio and Interactive Reporting Web Client.
Each method has its own syntax. For example, a typical syntax for a script that adds an image to Resource Manager is
ActiveDocument.ResourceManager.Images.Add(string path, string displayName).
ActiveDocument.ResourceManager.Images.Add(string path, string displayName).
Parameters:
Path | File system path to selected image |
displayName | Image display name or image file name |
Ensure that you place two backslashes in the file system path for each folder level.
For example, if the image, Server.gif is stored in the Images folder on your local hard drive, your script may look like this
For example, if the image, Server.gif is stored in the Images folder on your local hard drive, your script may look like this
ActiveDocument.ResourceManager.Images.Add("C:\\Images\\Server.gif").
Scenario
As a report designer, you are asked to create a dashboard with controls that will manage images in the Resource Manager. You create scripts with alerts to verify that the script automation is successful.
Prerequisites
Before starting this tutorial, you should:
1. | Have access to explore and view the Object Model |
2. | Have a user account in your authentication directory |
3. | Have some experience with script automation |
4. | Have access to images on your local drive |
Managing Images in Resource Manager
In this topic, you create a script to automate image management in Resource Manager. You first insert a dashboard. T hen you add a dashboard control and apply the Object Model script.
To add an Object Model script for managing images in Resource Manager, perform these steps:
1. |
In Interactive Reporting Studio, create or open an Interactive Reporting document.
|
2. |
Select Insert > Dashboard.
A blank dashboard section is displayed. The dashboard is in the default mode, design mode.
|
3. |
In the Elements pane, expand the Controls folder.
Dashboard controls are displayed.
|
4. |
Drag the Command Button control to the dashboard content pane.
The control is added to the dashboard. The control is automatically assigned the name CommandButton1.
|
5. |
Right-click the command button.
A shortcut menu is displayed.
|
6. |
Select Scripts.
Script Editor is displayed. You can copy and paste scripts that you have already created into Script Editor.
|
7. |
Leave the default selection for the Event Trigger as onClick.
|
8. |
Enter the script that will manage images in the Resource Manager, and click the Check Syntax button to ensure you included the correct number of parentheses.
In this example, the script adds an image to Resource Manager. The ActiveDocument is an Interactive Reporting document, PCW_Annual_Report_2008.bqy and the image file name is Comupter.gif. The complete script looks like this:
ActiveDocument.ResourceManager.Images.Add("C:\\Computer.gif") |
9. |
Click OK.
The script is saved for the control, CommandButton1.
|
10. |
Select Dashboard > Design Mode
The Dashboard mode is changed to run mode.
|
11. |
Click the command button.
The image is added from your local drive to Resource Manager.
|
12. |
Select Tools > Resource Manager to verify that the image was added successfully.
Resource Manager is displayed. The image that you added is listed as an available resource, for future use in the Interactive Reporting document.
|
Setting Prompts for Object Model Scripts
In this topic, you add a prompt to a script. In Interactive Reporting, continue to work with the same document. You invoke the script and verify the success of the script automation.
To add a prompt, perform these steps:
1. |
In Interactive Reporting, select the dashboard section.
The Dashboard section is displayed.
|
2.
.
|
Select Dashboard > Design Mode.
The Dashboard mode is in design mode.
|
3. |
Right-click the command button, and select Scripts.
Script Editor is displayed. You can add prompts by using the Alert() script method.
|
4. |
Above the existing script, enter the following text:
Alert("Adding Image to the Resource Manager"); |
5. |
Amend the original text to include a prompt and add an additional image.
In this example, the text is amended to add image, lobalNetwork.gif.
|
6. |
Click OK.
The script is updated.
|
7. |
Select Dashboard > Design Mode.
The Dashboard mode is in run mode.
|
8. |
Click the command button.
The first prompt is displayed.
|
9. |
Click OK.
The second prompt is displayed, confirming the script if the script has run successfully.
If the script was not run successfully, you see a prompt with a null value.
|
10. |
Click OK.
|
11. |
Select Tools > Resource Manager.
The new image is listed in the Resource Manager dialog box.
|
Changing Dashboard Control Properties
In this topic, you change the properties of a dashboard control. In Interactive Reporting, continue to work with the same document.
To add an alert, perform these steps:
1. |
In Interactive Reporting, select the Dashboard section.
The Dashboard section is displayed.
|
2.
.
|
Select Dashboard > Design Mode.
The Dashboard mode is in design mode.
|
3. |
Right-click the command button, and select Properties.
The Properties dialog box is displayed.
|
4. |
In the Title text box, enter a description or title for the command button, and under settings, select Locked.
You can change the font size properties, such as style, size, color and effects. You can specify the tab order of this control and any other controls. You can add comments, which appear as a tooltip when the cursor is placed over the control.
In this example, the title for CammandButton1 is Add Image. Since the control is now locked, the command button cannot be moved or deleted in error. The control cannot be cut or copied without first being unlocked.
|
5. |
Click OK.
The command button is displayed with the new title.
|
6. |
Select Dashboard > Design Mode.
The dashboard mode is changed to run mode. The renamed command button is displayed.
|
7. |
Select File > Save.
Your changes are saved.
|
Summary
In this tutorial, you learned how to:
Use Object Model Script to Manage Images in Resource Manager | ||
Set Prompts for Object Model Scripts | ||
Change Dashboard Control Properties |