Previous TopicNext Topic


How to create an event handler class and add it to the Java project

This section describes the process for using the Eclipse Java development environment to create an event handler class for a scriptable BIRT element.

  1. Add org.eclipse.birt.report.engine_Version.jar to your Java project, as outlined in the following steps:
    1. Select your Java project and choose File->Properties->Java Build Path->Libraries. Java Build Path appears, as shown in Figure 24-1.
    2. Figure 24-1 Adding a JAR file to the compiler's classpath

      Figure 24-1 Adding a JAR file to the compiler's classpath
    3. Choose Add External JARs. JAR Selection appears.
    4. Navigate to Eclipse /plugins directory. In a default Eclipse installation, this directory is in the following location:
    5. C:\eclipse\plugins 
      
    6. Select org.eclipse.birt.report.engine_Version.jar. Choose Open. Java Build Path reappears.
    7. Choose OK.
  2. Select your Java project and choose File->New->Other. Select a wizard appears.
  3. Expand Java and select Class, as shown in Figure 24-2.
  4. Figure 24-2 The Select a wizard dialog

    Figure 24-2 The Select a wizard dialog
    Choose Next. New Java Class appears, as shown in Figure 24-3.

    Figure 24-3  New Java Class

    Figure 24-3 New Java Class
  5. Navigate to the folder where you want the Java source file to reside by choosing the Browse button beside Source Folder.
  6. If your new Java class is a part of a package, type the fully qualified package name in Package.
  7. In Name, type a name for your class.
  8. In Modifiers, choose Public.
  9. Choose the Browse button beside Superclass. Superclass Selection appears, as shown in Figure 24-4.
  10. Figure 24-4 Superclass Selection

    Figure 24-4 Superclass Selection
  11. In Choose a type, type the name of the adapter class for the ROM element. For example, enter Label EventAdapter for the Label element. Choose OK. New Java Class reappears.
  12. Select Generate comments. Choose Finish. A Java editor view appears, similar to the one shown in Figure 24-5.
  13. Figure 24-5 The Java editor

    Figure 24-5 The Java editor
  14. Add the event handler method for your new event handler class. Figure 24-6 shows the addition of an onPrepare( ) method that sets the background color of the label to red.
  15. Figure 24-6 The onPrepare method in the Java editor

    Figure 24-6 The onPrepare( ) method in the Java editor

(c) Copyright Actuate Corporation 2006

Previous TopicNext Topic