Report item model
The BIRT Report Model provides the org.eclipse.birt.report.model
.reportItemModel extension point. As shown in Figure 23‑15, defining the report item model involves creating a reportItem element under the extension and specifying the extensionName property as RotatedText. The extension name is the identifier for the extended item and connects the report model to the engine and the designer extensions.
Figure 23‑15 Adding the basic extension points
As shown in Figure 23‑16, the model factory class org.eclipse.birt.sample
.reportitem.rotatedtext.RotatedTextItemFactory must be defined.
Figure 23‑16 Defining the report model
This factory class creates and initializes the IReportItem instance, and provides optional localization support.
Listing 23‑9 shows the code for the RotatedTextItemFactory class.
Listing 23‑9 RotatedTextItemFactory class
public class RotatedTextItemFactory extends ReportItemFactory
{
public IReportItem newReportItem( DesignElementHandle
modelHandle )
{
if ( modelHandle instanceof ExtendedItemHandle &&
RotatedTextItem.EXTENSION_NAME.equals( (
( ExtendedItemHandle) modelHandle )
.getExtensionName( ) ) )
{
return new RotatedTextItem( ( ExtendedItemHandle )
modelHandle );
}
return null;
}
 
public IMessages getMessages( )
{
// TODO implement this to support localization
return null;
}
}
The reportItem Properties page contains more properties such as defaultStyle, extendsFrom, hasStyle, and others, which can be used to define additional features. This example does not extend these features; it uses the default values for these properties.
Like the Rotated Label example, the Rotated text element has two properties:
*rotationAngle, which defines the text rotation angle, using type integer and a default value 0, as shown in Figure 23‑17.
Figure 23‑17 Defining the rotationAngle properties
*text, which defines the report item text content, using type expression and a default value “Rotated Text”, as shown in Figure 23‑18.
Figure 23‑18 Defining the text properties
These settings complete the report model definition. The next step is to create a class, RotatedTextItem. This class defines the basic methods for accessing the report item properties. The code is shown in Listing 23‑10.
Listing 23‑10 RotatedTextItem class
public class RotatedTextItem extends ReportItem
{
public static final String EXTENSION_NAME = "RotatedText";
//$NON-NLS-1$
public static final String TEXT_PROP = "text";
//$NON-NLS-1$
public static final String ROTATION_ANGLE_PROP =
"rotationAngle"; //$NON-NLS-1$
 
private ExtendedItemHandle modelHandle;
 
RotatedTextItem( ExtendedItemHandle modelHandle )
{
this.modelHandle = modelHandle;
}
 
public String getText( )
{
return modelHandle.getStringProperty( TEXT_PROP );
}
 
public int getRotationAngle( )
{
return modelHandle.getIntProperty( ROTATION_
ANGLE_PROP );
}
 
public void setText( String value ) throws
SemanticException
{
modelHandle.setProperty( TEXT_PROP, value );
}
 
public void setRotationAngle( int value ) throws SemanticException
{
modelHandle.setProperty( ROTATION_ANGLE_PROP, value );
}
}