From 1e17b5af6f2730031a5fefb82d178b820484d201 Mon Sep 17 00:00:00 2001 From: hieplq Date: Tue, 7 Nov 2017 20:52:49 +0700 Subject: [PATCH] IDEMPIERE-3549:allow IAction decorate toolbar button --- .../src/org/adempiere/webui/action/IAction.java | 10 ++++++++++ .../org/adempiere/webui/adwindow/ADWindowToolbar.java | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/IAction.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/IAction.java index 6389551c55..0e1666c022 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/IAction.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/action/IAction.java @@ -13,6 +13,8 @@ *****************************************************************************/ package org.adempiere.webui.action; +import org.zkoss.zul.Toolbarbutton; + /** * Custom UI action provided through OSGi service. Implementation must be thread safe. * @author hengsin @@ -24,4 +26,12 @@ public interface IAction { * @param target */ public void execute(Object target); + + /** + * you can customize toolbar button like add style, client javascript,... + * @param toolbarButton + */ + public default void decorate(Toolbarbutton toolbarButton) { + + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java index 4517e39723..9ab46c45c1 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java @@ -245,7 +245,8 @@ public class ADWindowToolbar extends FToolbar implements EventListener if (button.isCustomization()) { String actionId = button.getActionClassName(); IServiceHolder serviceHolder = Actions.getAction(actionId); - if (serviceHolder != null && serviceHolder.getService() != null) { + IAction action = serviceHolder.getService(); + if (serviceHolder != null && action != null) { String labelKey = actionId + ".label"; String tooltipKey = actionId + ".tooltip"; String label = Msg.getMsg(Env.getCtx(), labelKey); @@ -273,6 +274,7 @@ public class ADWindowToolbar extends FToolbar implements EventListener toolbarCustomButtons.add(toolbarCustomBtn); this.appendChild(btn); + action.decorate(btn); } } if (buttons.get(button.getComponentName()) != null) {