Jump to content
We've recently updated our Privacy Statement, available here ×

Add a new component to the palette


jeroenvv

Recommended Posts

 Hi!

I have created a custom jasperreports component that fetches content from a server and displays it on a report. Now, I want to create  a custom iReport component for this, so my novice collegues can edit the report that uses my new component using iReport. 

Is there any documentation on how to do this? I try to use the barcode or list component as an example, but iReport does not seem to recognize my definitions (probably I do not provide everything necessary  or put files in the wrong place).

What is the proper way to create an additional iReport component?

Regards,

Jeroen van Veldhuizen, Redora BV

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

Hi Jeroen,

Here are the steps. Suppose our plugin code is:

com.acme.*

STEP 1. define a file with extension .irpitem i.e. MyPaletteItem.irpitem(it stays for iReport palette item). The content should look pretty much like this:

id=MyPaletteItemId
name=MyPaletteItem
tooltip=MyPaletteItem_tooltip
icon16=com/acme/mypaletteitem-16.png
icon32=com/acme/mypaletteitem-32.png
action=com.acme.MyPaletteAction

MyPaletteItem and MyPaletteItem_tooltip can be translated in a resource Bundle added to the global resource bundle of ireport, in this case a installer class for your module should do something like:

I18n.addBundleLocation(ResourceBundle.getBundle("/com/acme/Bundle"));

To create an installer class, use the NetBEans wizard to create a module installer.

STEP 2: create com.acme.MyPaletteAction which must extends com.jaspersoft.ireport.designer.palette.PaletteItemAction. This class is very generic, and if your aim is to just create a new element you may be choose to implement
a more specific implementation of PaletteItemAction, like com.jaspersoft.ireport.designer.palette.actions.CreateReportElementAction

STEP 3: finally you need to "install" the palette item in the iReport palette. This is done using the layer.xml (an important file of your NetBeans plugin).
You need to add the following chunk of xml to your layer.xml:

<folder name="palette">
    <folder name="ReportElements">
         <attr name="SystemFileSystem.localizingBundle" stringvalue="com.jaspersoft.ireport.locale.Bundle"/>
         <file name="MyPaletteItem.irpitem" url="MyPaletteItem.irpitem"/>
    </folder>
</folder>

This will add your item inside the ReportElements section of the palette. You can even create your own palette section, or use the Tools section.

If everything has been done correctly, you should now see the item in the ireport palette.

Giulio

Link to comment
Share on other sites

I installed the nbm that NetBeans created and it said installation successful. However, I don't see my new item in the palette, so I take it there is a problem with my layer.xml. Should it look like this?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
<folder name="palette">
    <folder name="ReportElements">
         <attr name="SystemFileSystem.localizingBundle" stringvalue="com.jaspersoft.ireport.locale.Bundle"/>
         <file name="SomeAction.irpitem" url="SomeAction.irpitem"/>
</folder>
</filesystem>



Post Edited by pwd at 06/08/2010 19:12
Link to comment
Share on other sites

  • 9 months later...

 

STEP 3: finally you need to "install" the palette item in the iReport palette. This is done using the layer.xml (an important file of your NetBeans plugin).

You need to add the following chunk of xml to your layer.xml:

<folder name="palette">
    <folder name="ReportElements">
         <attr name="SystemFileSystem.localizingBundle" stringvalue="com.jaspersoft.ireport.locale.Bundle"/>
         <file name="MyPaletteItem.irpitem" url="MyPaletteItem.irpitem"/>
    </folder>
</folder>

 

"ireport" tag is missing from this XML. The XML added to layer.xml follows:

<filesystem>

    <folder name="ireport">

        <folder name="palette">

            <folder name="ReportElements">

                <attr name="SystemFileSystem.localizingBundle" stringvalue="com.jaspersoft.ireport.locale.Bundle"/>

                <file name="mypaletteitem.irpitem" url="mypaletteitem.irpitem"/>

            </folder>

        </folder>

    </folder>

</filesystem>

Link to comment
Share on other sites

 

Here are the steps. Suppose our plugin code is:

com.acme.*

STEP 1. define a file with extension .irpitem i.e. MyPaletteItem.irpitem(it stays for iReport palette item). The content should look pretty much like this:

id=MyPaletteItemId
name=MyPaletteItem
tooltip=MyPaletteItem_tooltip
icon16=com/acme/mypaletteitem-16.png
icon32=com/acme/mypaletteitem-32.png
action=com.acme.MyPaletteAction

MyPaletteItem and MyPaletteItem_tooltip can be translated in a resource Bundle added to the global resource bundle of ireport, in this case a installer class for your module should do something like:

I18n.addBundleLocation(ResourceBundle.getBundle("/com/acme/Bundle"));

To create an installer class, use the NetBEans wizard to create a module installer.

 

To add your Bundle.properties (localization text) add the following line to your plugin's manifest.mf:

OpenIDE-Module-Install: com/acme/Bundle/Installer.class

AND create Installer.java in com/acme with the following code (you will need to add 'Internationalization', 'Module System API' as Module Dependencies in your Project Properties in Netbeans)

Code:


Post Edited by markgrubb at 04/01/2011 14:01
Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...