
ADempiere Customization – Part II
146
Extending the desktop version of the toolbar
The toolbar is another great way to extend the capability of ADempiere. In ADempiere,
a toolbar is a standard set of buttons and each button is mapped to an action, which is
implemented as a Java program. For most of the parts so far, except the info windows,
the congurations we did and the changes we made are equally applicable to the desktop
version as well as the web version of ADempiere. However, the toolbar functionality has been
implemented differently for the desktop and web variants. This recipe will list the steps to
extend the desktop variant of the toolbar by adding a new button to it.
For our MOM case study, we are going to introduce a new Send Mail button. When a user
clicks on it, the handler will send the active MOM details to all the participants of that MOM.
Wherever applicable, I have mentioned the line number, next to the code,
where the mentioned code shall be inserted in the existing Java le. While I
don't guarantee the correctness of the line number, I have mentioned them
so that they indicate the logical location of where the mentioned code may
be inserted.
Moreover, some of the code you see here is already outlined in the previous
recipes. However, I have mentioned them here to have the natural control
ow and hence compromised on the encapsulation for the benet of clarity.
How to do it...
1. Add the following line in the jbInit() method in the APanel.java class:
private AppsAction aSendMail;
2. Add the following code in the createMenu() method in the APanel.java class:
aSendMail = addAction("SendMail", mTools, KeyStroke.
getKeyStroke(KeyEvent.VK_M, 0), false);
toolBar.add(aSendMail.getButton()); //Line# 414.
3. This will add an entry to the Tools menu.
4. Add the following code in the dataStatusChanged method in the APanel.java
class:
aSendMail.setEnabled(true); //Line# 968
aSendMail.setEnabled(false); //Line# 1234 to disable the button if
there are no records.
5. Clean and build the adempiere_360 project.