Feature
Java Feature — Developing an Eclipse BIRT Report Item Extension
Architecture and framework
Oct. 23, 2006 06:00 PM
Digg This!
Page 2 of 2
« previous page
Listing 1
shows the automatically generated manifest file plugin.xml for the
rotated label report item extension that describes the plug-in's
activation framework to the run-time environment.
After defining the
plug-in framework in the Eclipse PDE, the developer makes the
code-based extensions required to complete the plug-in development
process.
The rotated label report item extension implements the following interfaces and classes:
- org.eclipse.birt.report.designer.ui.extensions specifies the following interfaces:
- IPropertyTabUI
- Represents a new tab in the Property Editor view, creating the UI,
updating property values on request, and notifying the BIRT framework
of any UI-based property change. PropertyTabUIAdapter is the adapter
class that implements this interface.
- IReportItemLabelProvider
- Defines the interface for the accessor method that provides the label
text. ReportItemLabelProvider is the adapter class that implements this
interface.
- IReportItemPropertyEditUI - Provides the interface for defining tabs in the Property Editor.
-
org.eclipse.birt.report.designer.ui.views.attributes.providers.PropertyProcessor
provides accessor methods for processing general property information.
- org.eclipse.birt.report.engine.extension
- IRowSet - Defines the interface to a row set. Provides metadata, grouping level, and row navigation methods.
- IReportItemPresentation
- Defines the interface for presentation of a report item extension.
IReportItem-Presentation sets the locale, resolution, output, and image
formats and processes the extended item in the report presentation
environment. ReportItemPresentationBase is the adapter class that
implements this interface.
- org.eclipse.birt.report.model.api
- DesignElementHandle
- Functions as the base class for all report elements.
DesignElementHandle provides a high-level interface to the BIRT report
model. The class provides the generic services for all elements.
Derived classes provide specialized methods for each element type.
DesignElementHandle implements the interface,
org.eclipse.birt.report.model.elements.interfaces.IDesignElementModel.
- DesignEngine
- Provides an interface to the BIRT design engine. DesignEngine
instantiates a session handle to use when creating a new design,
opening an existing design, and managing design processing. The session
handle contains the report design's state. DesignEngine implements the
interface, IDesignEngine interface.
- ExtendedItemHandle
- Provides a handle to an extended item that appears in a section of a
report. The extended report item can have properties such as size,
position, style, visibility rules, or a binding to a data source.
ExtendedItemHandle extends ReportItemHandle, an abstract base class
that extends DesignElement-Handle.
- org.eclipse.birt.report.model.elements.Style extends
org.eclipse.birt.report.model.core.StyleElement, the base class for
report elements with a style, and implements
org.eclipse.birt.report.model.elements.interfaces.IStyleModel, the
interface for storing style element constants.
- org.eclipse.birt.report.model.api.extension specifies the following interfaces:
- IMessages - Defines the interface for getting a localized message from a message file using a resource key.
- IPropertyDefinition
- Defines the interface for the accessor methods that describe a
property. PropertyDefinition is the adapter class that implements this
interface.
- IReportItem - Defines the
interface for an instance of an extended report element. There is a
one-to-one correspondence between the BIRT report item and this
implementation. ReportItem is the adapter class that implements this
interface.
- IReportItemFactory -
Defines the interface for the factory that creates an instance of the
extended element, IReportItem. IReportItem stores the model data and
serializes the model state. ReportItemFactory is the adapter class that
implements this interface.
- org.eclipse.birt.report.model.metadata.PropertyType functions
as the base class for the metadata of a property type. A property type
provides the display name, data validation and conversion methods, XML
name, and other processing. PropertyType implements the interface,
org.eclipse.birt.re-port.model.api.metadata.IPropertyType.
- org.eclipse.core.runtime.Plugin defines the basic methods for starting, managing, and stopping the plug-in instance.
This article provides the implementation details for the most important classes in the rotated label report item
extension.
For example, the RotatedLabelItemFactoryImpl class instantiates a new
report item when the user drags a rotated label report item from the
Palette and drops the report item in the BIRT Report Designer Editor.
This class extends the adapter class,
org.eclipse.birt.report.model.api.extension.ReportItemFactory.
In the implementation class, the newReportItem( ) method receives a
reference to DesignElementHandle, which provides the interface to the
BIRT report model. The newReportItem( ) method instantiates the report
item, as shown in Listing 2.
In the RotatedLabelUI class, the getLabel( ) method provides the text
representation for the label to BIRT Report Designer. RotatedLabelUI
extends the adapter class,
org.eclipse.birt.report.designer.ui.extensions.ReportItemLabelProvider.
Listing 3 shows the code for the getLabel( ) method.
The RotatedLabelPresentationImpl class specifies how to process and
render the report item at presentation time. This class extends the
org.eclipse.birt.report.engine.extension.ReportItemPresentationBase
class.
The method, onRowSets( ), renders the rotated label report item as an
image, rotated by the angle specified in the report design, as shown in
Listing 4.
In the RotatedLabelReportItemImpl class, the method,
getPropertyDefinitions( ), instantiates
RotatedLabelPropertyDefinitionImpl objects for the displayText and
rotationAngle properties. RotatedLabelReportItemImpl extends the
adapter class, org.eclipse.birt.report.model.api.extension.ReportItem.
Listing 5 shows the code for the getPropertyDefinitions( ) method.
The RotatedLabelPropertyEditUIImpl class builds the UI using the
RotatedLabelGeneralTabUIImpl class to set up the controls for the UI.
RotatedLabelPropertyEditUIImpl implements the
org.eclipse.birt.report.designer.ui.extensions.IReportItemPropertyEditUI
interface.
In the RotatedLabelPropertyEditUIImpl class, the getCategoryTabs ( )
method instantiates the RotatedLabelGeneral-TabUIImpl class, as shown
in Listing 6.
The RotatedLabelGeneralTabUIImpl class contains an internal class
GeneralCategoryWrapper that creates the UI contents, as shown in
Listing 7.
The GraphicsUtil class creates the image containing the specified text
and rotates the text image to the specified angle, using the following
methods:
- createRotatedText( ) performs the following operations:
- Gets the display text and rotation angle properties
- Sets the display text font and determines the font metrics
- Creates an image the same size as the display text String
- Draws the display text as an image
- Calls the rotateImage( ) method to rotate the image at the specified angle
- Disposes of the operating system resources used to render the image
- Returns the image object
- rotateImage( ) rotates the image and determines the width, height, and point of origin for the image
Listing 8 shows the code for createRotatedText( ) method.
On the PDE Manifest Editor, in Overview, the Testing section contains
links to launch a plug-in as a separate Eclipse application in either
Run or Debug mode. In Testing, choose Launch an Eclipse application.
Eclipse launches the runtime workbench.
In Report Design, choose File->New->Project, and choose Report
Project. Create a new report in the project by choosing
File->New->Report.
In File name, type a file name if you want to change the default file
name. Choose Next. New Report displays the report templates. In Report
templates, choose Blank Report, and choose Finish.
The layout editor displays the report design, new_report.rptdesign. The Palette contains the RotatedText report item.
From the Palette, drag RotatedLabel to Layout, as shown in Figure 1. In
new_report.rptdesign, choose Preview. The preview appears, displaying
the rotated label report item, as shown in Figure 2.
This article is an excerpt from the book, Integrating and Extending BIRT
by Jason Weathersby, Don French, Tom Bondur, Jane Tatchell, and Iana
Chatalbasheva, soon to be published by Addison-Wesley. The book is the
second volume in a two-book series about business intelligence and
reporting technology. The book introduces programmers to BIRT
architecture and the reporting framework. It shows programmers how to
build and deploy customized reports using scripting and BIRT APIs. It
also describes how to use key extension points to create a customized
report item, a rendering extension for generating output other than
HTML or PDF, and an Open Data Access (ODA) driver for a new data
source. Integrating and Extending BIRT. Copyright 2007 Actuate. ISBN 0321443853. For more information, please visit www.awprofessional.com.
Page 2 of 2
« previous page
About Jason WeathersbyJason Weathersby is a member of the extended BIRT development team at Actuate Corporation and has backgrounds in both computer science and technical writing. He has many years experience in technical consulting, training, writing, and publishing about reporting, business intelligence tools, and database technologies.
About Iana ChatalbashevaIana Chatalbasheva is a member of the extended BIRT development team at Actuate Corporation and has backgrounds in both computer science and technical writing. She has many years experience in technical consulting, training, writing, and publishing about reporting, business intelligence tools, and database technologies.
About Tom BondurTom Bondur is a member of the extended BIRT development team at Actuate Corporation and has backgrounds in both computer science and technical writing. He has many years experience in technical consulting, training, writing, and publishing about reporting, business intelligence tools, and database technologies.