In addition to using the standard function blocks that Activity Editor provides, Map Designer allows you to import your own Java library for use as function blocks in Activity Editor. Importing custom Jar libraries into activity settings will enable any public methods in the Jar library to be used as function blocks in Activity Editor.
Before you begin: You need to export your Java classes into a .jar file.
Perform the following steps to import a Jar library into Activity Editor:
System Manager will try to import your custom .jar file for use as function blocks in Activity Editor. If the file is imported properly, the name of your custom .jar file will appear under BuildBlock Libraries in the Activity Settings view.
Tip: After you import your custom .jar files into Activity Settings, when your maps and collaboration template compile in System Manager, the custom .jar file will automatically be included into the compile CLASSPATH. To prepare InterChange Server Express for compilation, make sure that its CLASSPATH includes your custom.jar file. For information on setting up Interchange Server Express for importing your custom .jar files, see Importing third-party classes to Interchange Server Express.
Result: When you open Activity Editor, the custom Jar library will be listed in the Library window under My Library in Activity Editor. By default, available custom function blocks are listed according to their package structure. You can use them in an activity the same way as standard function blocks.
Rule: After you change any settings in the Activity settings view, you must restart Map Designer Express for the change to take effect in Activity Editor.
You can customize the display settings of the function blocks imported to Activity Editor, such as its name and icon, by changing the custom Jar library's properties. Perform the following steps to do this:
Result: When the Properties window for the custom Jar library is opened, it will list the available function blocks in this custom library in a tree structure on the right-hand side of the dialog. The available function blocks are listed as child nodes under the Java class and package that contain them.
For the Java package and classes, you can customize the display name of the entry and whether Activity Editor should display this Java package/class in the My Library tree structure by changing the check box "Hide level in tree display." If this option is enabled, Activity Editor will not display this entry in the My Library subtree. This option is usually useful when the Java methods in your custom Jar library are in a Java class that is in a package many levels deep, and enabling this option can better organize your My Library subtree in Activity Editor.
Figure 71 shows the dialog for customizing the Jar library
display.
Figure 71. Properties dialog for customizing Jar library display
For those Java methods used as function blocks in Activity Editor, you can specify the function block display name, description, icon, and parameter's display name in the Properties window. When you choose to import an icon for the function block, the icon that you choose will be copied into the Activity Settings folder and will be available for other function blocks in the same package to use.
Recommendation: If you choose to import an icon for your function block to use, the icon should be 32 pixels by 32 pixels in size and should be in .bmp format. The color depth of the icon can be up to 24-bit.
Figure 72 shows the Properties dialog for customizing the Jar library
function block display.
Figure 72. Properties dialog for customizing Jar library function block display
Rule: After you change any settings in the Activity settings view, you must restart Map Designer Express for the change to take effect in Activity Editor.
If the imported classes are in a third-party package rather than in the JDK, in order to set up the server compile, you must add them to the path of the imported classes in the JCLASSES variable.
Recommendation: You should use some mechanism to differentiate those classes in JCLASSES that are standard from those that are custom.
Example: You can create a new variable to hold only those custom classes and append this new variable to JCLASSES, by performing the following steps:
Example: Create a dependencies directory below the product directory and place the jar file in it.
set DEPENDENCIES=$ProductDir/dependencies/CwMacroUtils.jar
Add the following entry for Windows:
set DEPENDENCIES="%ProductDirS%"\dependencies\ CwMacroUtils.jar
For UNIX, add:
set JCLASSES=$JCLASSES:ExistingJarFiles:$DEPENDENCIES
For Windows, add:
set JCLASSES=ExistingJarFiles;%DEPENDENCIES%
Guidelines: When importing a custom class, you may get an error message indicating that the software could not find the custom class. If this occurs, check the following:
Example: When importing a custom class, you might create a folder called %ProductDir%\lib\com\<ProductDir>\package, where package is the name of your package. Then, place your custom class file under the folder you just created. Finally, in the CLASSPATH variable in the start_server.bat file, include the path %ProductDir%\lib.