Report item UI design
The designer provides the org.eclipse.birt.report.designer.ui.reportitemUI extension point to define the user interface of extended report items. Add
the org.eclipse.birt.report.designer.ui.reportitemUI extension point and create the design properties to define the user interface, as shown in Figure 23‑19.
Figure 23‑19 Defining the design
The design properties are as follows:
*RotatedText (model)
The first property, RotatedText (model), binds the designer extension to the model extension. The RotatedText’s extensionName is RotatedText, the same as the model extension name.
*palette
Palette properties specify the icon displayed in Palette view and the palette category. An empty category value causes the report item to use the default category of Report Item.
*editor
Editor properties define the report item visibility in different editor pages and whether the resizing control is enabled.
*outline
Outline specifies the icon shown in Outline view. Usually the icon is the same as the one in Palette view.
*UI provider
The user interface (UI) provider defines how to display and interact with the extended report item within the editor. The BIRT designer supports three types of UI providers:
*The Label UI provider implements the IReportItemLabelProvider interface, which manipulates and displays text content.
*The Image UI provider implements the IReportItemImageProvider interface, which manipulates and displays image content.
*The Figure UI provider implements the IReportItemFigureProvider, which uses the Figure interface from Graphical Editing Framework (GEF), which provides flexibility and interactivity support.
This example introduces all three providers, starting with the simplest Label UI provider. The property reportItemLabelUI, created under the extension, registers the Label UI provider, and specifies the implementer class org.eclipse.birt.sample.reportitem.rotatedtext.RotatedTextLabelUI.
The code for RotatedTextLabelUI class, shown in Listing 23‑11, reads the text property value from the model and returns it as a string.
Listing 23‑11 RotatedTextLabelUI class
public class RotatedTextLabelUI implements IReportItemLabelProvider
{
public String getLabel( ExtendedItemHandle handle )
{
try {
IReportItem item = handle.getReportItem( );
if ( item instanceof RotatedTextItem )
{
return ( (RotatedTextItem) item ).getText( );
}
} catch ( ExtendedElementException e )
{
e.printStackTrace( );
}
return null;
}
}
The final step is to test the completed report item definition in the BIRT designer. For more information about testing the report item definition, see Deploying and testing the rotated label report item plug-in, earlier in this section. Open
a new Eclipse instance in Report Design perspective. Open the Palette view. Palette contains the new RotatedText extended report item, as shown in Figure 23‑20.
Figure 23‑20 Palette showing the RotatedText report item
Right-click anywhere in Layout, and the RotatedText item is now also available in the Insert context menu, as shown in Figure 23‑21.
Figure 23‑21 Insert context menu showing the RotatedText report item
A RotatedText report item inserted in the layout also appears in the Outline view, as shown in Figure 23‑22.
Figure 23‑22 Outline view showing a RotatedText report item