This add-on based on the CUBA framework and provides functionality to add buttons to the header of the dialog screen. The demo project of this add-on you can find here: flaurite/headerbutton-demo.
Framework Version | Add-on version |
---|---|
7.2.5 | 0.1-SNAPSHOT |
Firstly you should install this add-on to your local maven repository:
- Download add-on
- Navigate to the project dir and run the following command:
./gradlew install
After that you will be able to add headerbutton
add-on to the project:
- Open your application in CUBA Studio. Check the latest version of CUBA Studio on the CUBA Platform site.
- Go to CUBA -> Marketplace in the main menu.
- Click the icon in the upper-right corner.
- Paste the add-on coordinates in the corresponding field as follows:
com.flaurite.addon.headerbutton:headerbutton-global:<add-on version>
Click Install and apply the changes. The add-on will be installed to your project.
The base functionality concluded in the facet: HeaderButtonFacet
,
so it is possible to use a declarative way to define header buttons.
Add the following schema to your dialog screen:
xmlns:hb="http://schemas.headerbutton/headerbutton/0.1/headerbutton.xsd"
Then add headerButtons
facet:
<facets>
<hb:headerButtons id="headerButtons">
<hb:button id="infoBtn"
icon="INFO"/>
</hb:headerButtons>
</facets>
If you launch the application in the open dialog screen, you will see the following:
Now we can add a click listener to the "Info" button. For this, we can use the "Subscription" API. In the dialog screen controller, add the following code:
@Subscribe("headerButtons.infoBtn")
private void onCaptionBtnClickEvent(HeaderButton.ButtonClickEvent event) {
notifications.create(Notifications.NotificationType.TRAY)
.withCaption("Info button is clicked")
.withDescription(event.getButtonId())
.show();
}