Customizing Maximo Spatial to create a Hello World tool
This article describes how to create a new tool in the Map toolbar. In this scenario, a simple tool is created to display Maximo messages when clicked. The same procedure can be used to insert any customized tool.
Tools in the Map toolbar
The Map toolbar is created based on configurations returned from the server, based on the context from which the map is launched. The context is dependent on where the map was launched, for example if it is in a Map tab or opened in a dialog originated from a Maximo filter field.
There are three types of tools in the toolbar:
- Navigation tools - the tools that actually control the map, like zoom, pan, or last extent.
- Tools without panels - tools that do not open a panel dialog on the map (like linker or identify).
- Tools with panels - tools that open a panel dialog to allow users to input more information or visualize results (like Query by Attributes or Drawing tool).
All the tools are created during map initialization in the ESRIIntegrationImpl.js file. The getConfiguration method returns the map configuration along with the tool configurations.
Here is a standard tool configuration example:
var thisToolConf =
{
label: STRING,
menu: [menuWidgets|menuNavWidgets],
menuCode: [navtools.navtool|widgets.widget|widgets.tool],
icon: ICON_RELATIVE_URL,
widgetType: DOJO_CLASS_NAME
};
The fields above are:
- label: used to identify the tool among the other tools; it is also the content of the tool tip when the mouse is over the tool icon.
- menu: which menu part to place the tool. It could be menuNav for navigation tools, or menuWidgets for the non-navigation tools.
- menuCode: defines the tool type. There are 3 types:
- widgets.widget - for tools with panels.
- widgets.tool - for tools without panels.
- navtools.navtool - for navigation tools.
- icon: the icon URL to be used by this tool.
- widgetType: this is the Dojo widget name that implements this tool.
Here is a simple example of the drawing tool:
var thisToolConf =
{
label:"Drawing tool",
menu: "menuWidgets",
menuCode: "widgets.widget",
icon: "assets/pluss/toolbar/tb_drawAndMeasure.png",
widgetType: "com.ibm.maximo.widgets.MeasureWidget"
};
Hello World Tool
The Hello World tool will display the Maximo message "Hello Map" when clicked. To create the tool, you need to:
- Create a message in Maximo.
- Create the Dojo widget that performs this task.
- Add the tool to the toolbar by customizing the ESRIIntegrationImpll.js file.
- Test the tool.
Create a message in Maximo
Create a MAXMESSAGE in the plussmap group and key helloworld as follows:
<Message id="XXXXXI" group="plussmap" key="helloworld" prefix="0">
<Display method="MSGBOX">
<Option>MSG_BTNOK</Option>
</Display>
<MsgText>Hello Map</MsgText>
<Explanation></Explanation>
<AdminResponse></AdminResponse>
<OperatorResponse></OperatorResponse>
</Message>
The message ID must be unique so choose one available in your system, for example PLUSS0001I. Import this message into Maximo.
Create the Dojo widget
Dojo provides widget support that allows you to create independent highly cohesive and very low coupling prototypes using JavaScript. Spatial tools are all widgets created using Dojo support with the ESRI JavaScript API.
Create a file called HelloWorldWidget.js and a folder called custom in the following path:
applications\maximo\maximouiweb\webmodule\webclient\javascript\pluss\com\ibm\maximo
Paste the code below into the folder:
dojo.provide("com.ibm.maximo.custom.HelloWorldWidget");
dojo.require("com.esri.solutions.jsviewer._BaseWidget");
dojo.declare(
"com.ibm.maximo.custom.HelloWorldWidget",
[com.esri.solutions.jsviewer._BaseWidget],{
constructor: function( params) {},
startup: function() {
this.inherited(arguments);
ESRIIntegrationImpl.showMessage("helloworld");
}
});
The widget above implements the HelloWorld widget. Notice that this example prototypes the widget 'com.esri.solutions.jsviewer._BaseWidget' provided in the Maximo Spatial code. This widget contains most of the code for defining the widget configuration, title, and position on the toolbar. The method start is always executed when a user clicks on the tool in the toolbar. Everytime the user clicks on the tool, the showMessage method is called with the helloworld parameter of the ERSIIntegrationImpl object. The showMessage method invokes the Maximo API to display a Maximo message with the key defined in the parameter passed ('helloworld') and in the group plussmap (default group for map messages).
Add the tool to the toolbar
To add the tool to the toolbar, you need to customize the ESRIIntegrationImpl.js object to load the HelloWorldWidget configuration.
First create the following method at the end of the ESRIIntegrationImpl.js file:
_getHelloWorldConf:function(){
var thisToolConf = {
label: "Hello World",
menu: "menuWidgets",
menuCode: "widgets.tool",
icon: dojo.moduleUrl("com.ibm.maximo.custom", "assets/images/helloWorld.[PNG|helloWorld.jpg]"),
config: "{}",
widgetType: "com.ibm.maximo.custom.HelloWorldWidget"
};
return thisToolConf;
},
This configuration sets the widget title as "Hello World", its position in the widgets part of the toolbar, its type as a widget with no dialog, its icon and the dojo widget implementation as the widget created in the previous section.
The icon image is: 
Copy it under:
applications\maximo\maximouiweb\webmodule\webclient\javascript\pluss\com\ibm\maximo\custom\assets\images
Name it helloWorld.jpg.
Now add this tool to the toolbar. Open the ESRIIntegartionImpl.js file. Find the getConfiguration method. At the end of this method just before the following code:
conf.widgets = widgets;
Add the hello world widget to the widgets list:
widgets.push(this._getHelloWorldConf());
Test the new Hello World tool
Start Maximo and go to any GIS-enabled application and open the map tab. You will see the new tool in the toolbar as below:
And clicking on it you get the following result:
Resources